首页 > 解决方案 > wxPython - 检测无输入变化的最佳方法?

问题描述

我有一个带有 wxPython 的 GUI,用于管理我的 SQL 查询的输入。我需要检查是否有任何输入(TextCtrl、ComboBox 等)被更改。

最好的方法是什么?我真的需要将所有输入保存在任何地方吗?

很抱歉没有提供代码,但我认为发布一个小的 wxPython 工具不会支持我的问题。

标签: pythonpython-3.xwxpython

解决方案


试试这个 //sw

注意:我不知道 wxPython 是如何工作的,只有 pygame 和 tkinter

有一个空闲函数来检查_thread

import _thread

def this_function_should_return_the_text_of_the_inputbox():
    
    return content_of_the_inputbox

def  this_function_will_be_called_if_the_inputbox_is_changed():

    Do something


def idle_checking():

    latest_check = this_function_should_return_the_text_of_the_inputbox()
    
    while True:

        check = this_function_should_return_the_text_of_the_inputbox()

        if latest_check != check:
            
            latest_check = check

            this_function_will_be_called_if_the_inputbox_is_changed()

            
            

_thread.start_new_thread(idle_checking,())

推荐阅读