我有一个程序可以检查几个条件并检查数据是否可用。如果有任何丢失的数据,那么我将弹出另一个窗口,该窗口将在该窗口中收集数据。它将有两个按钮(应用和关闭)。我想在按钮被触发后返回一个值。
两者program.py
都有dataEntry.py
自己的用 PyQt Disigner 设计的 UI。
我希望我的程序等待来自其他窗口的返回值。并根据输入我将继续我的其他过程。
假设程序文件是program.py
,另一个窗口dataEntry.py
被导入program.py
我的dataEntry.py
样子
#imports necessary modules
class dataEntry(QtGui.QMainWindow,Ui_DataEntry):
def __init__(self):
super(dataEntry,self).__init__()
self.setupUi(self)
self.Btn_Apply.clicked.connect(self.ApplyChanges)
self.Btn_Close.clicked.connect(self.CancelChanges)
def ApplyChanges(self):
#This will trigger when ApplyButonn is clicked
#I want to return True value from here
return True
def CancelChanges(self):
#This will trigger when CancelButonn is clicked
#I want to return False value from here
return False
我的program.py
样子
from dataEntry import dataEntry
class MainApp(QtGui.QMainWindow,Ui_MainApp):
def __init__(self):
super(MainApp,self).__init__()
self.setupUi(self)
self.CheckDetails()
def CheckDetails(self):
#Here i will check if required data is present else i will take data from dataEntry class
if checkFails:
input = dataEntry()
input.show()
#Here i want this class to wait until i get the result from dataEntry class
EntryResult = return value from dataEntry
if EntryResult:
#Do some thing when its True
else:
#Do some thing when its False