Python Forum
how to positon a tkinter canvas
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to positon a tkinter canvas
#1
could someone please help.

at the moment I created a tkinter canvas but when I run it, it is close to the top left.

how do I position it in the center.
Reply
#2
Hi,

a) check out the bespoke GUI forum on this site!
b) Your question: check out the "geometry" keyword and it's positional syntax . in Tkinter,

Paul
Reply
#3
geometry statement (from John Shipman's tkinter manual):

A geometry string is a standard way of describing the size and location of a top-level window on a
desktop.

A geometry string has this general form: 'wxh±x±y'

where:
  • The w and h parts give the window width and height in pixels. They are separated by the character
    'x'.
  • If the next part has the form +x, it specifies that the left side of the window should be x pixels from
    the left side of the desktop. If it has the form -x, the right side of the window is x pixels from the
    right side of the desktop.
  • If the next part has the form +y, it specifies that the top of the window should be y pixels below the
    top of the desktop. If it has the form -y, the bottom of the window will be y pixels above the bottom
    edge of the desktop.

For example, a window created with geometry='120x50-0+20' would be 120 pixels wide by 50
pixels high, and its top right corner will be along the right edge of the desktop and 20 pixels below the
top edge.
Reply
#4
There are multiple ways to position widgets inside a window. You can use pack() or place() or grid(). The answer to how to center your canvas is different based on which of these you used. You need to provide some code before anyone can answer your question.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter & Canvas Peter_Emp1 5 368 Mar-24-2024, 07:40 PM
Last Post: deanhystad
  use classes in tkinter canvas fardin 2 2,619 Jan-06-2019, 04:23 AM
Last Post: fardin

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020