[Tutor] tkinter?
Michael P. Reilly
arcege@speakeasy.net
Wed, 23 May 2001 09:40:49 -0400 (EDT)
sheri wrote
>
> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_0009_01C0E35B.4DF67360
> Content-Type: text/plain;
> charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> hello my little script is working just fine thanks to everyone.
> i was looking at the tcl widget demo and saw the file selection
> dialog code which would be really neat to integrate into my program.
> unfortunately i cannot figure out how to do this. is there a nice =
> tkinter
> way of adding this to my program?=20
>
> ------=_NextPart_000_0009_01C0E35B.4DF67360
There are two file dialog widget sets in Tkinter. One is built from
the raw Tk(inter) widgets. The second is newer and uses Tk's new
"native-feel" widgets.
First one (from FileDialog.test):
from FileDialog import *
root = Tk() # Dialog has a bug where it cannot take None as root
root.withdraw() # don't display root window
fd = FileDialog.LoadFileDialog(root)
loadfile = fd.go(key="test")
fd = FileDialog.SaveFileDialog(root)
savefile = fd.go(key="test")
print loadfile, savefile
Second one (from tkFileDialog main code):
import tkFileDialog
print "open" askopenfilename(filenames=[('all filez", "*")])
print "saveas", asksaveasfilename()
The advantage of the first is that it is easier to reuse the widget (and
to make subclasses). The second looks more like a X-Windows/WinXX/Mac
file dialog.
-Arcege
--
+----------------------------------+-----------------------------------+
| Michael P. Reilly | arcege@speakeasy.net |