나는 파이썬 2.7로 프로그램을 만들고 있는데, 구글과 포럼 검색에 몇 시간의 시간이 필요하다는 문제가있다.Python 2.7 PyQt4 다른 메인 윈도우의 탭에 메인 윈도우 파일 추가
내 프로그램은 탭 위젯을 보유하는 sessions_window.py라는 Main_Window로 구성됩니다. 각 탭에는 별도의 메인 윈도우 파일이 있어야합니다. 예를 들어, sessions_window.py의 한 탭은 계정 탭이며 계정 탭에 포함하려는 계정 정보가 들어있는 또 다른 acount1.py 파일이 있습니다 (예, 계정 "acount"의 철자가 있음을 알고 있습니다. 나중에 해결할 것입니다.) 다른 탭은 그래프라고 불리며 다른 Graph.py 파일을 포함해야합니다 (아직이 시점에 이르지는 못했지만).
* 색인/설명 시스템에 따라 요소의 이름을 지정했기 때문에 약간 길고 펑키하지만 도움이됩니다.
파일을 성공적으로 만들었지 만 session_window.py 탭에 파일을 임베드하지 않았습니다. 내가 파일을 가져온
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import acount1
class Ui_BxSession(object):
def configurePageB(self, BxSession):
self.accountTabImport = acount1.Ui_MainWindow
# B : Session Page
BxSession.setObjectName("BxSession")
BxSession.resize(800, 600)
# B_cn1 : Main Space Container
self.B_cn1xMainSpace = QWidget(BxSession)
self.B_cn1xMainSpace.setObjectName("B_cn1xMainSpace")
self.gridLayout_MainB = QGridLayout(self.B_cn1xMainSpace)
self.gridLayout_MainB.setObjectName("gridLayout_MainB")
BxSession.setCentralWidget(self.B_cn1xMainSpace)
# B_cn1_cn1 : Tab Window Space Container
self.B_cn1_cn1xTabWindowSpace = QTabWidget(self.B_cn1xMainSpace)
self.B_cn1_cn1xTabWindowSpace.setObjectName("B_cn1_cn1xTabWindowSpace")
self.gridLayout_MainB.addWidget(self.B_cn1_cn1xTabWindowSpace)
# B_cn1_cn1_tb1 : Account Tab
self.B_cn1_cn1_tb1xAccount = QWidget(self.B_cn1_cn1xTabWindowSpace)
self.B_cn1_cn1_tb1xAccount.setObjectName("B_cn1_cn1_tb1xAccount")
self.B_cn1_cn1xTabWindowSpace.addTab(self.B_cn1_cn1_tb1xAccount, "Account")
self.gridLayout_AccountTab = QGridLayout(self.B_cn1_cn1_tb1xAccount)
self.gridLayout_AccountTab.setObjectName("gridLayout_AccountTab")
self.gridLayout_AccountTab.addWidget(self.accountTabImport)
# B_cn1_cn1_tb2 : Session Tab
self.B_cn1_cn1_tb2xSession1 = QWidget(self.B_cn1_cn1xTabWindowSpace)
self.B_cn1_cn1_tb2xSession1.setObjectName("B_cn1_cn1_tb2xSession1")
self.B_cn1_cn1xTabWindowSpace.addTab(self.B_cn1_cn1_tb2xSession1, "Session")
### rest of code left out
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
BxSession = QMainWindow()
ui = Ui_BxSession()
ui.configurePageB(BxSession)
BxSession.show()
sys.exit(app.exec_())
는 탭 그리드를 생성하고, 그리드 개의 addWidget하려고 노력했다. 하지만 아래 오류가 발생합니다.
C:\Python27\python.exe "C:/Users/smiths/Desktop/App Project/AppDev_2/rewritecode/program/session_window.py"
Traceback (most recent call last):
File "C:/Users/smiths/Desktop/App Project/AppDev_2/rewritecode/program/session_window.py", line 139, in <module>
ui.configurePageB(BxSession)
File "C:/Users/smiths/Desktop/App Project/AppDev_2/rewritecode/program/session_window.py", line 50, in configurePageB
self.gridLayout_AccountTab.addWidget(self.accountTabImport)
TypeError: arguments did not match any overloaded call:
QGridLayout.addWidget(QWidget): argument 1 has unexpected type 'type'
QGridLayout.addWidget(QWidget, int, int, Qt.Alignment alignment=0): argument 1 has unexpected type 'type'
QGridLayout.addWidget(QWidget, int, int, int, int, Qt.Alignment alignment=0): argument 1 has unexpected type 'type'
Process finished with exit code 1
나는 같은 오류 메시지와 함께
self.accountTabImport = acount1.Ui_MainWindow()
을 시도했다.
나는 또한 위의 정의에 나가 건너 뛰고self.gridLayout_AccountTab.addWidget(acount1.Ui_MainWindow).
동일한 오류를 포함했습니다.
acount1.py에는 일련의 기능이 들어있는 클래스가 들어 있습니다. 필요가 없다면 여기에 포함 시키십시오. 그러나 필요한 경우 알려주십시오. 어떤 도움이라도 대단히 감사하겠습니다.
먼저 클래스를 인스턴스화 할 필요가