Mailing List Archive

Tkinter question
I've got a tkinter canvas, and I want to get it's width.... I call

w = int( thecanvas.cget("width") )

this works fine.. except when I resize the window, this still returns
the width that the canvas was when it was created.. the canvas is
getting resized (it has a visible background color)..

any ideas?

joel

--
----------------------------------------------------------------
joeld@anisci.com
Tkinter question [ In reply to ]
Joel Davis wrote:
>
> I've got a tkinter canvas, and I want to get it's width.... I call
>
> w = int( thecanvas.cget("width") )
>
> this works fine.. except when I resize the window, this still returns
> the width that the canvas was when it was created.. the canvas is
> getting resized (it has a visible background color)..
>
> any ideas?
>
> joel
>
> --
> ----------------------------------------------------------------
> joeld@anisci.com

Use

thecanvas.winfo_width()

This works for any widget, not just canvas.


Here's a list of all the winfo_... methods, taken from Tkinter.py:

def winfo_atom(self, name, displayof=0):
def winfo_atomname(self, id, displayof=0):
def winfo_cells(self):
def winfo_children(self):
def winfo_class(self):
def winfo_colormapfull(self):
def winfo_containing(self, rootX, rootY, displayof=0):
def winfo_depth(self):
def winfo_exists(self):
def winfo_fpixels(self, number):
def winfo_geometry(self):
def winfo_height(self):
def winfo_id(self):
def winfo_interps(self, displayof=0):
def winfo_ismapped(self):
def winfo_manager(self):
def winfo_name(self):
def winfo_parent(self):
def winfo_pathname(self, id, displayof=0):
def winfo_pixels(self, number):
def winfo_pointerx(self):
def winfo_pointerxy(self):
def winfo_pointery(self):
def winfo_reqheight(self):
def winfo_reqwidth(self):
def winfo_rgb(self, color):
def winfo_rootx(self):
def winfo_rooty(self):
def winfo_screen(self):
def winfo_screencells(self):
def winfo_screendepth(self):
def winfo_screenheight(self):
def winfo_screenmmheight(self):
def winfo_screenmmwidth(self):
def winfo_screenvisual(self):
def winfo_screenwidth(self):
def winfo_server(self):
def winfo_toplevel(self):
def winfo_viewable(self):
def winfo_visual(self):
def winfo_visualid(self):
def winfo_visualsavailable(self, includeids=0):
def winfo_vrootheight(self):
def winfo_vrootwidth(self):
def winfo_vrootx(self):
def winfo_vrooty(self):
def winfo_width(self):
def winfo_x(self):
def winfo_y(self):

--
Dr. Gary Herron <gherron@aw.sgi.com>
206-287-5616
Alias | Wavefront
1218 3rd Ave, Suite 800, Seattle WA 98101
Tkinter question [ In reply to ]
Gary Herron <gherron@aw.sgi.com> wrote:
> > I've got a tkinter canvas, and I want to get it's width.... I call
> >
> > w = int( thecanvas.cget("width") )
> >
> > this works fine.. except when I resize the window, this still returns
> > the width that the canvas was when it was created.. the canvas is
> > getting resized (it has a visible background color)..
> >
> > any ideas?
> >
> > joel
> >
> > --
> > ----------------------------------------------------------------
> > joeld@anisci.com
>
> Use
>
> thecanvas.winfo_width()
>
> This works for any widget, not just canvas.
>
> Here's a list of all the winfo_... methods, taken from Tkinter.py:

...

and here's the documentation:
http://www.pythonware.com/library/tkinter/introduction/basic-widget-methods.htm

</F>
Tkinter question [ In reply to ]
Joel Davis wrote:
>
> w = int( thecanvas.cget("width") )
>
> this works fine.. except when I resize the window, this still returns
> the width that the canvas was when it was created.

w = int(thecanvas.winfo_width())

Greg