請問各位:
我有兩個下單式選單A, B,當選單A選擇後會丟出一個值a,我希望選單B能收到a這個值,
請問該怎麼作?
下面是我的程式,請問我該修改哪裡呢?
import tkinter as tk
import pandas as pd
import tkinter.ttk as tt
gui = tk.Tk()
gui.title('test')
gui.geometry('800x450')
def A(*args):
a = A_grade.get()
return a
A_grade = tt.Combobox(gui, width = 50, values = ['1','2','3', '4'], justify =
'center')
A_grade.place(x = 80, y = 355, width = 45, height = 20)
A_grade.current(0)
A_grade.bind("<<ComboboxSelected>>", A)
a = A()
def B(*args):
b= B_grade.get()
print(a)
print(b)
B_grade = tt.Combobox(gui, width = 50, values = ['5','7'], justify = 'center')
B_grade.place(x = 80, y = 405, width = 45, height = 20)
B_grade.current()
B_grade.bind("<<ComboboxSelected>>", B)
gui.mainloop()
執行選單B無法印出a的值,該怎麼把 a 丟到選單B裡呢?