I am still new to this and I need some help in inserting a scrollbar to scroll the circled area just in case the list gets long in future. Thanks in advance.
The image is included here.(the circled area is actually an individual frame so is there any method to add scrollbar to that?
The usual way to do this is to create a canvas with scrollbars and then place the frame which contains the checkbox widgets on the canvas with create_window.
Related
What is the difference between a Frame and Canvas in tkinter? I'm a beginner in tkinter, and I don't really see any difference between the two... I've been using them interchangeably. Are they the same or is there some sort of internal or external difference?
A Frame is designed to be a container for other widgets. It really doesn't do anything but provide a border and color, and to collect a set of widgets into a logical group.
A Canvas is something that can act as a container for other widgets (as can just about any widget), but it also has features that let you draw circles, lines, rectangles, and other objects on it.
A Canvas can also be scrolled, whereas a frame cannot.
I want to make a list of custom widget vertically aligned, where I dynamically add the custom widget inside a scroll Area.
If I click on "add image", a custom widget is added to the scroll area with vertical layout.
like this :
Note that I didn't succeed to make the scroll Area expand as I add widget inside, I had to put a big minimum height to make a scrollbar appear.
The second issue is, when i add like this my widget they are spaced to much, and not added under each other. To prevent this I tried to add a vertical spacer. However, with the vertical spacer, the widget added by clicking on "add image" does not appear anymore (I use insertWidget(Vlayout.count()-1, mycustomwidget)
I organised everything like this :
the pushbutton is an example, I add my custom widget here.
Why the scroll Area doesn't expand as I had widget ? I tried :
self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.scroll.setWidgetResizable(True)
Why, when I had a spacer, the widget does not appear anymore ?
I was wondering whether it is possible to use some of the tkinter canvas drawing methods on a text widget. Ideally I would have the text widget placed onto the canvas so that I can draw onto the canvas and make it look like it shows up on the text widget.
No, it is not possible to draw over or into a tkinter Text widget. You can, however, add text to a canvas with the create_text method and draw over that.
I am creating a Solitaire clone using Python's Tkinter window toolkit. My window contains a main canvas, and within the main canvas a series of widgets that inherit from Canvas that hold the cards. I have implemented a "Drag to Move" system where a user can click the mouse down to select a card in one of the inner canvases, drag it to a new canvas, and let go to place the card into the receiving canvas.
The Problem: I want to draw the cards in motion between the canvas on which they are drawn, and the canvas they are moving to, so the user can see them moving across the screen during the click and drag motion. When I try to draw cards in-between the canvases that I already have, they are always drawn behind, meaning I can only see cards through the padding around the inner canvases.
Here is an example where I drew several of them so the effect could be seen clearly, and the inner canvases are also clearly visible.
What I've Tried: I've tried to move the canvases back using Misc.lower(aCanvas), but i wasn't able to create the desired effect. I've also tried to design a custom overridden cursor, but it seems my cursor size is limited to 32px*32px, which is insufficient for the size of the card images I want to move.
My Question: How can I draw on top of a canvas that is inside of another canvas? If I can't, how would you solve this problem?
You cannot do what you want. Embedded widgets are always above the canvas items.
Why is it that you are embedding canvases insidebcanvases? Why not just use a single canvas?
I'm working on a Tkinter application using the Grid geometry manager (It's my first time using Grid, and I love it! :D) that contains a scrolling listbox that displays options whenever a user selects an option.
It's working well, but the window is small and ugly. When I maximize it, everything else resizes fine (thanks to columnconfigure) but the listbox stays the same height. Is there a simple way to fix this?
(I have seen this question but it's for Pack, not Grid)
Thanks in advance.
Code sample because one was asked for:
self.tasklist = Listbox(self.frame, exportselection=0)
self.tasklist.grid(row=1, sticky=W+E+N+S)
yscroll = Scrollbar(self.frame, command=self.tasklist.yview, orient=VERTICAL)
yscroll.grid(row=1, column=1, sticky=N+S)
Without seeing more of your code it's impossible to say. Most likely your listbox is expanding properly, but your self.frame is not. Though, I don't see you giving any weight to the row and column that the listbox is in, so that could be a factor.
An easy way to debug this is to give self.frame a garish color that will stick out (red, bright green, etc). Then it will be easy to see if the listbox is properly resizing inside the frame, and if the frame is properly resizing inside its parent.