I have a listbox, and I would like to have a progress bar inside each line of this listbox. Is there a simple way to do that, or do I have to rewrite the listbox class, or maybe override it ?
There is no simple way. A listbox can only contain text.
You can fake it fairly easily with a text widget, since a text widget allows you to embed widgets. For each row you could insert the text, insert a progress bar, and then insert a newline.
Related
i am using python 3, GUI, tkinter.
i use grid method (row and column) to create a table containing info, a button is placed in the end of each row. if someone press that button, the whole row will disappear/destroy and next row will replace it, which function should i use to achieve that?
The grid_forget() method will cause the grid geometry manager to stop managing a widget. So if you put your widgets for a row into a frame and grid that, you can grid_forget the frame to have all the widgets in the frame removed from display together. However, you might want to investigate the Ttk treeview which can display tabular information or the tktable package (see this answer).
I'm trying to make a list where a row has some data that can be represented as text, where the row is selectable, and can contain a progressbar. I can't figure out how to implement this with tkinter, I can set up a selectable list with a treeview element, and a progressbar with the progressbar element. But I can't put them together. While I'm using tkinter right now, I'm open to other packages that would support this. Here's the layout I've been working off of http://i.imgur.com/x9cv29j.png
Win7, Python 2.7, Tkinter
I have several list boxes on the screen at once, and I am setting up a way to let the user change the colors (background, text color, border width, border color, etc...) There are more then just list boxes, there are label frames, progress bars, window frames, to name a few.
The listbox (and other widgets) labels are declared in a globals file, thuis:
globs.lb1 = tk.Listbox(root, ...
I can change the attributes easily enough, but what is the best method to update all the widgets?
Currently, in my Settings.py file, I am manually setting each list box, (and other widgets) but, or course, if I add a widget later, I must remember to change the Settings.py file.
I would like to use ttk, I think ttk allows me to change the style, then ttk will remember which widgets use that style, but there is no Listbox in ttk.
If there were an event or something of that nature I could setup for each list box...
Thanks, Mark.
Option 1: define a subclass of Listbox that registers each listbox you create so that when a user changes settings, you can iterater through the set/list of listboxes.
Option 2: use a ttk.Combobox or a ttk.Treeview (with only top-level items and not expansion for subitems). I think one could think of a treeview as a supercharged listbox, with multiple columns and possible hierarchical relationships.
I want to make a whole column of various widgets scrollable in a Tkinter GUI, like so:
Tkinter can only attach scrollbars to certain widgets, of which, frames are not included. Making a scollable column is a common practice in interfaces, and there should be a simple solution, but so far, all I have been able to find is this hacky example of a scrollable frame, using a canvas widget. A similar hacky solution was used in a similar stack overflow question.
Is there a commonly accepted way in Tkinter to make a column, or a group of widgets, that is scrollable?
The solution using the canvas is the commonly accepted way to solve this problem. It's really not all that hacky, and the end result can be indistinguishable from having a native scrolling container widget.
If you're making a single column, another option is to use a text widget, and use the widget's ability to embed other widgets. Insert a widget, then insert a newline, insert another widget, etc. You then get the scrolling ability for free. The only thing you need to worry about is configuring the width of the embedded windows, which isn't too hard to do.
I want to provide a listbox where the user can select (multiple) characters (usually close to 15). Quite often some of these will be sequenced, so a listbox is easier than a validated text entry field.
Since the character combination has a meaning to the user, it is user friendly to orient the listbox horizontally.
Is there an easy way e.g. a theme, setting or subclass of the Tkinter listbox so I do not have to build my own?
No, there is no setting, subclass or theme that will let you do that with a listbox.
What you might want to use instead is a set of check buttons with the indicator turned off so they each appear as a button with a single letter. You can then pack them all horizontally in a frame. With the indicator off, the button will appear sunken when selected, or normal otherwise.