How big is that canvas in the window?

Koen Bossers koen at behindthesofa.dhs.org
Sun Aug 26 14:12:52 CEST 2001


Joseph Andrew Knapka <jknapka at earthlink.net> wrote in message news:<3B86C522.169F2868 at earthlink.net>...
> Bob Greschke wrote:
> > 
> > Here's the idea:
> > 
> > www.passcal.nmt.edu/~bob/unlinked/images/trdpy.jpg
> > 
> > It's in Python/Tkinter.  See the "Plot" button?  I want to draw a
> > graph in the black area.  How do I find out the dimensions of the
> > black canvas area???  I can make a guess when I first draw everything
> > by setting the size of everything, but I don't want to do that.  I
> > want the user to be able to resize the window and then redraw the
> > graph.  I got to exactly this same point in GTK+ and had to give up.
> > Am I going to have to write this program in Java?? :-)
> > 
> > (The program is actually being written for/on a UNIX box.  I just had
> > to use a Windows machine to get the screen dump.)
> > 
> > Thanks!
> >

interactive session:

>>> from Tkinter import *
>>> root = Tk()
>>> canv = Canvas(root)
>>> canv.pack()
>>> canv.cget('height')
'267'
>>> canv.cget('width')
'381'


found at:
http://www.pythonware.com/library/tkinter/introduction/index.htm.
Section "Basic Widget Methods"

Please bookmark this site: a lifesaver when programming with Tkinter.


Cheers, Koen



More information about the Python-list mailing list