【发布时间】:2021-06-10 04:40:12
【问题描述】:
我开始使用 Python 中的 Tkinter。我很难做一件简单的事情。有两个组合框。例如,在第一个组合框Category中选择文本“”Test1“,我想在第二个combobox Subcategory中打开Hello1”、“Hello2”、“Hello3”。
也许我一开始就写错了代码。我想问你两件事:
-
你能帮我解决我的 IF 问题吗?
-
我认为我没有从第一行编写正确的代码。你能给我一个所有代码的系统吗?幸好时间不长谢谢
from tkinter import * from tkinter import ttk import sqlite3 window=Tk() window.title("aaaa") window.geometry("700x700") categoria=["Test1", "Test2", "Test3"] categoria=ttk.Combobox(window,value=categoria,width=16) categoria.place(x=5, y=100) categoria.set("Scegliere categoria") categoria.pack sottocategoria=["aaaa"] sottocategoria=ttk.Combobox(window,value=sottocategoria,width=16) sottocategoria.place(x=5, y=130) sottocategoria.pack if categoria == ("Test1"): sottocategoria = ["Hello1", "Hello2", "Hello3"] window.mainloop()
【问题讨论】:
-
您需要跟踪变量以检测值的任何变化
-
您应该阅读有关事件驱动编程的更多信息。
标签: tkinter