def LoadLayout(self): ScrollBoxStyleSheet = (""" QScrollBar:vertical { border: 0px solid #999999; background:white; width:5px; margin: 0px 0px 0px 0px; } QScrollBar::handle:vertical { background-color: gray ; min-height: 0px; border-radius:2px; } QScrollBar::add-line:vertical { background-color: white; height: 0px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical { background-color:white; height: 0 px; subcontrol-position: top; subcontrol-origin: margin; } QScrollArea { border :0px; }""") root = QStackedWidget(self) reminders, count = FileUtil.loadRemindersFromFile(self) self.reminderContainer = QVBoxLayout() scroll = QScrollArea() scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) scroll.setWidgetResizable(True) scroll.setStyleSheet(ScrollBoxStyleSheet) reminderGroupBox = QGroupBox() self.reminderContainer.addStretch() reminderGroupBox.setLayout(self.reminderContainer) scroll.setWidget(reminderGroupBox) if (count != 0): for reminder in reminders: self.reminderContainer.addWidget(self.reminderUI(reminder)) root.setStyleSheet("padding:0px;\n" + self.NoBoderStyleSheet) #root.addWidget(reminderGroupBox) #rootBox = QGroupBox() #rootBox.setLayout(scroll) root.addWidget(scroll) templayout = QGridLayout() templayout.setContentsMargins(0, 0, 0, 10) templayout.setSpacing(0) templayout.addWidget(self.upperFrame()) templayout.addWidget(root) return templayout
class MainApp(QMainWindow): def __init__(self): super(MainApp, self).__init__() # App metadata self.setWindowTitle('Alice Installer') self.setWindowIcon(QIcon(PATH + '/images/icon.png')) self.setWindowFlags(Qt.WindowCloseButtonHint) self.setFixedSize(800, 400) self.load_fonts() # Set central widget and init ui self.central_widget = QWidget(self) self.central_widget.resize(self.frameSize()) self.initUI() def initUI(self): self.stacked_widget = QStackedWidget(self.central_widget) self.stacked_widget.resize(self.frameSize()) self.stacked_widget.setAutoFillBackground(False) self.stacked_widget.setStyleSheet('background-color: #111118;') # Import activities and add to stack self.start_app = StartApp(self) self.install_window = InstallWindow(self) self.install_complete = InstallComplete(self) self.stacked_widget.addWidget(self.start_app) self.stacked_widget.addWidget(self.install_window) self.stacked_widget.addWidget(self.install_complete) # Activities Triggers self.start_app.install.clicked.connect(lambda: self.switch_layout(1)) def load_fonts(self, path=PATH + '/fonts/'): fonts = [f for f in listdir(path) if isfile(join(path, f))] self.font_db = {} # For each font finded in /fonts add to Application and create a directory of fonts for font in fonts: self.font_id = QFontDatabase.addApplicationFont(path + font) self.font_db[font.replace("-", " ")[:-4]] = self.font_id def set_font(self, font_name, font_size): selected_font = QFontDatabase.applicationFontFamilies( self.font_db[font_name]) font = QFont() font.setFamily(selected_font[0]) font.setPointSize(int(font_size)) return font def switch_layout(self, index): self.stacked_widget.setCurrentIndex(index)
import sys from PyQt5.QtWidgets import QApplication, QStackedWidget from PyQt5 import QtGui from Login.View.ViewLogin import ViewLogin if __name__ == '__main__': app = QApplication(sys.argv) widget = QStackedWidget() Vista_login = ViewLogin(widget) widget.addWidget(Vista_login) widget.setStyleSheet("background-color: rgb(254, 235, 156)") widget.setWindowTitle("Cinema") icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap("images/biglietto.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) widget.setWindowIcon(icon) # Spostamento widget al centro (fissare dimensione login al max per mantenere tutto al centro) widget.show() centerPoint = QtGui.QScreen.availableGeometry(app.primaryScreen()).center() fg = widget.frameGeometry() fg.moveCenter(centerPoint) widget.move(fg.topLeft()) sys.exit(app.exec())
class mywindow(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.F = MyFigure(width=1,height=1,dpi=100) self.F.plotsin() self.timer = QBasicTimer() self.step = 0 #self.workmodule1.clicked.connect(self.workmodule_1) #全局布局 self.GlobalLayout=QHBoxLayout() #三个按钮 self.fasong_btn1 = QPushButton('存储', self) self.fasong_btn1.setFont(QFont("微软雅黑",20,QFont.Bold)) self.fasong_btn1.setFixedSize(140,60) self.fasong_btn1.clicked.connect(self.cunchu) self.fasong_btn2 = QPushButton('温度',self) self.fasong_btn2.setFont(QFont("微软雅黑",20,QFont.Bold)) self.fasong_btn2.setFixedSize(140,60) self.fasong_btn2.clicked.connect(self.wendu) self.fasong_btn3 = QPushButton('工作状态',self) self.fasong_btn3.setFont(QFont("微软雅黑",12,QFont.Bold)) self.fasong_btn3.setFixedSize(140,60) self.fasong_btn3.clicked.connect(self.work) #工作模式按钮 self.workmodule1=QPushButton('模式1',self) self.workmodule1.setFont(QFont("微软雅黑",18,QFont.Bold)) self.workmodule1.setFixedSize(100,100) #self.workmodule1.clicked.connect(self.workmodule_1) self.workmodule1.clicked.connect(self.doAction) self.workmodule2=QPushButton('模式2',self) self.workmodule2.setFont(QFont("微软雅黑",18,QFont.Bold)) self.workmodule2.setFixedSize(100,100) self.workmodule3=QPushButton('模式3',self) self.workmodule3.setFont(QFont("微软雅黑",18,QFont.Bold)) self.workmodule3.setFixedSize(100,100) #存储按钮 self.cunchu_btn1 = QPushButton('',self) self.cunchu_btn1.clicked.connect(self.cunchu_btn1_1) self.cunchu_btn1.setFixedSize(90,90) self.cunchu_btn1.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn2 = QPushButton('',self) self.cunchu_btn2.setFixedSize(90,90) self.cunchu_btn3 = QPushButton('',self) self.cunchu_btn3.setFixedSize(90,90) self.cunchu_btn4 = QPushButton('',self) self.cunchu_btn4.setFixedSize(90,90) self.cunchu_btn5 = QPushButton('',self) self.cunchu_btn5.setFixedSize(90,90) self.cunchu_btn6 = QPushButton('',self) self.cunchu_btn6.setFixedSize(90,90) self.cunchu_btn7 = QPushButton('',self) self.cunchu_btn7.setFixedSize(90,90) self.cunchu_btn8 = QPushButton('',self) self.cunchu_btn8.setFixedSize(90,90) self.cunchu_btn9 = QPushButton('',self) self.cunchu_btn9.setFixedSize(90,90) self.cunchu_btn10 = QPushButton('',self) self.cunchu_btn10.setFixedSize(90,90) self.cunchu_btn11 = QPushButton('',self) self.cunchu_btn11.setFixedSize(90,90) self.cunchu_btn12 = QPushButton('',self) self.cunchu_btn12.setFixedSize(90,90) self.cunchu_btn13 = QPushButton('',self) self.cunchu_btn13.setFixedSize(90,90) self.cunchu_btn14 = QPushButton('',self) self.cunchu_btn14.setFixedSize(90,90) self.cunchu_btn15 = QPushButton('',self) self.cunchu_btn15.setFixedSize(90,90) self.cunchu_btn16 = QPushButton('',self) self.cunchu_btn16.setFixedSize(90,90) self.cunchu_btn17 = QPushButton('',self) self.cunchu_btn17.setFixedSize(90,90) self.cunchu_btn18 = QPushButton('',self) self.cunchu_btn18.setFixedSize(90,90) self.cunchu_btn19 = QPushButton('',self) self.cunchu_btn19.setFixedSize(90,90) self.cunchu_btn20 = QPushButton('',self) self.cunchu_btn20.setFixedSize(90,90) self.cunchu_btn21 = QPushButton('',self) self.cunchu_btn21.setFixedSize(90,90) self.cunchu_btn22 = QPushButton('',self) self.cunchu_btn22.setFixedSize(90,90) self.cunchu_btn23 = QPushButton('',self) self.cunchu_btn23.setFixedSize(90,90) self.cunchu_btn24 = QPushButton('',self) self.cunchu_btn24.setFixedSize(90,90) self.cunchu_btn25 = QPushButton('',self) self.cunchu_btn25.setFixedSize(90,90) self.cunchu_btn26 = QPushButton('',self) self.cunchu_btn26.setFixedSize(90,90) self.cunchu_btn27 = QPushButton('',self) self.cunchu_btn27.setFixedSize(90,90) self.cunchu_btn28 = QPushButton('',self) self.cunchu_btn28.setFixedSize(90,90) self.cunchu_btn29 = QPushButton('',self) self.cunchu_btn29.setFixedSize(90,90) self.cunchu_btn30 = QPushButton('',self) self.cunchu_btn30.setFixedSize(90,90) self.cunchu_btn31 = QPushButton('',self) self.cunchu_btn31.setFixedSize(90,90) self.cunchu_btn32 = QPushButton('',self) self.cunchu_btn32.setFixedSize(90,90) self.cunchu_btn33 = QPushButton('',self) self.cunchu_btn33.setFixedSize(90,90) self.cunchu_btn34 = QPushButton('',self) self.cunchu_btn34.setFixedSize(90,90) self.cunchu_btn35 = QPushButton('',self) self.cunchu_btn35.setFixedSize(90,90) self.cunchu_btn36 = QPushButton('',self) self.cunchu_btn36.setFixedSize(90,90) self.cunchu_btn2.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn3.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn4.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn5.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn6.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn7.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn8.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn9.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn10.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn11.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn12.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn13.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn14.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn15.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn16.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn17.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn18.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn19.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn20.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn21.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn22.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn23.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn24.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn25.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn26.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn27.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn28.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn29.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn30.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn31.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn32.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn33.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn34.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn35.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") self.cunchu_btn36.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(255,0,0)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") #左边框 vlayout = QVBoxLayout(self) vlayout.addWidget(self.fasong_btn1) vlayout.addWidget(self.fasong_btn2) vlayout.addWidget(self.fasong_btn3) #hbox = QHBoxLayout(self) ###将界面分割成可以自由拉伸的三个窗口 #第一个,左上角,图像显示框 self.topleft = QFrame(self) self.topleft.setFrameShape(QFrame.StyledPanel) self.topleft.setLayout(vlayout) #第二个,右上角串口选择框 self.topright = QStackedWidget(self) self.topright.setStyleSheet("background:url(:Icon/meidui.jpg)") CunFrame = QFrame() CunFrame.setFrameShape(QFrame.StyledPanel) Cunlayout = QGridLayout() Cunlayout.addWidget(self.cunchu_btn1,0,0) Cunlayout.addWidget(self.cunchu_btn2,0,1) Cunlayout.addWidget(self.cunchu_btn3,0,2) Cunlayout.addWidget(self.cunchu_btn4,0,3) Cunlayout.addWidget(self.cunchu_btn5,0,4) Cunlayout.addWidget(self.cunchu_btn6,0,5) Cunlayout.addWidget(self.cunchu_btn7,1,0) Cunlayout.addWidget(self.cunchu_btn8,1,1) Cunlayout.addWidget(self.cunchu_btn9,1,2) Cunlayout.addWidget(self.cunchu_btn10,1,3) Cunlayout.addWidget(self.cunchu_btn11,1,4) Cunlayout.addWidget(self.cunchu_btn12,1,5) Cunlayout.addWidget(self.cunchu_btn13,2,0) Cunlayout.addWidget(self.cunchu_btn14,2,1) Cunlayout.addWidget(self.cunchu_btn15,2,2) Cunlayout.addWidget(self.cunchu_btn16,2,3) Cunlayout.addWidget(self.cunchu_btn17,2,4) Cunlayout.addWidget(self.cunchu_btn18,2,5) Cunlayout.addWidget(self.cunchu_btn19,3,0) Cunlayout.addWidget(self.cunchu_btn20,3,1) Cunlayout.addWidget(self.cunchu_btn21,3,2) Cunlayout.addWidget(self.cunchu_btn22,3,3) Cunlayout.addWidget(self.cunchu_btn23,3,4) Cunlayout.addWidget(self.cunchu_btn24,3,5) Cunlayout.addWidget(self.cunchu_btn25,4,0) Cunlayout.addWidget(self.cunchu_btn26,4,1) Cunlayout.addWidget(self.cunchu_btn27,4,2) Cunlayout.addWidget(self.cunchu_btn28,4,3) Cunlayout.addWidget(self.cunchu_btn29,4,4) Cunlayout.addWidget(self.cunchu_btn30,4,5) Cunlayout.addWidget(self.cunchu_btn31,5,0) Cunlayout.addWidget(self.cunchu_btn32,5,1) Cunlayout.addWidget(self.cunchu_btn33,5,2) Cunlayout.addWidget(self.cunchu_btn34,5,3) Cunlayout.addWidget(self.cunchu_btn35,5,4) Cunlayout.addWidget(self.cunchu_btn36,5,5) CunFrame.setLayout(Cunlayout) self.topright.addWidget(CunFrame) #温度 WenFrame = QFrame(self) WenFrame.setFrameShape(QFrame.StyledPanel) Wenlayout = QHBoxLayout() Wenlayout.addWidget(self.F) WenFrame.setLayout(Wenlayout) self.topright.addWidget(WenFrame) #工作状态 WorkFrame = QFrame(self) WorkFrame.setFrameShape(QFrame.StyledPanel) Worklayout = QVBoxLayout() self.WeiZhi_btn = QPushButton('未知血型',self) self.WeiZhi_btn.setFont(QFont("微软雅黑",16,QFont.Bold)) self.WeiZhi_btn.setFixedSize(140,80) self.YiZhi_btn = QPushButton('已知血型',self) self.YiZhi_btn.setFont(QFont("微软雅黑",16,QFont.Bold)) self.YiZhi_btn.setFixedSize(140,80) self.ChuXue_btn = QPushButton('直接出血',self) self.ChuXue_btn.setFont(QFont("微软雅黑",16,QFont.Bold)) self.ChuXue_btn.setFixedSize(140,80) hFrame = QFrame() vFrame = QFrame() #vFrame.setFocus() hwg = QHBoxLayout() vwg = QVBoxLayout() hwg.addWidget(self.WeiZhi_btn) hwg.addWidget(self.YiZhi_btn) hwg.addWidget(self.ChuXue_btn) self.prsbar = QProgressBar(self) self.jindu_btn = QPushButton(self) self.jindu_btn.setFixedSize(180,80) #self.lb1 = QLineEdit(self) #vwg.setAlignment(Qt.AlignVCenter) vwg.setAlignment(Qt.AlignHCenter) #vwg.addWidget(self.jindu_btn) vwg.addWidget(self.prsbar,Qt.AlignHCenter) #vwg.addWidget(self.lb1,Qt.AlignHCenter) vwg.addWidget(self.jindu_btn) hFrame.setLayout(hwg) vFrame.setLayout(vwg) Worklayout.addWidget(hFrame) Worklayout.addWidget(vFrame) WorkFrame.setLayout(Worklayout) self.topright.addWidget(WorkFrame) #第三个,底部,串口通信框 self.bottom = QFrame(self) self.bottom.setFrameShape(QFrame.StyledPanel) bwg=QHBoxLayout() bwg.addWidget(self.workmodule1) bwg.addWidget(self.workmodule2) bwg.addWidget(self.workmodule3) self.bottom.setLayout(bwg) self.bottom.setStyleSheet("#MainWindow{border-image:url(Icon/xinbo.png);}") #调用splitter控件,使窗口可以拖动起来 splitter1 = QSplitter(Qt.Horizontal) splitter1.addWidget(self.topleft) splitter1.addWidget(self.topright) splitter1.setSizes([80,600]) splitter2=QSplitter(Qt.Vertical) splitter2.addWidget(splitter1) splitter2.addWidget(self.bottom) splitter2.setSizes([800,200]) self.GlobalLayout.addWidget(splitter2) #topright.setLayout(hbox) self.setLayout(self.GlobalLayout) self.setGeometry(300, 300, 800, 600) self.setWindowTitle('莘博医疗') self.setWindowIcon(QIcon('Icon\senbo.jpg')) self.show() def cunchu_btn1_1(self): self.cunchu_btn1.setStyleSheet("QPushButton{color:black}" "QPushButton:hover{color:red}" "QPushButton{background-color:rgb(175,238,238)}" "QPushButton{border:2px}" "QPushButton{border-radius:10px}" "QPushButton{padding:2px 4px}") def workmodule_31(self): print(self.step) #self.jindu_btn.setText('jiaocha') if self.step == 18 : #print('asdas') self.jindu_btn.setText('交叉配血') self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) elif self.step == 40: self.jindu_btn.setText('孵育') self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) elif self.step == 60: self.jindu_btn.setText('离心') self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) elif self.step ==80: self.jindu_btn.setText('图像处理') self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) def timerEvent(self, e): if self.step == 100: self.jindu_btn.setText('检测完毕') self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) self.timer.stop() #return self.step = self.step+1 self.workmodule_31() # print('jwhy') # if(int(self.step) >= 100): # self.jindu_btn.setText('离心') # print('jwhy') # self.lb1.setText('djaoisdj') self.prsbar.setValue(self.step) def doAction(self, value): if self.timer.isActive(): self.timer.stop() else: self.timer.start(700, self) self.jindu_btn.setText('离心') self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) def closeEvent(self, event): reply = QMessageBox.question(self, '提示', "Are you sure to quit?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: event.accept() else: event.ignore() def cunchu(self): self.topright.setCurrentIndex(0) def wendu(self): self.topright.setCurrentIndex(1) def work(self): self.topright.setCurrentIndex(2)
class Settings(QWidget): def __init__(self): super(Settings, self).__init__() self.leftlist = QListWidget() self.leftlist.insertItem(0, 'General') self.leftlist.insertItem(1, 'Personal') self.leftlist.insertItem(2, 'About') self.leftlist.setFixedWidth(150) self.leftlist.setSpacing(3) self.leftlist.setStyleSheet(""" QListWidget{ background: transparent; border: none; font-size: 8pt; } QListView{ outline: none; } QListWidget::item{ background: transparent; } QListWidget::item:hover{ color: #fff; padding: 5px; background: transparent; } QListWidget::item:selected{ color: #fff; background: transparent; } QListWidget::item:selected:active{ background: transparent; color: #fff; } """) self.leftlist.setFont(QFont("Muli")) self.generalView = QWidget() self.aboutview = QWidget() self.personalView = QWidget() self.view = QStackedWidget(self) self.view.setStyleSheet("background: transparent;") self.view.addWidget(self.createGeneralView()) self.view.addWidget(self.createPersonalView()) self.view.addWidget(self.createAboutView()) self.leftlist.setCurrentRow(0) hbox = QHBoxLayout(self) hbox.addWidget(self.leftlist) hbox.addWidget(self.view) self.setLayout(hbox) self.leftlist.currentItemChanged.connect(self.display) def createGeneralView(self): vbox = QVBoxLayout() defaultpathlayout = QHBoxLayout() datasetlbl = QLabel("Dataset Path") self.defaultdatasetpath = SeleniumUILineEdit(text=os.getcwd() + "\\checkpoint") self.defaultdatasetpath.setReadOnly(True) defaultbtn = SeleniumUIButton("DEFAULT") defaultbtn.clicked.connect(self.defaultdatasetpathconnect) datasetlbl.setFont(QFont("Muli")) defaultpathlayout.addWidget(self.defaultdatasetpath) defaultpathlayout.addWidget(defaultbtn) defaultpathlayout.setAlignment(Qt.AlignLeft) outputlbl = QLabel("Output Path") self.defaultoutputpathlayout = QHBoxLayout() self.defaultoutputpath = SeleniumUILineEdit( text=os.path.expanduser("~\\Documents\\Visual Model")) self.defaultoutputpath.setReadOnly(True) defaultoutputpathbtn = SeleniumUIButton("DEFAULT") defaultoutputpathbtn.clicked.connect(self.defaultoutputpathconnect) self.defaultoutputpathlayout.addWidget(self.defaultoutputpath) self.defaultoutputpathlayout.addWidget(defaultoutputpathbtn) self.defaultoutputpathlayout.setAlignment(Qt.AlignLeft) vbox.addWidget(datasetlbl) vbox.addLayout(defaultpathlayout) vbox.addWidget(outputlbl) vbox.addLayout(self.defaultoutputpathlayout) vbox.addStretch(0) self.generalView.setLayout(vbox) return self.generalView def defaultoutputpathconnect(self): self.defaultoutputpath.setText(os.path.expanduser("~\\Documents")) def defaultdatasetpathconnect(self): self.defaultdatasetpath.setText(os.getcwd() + "\\dataset") def createPersonalView(self): layout = QVBoxLayout() layout.setAlignment(Qt.AlignTop) lbl = QLabel("Personal") layout.addWidget(lbl) self.personalView.setLayout(layout) return self.personalView def createAboutView(self): layout = QVBoxLayout() layout.setAlignment(Qt.AlignTop) version = QLabel("""Visual Model version 0.1 This software is build for creating image animation model powered by first order model. It creates a image animation in a video input. Visual Model only supports VoxCeleb dataset use for creating deepfake animations """) version.setFont(QFont("Muli")) version.setStyleSheet("color: #fff;\nfont-size: 7.5px") developerlbl = QLabel("DEVELOPERS") developerlbl.setFont(QFont("Muli")) developerlbl.setStyleSheet( "color: #fff;\nfont-size: 10px;\nfont-weight: bold;") urlLink = QLabel( "<a href=\"https://github.com/AliaksandrSiarohin/first-order-model/graphs/contributors\" style=\"color: rgb(180,180,180);\">First order model developers</a>" ) urlLink.setFont(QFont("Muli")) urlLink.setOpenExternalLinks(True) developer = QLabel( "<a href=\"http://www.github.com/zenqii\" style=\"color: rgb(180,180,180);\">Zenqi</a>" ) developer.setOpenExternalLinks(True) developer.setFont(QFont("Muli")) layout.addWidget(version) layout.addWidget(developerlbl) layout.addWidget(developer) layout.addWidget(urlLink) self.aboutview.setLayout(layout) return self.aboutview def writeWindowSettings(self): createWindowSettings("dataset_path", self.defaultdatasetpath.text()) createWindowSettings("output_path", self.defaultoutputpath.text()) def display(self): self.view.setCurrentIndex(self.leftlist.currentRow())
class DnmrGui(QMainWindow): """ Create the GUI for the application. Currently the app features a single simulation model (two uncoupled spins), and so a single main window. TODO: as views are added, create a toggle between GUI windows tailored to each simulation (e.g. appropriate widgets for data entry) """ def __init__(self, parent=None): print('ititializing gui class') super(DnmrGui, self).__init__(parent) print('creating views list') self.views = [] self.models = [dnmrplot_2spin, dnmrplot_AB] self.setObjectName('toplevel') self.setupUi() class MainView(QWidget): """A QWidget that has the following properties: - A top row of labeled QDoubleSpinBox es for data entry - Beneath them, a pqtgraph PlotWidget for the simulated plot - the ability to detect changes to the data entries, store their current values, call the appropriate model and pass the simulation results to the pyqtgraph widget """ def __init__(self, name, *args): super().__init__() self.setObjectName(name + 'widget') self.setAutoFillBackground(True) self.setStyleSheet("background-color: rgb(60, 63, 65);") self.simulation_vars = {} layout = QGridLayout() layout.setObjectName(name + 'layout') for i, widget in enumerate(args): # make a label for the widget wlabel = QLabel(widget.string) wlabel.setObjectName(widget.key + '_label') wlabel.setStyleSheet('color: white') wlabel.setAlignment(Qt.AlignCenter) # Make a QDoubleSpinBox widget wbox = QDoubleSpinBox() wbox.setObjectName(widget.key) wbox.setStyleSheet('color: white') wbox.setRange(*widget.range) # SET RANGE BEFORE VALUE wbox.setValue(widget.value) wbox.setAlignment(Qt.AlignCenter) wbox.setAccelerated(True) # Add label (above) and spinbox (below) to layout layout.addWidget(wlabel, 0, i) layout.addWidget(wbox, 1, i) # Store the default simulation value self.simulation_vars[widget.key] = widget.value # update the view if this widget's value is changed # Using the lambda expression below allows extra information to # be passed to the self.update slot, allowing the delegator to # see who sent the signal, update the dictionary of model # inputs, call the model for a simulation result, and plot # it. See: # https://mfitzp.io/article/transmit-extra-data-with-signals-in-pyqt/ wbox.valueChanged.connect( lambda val, key=widget.key: self.parent().parent().updateView(key, val)) # Add pyqtgraph widget setConfigOption('background', (43, 43, 43)) setConfigOption('foreground', (187, 187, 187)) graphicsView = PlotWidget() layout.addWidget(graphicsView, 2, 0, 1, len(twosinglets_vars)) plots.append(graphicsView.plot()) # lets the graph span the entire width of the window, no matter how # many input widgets appear above self.setLayout(layout) def setupUi(self): """ Set up the GUI with the default moded, default variables, and simulated lineshape. """ self.setupCentral() self.setupModelBar() self.initializeGui() def setupCentral(self): self.stackedWidget = QStackedWidget() self.stackedWidget.setObjectName('stackedwidget') self.stackedWidget.setStyleSheet("background-color: rgb(60, 63, 65);") for view in mainviews: widget = self.MainView(view[0], *view[1]) self.stackedWidget.addWidget(widget) self.setCentralWidget(self.stackedWidget) def setupModelBar(self): """ Add a tool bar to the GUI for selecting which model to display """ leftToolBar = QToolBar() leftToolBar.setStyleSheet("background-color: rgb(60, 63, 65);") leftToolBar.setObjectName('lefttoolbar') leftToolBar.addWidget(self.modelButtonGroup()) self.addToolBar(Qt.LeftToolBarArea, leftToolBar) def modelButtonGroup(self): """ A widget of radio buttons that will determine which QStackedWidget is displayed. """ # It seems that in order for the buttonClicked signal to work, # self.ButtonGroup and not ButtonGroup is necessary. Does not work # with out 'self.' prefix!!! modelsWidget = QWidget() modelsWidget.setObjectName('modelswidget') modelsLayout = QVBoxLayout() modelsLayout.setObjectName('modelslayout') self.ButtonGroup = QButtonGroup() selectModelLabel = QLabel('Select Model:') selectModelLabel.setAlignment(Qt.AlignCenter) selectModelLabel.setStyleSheet('color: white') twosingletbutton = QRadioButton('Two uncoupled spin-1/2 nuclei') twosingletbutton.setObjectName('twosingletbutton') twosingletbutton.setStyleSheet('color: white') twosingletbutton.setChecked(True) self.ButtonGroup.addButton(twosingletbutton, 0) abbutton = QRadioButton('Two coupled spin-1/2 nuclei\n ("AB quartet)') abbutton.setObjectName('abbutton') abbutton.setStyleSheet('color: white') self.ButtonGroup.addButton(abbutton, 1) self.ButtonGroup.buttonClicked[int].connect(self.switchView) modelsLayout.addStretch() modelsLayout.addWidget(selectModelLabel) modelsLayout.addWidget(twosingletbutton) modelsLayout.addWidget(abbutton) modelsLayout.addStretch() modelsWidget.setLayout(modelsLayout) modelsWidget.setStyleSheet("background-color: rgb(60, 63, 65);") return modelsWidget def switchView(self, index): self.stackedWidget.setCurrentIndex(index) self.call_model() def initializeGui(self): # Note order of models in stackedWidget and plots must be same for i in range(len(plots)): self.stackedWidget.setCurrentIndex(i) plot = plots[i] plot.getViewBox().invertX(True) # Reverse x axis "NMR style" plot.setData(*self.call_model()) self.stackedWidget.setCurrentIndex(0) self.setGeometry(50, 50, 800, 600) self.setWindowTitle('pyDNMR') self.statusBar().showMessage('Ready') def call_model(self): """ Send the dictionary as **kwargs to the model :return: a spectrum, consisting of a tuple of x and y coordinate arrays """ model = self.models[self.stackedWidget.currentIndex()] x, y = model( **self.stackedWidget.currentWidget().simulation_vars) return x, y def updateView(self, key, val): """ Detect a change in numerical input; record the change in the dictionary of widget values; call the model to get an updated spectrum; and plot the spectrum. :param key: the dictionary key for the variable associated with the signalling widget :param val: the current value of the signalling widget """ self.stackedWidget.currentWidget().simulation_vars[key] = val self.plot_graph() def plot_graph(self): activePlot = plots[self.stackedWidget.currentIndex()] activePlot.setData(*self.call_model())
class LeftTabWidget(QWidget): def __init__(self, *args, **kwargs): super(LeftTabWidget, self).__init__(*args, **kwargs) self.resize(1200, 600) #左右布局(左边一个QListWidget + 右边QStackedWidget) self.setWindowFlags(Qt.FramelessWindowHint) layout = QHBoxLayout(self) #布局边距 layout.setContentsMargins(0, 0, 0, 0) # 左侧列表 self.listWidget = QListWidget(self) self.listWidget.setStyleSheet(Stylesheet_listwidget) layout.addWidget(self.listWidget) # 右侧层叠窗口 self.stackedWidget = QStackedWidget(self) self.stackedWidget.setStyleSheet(Stylesheet_stacked) layout.addWidget(self.stackedWidget) self.initUi() def initUi(self): # 初始化界面 # 通过QListWidget的当前item变化来切换QStackedWidget中的序号 self.listWidget.currentRowChanged.connect( self.stackedWidget.setCurrentIndex) # 去掉边框 self.listWidget.setFrameShape(QListWidget.NoFrame) # 隐藏滚动条 self.listWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.listWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # 这里就用一般的文本配合图标模式了(也可以直接用Icon模式,setViewMode) # for i in range(20): # item = QListWidgetItem( # QIcon('Data/0%d.ico' % randint(1, 8)), str('选 项 %s' % i), self.listWidget) # # 设置item的默认宽高(这里只有高度比较有用) # item.setSizeHint(QSize(16777215, 60)) # # 文字居中 # item.setTextAlignment(Qt.AlignCenter) item_node_edit = QListWidgetItem(QIcon('Data/01d.ico'),str('编辑节点'),self.listWidget) item_node_edit.setSizeHint(QSize(16777215,60)) item_node_edit.setTextAlignment(Qt.AlignCenter) item_dataset = QListWidgetItem(QIcon('Data/02d.ico'),str('选择数据'),self.listWidget) item_dataset.setSizeHint(QSize(16777215,60)) item_dataset.setTextAlignment(Qt.AlignCenter) item_dataset = QListWidgetItem(QIcon('Data/03d.ico'), str('过程可视化'), self.listWidget) item_dataset.setSizeHint(QSize(16777215, 60)) item_dataset.setTextAlignment(Qt.AlignCenter) # 左侧的页面 # 右侧的页面 # label = QLabel('我是页面 %d' % i, self) # label.setAlignment(Qt.AlignCenter) # # 设置label的背景颜色(这里随机) # # 这里加了一个margin边距(方便区分QStackedWidget和QLabel的颜色) # label.setStyleSheet('background: rgb(%d, %d, %d);margin: 50px;' % ( # randint(0, 255), randint(0, 255), randint(0, 255))) ui_edit_nodes = Ui_Nodes_Edit() self.stackedWidget.addWidget(ui_edit_nodes) ui_data_choose = Data_Choose() self.stackedWidget.addWidget(ui_data_choose) ui_line = Dynamic_line() self.stackedWidget.addWidget(ui_line)
super(Downloader, self).__init__() self.title = title self.url = url self.extension = extension def run(self): book_module.downloadBook(self.title, self.url, self.extension) if __name__ == '__main__': app = QApplication(sys.argv) bookmark_module.makeFiles() main_win = MainWin() search = Search() bookmarks = Bookmarks() book_page = bookPage() stackedWidget = QStackedWidget() stackedWidget.addWidget(main_win) stackedWidget.addWidget(search) stackedWidget.addWidget(bookmarks) stackedWidget.addWidget(book_page) stackedWidget.setFixedSize(712, 403) stackedWidget.setStyleSheet("background-color: rgb(54, 54, 54); " "color: rgb(255, 255, 255);") stackedWidget.show() sys.exit(app.exec_())
class GettingStarted(QWidget): """This defines the window for the tutorial""" def __init__(self): """initializes the window""" super().__init__() self.page_number = 0 self.layout_list = [] self.init_ui() def init_ui(self): """sets window title, layout, and adds the widgets to the window""" self.setWindowTitle('L-System Help') self.main_layout = QVBoxLayout() self.button_layout = QHBoxLayout() self.pages_widget = QStackedWidget() self.pages_widget.setStyleSheet(''' QLabel#title{ font-weight: bold; font-size: 16px; text-decoration: underline; text-align: center;} QLabel#warning{ font-size: 14px; color: #FF0000; text-decoration: underline;} QLabel{ font-size: 14px;} ''') self.page_one_widget = QWidget() #axiom self.page_one_layout = QGridLayout() self.page_two_widget = QWidget() #production rules self.page_two_layout = QGridLayout() self.page_three_widget = QWidget() #Angle self.page_three_layout = QGridLayout() self.page_four_widget = QWidget() #iterations self.page_four_layout = QGridLayout() self.page_five_widget = QWidget() #branching self.page_five_layout = QGridLayout() self.page_six_widget = QWidget() #turning angle self.page_six_layout = QGridLayout() self.page_seven_widget = QWidget() #line scale self.page_seven_layout = QGridLayout() self.create_widgets() self.add_widgets() self.setLayout(self.main_layout) def create_widgets(self): """creates labels and buttons for the window""" self.axiom_title = QLabel('Axiom', objectName='title') self.axiom_one = QLabel('The axiom is where your L-System starts.') self.axiom_two = QLabel( 'Use production rules to transform your axiom into an L-System.') self.axiom_three = QLabel('See the symbols glossary for valid inputs.') self.axiom_screenshot = QLabel(self) self.axiom_pic = QPixmap('lsystem/assets/screenshots/axiom.PNG') self.axiom_screenshot.setPixmap(self.axiom_pic) self.prod_rule_title = QLabel('Production Rules', objectName='title') self.prod_rule_one = QLabel( 'Production rules are part of how you transform your axiom into an L-System.' ) self.prod_rule_two = QLabel( 'This string will then be used to generate your L-System.') self.prod_rule_three = QLabel( 'Valid rules are in the form X: Y.\nX is one or more characters in your L-System.\n' + 'Y is one ore more characters you want to replace it with.') self.prod_rule_four = QLabel( 'The box on the right side is for the weight of the rule.\n' + 'If you only have one rule for a symbol than this box does nothing.\n' + 'If you have multiple rules with the same symbol on the left side ' + 'you can weight them so one is chosen more often than the others.') self.prod_rule_five = QLabel( 'The sum of all boxes for a left side must add up to 100.') self.prod_rule_six = QLabel( 'The plus buttons on the right can be used to add up to 7 more production rules to your L-System for a total of 8 rules.' ) self.prod_rule_screenshot = QLabel(self) self.prod_rule_pic = QPixmap( 'lsystem/assets/screenshots/prod_rules.png') self.prod_rule_screenshot.setPixmap(self.prod_rule_pic) self.angle_title = QLabel('Angle', objectName='title') self.angle_one = QLabel( 'The angle determines how large the turns are in your L-System.') self.angle_two = QLabel('Valid inputs are any number from -360 to 360') self.angle_screenshot = QLabel(self) self.angle_pic = QPixmap('lsystem/assets/screenshots/angles.png') self.angle_screenshot.setPixmap(self.angle_pic) self.iteration_title = QLabel('Iterations', objectName='title') self.iteration_one = QLabel( 'Iterations affect the number of times rules get applied to the string.' ) self.iteration_two = QLabel( 'The more iterations, the more defined the shape of your L-System becomes.' ) self.iteration_three = QLabel( 'Valid inputs are any number greater than 0.') self.iteration_screenshot = QLabel(self) self.iteration_pic = QPixmap( 'lsystem/assets/screenshots/iterations.png') self.iteration_screenshot.setPixmap(self.iteration_pic) self.branching_title = QLabel('Branching', objectName='title') self.branching_one = QLabel( 'Branching allows for the L-System to create offshoots') self.branching_two = QLabel( 'You can add a branch by placing symbols between brackets') self.branching_three = QLabel( 'For example [F] will create a straight line branching from the main system' ) self.turn_angle_title = QLabel('Turning Angle', objectName='title') self.turn_angle_one = QLabel( 'The turning angle text box only appears if the axiom or a production rule has the symbols ( or ) in it.' ) self.turn_angle_two = QLabel( '( decreases the angle by the turning angle and ) increases it.') self.turn_angle_three = QLabel( 'Valid inputs are any number between 0 and 360.') self.turn_angle_screenshot = QLabel(self) self.turn_angle_pic = QPixmap( 'lsystem/assets/screenshots/turn_angle.png') self.turn_angle_screenshot.setPixmap(self.turn_angle_pic) self.line_scale_title = QLabel('Line Scaling', objectName='title') self.line_scale_one = QLabel( 'The line scaling text box only appears if the axiom or a production rule has the symbols < or > in it.' ) self.line_scale_two = QLabel( '< divides the length of all subsequent lines by the line scaling factor and > increases it.' ) self.line_scale_three = QLabel('Valid inputs are any number') self.line_scale_screenshot = QLabel(self) self.line_scale_pic = QPixmap( 'lsystem/assets/screenshots/line_scale.png') self.line_scale_screenshot.setPixmap(self.line_scale_pic) self.noThreeD_one = QLabel("This feature is not available in 3D mode.", objectName='warning') self.noThreeD_two = QLabel("This feature is not available in 3D mode.", objectName='warning') #cant have the same label in two layouts for some reason self.next_button = QPushButton("Next Page") self.next_button.setShortcut('Ctrl+N') self.next_button.clicked.connect(lambda: self.change_page(True)) self.previous_button = QPushButton("Previous Page") self.previous_button.setShortcut('Ctrl+P') self.previous_button.clicked.connect(lambda: self.change_page(False)) def add_widgets(self): """adds widgets to the window""" self.button_layout.addWidget(self.previous_button) self.button_layout.addStretch() self.button_layout.addWidget(self.next_button) self.page_one_layout.addWidget(self.axiom_title, 0, 0) self.page_one_layout.addWidget(self.axiom_one, 1, 0) self.page_one_layout.addWidget(self.axiom_two, 2, 0) self.page_one_layout.addWidget(self.axiom_three, 3, 0) self.page_one_layout.addWidget(self.axiom_screenshot, 4, 0) self.page_one_widget.setLayout(self.page_one_layout) self.layout_list.append(self.page_one_widget) self.pages_widget.addWidget(self.page_one_widget) self.page_two_layout.addWidget(self.prod_rule_title, 0, 0) self.page_two_layout.addWidget(self.prod_rule_one, 1, 0) self.page_two_layout.addWidget(self.prod_rule_two, 2, 0) self.page_two_layout.addWidget(self.prod_rule_three, 3, 0) self.page_two_layout.addWidget(self.prod_rule_four, 4, 0) self.page_two_layout.addWidget(self.prod_rule_five, 5, 0) self.page_two_layout.addWidget(self.prod_rule_six, 6, 0) self.page_two_layout.addWidget(self.prod_rule_screenshot, 7, 0) self.page_two_widget.setLayout(self.page_two_layout) self.layout_list.append(self.page_two_widget) self.pages_widget.addWidget(self.page_two_widget) self.page_three_layout.addWidget(self.angle_title, 0, 0) self.page_three_layout.addWidget(self.angle_one, 1, 0) self.page_three_layout.addWidget(self.angle_two, 2, 0) self.page_three_layout.addWidget(self.angle_screenshot, 3, 0) self.page_three_widget.setLayout(self.page_three_layout) self.layout_list.append(self.page_three_widget) self.pages_widget.addWidget(self.page_three_widget) self.page_four_layout.addWidget(self.iteration_title, 0, 0) self.page_four_layout.addWidget(self.iteration_one, 1, 0) self.page_four_layout.addWidget(self.iteration_two, 2, 0) self.page_four_layout.addWidget(self.iteration_three, 3, 0) self.page_four_layout.addWidget(self.iteration_screenshot, 4, 0) self.page_four_widget.setLayout(self.page_four_layout) self.layout_list.append(self.page_four_widget) self.pages_widget.addWidget(self.page_four_widget) self.page_five_layout.addWidget(self.branching_title, 0, 0) self.page_five_layout.addWidget(self.branching_one, 1, 0) self.page_five_layout.addWidget(self.branching_two, 2, 0) self.page_five_layout.addWidget(self.branching_three, 3, 0) self.page_five_widget.setLayout(self.page_five_layout) self.layout_list.append(self.page_five_widget) self.pages_widget.addWidget(self.page_five_widget) self.page_six_layout.addWidget(self.turn_angle_title, 0, 0) self.page_six_layout.addWidget(self.turn_angle_one, 1, 0) self.page_six_layout.addWidget(self.turn_angle_two, 2, 0) self.page_six_layout.addWidget(self.turn_angle_three, 3, 0) self.page_six_layout.addWidget(self.noThreeD_one, 4, 0) self.page_six_layout.addWidget(self.turn_angle_screenshot, 5, 0) self.page_six_widget.setLayout(self.page_six_layout) self.layout_list.append(self.page_six_widget) self.pages_widget.addWidget(self.page_six_widget) self.page_seven_layout.addWidget(self.line_scale_title, 0, 0) self.page_seven_layout.addWidget(self.line_scale_one, 1, 0) self.page_seven_layout.addWidget(self.line_scale_two, 2, 0) self.page_seven_layout.addWidget(self.line_scale_three, 3, 0) self.page_seven_layout.addWidget(self.noThreeD_two, 4, 0) self.page_seven_layout.addWidget(self.line_scale_screenshot, 5, 0) self.page_seven_widget.setLayout(self.page_seven_layout) self.layout_list.append(self.page_seven_layout) self.pages_widget.addWidget(self.page_seven_widget) self.main_layout.addWidget(self.pages_widget) self.main_layout.addStretch() self.main_layout.addLayout(self.button_layout) def change_page(self, up): """Changes the page displayed. Inputs up - the number of pages to move in the tutorial. Can be negative """ if (up): self.page_number += 1 self.page_number %= len(self.layout_list) else: self.page_number -= 1 if (self.page_number < 0): self.page_number += len(self.layout_list) self.pages_widget.setCurrentIndex(self.page_number)