tkinterep / ttkwidgets Goto Github PK
View Code? Open in Web Editor NEWA collection of widgets for Tkinter's ttk extensions by various authors
License: GNU General Public License v3.0
A collection of widgets for Tkinter's ttk extensions by various authors
License: GNU General Public License v3.0
I have a list with about 200 entries and probably I am missing something here :)
What is the suggested way to use the (very nice) checkboxtreeview widget with a vertical scrollbar?
Do I have to cover that showhow with a scrollable canvas?
Or could such a vertical scrollbar be added as a native part of the widget? If yes: How would be the approach for the latter?
Hi,
I tried the following code, but the checkbox is not appearing when I add the image.
from ttkwidgets import CheckboxTreeview
import tkinter as tk
root = tk.Tk()
tree = CheckboxTreeview(root)
tree.pack()
folder_image = tk.PhotoImage(file=r"../Blog Beast//UI/icons/start.png")
# file_image = tk.PhotoImage(file="page.png")
tree.insert("", "end", "1", text="1")
tree.insert("1", "end", "11", text="11", icon=folder_image)
tree.insert("1", "end", "12", text="12")
tree.insert("11", "end", "111", text="111")
tree.insert("", "end", "2", text="2")
root.mainloop()
Any help would be appreciated.
Thank you.
Given how the amount of widgets has grown, I think it would be appropriate to separate the widgets into separate packages within the ttkthemes
package.
For example: I think the fontframe.py
file should be split in files each containing a single class, and then placed into a font
package. The same would apply to the colorpicker.py
file (see PR #7 ), as that is currently the largest file of the whole package.
Full proposal
autocompletely.py
/autocomplete
colorpicker.py
/color
fontframe.py
/font
scrolledframe.py
and toggledframe.py
/frames
All the other widgets would remain at the root of the package. What do you think, @j4321?
I'm trying to use the CheckboxTreeview from ttkwidgets to put checkboxes in front of each line of a treeview I populate with an SQLite query where each row returned by the cursor should be a row in the treeview. I either get a blank tree with checkboxes or the same view as I get with a standard treeview. Is this something that can be supported or am I just doing it completely wrong?
Firstly, CheckboxTreeview() is awesome!
Secondly, the images for "checked", "unchecked" and "tristate" shown below in Gimp at 1600% magnification reveal shadows which shows up on our screens making it harder to tell the difference between images.
Lastly, can we make it easier to pass IM_CHECKED, IM_UNCHECKED and IM_TRISTATE keywords to init_ for the three images? My fonts are on HDPI monitors and such are about 40% larger than the checkboxes so I'll be creating new images. This code I believe needs to be changed to allow passing keyword image arguments:
# checkboxes are implemented with pictures
self.im_checked = ImageTk.PhotoImage(Image.open(IM_CHECKED), master=self)
self.im_unchecked = ImageTk.PhotoImage(Image.open(IM_UNCHECKED), master=self)
self.im_tristate = ImageTk.PhotoImage(Image.open(IM_TRISTATE), master=self)
Gimp screenshot of existing images zoomed to 1600%:
Tkinter does
It all started from the fact that a normal tk.Scale
was not themed correctly (I'm using a custom theme).
I then switched to ttk.Scale
but it was not showing the value above the slider when I changed it.
I then discovered ttkwidget
, which seems to work but with graphical glitches.
(The part in red should not appear)
Code: https://pastebin.com/bxgvsjSF
P.S. Furthermore, the the widgets that have problems are very slow to load widgets.
Is this a problem that regards my code or the ttkwidget library?
so it seems that it is more like a decoration
The help document seems incorrect, type of resolution
, tick_resolution
should be float
,
https://github.com/TkinterEP/ttkwidgets/blob/master/ttkwidgets/timeline.py#L100
:param resolution: Amount of time per pixel [s/pixel] :type resolution: int :param tick_resolution: Amount of time between ticks on the timeline :type tick_resolution: int
resolution
seems must >= 0.01
, otherwise the program will not response.
When options start
, finish
fixed, can I configure resolution
>= 0.01
?
(e.g. 1.0
, let the marker move and return args
interval is 1.0
.)
It makes it hard to choose widgets if there are no screenshots of them.
Widget: CreateToolTip
File: tkinterpp/tooltip.py
Functionality:
Create a tooltip similar to the Balloon
widget to provide a tooltip when hovering over a widget.
TODO:
Balloon
widgetIn ComboBox, we have <<ComboboxSelected>>
.
company_box.bind("<<ComboboxSelected>>", pick_theme)
Similarly whats the equivalent for <<ComboboxSelected>>
in AutocompleteCombobox
As suggested by @Dogeek, having tooltips in a way that they are easier to create would be beneficial for a lot of developers. Therefore, I have devised a way based on the way mtTkinter works, redefining the ttk.Widget.__init__
function during runtime and by so doing inserting two new keyword arguments into it: tooltip
and tooltip_options
.
All the developer has to do is import the module from ttkwidgets
(I do not intend for it to be imported by default, as there would be a performance penalty, even if slight) and the two new keyword arguments become available in all widgets derived from ttk.Widget
. See the example also created for a usage example.
The commit adding these features may be found here.
This issue is intended for discussion of this feature until such a time that it is ready to merge.
So I've been using the ttkwidgets
library for a quite a long time, and I have some improvement, and modification ideas I'd like to share here. Unfortunately(?), it got a bit long.
master
option to the dialog, and make the chooser window transient
sunken
relief to solid
to flatten it and make it look less 90-ishAutocompleteEntryListbox
instead of a Label & Listbox
for improve search (like in tkFontChooser)HTML
label to Hex
tk.Spinboxes
with a ttk.Spinbox
solid
Toolbutton
stylehand1
to hand2
, it looks native (yes, even on Linux :). Maybe pointerhand
on the Mac.exchange
to fleur
, it looks much more "moving"
I agree with @Dogeek (Merge Tooltip from tkinterpp) tooltips usually have no title, and images. Today, tooltips look like this:
GitHub:
WinUI:
So, I would change this widget, because the current one doesn't look too good, and modern.
To display title labels and images, maybe buttons, TeachingTips
are used these days, not ToolTips
I think it’s a very good idea to collect widgets from various authors, but I think they should be standardized somehow. For example, there are very striking differences between askfont
and askcolor
, like that Askfont
doesn't support master, askcolor
do, but calls it parent
(note that Tkinter uses master
).
Here I couldn’t really decide what would fit in ttkwidgets
because I don’t know what the concept of ttkwidgets actualky is.
tooltips
)This is a very good and useful package, so keep going!
from ttkwidgets import debugwindow
try:
import Tkinter as tk
import ttk
except ImportError:
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
ttk.Button( root, text="Print 111", command="print(111)" ).pack()
debugwindow.DebugWindow(root)
print (222 , "this works, the button does not, all is broken" )
root.mainloop()
This is really trivial but I thought I would share my first few minutes of experience converting an existing ttk.Treeview() to CheckboxTreeview().
First this error at line 175:
kw["tags"] += (tag,)
TypeError: cannot concatenate 'str' and 'tuple' objects
My tree already contained tags for grandparent = "Artist", parent = "Album" and child = "Song".
So I changed the code thusly:
# TypeError: cannot concatenate 'str' and 'tuple' objects
try: # Oct 24 2020 fix exception
kw["tags"] += (tag,)
except TypeError:
kw["tags"] += tag
The error went away but the treeview had NO checkboxes!
So I changed my existing tags and appended "unchecked" to all of them:
tags=("Artist", "unchecked"), open=True, \
text=Album, tags=("Album", "unchecked"), \
tags=("Song", "unchecked"), values = (ftime, fsize, '', \
Voila! checkboxes appeared and I can reverse changes to checkboxtreeview.py with:
sudo apt-get install --reinstall python-ttkwidgets
I hope this helps others. CheckboxTreeview() is an awesome extension to ttk.Treeview()!
My first python GUI program was using tkinter then I moved to GTK then move to web programming. When I was working with tkinter, It was hard to find the library or widgets so I end up building few.
https://github.com/bekar/tk_textag
https://github.com/bekar/tk_xmlview
https://github.com/bekar/tk_lineno
https://github.com/bekar/tk_zoomText
https://github.com/bekar/vtk100_colors
https://github.com/bekar/tk_tooltip
https://github.com/bekar/ttksearchbox
After years doing web, I'm again back in tkinter for the small project. And I'm really glad too see the Tkinter Extension Project running. I browsing thought the widgets and they are amazing few were the same as I did (form validator which i'm still working currently). I guess my work can find the new home and maintenance in this repository.
I am using checkboxTreeview, in princible this works as expected but I have some issues in
highlighting the active row If I click on the row or use "selection_set".
if i do the same with Treeview it works fine.
in example file you can set tree_type = 1 # 0: Treeview, 1: CheckboxTreeview to test it.
any support is apriciated.
I was trying to use ttkwidgets in vscode, after installing it via pip which went properly.
But vscode threw an error saying the module ttkwidgets is missing when I tried importing it.
But when I used it via IDLE, it worked properly.
But I did manage to resolve it,
What I did is downloading this repo, then modified setup.py according to this comment https://github.com/TkinterEP/ttkwidgets/pull/10#commitcomment-23576599
After running this setup with the command python setup.py sdist
ttkwidgets is working properly.
btw, my python is v3.10.1
and ttkwidgets is v0.12.1
And here's the modified setup
setup.txt
The check icons ttkwidgets/assets/checked.png and unchecked.png (and I assume others) have white backgrounds. This causes a border to be visible when the background colour of a row is set. Would it be possible to make the outer background of the images transparent?
I realise that I can manually replace the images using tree.tag_configure("unchecked", image=...)
and will be using this as a work around.
Test environment: Windows 8.1, Python3.9.0
style = ttk.Style(root)
style.theme_use('xpnative')
'winnative', 'vista', 'xpnative' Style works fine,
'clam', 'alt', 'default', 'classic' Style rise Error below:
Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files\Python39\lib\site-packages\ttkwidgets-0.11.0-py3.9.egg\ttkwidgets\table.py", line 68, in >init
self._initialize_style()
File "C:\Program Files\Python39\lib\site-packages\ttkwidgets-0.11.0-py3.9.egg\ttkwidgets\table.py", line 122, in _initialize_style
style.map('Table', **style_map)
File "C:\Program Files\Python39\lib\tkinter\ttk.py", line 403, in map
self.tk.call(self._name, "map", style, *_format_mapdict(kw)),
_tkinter.TclError: Invalid state name d
when create 'table' with:
table = Table(root, columns=columns, sortable=sortable.get(), drag_cols=drag_col.get(), drag_rows=drag_row.get(),height=6)
Right now there are four calender widgets for Tkinter that I know of which all contain a set of features which might be interesting to have.
ttkwidgets version
A simple date picker, really. Built using a Canvas, which results in a pretty compact design. Not many options. Lacks a callback for when a new date is selected.
tkcalendar
A separate package containing an excellent, compactly styles, calendar widget with a huge amount of options, maintained by @j4321 .
tkinterpp version
A Calendar using buttons instead of a Canvas. Uses the Tk
widget set currently and a tk.Variable
-like variable for storing the date.
gsf-parser version
For the GSF Parser I have developed a widget based on the widgets contained in this package. It acts also as a heatmap. It may be found here.
Which of these widgets should be in the package is the big question here. tkcalendar could be included in an of itself, but I am not sure whether that would be beneficial to that project. Could you give your opinion on this, @j4321?
All in all, I think it might actually be best to remove the Calendar widget from ttkwidgets
altogether and just point to tkcalendar
. It is by far the best widget out there for this purpose that I know of and building something that does all those things in parallel seems like a waste of time and resources. The only thing I can think off that could be added to tkcalendar is offering multiple colour schemes in the widget itself.
Python 3.4 has already reached EOL, and 3.5 is due to reach EOL the 13th of september 2020.
Furthermore, on unix systems, the system interpreter uses python 3.7 by default. There is not much of an advantage in keeping backwards compatibility with unsupported versions of python.
I am testing with the AutocompleteCombobox from ttkwidgets, and I found that this part might have the bug.
# now finally perform the auto completion
if self._hits:
self.delete(0, tk.END)
self.insert(0, self._hits[self._hit_index])
self.select_range(self.position, tk.END)
What I tested is that when I type very fast, the self.position sometimes will just jump from let's say 7 to 16.
And then the symtom is that my cursor is already in the end of the auto completed string and whatever I type will be wrongly append to it.
What I want is that no matter how we type, unless we press Enter or right arrow key, it should always kind of "hinting" you what is the current hits.
Can you check whether this is a bug or whether it's something we can workaround?
I really need to use this Auto complete feature but no with this bug.
Thanks!
I searched google for solutions but there is no correct answer.
Repository Owner Edit:
Issue Details:
OS: ?
Python version: ?
pip
version: ?
setuptools
version: ?
Error encountered: ValueError: Entry points must be listed in groups
Stack trace:
Stack trace here
I'm running the example for ChecklistTreeView on macos 10.15.2, and the images for the checklist do not appear.
Python version: Python 3.7.6 - installed from homebrew
OS: macos 10.15.2
ttkwidgets version: 0.10.0
Example being run:
from ttkwidgets import *
import tkinter as tk
root = tk.Tk()
tree = CheckboxTreeview(root)
tree.pack()
tree.insert("", "end", "1", text="1")
tree.insert("1", "end", "11", text="11")
tree.insert("1", "end", "12", text="12")
tree.insert("11", "end", "111", text="111")
tree.insert("", "end", "2", text="2")
root.mainloop()
If I update the images to be converted to RGB in checkboxtreeview.py, the pictures are displayed:
self.im_checked = ImageTk.PhotoImage(Image.open(IM_CHECKED).convert('RGB'), master=self)
self.im_unchecked = ImageTk.PhotoImage(Image.open(IM_UNCHECKED).convert('RGB'), master=self)
self.im_tristate = ImageTk.PhotoImage(Image.open(IM_TRISTATE).convert('RGB'), master=self)
Similar issue: https://stackoverflow.com/questions/29708822/png-image-not-showing-up-when-using-tkinter-pillow-pil-in-python-2-7-under-m
Hello, this is my first time using github.....
So I use checkboxtreeview in my project, and try to make an exe using pyinstaller. But this error came out:
Traceback (most recent call last):
File "main.py", line 896, in <module>
File "site-packages\ttkwidgets\checkboxtreeview.py", line 49, in __init__
File "site-packages\PIL\Image.py", line 2634, in open
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\....\\AppData\\Local\\Temp\\_MEI46002\\ttkwidgets\\assets\\checked.png'
[5880] Failed to execute script main
Please help,
Thank you
I am listing several folders using checkbox preview.
If a folder has an image file inside, the image is inserted into the row.
However, rows that have an image does not have a checkbox as if the image is replacing the checkbox.
Is this the intended behavior?
Is there a way to add the image to another column?
Thank you in advance.
WHAT:
Library ttkwidgets==0.12.0 automatically installed under Python 2 which fails the execution
WHY:
Lack of python_requires record within setup.py
SOLUTION
Add python_requires='>=3.6' into setup.py and blacklist the 0.12.0 version
LOGS:
ERROR: Command errored out with exit status 1:
command: /home/ute/Repositories/venvs/test_test/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2S13Og/ttkwidgets/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2S13Og/ttkwidgets/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-JOS1DZ
cwd: /tmp/pip-install-2S13Og/ttkwidgets/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-2S13Og/ttkwidgets/setup.py", line 9
def read(file_name: str):
^
SyntaxError: invalid syntax
----------------------------------------
ScrolledFrame is awesome.
but widgets can't be placed with place()
method when i use ScrolledFrame.
other pack()
like example and grid()
does work.
no error message appears.
how does place()
work with ScrolledFrame?
i tried the code below. (almost the same as example code from ttkwidgets.)
from ttkwidgets.frames import ScrolledFrame
import tkinter as tk
from tkinter import ttk
window = tk.Tk()
frame = ScrolledFrame(window, compound=tk.RIGHT, canvasheight=200, canvaswidth=100)
frame.pack(fill='both', expand=True)
for i in range(30):
label = ttk.Label(frame.interior, text='Label %i' % i)
label.place(x=5, y=i*25)
window.mainloop()
the problem was solved.
i place extra frame
specified size on ScrolledFrame w/ pack()
, then place some label
s like below.
window = tk.Tk()
frame = ScrolledFrame(window, compoundV=tk.RIGHT, compoundH=tk.BOTTOM, canvasheight=200, canvaswidth=100, canvasborder=1)
frame.pack(fill='both', expand=True)
subframe = ttk.Frame(frame.interior, width=400, height=600)
subframe.pack()
for i in range(100):
label = ttk.Label( subframe, text='Label %i' % i)
label.place(x=5, y=i*30)
I think changing the license for this repository to LGPL would make this repository be used by more people and make tkinter more popular.😂 @RedFantom
Regards.
larryw3i
This code is inside a window class:
from ttkwidgets.font import askfont
def font():
self.res = askfont()
if self.res[0] is not None:
self.label.configure(font=self.res[0])
print('««««««««', self.res[0])
# return
self.label = ttk.Label(self, text='Texto de exemplo.')
self.label.pack(padx=10, pady=10)
self.botao_fonte = ttk.Button(self, text="Escolher a fonte e tamanho da letra", command=font)
self.botao_fonte.pack()
and if I select the size and then the type font, then it works. But if I select first the type and then the font size it don't.
Thanks.
Hi,
I am looking for xscroll to see the large text in Checkboxtreeview. can you please help me.
Thanks,
Anantha
Given that with the merge of PR #10 the ttkwidgets
package now installs correctly onto any user's system, be it Linux or Windows, the package is, in my opinion, ready to be published to PyPI as non-production ready. There are still some issues with some widgets, and they should be worked on, but as long as this is clearly indicated, I'd say that the package is ready, given that it has useful content and a clear target audience. What do you think, @j4321?
I have been poking around with the table example code:
ttkwidgets/example_table.py at master · TkinterEP/ttkwidgets
https://github.com/TkinterEP/ttkwidgets/blob/master/examples/example_table.py
And cannot get past the error:
Python 3.7.13 (default, Mar 28 2022, 08:03:21) [MSC v.1916 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 7.31.1 -- An enhanced Interactive Python.
runfile('D:/Russ/0000/python00/python3/_projects/clipboard/untitled2.py', wdir='D:/Russ/0000/python00/python3/_projects/clipboard')
_format_mapdict {}
_format_mapdict {'foreground': [('disabled', '#a3a3a3'), ('!disabled', '!selected', 'black'), ('selected', '#ffffff'), ('disabled', 'gray40')], 'background': ['disabled', '#d9d9d9', '!disabled !selected', '#ffffff', 'selected', '#4a6984', ('disabled', '#E6E6E6')], 'fieldbackground': [('disabled', '#E6E6E6')]}
Traceback (most recent call last):
File "D:\Russ\0000\python00\python3_projects\clipboard\untitled2.py", line 30, in
drag_rows=drag_row.get(), height=6)
File "C:\apps\Anaconda3\envs\all_exp\lib\site-packages\ttkwidgets\table.py", line 64, in init
self._initialize_style()
File "C:\apps\Anaconda3\envs\all_exp\lib\site-packages\ttkwidgets\table.py", line 118, in _initialize_style
style.map('Table', **style_map)
File "C:\apps\Anaconda3\envs\all_exp\lib\tkinter\ttk.py", line 405, in map
self.tk.call(self._name, "map", style, *_format_mapdict(kw)),
TclError: Invalid state name d
Added line to def _mapdict_values(items):
print( f"_format_mapdict {mapdict}")
_format_mapdict {}
and debugger shows:
!continue
_format_mapdict {'foreground': [('disabled', '#a3a3a3'), ('!disabled', '!selected', 'black'), ('selected', '#ffffff'), ('disabled', 'gray40')], 'background': ['disabled', '#d9d9d9', '!disabled !selected', '#ffffff', 'selected', '#4a6984', ('disabled', '#E6E6E6')], 'fieldbackground': [('disabled', '#E6E6E6')]}
!continue
Traceback (most recent call last):
File "d:\russ\0000\python00\python3_examples\tk\ex_tk_ttkwidgets.py", line 119, in
ex_table()
File "d:\russ\0000\python00\python3_examples\tk\ex_tk_ttkwidgets.py", line 92, in ex_table
height = 6 )
File "C:\apps\Anaconda3\envs\all_exp\lib\site-packages\ttkwidgets\table.py", line 64, in init
self._initialize_style()
File "C:\apps\Anaconda3\envs\all_exp\lib\site-packages\ttkwidgets\table.py", line 118, in _initialize_style
style.map('Table', **style_map)
File "C:\apps\Anaconda3\envs\all_exp\lib\tkinter\ttk.py", line 405, in map
self.tk.call(self._name, "map", style, *_format_mapdict(kw)),
TclError: Invalid state name d
Stepping into this I get:
forground of mapdict
[('disabled', '#a3a3a3'), ('!disabled', '!selected', 'black'), ('selected', '#ffffff'), ('disabled', 'gray40')]
and I get back a "parsed" value for it of:
['d i s a b l e', 'd', '# d 9 d 9 d', '9', '! d i s a b l e d ! s e l e c t e', 'd', '# f f f f f', 'f', 's e l e c t e', 'd', '# 4 a 6 9 8', '4', 'disabled', '#E6E6E6']
which I think causes "TclError: Invalid state name d" I suspect the state name is supposed to be "disabled" ?
That is about as far as I can go. In any case the example appears not to work.
Contact me if you need any other information.
( I have been using your tkCalendar for a long time, thanks. )
Russ
As a prospective user of ttkwidgets, it would be very helpful to have example screenshots to see how these widgets look, and if they align with my desired functionality. I imagine I'm not alone in this.
Not a priority but it would be nice :)
Here is an example of this in another set of widgets: https://github.com/slightlynybbled/tk_tools
I have a project that needs ttkwidgets.hook
module, but unfortunately it's not included in the Pypi package. The validated_entries submodule also missing from the setup.py
file. These should be updated.
I have started merging the NodeView
widget into ttkwidgets
. This widget is intended to give a convenient interface to interact with, and display graphs (series of nodes connected to one another).
So far, the NodeView widget has the following features :
There's a lot working already, but it's a bit buggy at the moment, hence why I'd like some help. Bugs I've noticed include :
The bezier curves for connections don't show up properly, they are very wonky and do not display how the nodes relate to one another properly
Node dragging is also quite a bit wonky. It works, but the node is offset from the mouse pointer which makes it hard to use
Connections do not snap to the edge of the Nodes
It would be great if nodes would scale with the length of the text inside of it
The connection won't show if it is created when the node is created
The connections won't move with the nodes when the nodes are dragged
Also, the following features are desired :
Ability to export the graph into a dictionary. This dictionary should map nodes to other nodes, following the connections between them.
Ability to delete connections
Ability to delete nodes, and all connections to and from that node
Maybe some virtual events : <<NodeMoved>>
, <<NodeSelected>>
, <<ConnectionCreated>>
, <<ConnectionDeleted>>
, <<NodeDeleted>>
, <<NodeCreated>>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.