Is it possible to draw lines such as the following with the Tkinter .grid() system? Every tutorial that talks about canvas drawing uses .pack() exclusively.
There are no answers for using canvas with .grid() when you search online.
I have tried using canvas with .grid() but my GUI got completely messed up and no lines were drawn.
Is it actually possible to use canvas with .grid()?
You use neither grid nor pack for drawing items on a canvas. The canvas has the following methods for drawing:
create_arc
create_bitmap
create_image
create_line
create_oval
create_polygon
create_rectangle
create_text
create_window
If you're not actually asking about drawing figures on canvas, but on adding the canvas to a window with pack or grid, you can use either.
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.
Is there a widget usable in Python with tkinter, which is a scrollbar with resizable slider? This makes sense e.g. when displaying something in graphical format to pan (moving the slider) and zoom (resizing the slider) with the same widget.
In a waveform viewer from Cadence it looks like this:
You can resize the handle using the little triangles or just grabbing the left or right edge of the handle with the mouse.
No, there is nothing like that in tkinter. Tkinter provides the basic building blocks, however. You could probably craft one using frames or a canvas.
I am extremely new to Python and just started working in turtle contrary to tkinter.
I've been trying to make a borderless window using overridedirect(True) and making the background color
of the window transparent by using wm_attributes("-transparentcolor", "color") which I had to use "turtle.Screen().getcanvas()._root()" to be able to use the mentioned methods using turtle.
using the two methods indeed removes the window's border and turns the background of the window transparent although there seems to be a "frame" that so far I haven't found a way to remove nor did I manage to figure out(or find online) how to apply highlightthickness=0 to my code/in turtle.
I attached an image showing the undesired frame, any help would be appreciated.
Thanks in advance,
-Omri
Ended up making a Canvas, passed the Canvas into TurtleScreen and then passed TurtleScreen into RawTurtle.
Doing so allows me to draw analog clock hands using turtle on an analog clock image while still being able to make the window draggable,
with no border(without the undesired frame mentioned/linked above) and with a transparent background. Current clock
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?