473,325 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Tkinter canvas size determination

I need to determine the size of a canvas while the process is running.
Does anyone know of a technique that will let me do that?

Thanks,

Dean
Feb 22 '06 #1
5 14852
In article <43**************@rpcl.com>,
Dean Allen Provins <dp******@rpcl.com> wrote:
I need to determine the size of a canvas while the process is running.
Does anyone know of a technique that will let me do that?

Feb 22 '06 #2
Cameron Laird wrote:
In article <43**************@rpcl.com>,
Dean Allen Provins <dp******@rpcl.com> wrote:
I need to determine the size of a canvas while the process is running.
Does anyone know of a technique that will let me do that?


.
.
.
Does
>>> import Tkinter
>>> c = Tkinter.Canvas()
>>> c.create_oval(13, 51, 80, 130) 1 >>> c.pack()
>>> print c.cget("width")

284
help?

There are actually several different notions of the size of a
canvas. The example abovve should be a good starting point,
though.

There's also a mailing list specifically for Tkinter <URL:
http://tkinter.unpythonic.net/wiki/mailing_20lists >; that
might interest you.


Your suggestion helps immensely. I missed it in Shipman's Tkinter
reference. And thank you for the mail list reference. I'll pursue it.

Regards,

Dean
Feb 22 '06 #3
Cameron:

Cameron Laird wrote:
In article <43**************@rpcl.com>,
Dean Allen Provins <dp******@rpcl.com> wrote:
I need to determine the size of a canvas while the process is running.
Does anyone know of a technique that will let me do that?


.
.
.
Does
>>> import Tkinter
>>> c = Tkinter.Canvas()
>>> c.create_oval(13, 51, 80, 130) 1 >>> c.pack()
>>> print c.cget("width")

284
help?

There are actually several different notions of the size of a
canvas. The example abovve should be a good starting point,
though.

There's also a mailing list specifically for Tkinter <URL:
http://tkinter.unpythonic.net/wiki/mailing_20lists >; that
might interest you.


I tried the "cget" function, and it returned the width that I had used
when creating the canvas - even though the canvas was wider than that
value at display time (and also after manually resizing the window).

To your knowledge, is there a method to determine the current dimensions?

Thanks,

Dean
Feb 24 '06 #4
Dean Allen Provins wrote:
Cameron:

Cameron Laird wrote:
In article <43**************@rpcl.com>,
Dean Allen Provins <dp******@rpcl.com> wrote:
I need to determine the size of a canvas while the process is running.
Does anyone know of a technique that will let me do that?

.
.
.
Does
>>> import Tkinter
>>> c = Tkinter.Canvas()
>>> c.create_oval(13, 51, 80, 130)

1
>>> c.pack()
>>> print c.cget("width")

284
help?

There are actually several different notions of the size of a
canvas. The example abovve should be a good starting point,
though.

There's also a mailing list specifically for Tkinter <URL:
http://tkinter.unpythonic.net/wiki/mailing_20lists >; that
might interest you.


I tried the "cget" function, and it returned the width that I had used
when creating the canvas - even though the canvas was wider than that
value at display time (and also after manually resizing the window).

To your knowledge, is there a method to determine the current dimensions?

Thanks,

Dean

Dean,

Look at the winfo_* methods of Tkinter widgets, I think the one you want
is called winfo_reqheight / winfo_reqwidth or something very similar
pydoc Tkinter.Canvas will sort that out

Martin




Feb 24 '06 #5
Martin:

Martin Franklin wrote:
Dean Allen Provins wrote:
Cameron:

Cameron Laird wrote:
In article <43**************@rpcl.com>,
Dean Allen Provins <dp******@rpcl.com> wrote:

I need to determine the size of a canvas while the process is running.
Does anyone know of a technique that will let me do that?

.
.
.
Does
>>> import Tkinter
>>> c = Tkinter.Canvas()
>>> c.create_oval(13, 51, 80, 130)
1
>>> c.pack()
>>> print c.cget("width")
284
help?

There are actually several different notions of the size of a
canvas. The example abovve should be a good starting point,
though.
There's also a mailing list specifically for Tkinter <URL:
http://tkinter.unpythonic.net/wiki/mailing_20lists >; that
might interest you.

I tried the "cget" function, and it returned the width that I had used
when creating the canvas - even though the canvas was wider than that
value at display time (and also after manually resizing the window).

To your knowledge, is there a method to determine the current dimensions?

Thanks,

Dean


Dean,

Look at the winfo_* methods of Tkinter widgets, I think the one you want
is called winfo_reqheight / winfo_reqwidth or something very similar
pydoc Tkinter.Canvas will sort that out

Martin


Thanks. That is exactly what I needed. I tried it, and it returned the
desired values.

Regards,

Dean
Feb 24 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mickel Grönroos | last post by:
Hi, I'm trying to put an Tkinter.Entry of fixed size onto a specific location on a canvas using the place manager. The idea is that one can double-click a rectangle object on a canvas to get an...
3
by: John Velman | last post by:
I want to draw a box around a short piece of text in canvas (one line text). I know how to do it if I place the text on the canvas first,then draw the box around it. Is there a way to find out...
1
by: syed_saqib_ali | last post by:
Please take a look at and run the code snippet shown below. It creates a canvas with vertical & Horizontal scroll-bars. If you shrink the window to smaller than the area of the canvas, the...
0
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust...
0
by: Stewart Midwinter | last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item that does nothing more than fetch a directory listing and display it in a Toplevel window (I'd use a tkMessageBox showinfo...
1
by: dmsbox2000-list1 | last post by:
This is a beginner question. I am using a Mac running OS X. I have TclTkAqua installed. If I type: import Tkinter r = Tkinter.Tk() c = Tkinter.Canvas(r) c.pack() c.create_line(0,0,100,0)
1
by: Bob Greschke | last post by:
I have a program that sucks in a list of equipment positions (Lats/Longs), opens a Toplevel frame with a canvas set to, for example, 700x480 pixels, and then does all of the calculations and plots...
3
by: joshdw4 | last post by:
I hate to do this, but I've thoroughly exhausted google search. Yes, it's that pesky root window and I have tried withdraw to no avail. I'm assuming this is because of the methods I'm using. I...
1
by: akineko | last post by:
Hello everyone, I'm trying to create custom Tkinter/Pmw widgets for my project. After testing my widgets under Unix (Solaris), I have tried them under Windows and I got a surprise. The...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.