Skip to content
Advertisement

Tag: tkinter-canvas

How do I get text to be centered in a Tkinter Canvas?

I am making Checkers and am using an asterisk to mark the kings. I need the asterisk to be centered in the middle of the canvas. I made this example to show what’s going wrong: The asterisk looks like it’s centered on the horizantal axis, but it is too high on the vertical one. I’m placing it at (50,50), since

Suppressing other canvas items from reacting to event

I have a rectangle on a canvas listening for events, with a callback function “A”. The blank space in the canvas is also listening to events with a callback function “B”. When the I right-click on the rectangle, both “A” and “B” are executed. I understand why this happens (the rectangle is on the canvas). The behavior I want to

How to update a frame with a scrollbar linked in it that has buttons so that it updates and works correctly when adding buttons?

I’m writing an application in tkinter which has the following structure: Notebook Tab (frame on the notebook) Canvas (on the frame) SecondFrame (on the canvas) ← this is where I want to pack my buttons MyButtons (on second frame) While scrollbar is linked as expected to my canvas. Lets say I have 20 buttons when running the program and by

How to make button using canvas in toplevel() Tkinter

I’m trying to make a button using canvas.create_window in toplevel() in Tkinter. Button is used to go back to main window. First “Start” button is displayed but second “Back” button is not. Code below. Answer The problem is the ordering of creation of canvas_two and button_back. You need to create the Canvas first and then put the Button on top

Is there a way to make a object follow another object?

So, I have been working on a project for a very basic Space Invaders. But, I can’t seem to get the Bullet (see code) class to follow the Jet class(see code): I have already searched some websites (and yours, too) and couldn’t find anything. Do I have any way to make the classes follow each other? Answer You could do

How to scroll a tkinter canvas to an absolute position?

I’m using Python and tkinter. I have a Canvas widget that will display just one image. Most times the image will be larger than the canvas dimensions, but sometimes it will be smaller. Let’s just focus on the first case (image larger than canvas). I want to scroll the canvas to an absolute position that I have already calculated (in

Advertisement