34 lines
740 B
Python
34 lines
740 B
Python
|
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()
|