From 778fb469eebf884d3825773ea2e2bcc106e9916a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kn=C3=BCttel?= Date: Wed, 9 Jan 2019 15:38:19 +0100 Subject: [PATCH] added ex37 --- ex_37.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ex_37.py diff --git a/ex_37.py b/ex_37.py new file mode 100644 index 0000000..9a0968c --- /dev/null +++ b/ex_37.py @@ -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()