Я хочу изменить отображение по нажатию кнопки. мой текущий код:
import sys
from PyQt5 import QtWidgets, uic
Ui_bankApp, _ = uic.loadUiType("bankApp.ui")
Ui_Borrow, _ = uic.loadUiType("Borrow.ui")
Ui_Login, _ = uic.loadUiType("login.ui")
Ui_Pay, _ = uic.loadUiType("Pay.ui")
class Borrow(object):
def setupUI(self, Ui):
uic.loadUi('Borrow.ui', self)
class Ui(QtWidgets.QMainWindow):
def __init__(self):
super(Ui, self).__init__()
self.bankApp()
def bankApp(self):
print("bankApp")
self.ui = Ui_bankApp()
self.ui.setupUi(self)
self.hide()
self.show()
self.button = self.findChild(QtWidgets.QPushButton, 'pushButton_2')
self.button.clicked.connect(self.Borrow)
def Borrow(self):
print("Borrow")
self.ui1 = Ui_Borrow()
self.ui1.setupUi(self)
self.button1 = self.findChild(QtWidgets.QPushButton, 'pushButton_2')
self.button1.clicked.connect(self.bankApp)
def Login(selft):
self.ui = Ui_Login()
self.ui.setupUi(self)
def Pay():
self.ui = Ui_Pay()
self.ui.setupUi(self)
app = QtWidgets.QApplication(sys.argv)
window = Ui()
window.show()
app.exec_()
мои два файла пользовательского интерфейса выглядят так: bankApp.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>80</x>
<y>190</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Pay</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>610</x>
<y>180</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Borrow</string>
</property>
</widget>
<widget class="QLCDNumber" name="lcdNumber">
<property name="geometry">
<rect>
<x>210</x>
<y>30</y>
<width>321</width>
<height>91</height>
</rect>
</property>
<property name="intValue" stdset="0">
<number>1000</number>
</property>
</widget>
<widget class="QLCDNumber" name="lcdNumber_2">
<property name="geometry">
<rect>
<x>600</x>
<y>270</y>
<width>131</width>
<height>51</height>
</rect>
</property>
</widget>
<widget class="QLCDNumber" name="lcdNumber_3">
<property name="geometry">
<rect>
<x>600</x>
<y>370</y>
<width>131</width>
<height>51</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>600</x>
<y>230</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Spent</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>600</x>
<y>340</y>
<width>47</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Earned</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>40</x>
<y>250</y>
<width>47</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Debt</string>
</property>
</widget>
<widget class="QLCDNumber" name="lcdNumber_4">
<property name="geometry">
<rect>
<x>40</x>
<y>270</y>
<width>141</width>
<height>51</height>
</rect>
</property>
</widget>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
Заимствовать:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Borrow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>51</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Back</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>220</x>
<y>290</y>
<width>281</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Borrow</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>220</x>
<y>200</y>
<width>281</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>Amount</string>
</property>
</widget>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
, поэтому я хочу перейти на заимствование страницу, когда я нажимаю кнопку заимствования в bankApp, затем я хочу перейти на страницу bankApp, когда нажимаю кнопку возврата. но когда я нажимаю кнопку возврата на странице заимствования, она не go возвращается на страницу bankApp