いくつかの条件をチェックし、データが利用可能かどうかをチェックするプログラムがあります。欠落しているデータがある場合は、そのウィンドウでデータを収集する別のウィンドウをポップアップ表示します。2 つのボタン (適用と閉じる) があります。ボタンがトリガーされた後に値を返したい。
と の両方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