added ex37
This commit is contained in:
parent
1daf019b2c
commit
778fb469ee
33
ex_37.py
Normal file
33
ex_37.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import tkinter
|
||||
|
||||
messages = {"python": "Ok do that"
|
||||
, "C": "Ok that is fine"
|
||||
, "Fortran": "Weird but ok"
|
||||
, "Perl": "Go back to your BDSM buddies"
|
||||
, "Haskell": "Weird flex but ok"
|
||||
}
|
||||
|
||||
root = tkinter.Tk()
|
||||
selection = tkinter.StringVar()
|
||||
|
||||
textbox = tkinter.Text(root, height=1, width=30)
|
||||
textbox.pack(anchor=tkinter.W)
|
||||
|
||||
def on_selection_changed():
|
||||
my_selection = selection.get()
|
||||
on_selection_changed_callback(my_selection)
|
||||
|
||||
for s in messages.keys():
|
||||
r = tkinter.Radiobutton(root, text=s, command=on_selection_changed
|
||||
, variable=selection
|
||||
, value=s)
|
||||
r.pack(anchor=tkinter.W)
|
||||
|
||||
|
||||
def on_selection_changed_callback(selection):
|
||||
textbox.delete("1.0", tkinter.END)
|
||||
textbox.insert(tkinter.END, messages[selection])
|
||||
|
||||
|
||||
|
||||
root.mainloop()
|
Loading…
Reference in New Issue
Block a user