I'm using python 2.7 and I'd like to have an GUI with a scrollable list where each item in the list has both an image and some text. I'd like these items to be selectable like in a ListBox. I've tried a couple things and it seems ListBox only accepts text?
What widget/combination of widgets should I use?
Try placing a whole bunch of buttons in a frame and assigning a scroll bar a to that frame and make it so when the user presses a button is changes colour or picture or something and then any button with that same colour of picture before will go back to normal. Also, and a tkinter variable with which button is active so you can reference it later.
I'm fairly sure you can use both texts and images in a button simultaneously, but if not you can just put a button and an image side by side in the same row on the frame
I recommend you make this entire scrolling object a class and keep references of everything inside within that class.
If you need any help doing this, just give me a shout.
Related
Iv'e tried a bunch of random things. I know I'm supposed to be specific when explaining this but I don't really know what to say. I made a scrollbar in a def function, it was in a whole new screen and I added it to a text box. So I'm wondering if I can just add my main scrollbar to the frame/screen in my main window. My previous scrollbar is in the recipe_steps function.
How do I make a step-by-step GUI Layout with Tkinter Python 3.7? What I mean is that I want to have the user enter some information, press the "NEXT" button and enter some more information, etc. I don't think there's really a feasible way to completely change the layout like this with Tkinter, so I'm hoping there's something I'm missing. How do I do this?
I don't think there's really a feasible way to completely change the layout like this with Tkinter,
That is incorrect. This is trivially easy with Tkinter. Create a function or class for each step. All of the widgets for that step should be inside a single frame.
You then just need to call the first function or class to create the frame. When the user clicks "next", destroy the frame and create the next frame. And so on.
I am developing a UI that uses a Tkinter Listbox item to display a bunch of dynamically inserted frames that contain other labels. The Listbox works, but in turn it is displaying some weird indexes that I do not want to see in the window.
They look like this.
How can I disable these indexes from showing up?
This is the part of code that is responsible for initialising the Listbox
vertical_frame = Listbox(root)
vertical_frame.config(bg="#394144", bd=0, highlightthickness=0, height=10, selectmode=0,
activestyle="none", fg="#fff", exportselection=0)
Also, the frame is used in a function to be able to modify it's contents in a dynamic way.
The only thing I do there is
_frame.insert(END, temp_frame)
_frame.pack()
where _frame stands for vertical_frame, but it is passed to a function.
How can I disable the wierd numbers from showing up?
Those "weird indexes" are the string representation of widgets. To get them to not show up, you need to remove the code that is trying to insert a widget into a listbox. The listbox can only display text.
If you are trying to create a scrollable list of frames, you will need to either embed them in a canvas, or embed them in a text widget. Those are the two widgets that both support scrolling and the embedding of other widgets.
I need to create a message box for a user in a GUI with tkinter. For 3/4 of my entries, Entry(master, options. . .,) works. But for a message box, I need a multi line entry.
How would I do this? I tried ScrolledText(root).pack(), but it doesn't have the same commands/variables as Entry.
It is not explicitly mentioned in the documentation, but even if the tkinter.Entry widget's content can be scrolled, it can only be scrolled horizontally meaning that you can not use the yscrollcommandoption unlike with Canvas, Text and Listbox widgets.
This means technically your goal is not feasible, I mean you can not write multiple lines inside an Entry widget so that you scroll them vertically but only horizontally:
(if you need the code of this screenshot, please let me know).
Billal is right, however i would recomend simply using a Textbox.
go to: http://www.tutorialspoint.com/python/tk_text.htm
for more information
Is it possible to mount more than one image AND text on a Tkinter button?
Or, is it possible to put a FRAME containing images + text on a button?
I want a big button containing multiple widgets that, when taken together, fully describe the option the user will be able to choose.
I appreciate any suggestions!!
Is it possible to mount more than one image AND text on a Tkinter button?
Strictly speaking, no, it is not possible.
Or, is it possible to put a FRAME containing images + text on a button?
Yes, though it probably won't work on OSX. It would probably take you less time to actually try it than to type in the question on stackoverflow. A little research goes a long way.
You can also simply not use a button. Just use a frame or canvas, and set up bindings on the container and/or it's contents to react to a button click.