python - 当我在 tkinter 中调用我为 bind 创建的函数时,我应该给出什么参数
问题描述
下面是一个问题的例子:
from tkinter import ttk
from tkinter import *
root = Tk()
combobox1 = ttk.Combobox(root, values = ('Jan', 'Feb', 'August'))
combobox1.pack()
comb2 = ttk.Combobox(root, state=DISABLED)
comb2.pack()
def comb1_selected(*args):
someword = ""
if combobox1.get() == 'Jan':
someword = 'J'
comb2.config(state='normal')
comb2.config(values=someword)
return someword
def use_comb1_selected():
print(comb1_selected(*args))
use_comb1_selected() #What arguments should I give here??
combobox1.bind("<<ComboboxSelected>>", comb1_selected)
root.mainloop()
我无法弄清楚要为我创建的函数提供哪些参数尝试提供诸如“事件”之类的参数导致以下错误
NameError: name 'event' is not defined
如果没有参数,该函数什么也不做,即使它应该打印为 'J'
请帮助我了解我需要做什么
解决方案
推荐阅读
- c# - 需要帮助编辑代码以在键盘而不是滚轮上旋转
- javascript - 如何在 three.js 中修复 FirstPersonControls 给出错误 targetPosition.setFromSphericalCoords is not a function
- python - 如果在函数定义中给出默认服务器名称,pyodbc 会自动连接到数据库吗?
- python - 使用另一个模块中的方法跳出循环
- javascript - 创建参数类型的变量
- git - git push:对象为12311134字节,大于本仓库对象的1048576字节限制
- java - 我的场景大纲似乎没有以我以前见过的格式输出
- java - 从多个数据包写入字节到文件
- python - 如何知道在 spaCy NLP 输出中按空格连接的位置
- node.js - 无法使用 lokijs 将数据保存在文件中