QT 디자이너를 사용하여 PyQT에서 많은 GUI 인터페이스를 만들었지 만 다른 인터페이스를 열려고하는데 현재 어떻게해야할지 모르겠다. Start.py는 GUI 인터페이스를 실행 파일입니다 Authentification_1 및 Acceuil_start.py은, 지금은 Start.py에서 점심 Acceuil_start하려는 GUI 인터페이스 Acceuil_2.py을 실행 파일입니다 .py. 그것에 대해 알고 있습니까? 고맙습니다. 여기 내 코드입니다 :다른 파일에서 GUI 파일 열기 PyQT
이Start.py :
import sys
from PyQt4 import QtCore, QtGui
from Authentification_1 import Ui_Fenetre_auth
from Acceuil_2 import Ui_MainWindow #??? Acceuil_2.py is the file which I want to open
class StartQT4(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Fenetre_auth()
self.ui.setupUi(self)
def authentifier(val): #Slot method
self.Acceuil = Acceuil() #???
self.Acceuil.show() #???
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()
sys.exit(app.exec_())
, 당신은 그들이 다른 이름, 그리고 일반적인 하나가 귀하의 GUI 클래스의 이름을 지정해야
Acceuil_start.py
import sys
from PyQt4 import QtCore, QtGui
from Authentification_1 import Ui_Fenetre_auth
from Acceuil_2 import Ui_MainWindow
class StartQT4(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()
sys.exit(app.exec_())
감사합니다. Is 부모 클래스, 다른 클래스를 열어야하는 클래스? _Acceuil_start.py_에서 클래스 이름을 변경해야하는 이유는 무엇입니까? – Copernic
@Mehdi 답변을 업데이트하겠습니다! 이게 지금까지 작동합니까? –
아니, 그것은 내게이 오류가 발생합니다 : _NameError : 전역 이름 'Acceuil'정의되지 않았습니다 :'self.Acceuil = Acceuil (자체)' – Copernic