Hi,
ich versuche gerad in tKinter mit einer Combox bei drücken einer
Schaltfläche eine Variable auszugeben, aber komme hier nicht weiter.
Wenn ich z.B.:
auswähle soll er mir in die Printausgabe
anzeigen
1 | # coding: utf-8
|
2 | from tkinter import *
|
3 | import tkinter as tk
|
4 | from tkinter import ttk
|
5 |
|
6 | def select():
|
7 | name_option = var.get()
|
8 | print (name_option)
|
9 |
|
10 |
|
11 | fenster = tk.Tk()
|
12 |
|
13 |
|
14 | var = StringVar(fenster)
|
15 |
|
16 | choices = {
|
17 | 'A': '11',
|
18 | 'B': '22',
|
19 | 'C': '33',
|
20 | 'D': '44',
|
21 | 'E': '55',
|
22 | }
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | option = tk.OptionMenu(fenster, var, *choices)
|
28 | option.place(x = 1, y = 50, width=80, height=25)
|
29 |
|
30 | change_button = tk.Button(fenster, text="Klick me", command=select)
|
31 | change_button.place(x = 100, y = 50, width=80, height=25)
|
32 |
|
33 |
|
34 | fenster.mainloop()
|