Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用GUI界面控制应用程序流_Python_User Interface_Matplotlib_Tkinter - Fatal编程技术网

Python 使用GUI界面控制应用程序流

Python 使用GUI界面控制应用程序流,python,user-interface,matplotlib,tkinter,Python,User Interface,Matplotlib,Tkinter,(如果您决定回答,请提前感谢。如果我无法清楚描述申请的内容,请道歉。) 我目前正在为我的gui界面使用Tkinter Python制作桌面应用程序。我遇到了一个与应用程序流程相关的问题 我的应用程序 我的申请的主页上有一些文本框和复选框。Check按钮作为True或False条件工作,其中每个Check按钮表示是否必须执行特定功能。 要存储check按钮的值,字典将使用键作为LabelName和值作为True/False值进行维护 复选框代码 表单中有一个提交按钮,按下该按钮时,所有数据都会与这

(如果您决定回答,请提前感谢。如果我无法清楚描述申请的内容,请道歉。)

我目前正在为我的gui界面使用Tkinter Python制作桌面应用程序。我遇到了一个与应用程序流程相关的问题

我的应用程序

我的申请的主页上有一些文本框和复选框。Check按钮作为True或False条件工作,其中每个Check按钮表示是否必须执行特定功能。 要存储check按钮的值,字典将使用键作为LabelName和值作为True/False值进行维护

复选框代码

表单中有一个提交按钮,按下该按钮时,所有数据都会与这些复选按钮一起输入文本框。基于真-假值,调用函数,函数由if-else条件处理

#submit button
ttk.Button(parent,text="Submit",command=onsubmit)
###########
def onsubmit():
    ----------statements to read data--------------
    dict['func1']=f1
    dict['func2']=f2
    #other statements
    -----------------------------------------------
    if dict['func1']:
        func1()
    if dict['func2']:
        func2()
    ---other if-else conditions---
每个函数都是单独的模块,由表单、带数据的框架或matplotlib图形组成,用于数据可视化,并对放置在根窗口框架上的数据和图形执行其他操作

我的问题

我希望用户在执行每个功能后,通过给他们下一个按钮来控制流程,然后根据他输入的检查按钮进入下一个功能的执行。程序应等待用户按下下一步按钮,在用户按下下一步按钮后,程序应执行下一步功能,然后再次等待下一步按钮

解决方案之一:
使用fig.waitforbuttonpress()就是解决方案。但我觉得它不可靠。因为即使是鼠标点击也会跳过函数的执行。但我需要特别指定一个按钮,用户可以通过该按钮选择何时继续执行下一个功能。

我不确定是否理解您的代码,但您可以这样做,我想:

next_button = ttk.Button(parent,text="Next",command=func1)

...

def func1():
    #do your stuff here        
    next_button.configure(command=func2)
然后,您必须将最后一行代码添加到所有函数中,以便始终重新分配按钮

另一种方法可以是:

process = 0

next_button = ttk.Button(parent,text="Next",command=next)

def next():
    global process
    process += 1
    if process == 1:
        func1()
    elif process == 2:
        func2()

    ...

    elif *last_function_reached*:
        process = 0
阅读和
process = 0

next_button = ttk.Button(parent,text="Next",command=next)

def next():
    global process
    process += 1
    if process == 1:
        func1()
    elif process == 2:
        func2()

    ...

    elif *last_function_reached*:
        process = 0