in file1, value of "source" is changed depends on which button I click.
source = 0
form_class2 = uic.loadUiType("./UI/Code.ui")[0]
class Code(QDialog, form_class2):
def __init__(self):
super().__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.aa)
self.pushButton_2.clicked.connect(self.bb)
def aa(self):
global source
source = 1
app.quit()
def bb(self):
global source
source = 2
app.quit()
if __name__ == "__main__":
app = QApplication(sys.argv)
myWindow = Code()
myWindow.show()
app.exec_()
import file2
then in file2:
from file1 import source
print(source)
output is 0
How can I get 1 or 2 for the output in flie2?
Maybe this can help you
from file1 import *
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.