How big is that canvas in the window?

Bob Greschke bob at passcal.nmt.edu
Tue Aug 28 17:01:40 CEST 2001


Why is everything in the appendix??  I NEVER look in the appendix. :-)

We just did install PMW to our server, so the project will go in that
direction.  I just want to get it to work ONCE the hard way.  I just
wanna see a graph! :-)

Thanks everybody!

Bob

> I can't view the URL you reference for some reason, but I'll
> take a shot at answering your question.
>
> The canvas object is always -logically- the same size: whatever
> values you give for the "width" and "height" options when the
> canvas was created. It will be clipped if the containing window
> is smaller than the canvas, but the contents of the clipped
> areas are "still there" (they'll be repainted if they become
> visible again). The upshot of all this is that you can just draw
> using absolute canvas coordinates and everything will work.
> If you need to find out the (canvas) coordinates of a particular
> item on the canvas, use "canvas.bbox(<item>)". If you need the
> canvas to be scrollable, attach scrollbars to it and hook
> them up using the xscrollcmd/yscrollcmd/xview/yview options.
>
>Does that help?
>
> --
> # Joe Knapka
> # "You know how many remote castles there are along the
> #  gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald
> # Linux MM docs:
> http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
> "Robert Roy" <rjroy at takingcontrol.com> wrote in message
news:3b8a4d88.3349828 at news1.on.sympatico.ca...
> On 26 Aug 2001 05:12:52 -0700, koen at behindthesofa.dhs.org (Koen
> Bossers) wrote:
>
> >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
>
> Bob,
>
> See also winfo_width, winfo_height. In some circumstances, I have
> found these to be more reliable than cget('width"), and
cget("height")
>
>
>
http://www.pythonware.com/library/tkinter/introduction/x9170-window-re
lated-information.htm
>
> also you might want to try using PMW
>
> http://pmw.sourceforge.net/
>
> It has nice megawidgets including a scrolled canval
>
>
>
> Bob Roy





More information about the Python-list mailing list