Files for 2.1b1 distribution.
[python/dscho.git] / Demo / tkinter / matt / dialog-box.py
blobcbfe29f9643426d64ea25b21fabdc43a828a461e
1 from Tkinter import *
2 from Dialog import Dialog
4 # this shows how to create a new window with a button in it
5 # that can create new windows
7 class Test(Frame):
8 def printit(self):
9 print "hi"
11 def makeWindow(self):
12 """Create a top-level dialog with some buttons.
14 This uses the Dialog class, which is a wrapper around the Tcl/Tk
15 tk_dialog script. The function returns 0 if the user clicks 'yes'
16 or 1 if the user clicks 'no'.
17 """
18 # the parameters to this call are as follows:
19 d = Dialog(
20 self, ## name of a toplevel window
21 title="fred the dialog box",## title on the window
22 text="click on a choice", ## message to appear in window
23 bitmap="info", ## bitmap (if any) to appear;
24 ## if none, use ""
25 # legal values here are:
26 # string what it looks like
27 # ----------------------------------------------
28 # error a circle with a slash through it
29 # grey25 grey square
30 # grey50 darker grey square
31 # hourglass use for "wait.."
32 # info a large, lower case "i"
33 # questhead a human head with a "?" in it
34 # question a large "?"
35 # warning a large "!"
36 # @fname X bitmap where fname is the path to the file
38 default=0, # the index of the default button choice.
39 # hitting return selects this
40 strings=("yes", "no"))
41 # values of the 'strings' key are the labels for the
42 # buttons that appear left to right in the dialog box
43 return d.num
46 def createWidgets(self):
47 self.QUIT = Button(self, text='QUIT', foreground='red',
48 command=self.quit)
49 self.QUIT.pack(side=LEFT, fill=BOTH)
51 # a hello button
52 self.hi_there = Button(self, text='Make a New Window',
53 command=self.makeWindow)
54 self.hi_there.pack(side=LEFT)
57 def __init__(self, master=None):
58 Frame.__init__(self, master)
59 Pack.config(self)
60 self.windownum = 0
61 self.createWidgets()
63 test = Test()
64 test.mainloop()