Я работаю с PySide2 уже пару дней. Я сделал отдельный модуль с именем splash_page.py
для хранения класса QWidget
. Но когда я импортирую и использую его, я не вижу виджеты.
splash_page.py
from PySide2.QtWidgets import *
from PySide2.QtGui import *
class SplashPage(QWidget):
def __init__(self):
super().__init__()
self.security_code_message = QLabel('Enter Security Code')
self.ipt_box = QLineEdit()
self.submit_button = QPushButton()
vbox = QVBoxLayout()
vbox.addWidget(self.security_code_message)
vbox.addWidget(self.ipt_box)
vbox.addWidget(self.submit_button)
self.setLayout(vbox)
self.initUI()
#self.show()
#self.showFullScreen()
def initUI(self):
self.security_code_message.move(301,170)
self.ipt_box.move(301,315)
self.submit_button.move(800,405)
main.py
from PySide2.QtWidgets import *
from PySide2.QtGui import *
import splash_page
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.cw = QWidget(self)
self.setCentralWidget(self.cw)
self.setGeometry(0,0,900,1000)
sp = splash_page.SplashPage()
vbox = QVBoxLayout()
vbox.addWidget(sp)
self.setLayout(vbox)
app = QApplication()
window = MainWindow()
window.show()
app.exec_()