def _left_panel(self): panel = QWidget() box = QVBoxLayout() btn_menu = QPushButton() icn = QtGui.QIcon.fromTheme("application-menu") btn_menu.setIcon(icn) btn_menu.setIconSize(QSize(BTN_MENU_SIZE, BTN_MENU_SIZE)) btn_menu.setMaximumWidth(BTN_MENU_SIZE) btn_menu.setMaximumHeight(BTN_MENU_SIZE) btn_menu.setToolTip(_("Options")) btn_menu.setObjectName("menuButton") # box.addWidget(btn_menu,Qt.Alignment(1)) indexes = [] for index, option in self.stacks.items(): idx = index lst_widget = QListWidgetItem() lst_widget.setText(option['name']) mod = option.get('module', None) if mod: try: idx = mod.index except: pass if idx > 0: icn = QtGui.QIcon.fromTheme(option['icon']) lst_widget.setIcon(icn) if 'tooltip' in option.keys(): lst_widget.setToolTip(option['tooltip']) while idx in indexes: idx += 1 indexes.append(index) self.stacks[idx]['widget'] = lst_widget orderedStacks = {} orderedStacks[0] = self.stacks[0] #self.lst_options.addItem(orderedStacks[0]['widget']) cont = 0 indexes.sort() for index in indexes: if index: orderedStacks[cont] = self.stacks[index].copy() if self.stacks[index].get('visible', True) == True: self.lst_options.addItem(orderedStacks[cont]['widget']) cont += 1 self.stacks = orderedStacks.copy() box.addWidget(self.lst_options) self.lst_options.currentRowChanged.connect(self._show_stack) self.lst_options.setCurrentIndex(QModelIndex()) self.last_index = None panel.setLayout(box) self.resize(self.size().width() + box.sizeHint().width(), self.size().height() + box.sizeHint().height() / 2) self.lst_options.setFixedSize( self.lst_options.sizeHintForColumn(0) + 2 * (self.lst_options.frameWidth() + 15), self.height() ) #self.lst_options.sizeHintForRow(0) * self.lst_options.count() + 2 * (self.lst_options.frameWidth()+15)) return (panel)
class ProgramUI(QtWidgets.QDialog): """Generic (GUI).""" def __init__(self, parent=None): super(ProgramUI, self).__init__(parent) # loads an exteranl styesheet as python newstyle = styles() self.setStyleSheet(newstyle.dark_orange) self.setWindowTitle("Motion Detector Editor") self.setFixedSize(375, 250) # create the main layout self.main_layout = QVBoxLayout() # create the top layout and add it self.createtoplayout() self.main_layout.addWidget(self.topGroupBox) # create the save botton and add it self.save_location_button = QtWidgets.QPushButton("Save Location") self.save_location_button.setAutoDefault(False) self.main_layout.addWidget(self.save_location_button) # create the bottom layout and add it self.createbottomlayout() self.main_layout.addLayout(self.proggresslayout) # resize window to match the width of what has been added self.setLayout(self.main_layout) layout_size = self.main_layout.sizeHint() self.setFixedSize(self.width(),layout_size.height()) def createtoplayout(self): self.topGroupBox = QGroupBox("") self.open_location_button = QtWidgets.QPushButton("Full Path Location") self.open_location_button.setAutoDefault(False) self.textboxlabel = QLabel("Wildcard") self.textboxlabel.setMinimumWidth(100) self.lineEdit = QLineEdit("") text_box_layout = QHBoxLayout() text_box_layout.addWidget(self.textboxlabel) text_box_layout.addWidget(self.lineEdit ) self.infoboxlabel = QLabel("Number of Videos to Process") self.infoboxlabel.setMinimumWidth(100) self.numberbox = QLabel("0") self.numberbox.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken ) self.numberbox.setStyleSheet(""" QWidget { padding: 1px; border-style: solid; border: 1px solid #1e1e1e; border-radius: 5; min-height: 15px; font-size: 12px; } """) info_box_layout = QHBoxLayout() info_box_layout.addWidget(self.infoboxlabel) info_box_layout.addWidget(self.numberbox) layout = QVBoxLayout() layout.addWidget(self.open_location_button) layout.addLayout(text_box_layout) layout.addLayout(info_box_layout) layout.addStretch(1) self.topGroupBox.setLayout(layout) def advanceProgressBar(self, percentage_complete): if percentage_complete < self.progressBar.maximum(): self.progressBar.setValue(percentage_complete) else: self.progressBar.setValue(self.progressBar.maximum()) def createbottomlayout(self): self.proggresslayout = QHBoxLayout() self.runprogram_button = QtWidgets.QPushButton("Run the Program") self.runprogram_button.setAutoDefault(False) #self.runprogram_button.setDisabled(True) self.progressBar = QProgressBar() self.progressBar.setRange(0, 100) self.progressBar.setValue(0) self.timer = QTimer(self) self.proggresslayout.addWidget(self.runprogram_button) self.proggresslayout.addWidget(self.progressBar) def showdialog(self, message, title = "Error", details = "An error has occured"): self.msg = QMessageBox() self.msg.setIcon(QMessageBox.Information) self.msg.setText(message) #self.msg.setInformativeText("This is additional information") self.msg.setWindowTitle(title) self.msg.setDetailedText(details) self.msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) #self.msg.buttonClicked.connect(msgbtn) retval = self.msg.exec_()
class Ui_Settings(): def __init__(self, Settings: QMainWindow): # Set window parameters Settings.setWindowTitle("ASL Tools - Settings") Settings.setWindowFlag(Qt.Window) icon_size = QSize(48, 48) # Main frame frame = QWidget() frame.setObjectName("mainwindow") self.v_layout = QVBoxLayout(frame) # Select tool window location self.label_location = QLabel() self.v_layout.addWidget(self.label_location) self.group_corner = QButtonGroup() self.grid_layout = QGridLayout() # Top left corner self.btn_corner_tl = QPushButton() self.btn_corner_tl.setObjectName("top-left") self.btn_corner_tl.setIcon(QIcon(":/images/corner-tl.svg")) self.btn_corner_tl.setIconSize(QSize(32, 32)) self.btn_corner_tl.setCheckable(True) self.group_corner.addButton(self.btn_corner_tl) self.grid_layout.addWidget(self.btn_corner_tl, 0, 1) # Top right corner self.btn_corner_tr = QPushButton() self.btn_corner_tr.setObjectName("top-right") self.btn_corner_tr.setIcon(QIcon(":/images/corner-tr.svg")) self.btn_corner_tr.setIconSize(QSize(32, 32)) self.btn_corner_tr.setCheckable(True) self.group_corner.addButton(self.btn_corner_tr) self.grid_layout.addWidget(self.btn_corner_tr, 0, 2) # bottom left corner self.btn_corner_bl = QPushButton() self.btn_corner_bl.setObjectName("bottom-left") self.btn_corner_bl.setIcon(QIcon(":/images/corner-bl.svg")) self.btn_corner_bl.setIconSize(QSize(32, 32)) self.btn_corner_bl.setCheckable(True) self.group_corner.addButton(self.btn_corner_bl) self.grid_layout.addWidget(self.btn_corner_bl, 1, 1) # Bottom right corner self.btn_corner_br = QPushButton() self.btn_corner_br.setObjectName("bottom-right") self.btn_corner_br.setIcon(QIcon(":/images/corner-br.svg")) self.btn_corner_br.setIconSize(QSize(32, 32)) self.btn_corner_br.setCheckable(True) self.group_corner.addButton(self.btn_corner_br) self.grid_layout.addWidget(self.btn_corner_br, 1, 2) # Spacers spacer = QSpacerItem(20, 20) self.grid_layout.addItem(spacer, 0, 0) spacer = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.grid_layout.addItem(spacer, 0, 3) self.v_layout.addLayout(self.grid_layout) # Window fit the layout Settings.setCentralWidget(frame) # Set size and position w, h = self.v_layout.sizeHint().toTuple() w_s, h_s = QApplication.primaryScreen().size().toTuple() x = round(w_s / 2 - w / 2) y = round(h_s / 2 - h / 2) Settings.setCentralWidget(frame) Settings.resize(w, h) Settings.move(x, y) self.retranslateUi(Settings) QtCore.QMetaObject.connectSlotsByName(Settings) def retranslateUi(self, Settings): self.label_location.setText( QtWidgets.QApplication.translate( "Settings", "Sélectionnez la position de la fenêtre :", None, -1))