#主要的思路就是建立兩個frame(如果有兩個以上同理)使用setvisible()函式顯示或者隱藏frame 引數是bool值
import sys
from pyqt5.qtwidgets import *
from pyqt5.qtcore import *
from pyqt5.qtgui import *
class logindialog(qdialog):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setwindowtitle('登入介面')
self.resize(200, 200)
self.setfixedsize(self.width(), self.height())
self.setwindowflags(qt.windowclosebuttonhint)
self.frame = qframe(self)
self.verticallayout = qvboxlayout(self.frame)
self.lineedit_account = qlineedit()
self.lineedit_account.setplaceholdertext("請輸入賬號")
self.verticallayout.addwidget(self.lineedit_account)
self.lineedit_password = qlineedit()
self.lineedit_password.setplaceholdertext("請輸入密碼")
self.verticallayout.addwidget(self.lineedit_password)
self.pushbutton_enter = qpushbutton()
self.pushbutton_enter.settext("進入下乙個介面")
self.verticallayout.addwidget(self.pushbutton_enter)
self.frame1 = qframe(self)
self.verticallayout = qvboxlayout(self.frame1)
self.pushbutton_quit = qpushbutton()
self.pushbutton_quit.settext("回到主頁面")
self.verticallayout.addwidget(self.pushbutton_quit)
self.frame1.setvisible(false)
self.pushbutton_enter.clicked.connect(self.on_pushbutton_enter_clicked)
self.pushbutton_quit.clicked.connect(self.on_pushbutton_enter_clicked_1)
def on_pushbutton_enter_clicked(self):
self.frame1.setvisible(true)
self.frame.setvisible(false)
def on_pushbutton_enter_clicked_1(self):
self.frame1.setvisible(false)
self.frame.setvisible(true)
if __name__ == "__main__":
dialog = logindialog()
if dialog.exec_() == qdialog.accepted:
pyqt5多視窗來回切換
coding utf 8 多視窗反覆切換,只用pyqt5實現 import sys 匯入系統 class firstui qmainwindow 第乙個視窗類 def init self super firstui,self init self.init ui def init ui self se...
pyqt5 多介面切換 QTabWidget
pyqt5 多介面切換 qtabwidget import sys from pyqt5.qtcore import from pyqt5.qtgui import from pyqt5.qtwidgets import class tabdemo qtabwidget def init self,...
PyQt5的簡單登入介面切換
這個demo中的介面切換通過pyqt5中按鍵槽函式響應介面close show 函式實現 import sys from pyqt5.qtwidgets import 登入介面類 class login qwidget def init self,parent none super login,se...