我有一个使用 python guizero 的 gui,它具有多个用于将整数值插入数据库的文本字段。当按下空格键时,会执行一些操作,如以下代码所示:
app = App(title="App", layout="auto", width=100%, height=100%)
def toggle(event_data):
if(event_data.key == " "):
print("space has been toggled")
#perform some action
app.when_key_pressed = toggle
切换功能按预期工作,问题是当按下空格键时,文本字段中添加了一个不需要的空格。
有没有办法从输入到文本字段中排除空格键?