[Tkinter-discuss] Tkinter-discuss Digest, Vol 76, Issue 9
zizou afix
ziz.root at gmail.com
Sun Jun 20 15:19:40 CEST 2010
Hi Michael,
I understand your clear explanations and now it works.
thanks a lot
ziz
2010/6/20 <tkinter-discuss-request at python.org>
> Send Tkinter-discuss mailing list submissions to
> tkinter-discuss at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> or, via email, send a message with subject or body 'help' to
> tkinter-discuss-request at python.org
>
> You can reach the person managing the list at
> tkinter-discuss-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tkinter-discuss digest..."
>
>
> Today's Topics:
>
> 1. adjust the size of two canvas when I resize (zizou afix)
> 2. Re: adjust the size of two canvas when I resize (Michael Lange)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 20 Jun 2010 04:06:45 +0200
> From: zizou afix <ziz.root at gmail.com>
> To: tkinter-discuss at python.org
> Subject: [Tkinter-discuss] adjust the size of two canvas when I resize
> Message-ID:
> <AANLkTil-63Iznw8yBv-pyxWb_ttVPA36tyi2aWZuv5Nh at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi,
> i'm a new user of tkinter,
> I would like to adjust my canevas to the main window when a resize it.
> i've just find this on the web :
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/layout-mgt.html#root-resize
> but in my case that don't work
>
> this is my code :
> 2 canvas and 2 scrollbars
> it runs but it does not fit at the window
> if someone can help me, very very thanks
>
>
> #####################################################################################
> from Tkinter import *
>
> class Application(Frame):
> def __init__(self, master=None):
> Frame.__init__(self, master)
> self.grid(sticky=N+S+E+W)
> self.canCompose()
>
> def canCompose(self):
> top=self.winfo_toplevel()
> top.rowconfigure(0, weight=1)
> top.columnconfigure(1, weight=1)
> self.rowconfigure(0, weight=1)
> self.columnconfigure(1, weight=1)
>
> self.canCompose = Canvas(self, width = 800, height = 400 ,bg =
> 'red', scrollregion=(0,0,100,400))
> self.canComposeTitle = Canvas(self, width = 100, height =400 ,bg =
> 'blue', scrollregion=(0,0,0,400))
>
> self.canComposeTitle.grid(row=0, column=0,
> sticky=N+S+E+W)
> self.canCompose.grid(row=0, column=1,
> sticky=N+S+E+W)
>
> self.scrollCompose_y = Scrollbar(self, orient='vertical')
> self.scrollCompose_y.config(command = self.twoScroll)
> self.scrollCompose_x = Scrollbar(self, orient='horizontal',
> command=self.canCompose.xview)
>
> self.canComposeTitle['yscrollcommand'] = self.scrollCompose_y.set
> self.canCompose['yscrollcommand'] = self.scrollCompose_y.set
> self.canCompose['xscrollcommand'] = self.scrollCompose_x.set
> self.scrollCompose_y.grid(row=0, column=2,sticky=N+S)
> self.scrollCompose_x.grid(row=1, column=0, columnspan=2, sticky=E+W)
>
> def twoScroll(self, *args):
> """Send y scroll *args to the two canvas"""
> self.canCompose.yview(*args)
> self.canComposeTitle.yview(*args)
> print args
>
> app = Application()
> app.master.title("Sample application")
> app.mainloop()
>
> #####################################################################################
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tkinter-discuss/attachments/20100620/a0884c94/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Sun, 20 Jun 2010 11:25:36 +0200
> From: Michael Lange <klappnase at web.de>
> To: tkinter-discuss at python.org
> Subject: Re: [Tkinter-discuss] adjust the size of two canvas when I
> resize
> Message-ID: <20100620112536.573c74bb.klappnase at web.de>
> Content-Type: text/plain; charset=US-ASCII
>
> Hi Zizou,
>
> On Sun, 20 Jun 2010 04:06:45 +0200
> zizou afix <ziz.root at gmail.com> wrote:
>
> > Hi,
> > i'm a new user of tkinter,
> > I would like to adjust my canevas to the main window when a resize it.
> > i've just find this on the web :
> >
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/layout-mgt.html#root-resize
> > but in my case that don't work
> >
> > this is my code :
> > 2 canvas and 2 scrollbars
> > it runs but it does not fit at the window
> > if someone can help me, very very thanks
> >
> >
> #####################################################################################
> > from Tkinter import *
> >
> > class Application(Frame):
> > def __init__(self, master=None):
>
> First we should find out which widget(s) actually does not expand when
> the window is resized. To do so it may be helpful to change the
> background color of the Frame surrounding the two Canvases :
>
> > Frame.__init__(self, master, bg='yellow')
> > self.grid(sticky=N+S+E+W)
> > self.canCompose()
>
> When you run this slightly modified example you will see that it is
> actually the Frame that does not get resized, not the Canvases.
> When I change the line
>
> self.grid(sticky=N+S+E+W)
>
> into
>
> self.pack(fill='both', expand=1)
>
> the Frame will expand as expected when the window is resized. So we see
> that the self.grid(...) command is the problematic part. In fact in
> your example the Frame expands vertically, but not horizontally, but
> why? The explanation is a few lines below:
>
> >
> > def canCompose(self):
> > top=self.winfo_toplevel()
> > top.rowconfigure(0, weight=1)
> > top.columnconfigure(1, weight=1)
>
> Here you tell the application window to expand row 0 and column 1 when
> the window is resized, but a few lines above you put your Frame into
> row 0 and column 0 (yet not explicitely, but if you do not define grid
> cells, the grid manager will begin automagically with row 0 and col. 0).
> So the solution is to change either
>
> self.grid(sticky=N+S+E+W) into
> self.grid(row=0, column=1, sticky=N +S +E +W)
> or
> top.columnconfigure(1, weight=1) into
> top.columnconfigure(0, weight=1)
>
> I hope this helps
>
> Michael
>
>
>
>
> ------------------------------
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
>
> End of Tkinter-discuss Digest, Vol 76, Issue 9
> **********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20100620/03513ae6/attachment.html>
More information about the Tkinter-discuss
mailing list