On Tue, 1 Feb 2005 19:08:41 +0200
Mark Kels <[EMAIL PROTECTED]> wrote:
Hi Mark,
> Hello,
> I got some Tkinter questions that I need the answer for to complete a
> little project of mine:
> 1. How can I make the program to open in a X*Y sized window ?
from Tkinter import *
root = Tk()
root.geometry('600x400+0+0')
This makes a window of 600x400 pixels placed in the upper left corner of the
screen (+0+0 is the x- and y- offset;
both of the window size and the offset may be omitted, so you can use '600x400'
or '+0+0' as arguments for geometry()
as well).
> 2. How can I open another window from the first one (without closing it) ?
Use instances of Toplevel() to create new windows as children of the root
(Tk()) window.
> 3. How can I add a file browser for my app (like the one you get when
> you press "Save as..." in windows apps) ?
import tkFileDialog
filename = tkFileDialog.asksaveasfilename()
if filename:
# save the file...; if the user presses the 'Cancel' button, filename
should be set to an empty string.
> 4. How do I configure the font size on the Text widget (its realy
> huge, and I would like to change it to somthing like 12).
text = Text(parent, font=('helvetica', '-12', 'normal'))# "negative" size ->
pixel size
or:
text.configure(font=('helvetica', '12', 'normal'))# "positive" size -> point
size
You can use any 3-tuple of the form (family, size, weight) as font descriptor;
if the requested font is not
found, the widget should fall back to some (probably ugly) default; tk
guarantees that at least 'times',
'helvetica' and 'courier' font families are available, the availability of
other fonts depends on your system.
I hope this helps
Michael
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor