diff options
author | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
commit | 458120dd40db6b4df55a4e96b650e16798ef06a0 (patch) | |
tree | 8f82685be24fef97e715c6f5ca4c68d34d5074ee /sys/src/cmd/python/Demo/tkinter/matt/radiobutton-simple.py | |
parent | 3a742c699f6806c1145aea5149bf15de15a0afd7 (diff) |
add hg and python
Diffstat (limited to 'sys/src/cmd/python/Demo/tkinter/matt/radiobutton-simple.py')
-rw-r--r-- | sys/src/cmd/python/Demo/tkinter/matt/radiobutton-simple.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/sys/src/cmd/python/Demo/tkinter/matt/radiobutton-simple.py b/sys/src/cmd/python/Demo/tkinter/matt/radiobutton-simple.py new file mode 100644 index 000000000..e9d6afee1 --- /dev/null +++ b/sys/src/cmd/python/Demo/tkinter/matt/radiobutton-simple.py @@ -0,0 +1,62 @@ +from Tkinter import * + +# This is a demo program that shows how to +# create radio buttons and how to get other widgets to +# share the information in a radio button. +# +# There are other ways of doing this too, but +# the "variable" option of radiobuttons seems to be the easiest. +# +# note how each button has a value it sets the variable to as it gets hit. + + +class Test(Frame): + def printit(self): + print "hi" + + def createWidgets(self): + + self.flavor = StringVar() + self.flavor.set("chocolate") + + self.radioframe = Frame(self) + self.radioframe.pack() + + # 'text' is the label + # 'variable' is the name of the variable that all these radio buttons share + # 'value' is the value this variable takes on when the radio button is selected + # 'anchor' makes the text appear left justified (default is centered. ick) + self.radioframe.choc = Radiobutton( + self.radioframe, text="Chocolate Flavor", + variable=self.flavor, value="chocolate", + anchor=W) + self.radioframe.choc.pack(fill=X) + + self.radioframe.straw = Radiobutton( + self.radioframe, text="Strawberry Flavor", + variable=self.flavor, value="strawberry", + anchor=W) + self.radioframe.straw.pack(fill=X) + + self.radioframe.lemon = Radiobutton( + self.radioframe, text="Lemon Flavor", + variable=self.flavor, value="lemon", + anchor=W) + self.radioframe.lemon.pack(fill=X) + + # this is a text entry that lets you type in the name of a flavor too. + self.entry = Entry(self, textvariable=self.flavor) + self.entry.pack(fill=X) + self.QUIT = Button(self, text='QUIT', foreground='red', + command=self.quit) + self.QUIT.pack(side=BOTTOM, fill=BOTH) + + + def __init__(self, master=None): + Frame.__init__(self, master) + Pack.config(self) + self.createWidgets() + +test = Test() + +test.mainloop() |