added ex37

gol
Daniel Knüttel 2019-01-09 15:38:19 +01:00
parent 1daf019b2c
commit 778fb469ee
1 changed files with 33 additions and 0 deletions

33
ex_37.py 100644
View 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()