Entry
Resizing a canvas
Jul 5th, 2000 10:03
Nathan Wallace, unknown unknown, Hans Nowak, Snippet 385, Ivan Van Laningham
"""
Packages: gui.tkinter
"""
"""
Date sent: Thu, 09 Dec 2020 13:31:06 -0700
From: Ivan Van Laningham <ivanlan@callware.com>
Organization: Callware Technologies, Inc.
To: Tobe Bradshaw <tbradshaw@orchestream.com>,
Python Mailing List <python-list@python.org>
Subject: Re: Tk stuff...
> I'm an intermediate Python user starting to get to grips with Tkinter..
> and I could do with some help here.. Hopefully if I just state the basic
> problem you'll not laugh too much at me...
>
> I want to write a one window application which contains just a canvas.
> Unfortunately I've fallen at the first hurdle 'cause I can't figure out
> how you'd make it so that resizing the main window will cause the canvas
> to be appropriately resized. Currently I've got a callback on
> <Configure> which simply calls .pack() on the canvas.. this obviously
> doesn't work.
"""
import sys
from Tkinter import *
w = 400
h = 400
def die(event=0):
sys.exit(0)
def chsize(event):
global w,h,xp,yp,xdelta,ydelta
w = event.width
h = event.height
if __name__ == "__main__":
root = Tk()
cv = Canvas(root,width=w,height=h,borderwidth=0,
background="#409040",
highlightthickness=0)
cv.bind("<Configure>", chsize)
root.bind("<Escape>", die)
cv.pack(expand=1,fill=BOTH)
root.mainloop()
"""
The key here is
cv.pack(expand=1,fill=BOTH)
That tells the Pack manager to expand the Canvas in BOTH directions when
the parent (root) is resized.
> So.. bearing in mind that I know absolutely nothing about tcl (he says,
> glaring at Ousterhout.. much use *that* is to me).. but a lot about Java
> (I notice at least a few common concepts in Tk, or do I misunderstand?)
> and GUIs in general.. can anyone give me a good overview of how you'd go
> about common GUI tasks using Tkinter/show me a good place to look for
> such info/come and write my code for me
> (delete as applicable)...
>
The only place to get info right now is at
http://www.pythonware.com
The tutorial there is not complete, but it's a lot better than nothing.
/F is so busy he doesn't have time to update it. There are several
books coming out, including one by Fredrik, but none are out *now*.
John Grayson's book looks very good to me.
I don't think you're going to get many volunteers to write your code for
you. No one wants to deprive you of your fun.;-)
> (And sorry to be a pain, but could I request you cc: my inbox, I am
> fighting with our Tech. dept. to fix their ***ing newsfeed).
>
<bribery-has-been-known-to-work>-ly y'rs,
Ivan
"""