def __init__(self, Wizard, parent=None): super(FinalPage, self).__init__(parent) self.base = Wizard.base ''' On this page will be "Finish button" instead of "Next" ''' FinalPage.setFinalPage(self, True) self.setTitle(self.tr("Final page")) self.setSubTitle(self.tr("Your package was successfully created")) finalLabel = QLabel("<html><head/><body><p align=\"center\"><span" + "style=\" font-size:24pt;\">Thank you for " + "using RPG!</span></p><p align=\"center\">" + "<span style=\" font-size:24pt;\">Your" + " package was built in:</span></p></body></html>") self.finalEdit = QLineEdit() grid = QGridLayout() grid.addWidget(finalLabel, 0, 0) grid.addWidget(self.finalEdit, 1, 0) mainLayout = QVBoxLayout() mainLayout.addSpacing(190) mainLayout.addWidget(finalLabel) mainLayout.addSpacing(190) mainLayout.addWidget(self.finalEdit) mainLayout.addSpacing(190) self.setLayout(mainLayout)
def init(self): vbox = QVBoxLayout() self.setLayout(vbox) text = QLineEdit('0.') text.setReadOnly(True) vbox.addWidget(text) grid = QGridLayout() vbox.addLayout(grid) names = ['Exit', 'AC', 'DEL', '+/-', '7', '8', '9', '/', '4', '5', '6', '*', '1', '2', '3', '-', '0', '.', '=', '+'] positions = [(i, j) for i in range(5) for j in range(4)] for position, name in zip(positions, names): btn = QPushButton(name) grid.addWidget(btn, *position) self.move(300, 200) self.setWindowTitle('Calculator') self.show()
def virtual_keyboard(self, i, pw): i = i % 3 if i == 0: chars = 'abcdefghijklmnopqrstuvwxyz ' elif i == 1: chars = 'ABCDEFGHIJKLMNOPQRTSUVWXYZ ' elif i == 2: chars = '1234567890!?.,;:/%&()[]{}+-' n = len(chars) s = [] for i in range(n): while True: k = random.randint(0, n - 1) if k not in s: s.append(k) break def add_target(t): return lambda: pw.setText(str(pw.text()) + t) vbox = QVBoxLayout() grid = QGridLayout() grid.setSpacing(2) for i in range(n): l_button = QPushButton(chars[s[i]]) l_button.setFixedWidth(25) l_button.setFixedHeight(25) l_button.clicked.connect(add_target(chars[s[i]])) grid.addWidget(l_button, i // 6, i % 6) vbox.addLayout(grid) return vbox
class OutputWidget(QWidget): Sections = {} def __init__(self, conf, parent=None): super().__init__(parent) # Import here for avoid circular import if len(self.Sections) == 0: from lisp.gst import settings OutputWidget.Sections = settings.sections_by_element_name() self._conf = conf self.gridLayout = QGridLayout(self) self.outputType = QLabel(self) self.outputType.setAlignment(Qt.AlignCenter) self.outputType.setText(conf['name']) self.gridLayout.addWidget(self.outputType, 0, 0, 1, 2) self.sinkSettings = QPushButton('Settings', self) self.sinkSettings.setEnabled(self._conf['name'] in self.Sections) self.sinkSettings.setIcon(QIcon.fromTheme('settings')) self.gridLayout.addWidget(self.sinkSettings, 0, 2) self.mute = QMuteButton(self) self.mute.setMute(conf.get('mute', False)) self.gridLayout.addWidget(self.mute, 1, 0) self.volume = QSlider(Qt.Horizontal, self) self.volume.setRange(-100, 0) self.volume.setPageStep(1) volume = linear_to_db(conf.get('volume', 1)) self.volume.setValue(volume) self.gridLayout.addWidget(self.volume, 1, 1) self.volumeLabel = QLabel(self) self.volumeLabel.setText(str(volume) + ' dB') self.volumeLabel.setAlignment(Qt.AlignCenter) self.gridLayout.addWidget(self.volumeLabel, 1, 2) self.volume.valueChanged.connect(self._volume_changed) self.sinkSettings.clicked.connect(self._settings) def get_settings(self): self._conf['volume'] = db_to_linear(self.volume.value()) self._conf['mute'] = self.mute.isMute() return self._conf def _volume_changed(self, value): self.volumeLabel.setText(str(value) + ' dB') def _settings(self): dialog = SettingsDialog(self.Sections[self._conf['name']], self._conf) dialog.exec_() if dialog.result() == dialog.Accepted: self._conf.update(dialog.get_settings())
def __init__(self, value, parent=None): QGridLayout.__init__(self) font = tuple_to_qfont(value) assert font is not None # Font family self.family = QFontComboBox(parent) self.family.setCurrentFont(font) self.addWidget(self.family, 0, 0, 1, -1) # Font size self.size = QComboBox(parent) self.size.setEditable(True) sizelist = list(range(6, 12)) + list(range(12, 30, 2)) + [36, 48, 72] size = font.pointSize() if size not in sizelist: sizelist.append(size) sizelist.sort() self.size.addItems([str(s) for s in sizelist]) self.size.setCurrentIndex(sizelist.index(size)) self.addWidget(self.size, 1, 0) # Italic or not self.italic = QCheckBox(self.tr("Italic"), parent) self.italic.setChecked(font.italic()) self.addWidget(self.italic, 1, 1) # Bold or not self.bold = QCheckBox(self.tr("Bold"), parent) self.bold.setChecked(font.bold()) self.addWidget(self.bold, 1, 2)
def __init__(self, game): super().__init__() self.game = game self.width, self.height = game.grid_dimensions() grid = QGridLayout() self.setLayout(grid) grid.setSpacing(5)
def __init__(self, size, Id, parent=None): super().__init__(size, parent) self.id = Id self.box = QWidget(self) self.box.setGeometry(0, 0, self.width(), 240) self.verticalLayout = QVBoxLayout(self.box) self.verticalLayout.setContentsMargins(0, 0, 0, 0) # FadeIn self.groupFadeIn = QGroupBox(self.box) self.fadeInLayout = QGridLayout(self.groupFadeIn) self.fadeInSpin = QDoubleSpinBox(self.groupFadeIn) self.fadeInSpin.setMaximum(3600) self.fadeInLayout.addWidget(self.fadeInSpin, 0, 0) self.fadeInLabel = QLabel(self.groupFadeIn) self.fadeInLabel.setAlignment(QtCore.Qt.AlignCenter) self.fadeInLayout.addWidget(self.fadeInLabel, 0, 1) self.fadeInCombo = QComboBox(self.groupFadeIn) self.fadeInCombo.setItemDelegate(QStyledItemDelegate()) for key in sorted(self.FadeIn.keys()): self.fadeInCombo.addItem(self.FadeIn[key], key) self.fadeInLayout.addWidget(self.fadeInCombo, 1, 0) self.fadeInExpLabel = QLabel(self.groupFadeIn) self.fadeInExpLabel.setAlignment(QtCore.Qt.AlignCenter) self.fadeInLayout.addWidget(self.fadeInExpLabel, 1, 1) self.verticalLayout.addWidget(self.groupFadeIn) # FadeOut self.groupFadeOut = QGroupBox(self.box) self.fadeOutLayout = QGridLayout(self.groupFadeOut) self.fadeOutSpin = QDoubleSpinBox(self.groupFadeOut) self.fadeOutSpin.setMaximum(3600) self.fadeOutLayout.addWidget(self.fadeOutSpin, 0, 0) self.fadeOutLabel = QLabel(self.groupFadeOut) self.fadeOutLabel.setAlignment(QtCore.Qt.AlignCenter) self.fadeOutLayout.addWidget(self.fadeOutLabel, 0, 1) self.fadeOutCombo = QComboBox(self.groupFadeOut) self.fadeOutCombo.setItemDelegate(QStyledItemDelegate()) for key in sorted(self.FadeOut.keys()): self.fadeOutCombo.addItem(self.FadeOut[key], key) self.fadeOutLayout.addWidget(self.fadeOutCombo, 1, 0) self.fadeOutExpLabel = QLabel(self.groupFadeOut) self.fadeOutExpLabel.setAlignment(QtCore.Qt.AlignCenter) self.fadeOutLayout.addWidget(self.fadeOutExpLabel, 1, 1) self.verticalLayout.addWidget(self.groupFadeOut) self.retranslateUi()
def __init__(self, parent=None): super(Form, self).__init__(parent) self.number = Number.Number(1) numberFromLabel = QLabel("Number:") self.numberFromLine = QLineEdit() baseFromLabel = QLabel("From Base:") self.baseFromLine = QLineEdit() baseToLabel = QLabel("To Base:") self.baseToLine = QLineEdit() self.submitButton = QPushButton("Convert!") self.resultLabel = QLabel("") vLayout1 = QVBoxLayout() vLayout1.addWidget(numberFromLabel) vLayout1.addWidget(self.numberFromLine) vLayout1.addWidget(baseFromLabel) vLayout1.addWidget(self.baseFromLine) vLayout1.addWidget(baseToLabel) vLayout1.addWidget(self.baseToLine) vLayout1.addWidget(self.submitButton) vLayout1.addWidget(self.resultLabel) self.submitButton.clicked.connect(self.submitNumbers) mainLayout = QGridLayout() mainLayout.addLayout(vLayout1, 0, 1) self.setLayout(mainLayout) self.setWindowTitle("Base converter")
class ShortcutWindow(QMainWindow): def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.setWindowTitle('Shortcut') self.setWindowIcon(QIcon(os.path.join(os.curdir, 'icons/Shortcut.ico'))) self.resize(300, 400) screenRect = QDesktopWidget().screenGeometry() self.move((screenRect.width() - self.width()) / 2, (screenRect.height() - self.height()) / 2) self.mainWidget = QWidget() self.gridlayout = QGridLayout() self.mainWidget.setLayout(self.gridlayout) self.setCentralWidget(self.mainWidget) try: configloader = ConfigLoader() except ConfigError as e: QMessageBox.about(self, 'Config Error', str(e)) return for i, (title, action) in enumerate(configloader.config.items()): if 'open' in action[0]: button = OpenButton(title, action[1]) elif 'edit' in action[0]: button = EditButton(title, action[1], action[2]) elif 'cmd' in action[0]: button = CmdButton(title, action[1]) else: continue colnum = 2 self.gridlayout.addWidget(button, i / colnum, i % colnum)
def initUI(self): # widgetを作る widgets = [ [None for j in range(10)] for i in range(10) ] for j in range(10): for i in range(10): widgets[j][i] = return_widget(i+j) # connectする H = 10 W = 10 for j in range(H): for i in range(W): if i == W-1: i2 = 0 j2 = (j + 1) % W else: i2 = i + 1 j2 = j widgets[j][i].valueChanged.connect(widgets[j2][i2].setValue) # gridに配置 grid = QGridLayout() self.setLayout(grid) for j in range(H): for i in range(W): grid.addWidget(widgets[j][i], j, i) self.move(300, 150) self.setWindowTitle('Too Many Sliders') self.show()
def initView(self): '''创建界面''' scrollArea = QScrollArea(self) # 滚动区域 scrollArea.setWidgetResizable(True) self.setCentralWidget(scrollArea) scrollWidget = QWidget() scrollArea.setWidget(scrollWidget) gridLayout = QGridLayout(scrollWidget) # 网格布局 # 从QEasingCurve获取所有的type curve_types = [(n, c) for n, c in QEasingCurve.__dict__.items() if isinstance(c, QEasingCurve.Type)] curve_types.sort(key = lambda ct: ct[1]) i = 0 for curve_name, curve_type in curve_types: index = curve_type % 4 widget = QWidget() widget.setObjectName("_BorderWidget") widget.setStyleSheet("QWidget#_BorderWidget{border: 1px solid black;}") name = QLabel("QEasingCurve." + curve_name, widget) mpb = MetroProgressCircleBar(widget, curve_type) layout = QVBoxLayout(widget) layout.addWidget(name) layout.addWidget(mpb) gridLayout.addWidget(widget, i, index, 1, 1) if index == 3: i += 1
def __init__(self, parent=None): super(ExportTabWidget, self).__init__(parent) self.checkboxes = [] self.keys = [] self.checkboxdict = [] self.tab1 = QWidget() self.tab2 = QWidget() self.tab3 = QWidget() self.tab4 = QWidget() self.tab5 = QWidget() self.grid1 = QGridLayout() self.grid2 = QGridLayout() self.grid3 = QGridLayout() self.grid4 = QGridLayout() self.addTab(self.tab1, "View") self.addTab(self.tab2, "Histogram") self.addTab(self.tab3, "Contact Map") self.addTab(self.tab4, "VMD") self.addTab(self.tab5, "Plain Text") self.tab1UI() self.tab2UI() self.tab3UI() self.tab4UI() self.tab5UI() self.setWindowTitle("Export") self.contacts = [] self.threshold = 0 self.nsPerFrame = 0 self.map1 = None self.map2 = None self.label1 = "" self.label2 = "" self.psf = "" self.dcd = ""
class T_window(QWidget): def __init__(self): super().__init__() self.tabs = QTabWidget() self.com = T_communication() self.pbar = QProgressBar() self.pbar.setFormat("Battery : %p%") self.grid = QGridLayout() self.setLayout(self.grid) self.grid.addWidget(self.pbar) self.grid.addWidget(self.tabs) self.dpi = T_dpi() self.com.getDpi(self.dpi) self.dpi.dataHasBeenSent() self.t = [] for i in range(0, 4): self.t.append(T_tab(i, self.dpi, self.com)) self.tabs.addTab(self.t[i], "Mode " + str(i + 1)) self.data = T_data(self.pbar, self.tabs, self.dpi, self.com) for i in range(0, 4): self.t[i].sendButton.clicked.connect(self.data.sendDpi) self.t[i].resetButton.clicked.connect(self.com.resetDpi) self.timer = QBasicTimer() self.timer.start(100, self.data) self.tabs.currentChanged.connect(self.com.sendMode)
def __init__(self, parent=None): """asdf.""" super(Form, self).__init__(parent) # Componentes self.name_label = QLabel("Nombre:") self.name_line = QLineEdit() self.submit_button = QPushButton("Aceptar") # Layout vertical button_layout_1 = QVBoxLayout() button_layout_1.addWidget(self.name_label) button_layout_1.addWidget(self.name_line) button_layout_1.addWidget(self.submit_button) # Layout Principal main_layout = QGridLayout() main_layout.addLayout(button_layout_1, 0, 1) # Propiedades de ventana inicial self.setLayout(main_layout) self.setWindowTitle("Hola Qt5") # Eventos self.submit_button.clicked.connect(self.submit_line)
def createReportDesignPage(): page = QWizardPage() page.setTitle("Report Design") page.setSubTitle("Choose Fields to report.") listWidget = QtWidgets.QListWidget() listWidget.setGeometry(QtCore.QRect(130, 50, 131, 192)) listWidget.setTabKeyNavigation(True) listWidget.setObjectName("FieldList") # nameLabel = QLabel("Name:") # nameLineEdit = QLineEdit() # # emailLabel = QLabel("Email address:") # emailLineEdit = QLineEdit() layout = QGridLayout() layout.addWidget(listWidget, 0, 0) # layout.addWidget(nameLineEdit, 0, 1) # layout.addWidget(emailLabel, 1, 0) # layout.addWidget(emailLineEdit, 1, 1) page.setLayout(layout) return page
def __init__(self, parent=None): super(TZprompt, self).__init__(parent) #self.idDates = QCheckBox("Import ID and created/modified dates") promptLabel = QLabel("Time Zone in which the Tellico data was entered:") self.zoneName = QComboBox(self) current = -1 self.suppliedTZ = 'America/Chicago' for i, zone in enumerate (pytz.common_timezones): self.zoneName.addItem(zone, i) if self.suppliedTZ == zone: current = i self.zoneName.setCurrentIndex(current) self.submitButton = QPushButton("Submit") self.submitButton.isDefault() buttonLayout1 = QVBoxLayout() #buttonLayout1.addWidget(self.idDates) buttonLayout1.addWidget(promptLabel) buttonLayout1.addWidget(self.zoneName) buttonLayout1.addWidget(self.submitButton) self.submitButton.clicked.connect(self.TZsubmitted) mainLayout = QGridLayout() mainLayout.addLayout(buttonLayout1, 0, 1) self.setLayout(mainLayout) self.setWindowTitle("Time Zone")
def initUI(self): grid = QGridLayout() self.setLayout(grid) names = ['Cls', 'Bck', '', 'Close', '7', '8', '9', '/', '4', '5', '6', '*', '1', '2', '3', '-', '0', '.', '=', '+'] positions = [(i, j) for i in range(5) for j in range(4)] for position, name in zip(positions, names): if name == '': continue button = QPushButton(name) grid.addWidget(button, *position) print(*position) print(grid.addWidget) self.setGeometry(300, 300, 500, 350) self.setWindowTitle('calculator') self.show()
class HelpDialog(QDialog): def __init__(self, parent, help_file): super(HelpDialog, self).__init__(parent) #QDialog.__init__(self, parent) self.setWindowTitle(_translate("Packaga Manager","Package Manager Help")) self.resize(700,500) self.setModal(True) self.layout = QGridLayout(self) self.htmlPart = QTextBrowser(self) self.layout.addWidget(self.htmlPart, 1, 1) locale = setSystemLocale(justGet = True) if locale in ["tr", "es", "en", "fr", "nl", "de", "sv"]: self.htmlPart.setSource( QUrl("/usr/share/package-manager/help/%s/%s" % (locale, help_files[help_file]))) else: self.htmlPart.setSource( QUrl("/usr/share/package-manager/help/en/%s" % help_files[help_file])) self.show()
def __init__(self, parent): super(MatrixDialog, self).__init__(parent) self.setWindowTitle(_("Trezor Matrix Recovery")) self.num = 9 self.loop = QEventLoop() vbox = QVBoxLayout(self) vbox.addWidget(WWLabel(MATRIX_RECOVERY)) grid = QGridLayout() grid.setSpacing(0) self.char_buttons = [] for y in range(3): for x in range(3): button = QPushButton('?') button.clicked.connect(partial(self.process_key, ord('1') + y * 3 + x)) grid.addWidget(button, 3 - y, x) self.char_buttons.append(button) vbox.addLayout(grid) self.backspace_button = QPushButton("<=") self.backspace_button.clicked.connect(partial(self.process_key, Qt.Key_Backspace)) self.cancel_button = QPushButton(_("Cancel")) self.cancel_button.clicked.connect(partial(self.process_key, Qt.Key_Escape)) buttons = Buttons(self.backspace_button, self.cancel_button) vbox.addSpacing(40) vbox.addLayout(buttons) self.refresh() self.show()
def __init__(self, Wizard, parent=None): super(FinalPage, self).__init__(parent) self.base = Wizard.base self.Wizard = Wizard ''' On this page will be "Finish button" instead of "Next" ''' FinalPage.setFinalPage(self, True) self.setTitle(self.tr("Final page")) self.setSubTitle(self.tr("Your package was successfully created")) self.finalLabel = QLabel() self.coprLabel = QLabel() self.coprLabel.setText( "<html><head/><body><p align=\"center\"><span" + "style=\" font-size:14pt;\">" + "For upload your package to Copr, choose Next " + "button, otherwise use Finish button." + "</p></body></html>") self.rpmButton = QPushButton("Build compiled rpm package") self.rpmButton.setMinimumHeight(45) self.rpmButton.setMinimumWidth(200) self.rpmButton.setMaximumHeight(45) self.rpmButton.setMaximumWidth(250) self.rpmButton.clicked.connect(self.buildRpm) mainLayout = QVBoxLayout() grid = QGridLayout() grid.addWidget(self.rpmButton) grid.setAlignment(QtCore.Qt.AlignCenter) mainLayout.addSpacing(100) mainLayout.addWidget(self.finalLabel) mainLayout.addSpacing(50) mainLayout.addWidget(self.coprLabel) mainLayout.addSpacing(50) mainLayout.addLayout(grid) self.setLayout(mainLayout)
def _setupInspector(self): """ F12키를 누르면 "개발자 도구"가 노출됨 """ # webinspector self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True) self.webInspector = QWebInspector(self) self.webInspector.setPage(self.page()) #Keyboard shortcuts shortcut = {} shortcut['F12'] = QShortcut(self) shortcut['F12'].setContext(Qt.ApplicationShortcut) shortcut['F12'].setKey(Qt.Key_F12) shortcut['F12'].activated.connect(self._toggleInspector) #F5 - Page reloading shortcut['F5'] = QShortcut(self) shortcut['F5'].setKey(Qt.Key_F5) shortcut['F5'].activated.connect(self.reload) # Devtools self.webInspector.setVisible(True) self.devTool = QDialog(self) self.devTool.setWindowTitle("Development Tool") self.devTool.resize(950, 400) layout = QGridLayout() layout.setContentsMargins(0,0,0,0) layout.addWidget(self.webInspector) self.devTool.setLayout(layout)
def createGUI(self): tableData = [ ("Alice", QColor('aliceblue')), ("Neptun", QColor('aquamarine')), ("Ferdinand", QColor('springgreen')) ] table = QTableWidget(3, 2) table.setHorizontalHeaderLabels(["Name", "Hair Color"]) table.verticalHeader().setVisible(False) table.resize(150, 50) for i, (name, color) in enumerate(tableData): nameItem = QTableWidgetItem(name) colorItem = QTableWidgetItem() colorItem.setData(Qt.DisplayRole, color) table.setItem(i, 0, nameItem) table.setItem(i, 1, colorItem) table.resizeColumnToContents(0) table.horizontalHeader().setStretchLastSection(True) layout = QGridLayout() layout.addWidget(table, 0, 0) self.setLayout(layout) self.setWindowTitle("Color Editor Factory")
def __init__(self, controller): super().__init__(controller) self.controller = controller self.setTitle('Routing') select_all_button = QPushButton() select_all_button.setText('Select / Unselect all') select_all_button.clicked.connect(self.selection) self.actions = ( 'Update AS topology', 'Creation of all virtual connections', 'Names / addresses interface allocation', 'Creation of all ARP / MAC tables', 'Creation of all routing tables', 'Path finding procedure', 'Refresh the display' ) layout = QGridLayout(self) layout.addWidget(select_all_button, 0, 1, 1, 1) self.checkboxes = [] for index, action in enumerate(self.actions, 1): checkbox = QCheckBox(action) checkbox.setChecked(True) self.checkboxes.append(checkbox) layout.addWidget(checkbox, index, 1, 1, 1) self.setLayout(layout)
class ControlPanel(QWidget): def __init__(self, parent, dmx_mon=None): QWidget.__init__(self, parent) self.layout = QGridLayout() self.dmx_mon = dmx_mon self.setLayout(self.layout) #self.channel = [LightChannel(self, i*6) for i in range(16)] self.channel = list() self.channel = [ LightChannel(self, lampa), #LightChannel(self, lampa2), ] for i, chan in enumerate(self.channel): self.layout.addWidget(chan, 0, i) chan.changed.connect(self.channel_change) def channel_change(self, chan): r, g, b =chan.get_rgb() if self.dmx_mon: self.dmx_mon.update_value(chan.address, round(r*255)) self.dmx_mon.update_value(chan.address+1, round(g*255)) self.dmx_mon.update_value(chan.address+2, round(b*255))
def __init__(self, latus_app_data_folder): latus.logger.log.info('starting ManagementDialog') super().__init__() pref = latus.preferences.Preferences(latus_app_data_folder) cloud_folders = latus.folders.CloudFolders(pref.get_cloud_root()) grid_layout = QGridLayout() cells = [[QLabel('User Name'), QLabel('Computer Name'), QLabel('Latus Node ID'), QLabel('How Long Since Last Seen'), QLabel(''), datetime.timedelta.max]] for node in latus.nodedb.get_existing_nodes(cloud_folders.nodes): node_db = latus.nodedb.NodeDB(cloud_folders.nodes, node) row_widgets = [QLineEdit(node_db.get_user()), QLineEdit(node_db.get_computer()), QLineEdit(node)] button = ForgetButton(node, node_db, row_widgets) row_widgets += [button] cells.append(row_widgets) widths = collections.defaultdict(int) for row in range(0, len(cells)): for column in range(0, len(cells[row]) - 1): text = cells[row][column].text() width = QFontMetrics(QFont()).width(text) * 1.05 widths[column] = max(widths[column], width) if row > 0 and column < len(cells[row]) - 2: cells[row][column].setReadOnly(True) grid_layout.addWidget(cells[row][column], row, column) for width in widths: grid_layout.setColumnMinimumWidth(width, widths[width]) for row in range(0, len(cells)): for column in range(0, len(cells[row]) - 2): cells[row][column].setMinimumWidth(widths[column]) self.setLayout(grid_layout) self.setWindowTitle("Latus Node Management")
def initUI(self): """ initUI() """ vbox = QVBoxLayout(self) grid1 = QGridLayout() grid1.setSpacing(10) self.text = QTextBrowser() self.text.setReadOnly(True) self.text.setOpenExternalLinks(True) self.text.append(self.message) self.text.moveCursor(QTextCursor.Start) self.text.ensureCursorVisible() vbox.addWidget(self.text) self.setLayout(vbox) self.setMinimumSize(550, 450) self.resize(550, 600) self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) self.setWindowTitle(self.title) iconWT = QIcon() iconWT.addPixmap(QPixmap(":images/DXF2GCODE-001.ico"), QIcon.Normal, QIcon.Off) self.setWindowIcon(QIcon(iconWT)) self.exec_()
def __init__(self, pose3d, parent=None): super(MainWindow, self).__init__(parent) layout = QGridLayout() self.seconds = 0 self.MAXseconds = 900 self.contSeconds = 0 self.secondsArray = [0] self.devPercentajes = [0] self.percentaje = porcentajeWidget(self, pose3d) self.percentajePrev = 0 self.figure = plt.figure() self.canvas = FigureCanvas(self.figure) layout.addWidget(self.canvas) vSpacer = QSpacerItem(30, 50, QSizePolicy.Ignored, QSizePolicy.Ignored) layout.addItem(vSpacer,1,0) self.setFixedSize(1200,500); self.setLayout(layout) timer = QTimer(self) timer.start(1000) timer.timeout.connect(self.contadorTime)
def __init__(self, parent=None): super(Login, self).__init__(parent) usr = QLabel(u"用户:") pwd = QLabel(u"密码:") self.usrLineEdit = QLineEdit() self.pwdLineEdit = QLineEdit() self.pwdLineEdit.setEchoMode(QLineEdit.Password) gridLayout = QGridLayout() gridLayout.addWidget(usr, 0, 0, 1, 1) gridLayout.addWidget(pwd, 1, 0, 1, 1) gridLayout.addWidget(self.usrLineEdit, 0, 1, 1, 3); gridLayout.addWidget(self.pwdLineEdit, 1, 1, 1, 3); okBtn = QPushButton(u"确定") cancelBtn = QPushButton(u"取消") btnLayout = QHBoxLayout() btnLayout.setSpacing(60) btnLayout.addWidget(okBtn) btnLayout.addWidget(cancelBtn) dlgLayout = QVBoxLayout() dlgLayout.setContentsMargins(40, 40, 40, 40) dlgLayout.addLayout(gridLayout) dlgLayout.addStretch(40) dlgLayout.addLayout(btnLayout) self.setLayout(dlgLayout) okBtn.clicked.connect(self.accept) cancelBtn.clicked.connect(self.reject) self.setWindowTitle(u"登录") self.resize(300, 200)
def initUI(self): QToolTip.setFont(QFont('SansSerif', 10)) self.setToolTip('This is a <b>QWidget</b> widget.') exitAction = QAction(QIcon('application-exit-4.png'), '&Exit', self) exitAction.setShortcut('Alt+F4') exitAction.setStatusTip('Exit Application') exitAction.triggered.connect(qApp.quit) menuBar = self.menuBar() fileMenu = menuBar.addMenu('&File') fileMenu.addAction(exitAction) self.toolbar = self.addToolBar('Exit') self.toolbar.addAction(exitAction) grid = QGridLayout() lbl_1 = QLabel('1,1') lbl_2 = QLabel('1,2') lbl_3 = QLabel('2,1') lbl_4 = QLabel('2,2') grid.addWidget(lbl_1, 1, 1) grid.addWidget(lbl_2, 1, 2) grid.addWidget(lbl_3, 2, 1) grid.addWidget(lbl_4, 2, 2) mainW = QWidget() mainW.setLayout(grid) self.setCentralWidget(mainW) self.statusBar().showMessage('Ready') self.setGeometry(300, 300, 500, 500) self.setWindowTitle('Photos') self.setWindowIcon(QIcon('camera-photo-5.png')) self.center() self.show()
def __init__(self): super().__init__() self.pwd = subprocess.Popen('pwd', shell=True, stdout=subprocess.PIPE).stdout.read().decode() self.button_open = QPushButton("Открыть", self) self.button_open.clicked.connect(self.open) self.button_open.setShortcut("ctrl+o") self.button_info = QPushButton("Инфо", self) self.button_info.clicked.connect(self.info) self.button_info.setShortcut("ctrl+i") self.label = QLabel(self) self.label.setAlignment(Qt.AlignCenter) self.setWindowTitle("GIF") layout = QGridLayout() layout.addWidget(self.label, 0, 0) layout.addWidget(self.button_open, 1, 0) layout.addWidget(self.button_info, 2, 0) self.setLayout(layout) self.open()
def __init__(self, parent=None): super().__init__(parent) # Display Window self.display = QLineEdit('') self.display.setReadOnly(True) self.display.setAlignment(Qt.AlignRight) self.display.setMaxLength(15) # Digit Buttons self.digitButton = [x for x in range(10)] for i in range(10): self.digitButton[i] = Button(str(i), self.buttonClicked) # . and = Buttons self.decButton = Button('.', self.buttonClicked) self.eqButton = Button('=', self.buttonClicked) # Operator Buttons self.mulButton = Button('*', self.buttonClicked) self.divButton = Button('/', self.buttonClicked) self.addButton = Button('+', self.buttonClicked) self.subButton = Button('-', self.buttonClicked) # Parentheses Buttons self.lparButton = Button('(', self.buttonClicked) self.rparButton = Button(')', self.buttonClicked) # Clear Button self.clearButton = Button('C', self.buttonClicked) # Layout mainLayout = QGridLayout() mainLayout.setSizeConstraint(QLayout.SetFixedSize) mainLayout.addWidget(self.display, 0, 0, 1, 2) numLayout = QGridLayout() # Number Buttons for i in range(1,10): numLayout.addWidget(self.digitButton[i], 3-((i+2)//3), (i+2)%3) numLayout.addWidget(self.digitButton[0], 3, 0) numLayout.addWidget(self.decButton, 3, 1) numLayout.addWidget(self.eqButton, 3, 2) mainLayout.addLayout(numLayout, 1, 0) # Operator Buttons opLayout = QGridLayout() opLayout.addWidget(self.mulButton, 0, 0) opLayout.addWidget(self.divButton, 0, 1) opLayout.addWidget(self.addButton, 1, 0) opLayout.addWidget(self.subButton, 1, 1) opLayout.addWidget(self.lparButton, 2, 0) opLayout.addWidget(self.rparButton, 2, 1) opLayout.addWidget(self.clearButton, 3, 0) mainLayout.addLayout(opLayout, 1, 1) self.setLayout(mainLayout) self.setWindowTitle("My Calculator")
class SortDialog(QDialog): def __init__(self, desc=None, parent=None): super().__init__(parent) self.setWindowModality(Qt.WindowModal) self.setWindowTitle(self.tr("Sort…")) self.smartSortBox = QRadioButton(self.tr("Canned sort"), self) self.smartSortBox.setToolTip( self.tr("A combination of simple, complex and custom " "sorts that give optimized ordering results.")) self.glyphSetBox = QRadioButton(self.tr("Glyph set"), self) self.glyphSetBox.toggled.connect(self.glyphSetToggle) self.glyphSetDrop = QComboBox(self) self.glyphSetDrop.setEnabled(False) glyphSets = settings.readGlyphSets() for name, glyphNames in glyphSets.items(): self.glyphSetDrop.addItem(name, glyphNames) self.customSortBox = QRadioButton(self.tr("Custom…"), self) self.customSortBox.toggled.connect(self.customSortToggle) self.customSortGroup = QGroupBox(parent=self) self.customSortGroup.setEnabled(False) descriptorsCount = 6 if desc is None: pass elif desc[0]["type"] == "glyphSet": self.glyphSetBox.setChecked(True) self.glyphSetDrop.setEnabled(True) # XXX: we must handle unknown glyphSets... or glyphSets with # the same name but different self.glyphSetDrop.setCurrentText(desc[0]["name"]) elif desc[0]["type"] == "cannedDesign": self.smartSortBox.setChecked(True) else: self.customSortBox.setChecked(True) self.customSortGroup.setEnabled(True) descriptorsCount = len(desc) self.customDescriptors = [[] for i in range(descriptorsCount)] self.customSortLayout = QGridLayout() for i, line in enumerate(self.customDescriptors): line.append(QComboBox(self)) line[0].insertItems(0, sortItems) line.append(QCheckBox(self.tr("Ascending"), self)) line.append(QCheckBox(self.tr("Allow pseudo-unicode"), self)) if self.customSortBox.isChecked(): line[0].setCurrentIndex(self.indexFromItemName( desc[i]["type"])) line[1].setChecked(desc[i]["ascending"]) line[2].setChecked(desc[i]["allowPseudoUnicode"]) else: line[0].setCurrentIndex(i) line[1].setChecked(True) line[2].setChecked(True) self.customSortLayout.addWidget(line[0], i, 0) self.customSortLayout.addWidget(line[1], i, 1) self.customSortLayout.addWidget(line[2], i, 2) btn = QPushButton(self) btn.setFixedWidth(32) btn.setProperty("index", i) line.append(btn) self.customSortLayout.addWidget(btn, i, 3) if i == 0: btn.setText("+") btn.clicked.connect(self._addRow) self.addLineButton = btn else: btn.setText("−") btn.clicked.connect(self._deleteRow) self.customSortGroup.setLayout(self.customSortLayout) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) layout = QVBoxLayout(self) layout.addWidget(self.smartSortBox) layout.addWidget(self.glyphSetBox) layout.addWidget(self.glyphSetDrop) layout.addWidget(self.customSortBox) layout.addWidget(self.customSortGroup) layout.addWidget(buttonBox) self.setLayout(layout) def _addRow(self): i = len(self.customDescriptors) line = [] line.append(QComboBox(self)) line[0].insertItems(0, sortItems) line[0].setCurrentIndex(0) line.append(QCheckBox("Ascending", self)) line.append(QCheckBox("Allow pseudo-unicode", self)) btn = QPushButton("−", self) btn.setFixedWidth(32) btn.setProperty("index", i) btn.clicked.connect(self._deleteRow) line.append(btn) self.customDescriptors.append(line) self.customSortLayout.addWidget(line[0], i, 0) self.customSortLayout.addWidget(line[1], i, 1) self.customSortLayout.addWidget(line[2], i, 2) self.customSortLayout.addWidget(line[3], i, 3) if i == 7: self.sender().setEnabled(False) def _deleteRow(self): rel = self.sender().property("index") desc = self.customDescriptors for i in range(rel + 1, len(desc) - 1): desc[i][0].setCurrentIndex(desc[i + 1][0].currentIndex()) desc[i][1].setChecked(desc[i + 1][1].isChecked()) desc[i][2].setChecked(desc[i + 1][2].isChecked()) for elem in desc[-1]: elem.setParent(None) del self.customDescriptors[-1] self.addLineButton.setEnabled(True) self.adjustSize() def indexFromItemName(self, name): for index, item in enumerate(sortItems): if name == item: return index print(self.tr("Unknown descriptor name: %s"), name) return 0 @classmethod def getDescriptor(cls, parent, sortDescriptor=None): dialog = cls(sortDescriptor, parent) result = dialog.exec_() if dialog.glyphSetBox.isChecked(): data = dialog.glyphSetDrop.currentData() name = dialog.glyphSetDrop.currentText() ret = [dict(type="glyphSet", glyphs=data, name=name)] elif dialog.customSortBox.isChecked(): descriptors = [] for line in dialog.customDescriptors: descriptors.append( dict( type=line[0].currentText(), ascending=line[1].isChecked(), allowPseudoUnicode=line[2].isChecked(), )) ret = descriptors else: ret = [dict(type="cannedDesign", allowPseudoUnicode=True)] return (ret, result) def glyphSetToggle(self): checkBox = self.sender() self.glyphSetDrop.setEnabled(checkBox.isChecked()) def customSortToggle(self): checkBox = self.sender() self.customSortGroup.setEnabled(checkBox.isChecked())
def __init__(self, theParent): QWidget.__init__(self, theParent) logger.debug("Initialising GuiItemDetails ...") self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theParent.theProject self.theTheme = theParent.theTheme self.theHandle = None self.mainBox = QGridLayout(self) self.mainBox.setVerticalSpacing(1) self.mainBox.setHorizontalSpacing(6) self.setLayout(self.mainBox) self.pS = 0.9 * self.theTheme.fontPointSize self.iPx = self.theTheme.baseIconSize self.sPx = int(round(0.8 * self.theTheme.baseIconSize)) self.expCheck = self.theTheme.getPixmap("check", (self.iPx, self.iPx)) self.expCross = self.theTheme.getPixmap("cross", (self.iPx, self.iPx)) self.fntLabel = QFont() self.fntLabel.setBold(True) self.fntLabel.setPointSizeF(self.pS) self.fntValue = QFont() self.fntValue.setPointSizeF(self.pS) # Label self.labelName = QLabel("Label") self.labelName.setFont(self.fntLabel) self.labelName.setAlignment(Qt.AlignLeft | Qt.AlignBaseline) self.labelFlag = QLabel("") self.labelFlag.setAlignment(Qt.AlignRight | Qt.AlignBaseline) self.labelData = QLabel("") self.labelData.setFont(self.fntValue) self.labelData.setAlignment(Qt.AlignLeft | Qt.AlignBaseline) self.labelData.setWordWrap(True) # Status self.statusName = QLabel("Status") self.statusName.setFont(self.fntLabel) self.statusName.setAlignment(Qt.AlignLeft) self.statusFlag = QLabel("") self.statusFlag.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.statusData = QLabel("") self.statusData.setFont(self.fntValue) self.statusData.setAlignment(Qt.AlignLeft) # Class self.className = QLabel("Class") self.className.setFont(self.fntLabel) self.className.setAlignment(Qt.AlignLeft) self.classFlag = QLabel("") self.classFlag.setFont(self.fntValue) self.classFlag.setAlignment(Qt.AlignRight) self.classData = QLabel("") self.classData.setFont(self.fntValue) self.classData.setAlignment(Qt.AlignLeft) # Layout self.layoutName = QLabel("Layout") self.layoutName.setFont(self.fntLabel) self.layoutName.setAlignment(Qt.AlignLeft) self.layoutFlag = QLabel("") self.layoutFlag.setFont(self.fntValue) self.layoutFlag.setAlignment(Qt.AlignRight) self.layoutData = QLabel("") self.layoutData.setFont(self.fntValue) self.layoutData.setAlignment(Qt.AlignLeft) # Character Count self.cCountName = QLabel(" Characters") self.cCountName.setFont(self.fntLabel) self.cCountName.setAlignment(Qt.AlignRight) self.cCountData = QLabel("") self.cCountData.setFont(self.fntValue) self.cCountData.setAlignment(Qt.AlignRight) # Word Count self.wCountName = QLabel(" Words") self.wCountName.setFont(self.fntLabel) self.wCountName.setAlignment(Qt.AlignRight) self.wCountData = QLabel("") self.wCountData.setFont(self.fntValue) self.wCountData.setAlignment(Qt.AlignRight) # Paragraph Count self.pCountName = QLabel(" Paragraphs") self.pCountName.setFont(self.fntLabel) self.pCountName.setAlignment(Qt.AlignRight) self.pCountData = QLabel("") self.pCountData.setFont(self.fntValue) self.pCountData.setAlignment(Qt.AlignRight) # Assemble self.mainBox.addWidget(self.labelName, 0, 0, 1, 1) self.mainBox.addWidget(self.labelFlag, 0, 1, 1, 1) self.mainBox.addWidget(self.labelData, 0, 2, 1, 3) self.mainBox.addWidget(self.statusName, 1, 0, 1, 1) self.mainBox.addWidget(self.statusFlag, 1, 1, 1, 1) self.mainBox.addWidget(self.statusData, 1, 2, 1, 1) self.mainBox.addWidget(self.cCountName, 1, 3, 1, 1) self.mainBox.addWidget(self.cCountData, 1, 4, 1, 1) self.mainBox.addWidget(self.className, 2, 0, 1, 1) self.mainBox.addWidget(self.classFlag, 2, 1, 1, 1) self.mainBox.addWidget(self.classData, 2, 2, 1, 1) self.mainBox.addWidget(self.wCountName, 2, 3, 1, 1) self.mainBox.addWidget(self.wCountData, 2, 4, 1, 1) self.mainBox.addWidget(self.layoutName, 3, 0, 1, 1) self.mainBox.addWidget(self.layoutFlag, 3, 1, 1, 1) self.mainBox.addWidget(self.layoutData, 3, 2, 1, 1) self.mainBox.addWidget(self.pCountName, 3, 3, 1, 1) self.mainBox.addWidget(self.pCountData, 3, 4, 1, 1) self.mainBox.setColumnStretch(0, 0) self.mainBox.setColumnStretch(1, 0) self.mainBox.setColumnStretch(2, 1) self.mainBox.setColumnStretch(3, 0) self.mainBox.setColumnStretch(4, 0) # Make sure the columns for flags and counts don't resize too often flagWidth = self.theTheme.getTextWidth("Mm", self.fntValue) countWidth = self.theTheme.getTextWidth("99,999", self.fntValue) self.mainBox.setColumnMinimumWidth(1, flagWidth) self.mainBox.setColumnMinimumWidth(4, countWidth) logger.debug("GuiItemDetails initialisation complete") return
class GuiItemDetails(QWidget): def __init__(self, theParent): QWidget.__init__(self, theParent) logger.debug("Initialising GuiItemDetails ...") self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theParent.theProject self.theTheme = theParent.theTheme self.theHandle = None self.mainBox = QGridLayout(self) self.mainBox.setVerticalSpacing(1) self.mainBox.setHorizontalSpacing(6) self.setLayout(self.mainBox) self.pS = 0.9 * self.theTheme.fontPointSize self.iPx = self.theTheme.baseIconSize self.sPx = int(round(0.8 * self.theTheme.baseIconSize)) self.expCheck = self.theTheme.getPixmap("check", (self.iPx, self.iPx)) self.expCross = self.theTheme.getPixmap("cross", (self.iPx, self.iPx)) self.fntLabel = QFont() self.fntLabel.setBold(True) self.fntLabel.setPointSizeF(self.pS) self.fntValue = QFont() self.fntValue.setPointSizeF(self.pS) # Label self.labelName = QLabel("Label") self.labelName.setFont(self.fntLabel) self.labelName.setAlignment(Qt.AlignLeft | Qt.AlignBaseline) self.labelFlag = QLabel("") self.labelFlag.setAlignment(Qt.AlignRight | Qt.AlignBaseline) self.labelData = QLabel("") self.labelData.setFont(self.fntValue) self.labelData.setAlignment(Qt.AlignLeft | Qt.AlignBaseline) self.labelData.setWordWrap(True) # Status self.statusName = QLabel("Status") self.statusName.setFont(self.fntLabel) self.statusName.setAlignment(Qt.AlignLeft) self.statusFlag = QLabel("") self.statusFlag.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.statusData = QLabel("") self.statusData.setFont(self.fntValue) self.statusData.setAlignment(Qt.AlignLeft) # Class self.className = QLabel("Class") self.className.setFont(self.fntLabel) self.className.setAlignment(Qt.AlignLeft) self.classFlag = QLabel("") self.classFlag.setFont(self.fntValue) self.classFlag.setAlignment(Qt.AlignRight) self.classData = QLabel("") self.classData.setFont(self.fntValue) self.classData.setAlignment(Qt.AlignLeft) # Layout self.layoutName = QLabel("Layout") self.layoutName.setFont(self.fntLabel) self.layoutName.setAlignment(Qt.AlignLeft) self.layoutFlag = QLabel("") self.layoutFlag.setFont(self.fntValue) self.layoutFlag.setAlignment(Qt.AlignRight) self.layoutData = QLabel("") self.layoutData.setFont(self.fntValue) self.layoutData.setAlignment(Qt.AlignLeft) # Character Count self.cCountName = QLabel(" Characters") self.cCountName.setFont(self.fntLabel) self.cCountName.setAlignment(Qt.AlignRight) self.cCountData = QLabel("") self.cCountData.setFont(self.fntValue) self.cCountData.setAlignment(Qt.AlignRight) # Word Count self.wCountName = QLabel(" Words") self.wCountName.setFont(self.fntLabel) self.wCountName.setAlignment(Qt.AlignRight) self.wCountData = QLabel("") self.wCountData.setFont(self.fntValue) self.wCountData.setAlignment(Qt.AlignRight) # Paragraph Count self.pCountName = QLabel(" Paragraphs") self.pCountName.setFont(self.fntLabel) self.pCountName.setAlignment(Qt.AlignRight) self.pCountData = QLabel("") self.pCountData.setFont(self.fntValue) self.pCountData.setAlignment(Qt.AlignRight) # Assemble self.mainBox.addWidget(self.labelName, 0, 0, 1, 1) self.mainBox.addWidget(self.labelFlag, 0, 1, 1, 1) self.mainBox.addWidget(self.labelData, 0, 2, 1, 3) self.mainBox.addWidget(self.statusName, 1, 0, 1, 1) self.mainBox.addWidget(self.statusFlag, 1, 1, 1, 1) self.mainBox.addWidget(self.statusData, 1, 2, 1, 1) self.mainBox.addWidget(self.cCountName, 1, 3, 1, 1) self.mainBox.addWidget(self.cCountData, 1, 4, 1, 1) self.mainBox.addWidget(self.className, 2, 0, 1, 1) self.mainBox.addWidget(self.classFlag, 2, 1, 1, 1) self.mainBox.addWidget(self.classData, 2, 2, 1, 1) self.mainBox.addWidget(self.wCountName, 2, 3, 1, 1) self.mainBox.addWidget(self.wCountData, 2, 4, 1, 1) self.mainBox.addWidget(self.layoutName, 3, 0, 1, 1) self.mainBox.addWidget(self.layoutFlag, 3, 1, 1, 1) self.mainBox.addWidget(self.layoutData, 3, 2, 1, 1) self.mainBox.addWidget(self.pCountName, 3, 3, 1, 1) self.mainBox.addWidget(self.pCountData, 3, 4, 1, 1) self.mainBox.setColumnStretch(0, 0) self.mainBox.setColumnStretch(1, 0) self.mainBox.setColumnStretch(2, 1) self.mainBox.setColumnStretch(3, 0) self.mainBox.setColumnStretch(4, 0) # Make sure the columns for flags and counts don't resize too often flagWidth = self.theTheme.getTextWidth("Mm", self.fntValue) countWidth = self.theTheme.getTextWidth("99,999", self.fntValue) self.mainBox.setColumnMinimumWidth(1, flagWidth) self.mainBox.setColumnMinimumWidth(4, countWidth) logger.debug("GuiItemDetails initialisation complete") return ### # Class Methods ## def clearDetails(self): """Clear all the data values. """ self.labelFlag.setPixmap(QPixmap(1, 1)) self.labelData.setText("") self.statusFlag.setPixmap(QPixmap(1, 1)) self.statusData.setText("") self.classFlag.setText("") self.classData.setText("") self.layoutFlag.setText("") self.layoutData.setText("") self.cCountData.setText("–") self.wCountData.setText("–") self.pCountData.setText("–") return def updateCounts(self, tHandle, cC, wC, pC): """Just update the counts if the handle is the same as the one we're already showing. """ if tHandle == self.theHandle: self.cCountData.setText(f"{cC:n}") self.wCountData.setText(f"{wC:n}") self.pCountData.setText(f"{pC:n}") return def updateViewBox(self, tHandle): """Populate the details box from a given handle. """ self.theHandle = tHandle nwItem = self.theProject.projTree[tHandle] if nwItem is None: self.clearDetails() else: theLabel = nwItem.itemName if len(theLabel) > 100: theLabel = theLabel[:96].rstrip() + " ..." iStatus = nwItem.itemStatus if nwItem.itemClass == nwItemClass.NOVEL: iStatus = self.theProject.statusItems.checkEntry( iStatus) # Make sure it's valid flagIcon = self.theParent.statusIcons[iStatus] else: iStatus = self.theProject.importItems.checkEntry( iStatus) # Make sure it's valid flagIcon = self.theParent.importIcons[iStatus] if nwItem.itemType == nwItemType.FILE: if nwItem.isExported: self.labelFlag.setPixmap(self.expCheck) else: self.labelFlag.setPixmap(self.expCross) else: self.labelFlag.setPixmap(QPixmap(1, 1)) self.statusFlag.setPixmap(flagIcon.pixmap(self.sPx, self.sPx)) self.classFlag.setText(nwLabels.CLASS_FLAG[nwItem.itemClass]) if nwItem.itemLayout == nwItemLayout.NO_LAYOUT: self.layoutFlag.setText("-") else: self.layoutFlag.setText( nwLabels.LAYOUT_FLAG[nwItem.itemLayout]) self.labelData.setText(theLabel) self.statusData.setText(nwItem.itemStatus) self.classData.setText(nwLabels.CLASS_NAME[nwItem.itemClass]) self.layoutData.setText(nwLabels.LAYOUT_NAME[nwItem.itemLayout]) if nwItem.itemType == nwItemType.FILE: self.cCountData.setText(f"{nwItem.charCount:n}") self.wCountData.setText(f"{nwItem.wordCount:n}") self.pCountData.setText(f"{nwItem.paraCount:n}") else: self.cCountData.setText("–") self.wCountData.setText("–") self.pCountData.setText("–") return
def __init__(self, parent = None): super().__init__(parent) # Display Window self.display = QLineEdit() # Python에서 0으로 시작하는 수는 8진수로 인식하므로 0이 안붙도록 수정 self.display.setReadOnly(True) self.display.setAlignment(Qt.AlignRight) self.display.setMaxLength(15) # Digit Buttons self.digitButton = [x for x in range(0, 10)] # 버튼 클래스 생성 for i in range(10) : self.digitButton[i] = Button(str([i]), self.buttonClicked) # . and = Buttons self.decButton = Button('.', self.buttonClicked) # callback을 넘겨줘야함 self.eqButton = Button('=', self.buttonClicked) ## self.~~~ = Button('~', self.buttonClicked)로 # Operator Buttons self.mulButton = Button('*', self.buttonClicked) self.divButton = Button('/', self.buttonClicked) self.addButton = Button('+', self.buttonClicked) self.subButton = Button('-', self.buttonClicked) # Parentheses Buttons self.lparButton = Button('(', self.buttonClicked) self.rparButton = Button(')', self.buttonClicked) # Layout mainLayout = QGridLayout() mainLayout.setSizeConstraint(QLayout.SetFixedSize) mainLayout.addWidget(self.display, 0, 0, 1, 2) # 맨 윗줄의 layout이 가로1칸 세로2칸을 차지하겠다는 뜻 (1,2) numLayout = QGridLayout() # 버튼 생성 부분 (기능을 구현하기 전에 버튼을 추가) for i in range(0, 3) : for j in range(0, 3): numLayout.addWidget(self.digitButton[7+j-3*i], i ,j) numLayout.addWidget(self.digitButton[0], 3, 0) numLayout.addWidget(self.decButton, 3, 1) numLayout.addWidget(self.eqButton, 3, 2) mainLayout.addLayout(numLayout, 1, 0) opLayout = QGridLayout() opLayout.addWidget(self.mulButton, 0, 0) opLayout.addWidget(self.divButton, 0, 1) opLayout.addWidget(self.addButton, 1, 0) opLayout.addWidget(self.subButton, 1, 1) opLayout.addWidget(self.lparButton, 2, 0) opLayout.addWidget(self.rparButton, 2, 1) opLayout.addWidget(self.clearButton, 3, 0) mainLayout.addLayout(opLayout, 1, 1) self.setLayout(mainLayout) self.setWindowTitle("My Calculator")
def initUI(self): self.resize(800, 600) self.centre() # Set background colour of main window to white palette = QPalette() palette.setColor(QPalette.Background,Qt.white) self.setPalette(palette) self.setWindowTitle('SPE Moto | Induction Motor Parameter Estimation Tool') self.setWindowIcon(QIcon('icons\motor.png')) """ Actions """ exitAction = QAction(QIcon('icons\exit.png'), '&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(QApplication.instance().quit) loadAction = QAction('&Open File...', self) loadAction.setStatusTip('Open file and load motor data') loadAction.triggered.connect(self.load_action) saveAction = QAction('&Save As...', self) saveAction.setStatusTip('Save motor data') saveAction.triggered.connect(self.save_action) aboutAction = QAction('&About Moto', self) aboutAction.setStatusTip('About Moto') aboutAction.triggered.connect(self.about_dialog) helpAction = QAction('&User Manual', self) helpAction.setShortcut('F1') helpAction.setStatusTip('Moto user documentation') helpAction.triggered.connect(self.user_manual) """ Menubar """ menu_bar = self.menuBar() fileMenu = menu_bar.addMenu('&File') fileMenu.addAction(loadAction) fileMenu.addAction(saveAction) fileMenu.addAction(exitAction) helpMenu = menu_bar.addMenu('&Help') helpMenu.addAction(helpAction) helpMenu.addSeparator() helpMenu.addAction(aboutAction) """ Main Screen """ heading_font = QFont() heading_font.setPointSize(10) heading_font.setBold(True) ################ # Motor details ################ header1 = QLabel('Motor') #header1.setMinimumWidth(50) header1.setMinimumHeight(30) header1.setFont(heading_font) label1 = QLabel('Description') #label1.setMinimumWidth(50) self.le1 = QLineEdit() #self.le1.setMinimumWidth(150) self.le1.setText(str(globals.motor_data["description"])) label2 = QLabel('Synchronous speed') #label2.setMinimumWidth(50) self.le2 = QLineEdit() #self.le2.setMinimumWidth(50) self.le2.setText(str(globals.motor_data["sync_speed"])) label2a = QLabel('rpm') #label2a.setMinimumWidth(30) label3 = QLabel('Rated speed') #label3.setMinimumWidth(50) self.le3 = QLineEdit() #self.le3.setMinimumWidth(50) self.le3.setText(str(globals.motor_data["rated_speed"])) label3a = QLabel('rpm') #label3a.setMinimumWidth(30) label4 = QLabel('Rated power factor') #label4.setMinimumWidth(50) self.le4 = QLineEdit() #self.le4.setMinimumWidth(50) self.le4.setText(str(globals.motor_data["rated_pf"])) label4a = QLabel('pf') #label4a.setMinimumWidth(20) label5 = QLabel('Rated efficiency') #label5.setMinimumWidth(50) self.le5 = QLineEdit() #self.le5.setMinimumWidth(50) self.le5.setText(str(globals.motor_data["rated_eff"])) label5a = QLabel('pu') #label5a.setMinimumWidth(20) label6 = QLabel('Breakdown torque') #label6.setMinimumWidth(50) self.le6 = QLineEdit() #self.le6.setMinimumWidth(50) self.le6.setText(str(globals.motor_data["T_b"])) label6a = QLabel('T/Tn') #label6a.setMinimumWidth(40) label7 = QLabel('Locked rotor torque') #label7.setMinimumWidth(50) self.le7 = QLineEdit() #self.le7.setMinimumWidth(50) self.le7.setText(str(globals.motor_data["T_lr"])) label7a = QLabel('T/Tn') #label7a.setMinimumWidth(40) label8 = QLabel('Locked rotor current') #label8.setMinimumWidth(50) self.le8 = QLineEdit() #self.le8.setMinimumWidth(50) self.le8.setText(str(globals.motor_data["I_lr"])) label8a = QLabel('pu') #label8a.setMinimumWidth(40) label_rp = QLabel('Rated Power') self.lex9 = QLineEdit() self.lex9.setText(str(globals.motor_data["rated_power"])) labelex9 = QLabel('Kw') label_ri = QLabel('Rated Current') self.lex10 = QLineEdit() self.lex10.setText(str(globals.motor_data["rated_current"])) labelex10 = QLabel('I') label_rv = QLabel('Rated Voltage') self.lex11 = QLineEdit() self.lex11.setText(str(globals.motor_data["rated_voltage"])) labelex11 = QLabel('V') ######## # Model ######## header2 = QLabel('Model') header2.setMinimumHeight(40) header2.setFont(heading_font) label_model = QLabel('Model') #label_model.setMinimumWidth(150) self.combo_model = QComboBox() self.combo_model.addItem("Single cage") # self.combo_model.addItem("Single cage w/o core losses") self.combo_model.addItem("Double cage") self.combo_model.setCurrentIndex(1) self.img1 = QLabel() self.img1.setPixmap(QPixmap('images\dbl_cage.png')) ##################### # Algorithm settings ##################### header3 = QLabel('Settings') header3.setMinimumHeight(40) header3.setFont(heading_font) label9 = QLabel('Maximum # iterations') self.le9 = QLineEdit() self.le9.setText(str(globals.algo_data["max_iter"])) self.le9.setStatusTip('Maximum number of iterations allowed') label10 = QLabel('Convergence criterion') self.le10 = QLineEdit() self.le10.setText(str(globals.algo_data["conv_err"])) self.le10.setStatusTip('Squared error required to qualify for convergence') self.label11 = QLabel('Linear constraint k_r') self.le11 = QLineEdit() self.le11.setText(str(globals.algo_data["k_r"])) self.le11.setStatusTip('Linear constraint for Rs') self.label12 = QLabel('Linear constraint k_x') self.le12 = QLineEdit() self.le12.setText(str(globals.algo_data["k_x"])) self.le12.setStatusTip('Linear constraint for Xr2') # Genetic Algorithm Widgets ############################ self.labeln_gen = QLabel('Maximum # generations') self.labeln_gen.setVisible(0) self.labelpop = QLabel('Members in population') self.labelpop.setVisible(0) self.labeln_r = QLabel('Members in mating pool') self.labeln_r.setVisible(0) self.labeln_e = QLabel('Elite children') self.labeln_e.setVisible(0) self.labelc_f = QLabel('Crossover fraction') self.labelc_f.setVisible(0) self.len_gen = QLineEdit() self.len_gen.setText(str(globals.algo_data["n_gen"])) self.len_gen.setStatusTip('Maximum number of generations allowed') self.len_gen.hide() self.lepop = QLineEdit() self.lepop.setText(str(globals.algo_data["pop"])) self.lepop.setStatusTip('Number of members in each generation') self.lepop.hide() self.len_r = QLineEdit() self.len_r.setText(str(globals.algo_data["n_r"])) self.len_r.setStatusTip('Number of members in a mating pool') self.len_r.hide() self.len_e = QLineEdit() self.len_e.setText(str(globals.algo_data["n_e"])) self.len_e.setStatusTip('Number of elite children') self.len_e.hide() self.lec_f = QLineEdit() self.lec_f.setText(str(globals.algo_data["c_f"])) self.lec_f.setStatusTip('Proportion of children spawned through crossover') self.lec_f.hide() label_algo = QLabel('Algorithm') #label_algo.setMinimumWidth(150) self.combo_algo = QComboBox() self.combo_algo.addItem("Newton-Raphson") self.combo_algo.addItem("Levenberg-Marquardt") self.combo_algo.addItem("Damped Newton-Raphson") self.combo_algo.addItem("Genetic Algorithm") self.combo_algo.addItem("Hybrid GA-NR") self.combo_algo.addItem("Hybrid GA-LM") self.combo_algo.addItem("Hybrid GA-DNR") calc_button = QPushButton("Calculate") calc_button.setStatusTip('Estimate equivalent circuit parameters') self.plot_button = QPushButton("Plot") self.plot_button.setDisabled(1) self.plot_button.setStatusTip('Plot torque-speed and current-speed curves') #################### # Algorithm results #################### header4 = QLabel('Results') #header4.setMinimumWidth(150) header4.setMinimumHeight(40) header4.setFont(heading_font) label13 = QLabel('R_s') #label13.setFixedWidth(50) self.leRs = QLineEdit() self.leRs.setStatusTip('Stator resistance (pu)') label14 = QLabel('X_s') #label14.setMinimumWidth(150) self.leXs = QLineEdit() self.leXs.setStatusTip('Stator reactance (pu)') label15 = QLabel('X_m') #label15.setMinimumWidth(150) self.leXm = QLineEdit() self.leXm.setStatusTip('Magnetising resistance (pu)') label16 = QLabel('X_r1') #label16.setMinimumWidth(150) self.leXr1 = QLineEdit() self.leXr1.setStatusTip('Inner cage rotor reactance (pu)') label17 = QLabel('R_r1') #label17.setMinimumWidth(150) self.leRr1 = QLineEdit() self.leRr1.setStatusTip('Inner cage rotor resistance (pu)') self.label18 = QLabel('X_r2') #label18.setMinimumWidth(150) self.leXr2 = QLineEdit() self.leXr2.setStatusTip('Outer cage rotor reactance (pu)') self.label19 = QLabel('R_r2') #label19.setMinimumWidth(150) self.leRr2 = QLineEdit() self.leRr2.setStatusTip('Outer cage rotor resistance (pu)') label20 = QLabel('R_c') #label20.setMinimumWidth(150) self.leRc = QLineEdit() self.leRc.setStatusTip('Core loss resistance (pu)') label21 = QLabel('Converged?') #label21.setMinimumWidth(150) self.leConv = QLineEdit() self.leConv.setStatusTip('Did algorithm converge?') label22 = QLabel('Squared Error') #label22.setMinimumWidth(150) self.leErr = QLineEdit() self.leErr.setStatusTip('Squared error of estimate') label23 = QLabel('Iterations') #label23.setMinimumWidth(150) self.leIter = QLineEdit() self.leIter.setStatusTip('Number of iterations / generations') ############## # Grid layout ############## grid = QGridLayout() # Motor details i = 0 grid.addWidget(header1, i, 0) grid.addWidget(label1, i+1, 0) grid.addWidget(self.le1, i+1, 1, 1, 5) grid.addWidget(label2, i+2, 0) grid.addWidget(self.le2, i+2, 1) grid.addWidget(label2a, i+2, 2) grid.addWidget(label3, i+3, 0) grid.addWidget(self.le3, i+3, 1) grid.addWidget(label3a, i+3, 2) grid.addWidget(label4, i+4, 0) grid.addWidget(self.le4, i+4, 1) grid.addWidget(label4a, i+4, 2) grid.addWidget(label5, i+5, 0) grid.addWidget(self.le5, i+5, 1) grid.addWidget(label5a, i+5, 2) grid.addWidget(label6, i+3, 4) grid.addWidget(self.le6, i+3, 5) grid.addWidget(label6a, i+3, 6) grid.addWidget(label7, i+4, 4) grid.addWidget(self.le7, i+4, 5) grid.addWidget(label7a, i+4, 6) grid.addWidget(label8, i+5, 4) grid.addWidget(self.le8, i+5, 5) grid.addWidget(label8a, i+5, 6) grid.addWidget(label_rp, i+6, 0) grid.addWidget(self.lex9, i+6, 1) grid.addWidget(labelex9, i+6, 2) grid.addWidget(label_ri, i+7, 0) grid.addWidget(self.lex10, i+7, 1) grid.addWidget(labelex10, i+7, 2) grid.addWidget(label_rv, i+8, 0) grid.addWidget(self.lex11, i+8, 1) grid.addWidget(labelex11, i+8, 2) # Model i = 9 #grid.addWidget(header2, i, 0) grid.addWidget(label_model, i+1, 0) grid.addWidget(self.combo_model, i+1, 1) grid.addWidget(self.img1, i+1, 3, i-7, 6) # Algorithm settings i = 12 grid.addWidget(header3, i, 0) grid.addWidget(label_algo, i+1, 0) grid.addWidget(self.combo_algo, i+1, 1) grid.addWidget(label9, i+2, 0) grid.addWidget(self.le9, i+2, 1) grid.addWidget(label10, i+3, 0) grid.addWidget(self.le10, i+3, 1) grid.addWidget(self.label11, i+2, 3) grid.addWidget(self.le11, i+2, 4) grid.addWidget(self.label12, i+3, 3) grid.addWidget(self.le12, i+3, 4) # Genetic algorithm parameters grid.addWidget(self.labeln_gen, i+2, 3) grid.addWidget(self.len_gen, i+2, 4) grid.addWidget(self.labelpop, i+3, 3) grid.addWidget(self.lepop, i+3, 4) grid.addWidget(self.labeln_r, i+4, 3) grid.addWidget(self.len_r, i+4, 4) grid.addWidget(self.labeln_e, i+2, 5) grid.addWidget(self.len_e, i+2, 6) grid.addWidget(self.labelc_f, i+3, 5) grid.addWidget(self.lec_f, i+3, 6) grid.addWidget(calc_button, i+4, 5) grid.addWidget(self.plot_button, i+4, 6) # Algorithm results i = 17 grid.addWidget(header4, i, 0) grid.addWidget(label13, i+1, 0) grid.addWidget(self.leRs, i+1, 1) grid.addWidget(label14, i+2, 0) grid.addWidget(self.leXs, i+2, 1) grid.addWidget(label15, i+3, 0) grid.addWidget(self.leXm, i+3, 1) grid.addWidget(label20, i+4, 0) grid.addWidget(self.leRc, i+4, 1) grid.addWidget(label16, i+1, 3) grid.addWidget(self.leXr1, i+1, 4) grid.addWidget(label17, i+2, 3) grid.addWidget(self.leRr1, i+2, 4) grid.addWidget(self.label18, i+3, 3) grid.addWidget(self.leXr2, i+3, 4) grid.addWidget(self.label19, i+4, 3) grid.addWidget(self.leRr2, i+4, 4) grid.addWidget(label21, i+1, 5) grid.addWidget(self.leConv, i+1, 6) grid.addWidget(label22, i+2, 5) grid.addWidget(self.leErr, i+2, 6) grid.addWidget(label23, i+3, 5) grid.addWidget(self.leIter, i+3, 6) grid.setAlignment(Qt.AlignTop) main_screen = QWidget() main_screen.setLayout(grid) main_screen.setStatusTip('Ready') self.setCentralWidget(main_screen) # Event handlers calc_button.clicked.connect(self.calculate) self.plot_button.clicked.connect(self.plot_curves) self.le1.editingFinished.connect(self.update_data) self.le2.editingFinished.connect(self.update_data) self.le3.editingFinished.connect(self.update_data) self.le4.editingFinished.connect(self.update_data) self.le5.editingFinished.connect(self.update_data) self.le6.editingFinished.connect(self.update_data) self.le7.editingFinished.connect(self.update_data) self.le8.editingFinished.connect(self.update_data) self.le9.editingFinished.connect(self.update_data) self.le10.editingFinished.connect(self.update_data) self.le11.editingFinished.connect(self.update_data) self.le12.editingFinished.connect(self.update_data) self.len_gen.editingFinished.connect(self.update_data) self.lepop.editingFinished.connect(self.update_data) self.len_r.editingFinished.connect(self.update_data) self.len_e.editingFinished.connect(self.update_data) self.lec_f.editingFinished.connect(self.update_data) ########################## #TO DO - connects for combo boxes - combo_model and combo_algo (what signal to use?) ########################## self.combo_algo.currentIndexChanged.connect(self.update_algo) self.combo_model.currentIndexChanged.connect(self.update_model) self.statusBar().showMessage('Ready')
def __init__(self, window: 'ElectrumWindow'): WindowModalDialog.__init__(self, window, _('Submarine Swap')) self.window = window self.config = window.config self.lnworker = self.window.wallet.lnworker self.swap_manager = self.lnworker.swap_manager self.network = window.network self.tx = None # for the forward-swap only self.is_reverse = True vbox = QVBoxLayout(self) self.description_label = WWLabel(self.get_description()) self.send_amount_e = BTCAmountEdit(self.window.get_decimal_point) self.recv_amount_e = BTCAmountEdit(self.window.get_decimal_point) self.max_button = EnterButton(_("Max"), self.spend_max) self.max_button.setFixedWidth(100) self.max_button.setCheckable(True) self.send_button = QPushButton('') self.recv_button = QPushButton('') # send_follows is used to know whether the send amount field / receive # amount field should be adjusted after the fee slider was moved self.send_follows = False self.send_amount_e.follows = False self.recv_amount_e.follows = False self.send_button.clicked.connect(self.toggle_direction) self.recv_button.clicked.connect(self.toggle_direction) # textChanged is triggered for both user and automatic action self.send_amount_e.textChanged.connect(self.on_send_edited) self.recv_amount_e.textChanged.connect(self.on_recv_edited) # textEdited is triggered only for user editing of the fields self.send_amount_e.textEdited.connect(self.uncheck_max) self.recv_amount_e.textEdited.connect(self.uncheck_max) fee_slider = FeeSlider(self.window, self.config, self.fee_slider_callback) fee_combo = FeeComboBox(fee_slider) fee_slider.update() self.fee_label = QLabel() self.server_fee_label = QLabel() vbox.addWidget(self.description_label) h = QGridLayout() h.addWidget(QLabel(_('You send')+':'), 1, 0) h.addWidget(self.send_amount_e, 1, 1) h.addWidget(self.send_button, 1, 2) h.addWidget(self.max_button, 1, 3) h.addWidget(QLabel(_('You receive')+':'), 2, 0) h.addWidget(self.recv_amount_e, 2, 1) h.addWidget(self.recv_button, 2, 2) h.addWidget(QLabel(_('Server fee')+':'), 4, 0) h.addWidget(self.server_fee_label, 4, 1) h.addWidget(QLabel(_('Mining fee')+':'), 5, 0) h.addWidget(self.fee_label, 5, 1) h.addWidget(fee_slider, 6, 1) h.addWidget(fee_combo, 6, 2) vbox.addLayout(h) vbox.addStretch(1) self.ok_button = OkButton(self) self.ok_button.setDefault(True) self.ok_button.setEnabled(False) vbox.addLayout(Buttons(CancelButton(self), self.ok_button)) self.update()
class LoadOutputWindow(QMainWindow): def __init__(self, parent=None): super(LoadOutputWindow, self).__init__(parent) self.mywidget = QWidget(self) self.setMinimumSize(700, 150) self.setWindowTitle('Post Export') self.setWindowIcon(QIcon(r".\icon\excel1.ico")) # root = QFileInfo(__file__).absolutePath() # self.setWindowIcon(QIcon(root + "./icon/Text_Edit.ico")) self.job_list = None self.lis_name = None self.job_path = None self.res_path = None self.dll_path = None self.xml_path = None self.njl_path = None self.para_con = None self.othe_con = None self.initUI() self.load_setting() self.center() def initUI(self): self.label1 = QLabel("Post Path") self.label1.setFont(QFont("Calibri", 10)) self.line1 = MyQLineEdit() self.line1.setFont(QFont("Calibri", 10)) self.line1.setPlaceholderText("Pick post path") self.btn1 = QPushButton("...") self.btn1.setFont(QFont("Calibri", 10)) self.btn1.clicked.connect(self.load_post) self.label2 = QLabel("Resutl Path") self.label2.setFont(QFont("Calibri", 10)) self.line2 = MyQLineEdit() self.line2.setFont(QFont("Calibri", 10)) self.line2.setPlaceholderText("Pick result path") self.btn2 = QPushButton("...") self.btn2.setFont(QFont("Calibri", 10)) self.btn2.clicked.connect(self.load_result) self.label3 = QLabel("Export Type") self.label3.setFont(QFont("Calibri", 10)) self.txt1 = QTextBrowser() self.cbx = QComboBox() self.cbx.setFont(QFont("Calibri", 10)) # self.cbx.addItem('All components') self.items = [ 'All Components', 'Blade', 'Pitch Bearing', 'Pitch Lock', 'Pitch System', 'Hub', 'Main Bearing', 'Main Shaft', 'Gearbox_64', 'Gearbox_144', 'Nacelle Acc', 'Yaw Bearing', 'Tower', 'Fatigue', 'Ultimate' ] self.cbx.addItems(self.items) self.cbx.currentTextChanged.connect(self.type_action) self.label4 = QLabel('LC Table') self.label4.setFont(QFont("Calibri", 10)) self.line3 = MyQLineEdit() self.line3.setFont(QFont("Calibri", 10)) # self.line3.setDisabled(True) self.btn3 = QPushButton("...") self.btn3.setFont(QFont("Calibri", 10)) self.btn3.clicked.connect(self.get_excel) # self.btn3.setDisabled(True) self.label5 = QLabel('Excel Name') self.label5.setFont(QFont("Calibri", 10)) self.line4 = MyQLineEdit() self.line4.setFont(QFont("Calibri", 10)) self.line4.setDisabled(True) self.label6 = QLabel('Time Step') self.label6.setFont(QFont("Calibri", 10)) self.line5 = MyQLineEdit() # self.line5.setText('0.05') self.line5.setFont(QFont("Calibri", 10)) # self.line5.setDisabled(True) self.btn4 = QPushButton("Write Excel") self.btn4.setFont(QFont("Calibri", 10)) self.btn4.clicked.connect(self.generate_excel) self.btn5 = QPushButton("Save Setting") self.btn5.setFont(QFont("Calibri", 10)) self.btn5.clicked.connect(self.save_setting) self.grid1 = QGridLayout() # 起始行,起始列,占用行,占用列 self.grid1.addWidget(self.label1, 0, 0, 1, 1) self.grid1.addWidget(self.line1, 0, 1, 1, 5) self.grid1.addWidget(self.btn1, 0, 6, 1, 1) self.grid1.addWidget(self.label2, 1, 0, 1, 1) self.grid1.addWidget(self.line2, 1, 1, 1, 5) self.grid1.addWidget(self.btn2, 1, 6, 1, 1) self.grid1.addWidget(self.label3, 2, 0, 1, 1) self.grid1.addWidget(self.cbx, 2, 1, 1, 5) self.grid1.addWidget(self.label4, 3, 0, 1, 1) self.grid1.addWidget(self.line3, 3, 1, 1, 5) self.grid1.addWidget(self.btn3, 3, 6, 1, 1) self.grid1.addWidget(self.label5, 5, 0, 1, 1) self.grid1.addWidget(self.line4, 5, 1, 1, 5) self.grid1.addWidget(self.label6, 4, 0, 1, 1) self.grid1.addWidget(self.line5, 4, 1, 1, 5) self.grid1.addWidget(self.btn5, 6, 0, 1, 3) self.grid1.addWidget(self.btn4, 6, 4, 1, 3) self.main_layout = QVBoxLayout() self.main_layout.addLayout(self.grid1) self.main_layout.addStretch(1) self.mywidget.setLayout(self.main_layout) self.setCentralWidget(self.mywidget) def keyPressEvent(self, e): if e.key() == QtCore.Qt.Key_Escape: self.close() def save_setting(self): config = configparser.ConfigParser() config.read('config.ini', encoding='utf-8') if not config.has_section('Post Export'): config.add_section('Post Export') config['Post Export'] = { 'Post Path': self.line1.text(), 'Result Path': self.line2.text(), 'LCT': self.line3.text(), 'Time Step': self.line5.text(), 'Xls Name': self.line4.text() } with open("config.ini", 'w') as f: config.write(f) def load_setting(self): config = configparser.ConfigParser() config.read('config.ini', encoding='utf-8') if config.has_section('Post Export'): self.line1.setText(config.get('Post Export', 'Post Path')) self.line2.setText(config.get('Post Export', 'Result Path')) self.line3.setText(config.get('Post Export', 'LCT')) self.line5.setText(config.get('Post Export', 'Time Step')) self.line4.setText(config.get('Post Export', 'Xls Name')) def clear_setting(self): self.line1.setText('') self.line2.setText('') def user_manual(self): os.startfile(os.getcwd() + os.sep + 'user manual\Load Report.docx') def type_action(self): items = [ 'All Components', 'Pitch Bearing', 'Main Bearing', 'Main Shaft', 'Gearbox_64', 'Gearbox_144', 'Yaw Bearing', 'Tower' ] if self.cbx.currentText() not in items: self.line4.setDisabled(False) self.line5.setDisabled(True) self.line3.setDisabled(True) self.btn3.setDisabled(True) else: self.line3.setDisabled(False) self.line4.setDisabled(True) self.line5.setDisabled(False) self.btn3.setDisabled(False) def load_post(self): post_path = QFileDialog.getExistingDirectory(self, "Choose result path", ".") if post_path: self.line1.setText(post_path.replace('/', '\\')) def load_result(self): restult_path = QFileDialog.getExistingDirectory( self, "Choose result path", ".") if restult_path: self.line2.setText(restult_path.replace('/', '\\')) def get_excel(self): excel_path, extension = QFileDialog.getOpenFileName( self, "Choose result path", ".xlsx") if excel_path: self.line3.setText(excel_path.replace('/', '\\')) def generate_excel(self): post_path = self.line1.text() res_path = self.line2.text() xls_path = os.getcwd() + os.sep + 'template' lct_path = self.line3.text() xls_name = self.line4.text() time_step = self.line5.text() if not os.path.isdir(res_path): os.makedirs(res_path) try: if post_path and os.path.isdir( post_path) and res_path and os.path.isdir(res_path): comp_flag = { 'blade': { 'fat': True, 'ult': True }, 'bladeroot': { 'fat': True }, 'hub': { 'fat': True, 'ult': True }, 'gearbox_64': { 'fat': True, 'ult': True }, 'gearbox_144': { 'fat': True, 'ult': True }, 'pitchbearing': { 'fat': True, 'ult': True }, 'yawbearing': { 'fat': True, 'ult': True }, 'mainbearing': { 'fat': True, 'ult': True }, 'mainshaft': { 'fat': True, 'ult': True }, 'tower': { 'fat': True, 'ult': True }, 'nacacc': { 'ult': True }, 'pitchlock': { 'ult': True }, 'pitchsystem': { 'ult': True } } if self.cbx.currentText() not in ['Fatigue', 'Ultimate']: if os.path.isdir( xls_path) and time_step and os.path.isfile( lct_path): comp_list = {} if self.cbx.currentText() == 'All Components': comp_list.update( (k, v) for k, v in comp_flag.items()) elif self.cbx.currentText() == 'Blade': comp_list.update((k, v) for k, v in comp_flag.items() if 'blade' in k) elif self.cbx.currentText() == 'Pitch Bearing': comp_list.update((k, v) for k, v in comp_flag.items() if 'pitchbearing' in k) elif self.cbx.currentText() == 'Pitch Lock': comp_list.update((k, v) for k, v in comp_flag.items() if 'pitchlock' in k) elif self.cbx.currentText() == 'Pitch System': comp_list.update((k, v) for k, v in comp_flag.items() if 'pitchsystem' in k) elif self.cbx.currentText() == 'Hub': comp_list.update((k, v) for k, v in comp_flag.items() if 'hub' in k) elif self.cbx.currentText() == 'Yaw Bearing': comp_list.update((k, v) for k, v in comp_flag.items() if 'yawbearing' in k) elif self.cbx.currentText() == 'Main Bearing': comp_list.update((k, v) for k, v in comp_flag.items() if 'mainbearing' in k) elif self.cbx.currentText() == 'Main Shaft': comp_list.update((k, v) for k, v in comp_flag.items() if 'mainshaft' in k) elif self.cbx.currentText() == 'Gearbox_64': comp_list.update((k, v) for k, v in comp_flag.items() if 'gearbox_64' in k) elif self.cbx.currentText() == 'Gearbox_144': comp_list.update((k, v) for k, v in comp_flag.items() if 'gearbox_144' in k) elif self.cbx.currentText() == 'Nacelle Acc': comp_list.update((k, v) for k, v in comp_flag.items() if 'nacacc' in k) elif self.cbx.currentText() == 'Tower': comp_list.update((k, v) for k, v in comp_flag.items() if 'tower' in k) writeCompLoads(post_path, res_path, xls_path, comp_list, time_step, lct_path) QMessageBox.about(self, 'Window', 'Post export is done!') elif not os.path.isdir(xls_path): QMessageBox.about( self, 'warnning', 'Please make sure the xls template path exist!\n%s' % xls_path) elif not time_step: QMessageBox.about(self, 'warnning', 'Please define time step first!') elif not os.path.isfile(lct_path): QMessageBox.about( self, 'warnning', 'Please choose a load case table first!') elif xls_name: if self.cbx.currentText() == 'Fatigue': try: # txt_path = os.path.join(res_path, xls_name+'.txt') xls_path = os.path.join(res_path, xls_name + '.xlsx') # writeRainflow(post_path, content=('DEL',)).write2singletxt(txt_path) table = openpyxl.Workbook() writeRainflow( post_path, content=('DEL', )).write2singlexls(table) table.save(xls_path) QMessageBox.about(self, 'Window', 'Post export is done!') except Exception as e: QMessageBox.about( self, 'Warnning', 'Error occurs in generating fatigue loads!\n%s' % e) elif self.cbx.currentText() == 'Ultimate': try: excel_path = os.path.join(res_path, xls_name + '.xlsx') table = openpyxl.Workbook() writeUltimate(post_path, table, sheetname='Ultimate', rowstart=1, colstart=1) table.save(excel_path) QMessageBox.about(self, 'Window', 'Post export is done!') except Exception as e: QMessageBox.about( self, 'Warnning', 'Error occurs in generating ultimate loads!\n%s' % e) else: QMessageBox.about(self, 'warnning', 'Please define a excel name first!') elif not post_path: QMessageBox.about(self, 'warnning', 'Please choose a post path first!') elif not os.path.isdir(post_path): QMessageBox.about(self, 'warnning', 'Please make sure the post path is right!') elif not res_path: QMessageBox.about(self, 'warnning', 'Please choose a result path first!') elif not os.path.isdir(res_path): QMessageBox.about( self, 'warnning', 'Please make sure the result path is right!') except Exception as e: QMessageBox.about(self, 'Warnning', 'Error occurs in post export\n%s' % e) def center(self): qr = self.frameGeometry() cp = QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft())
def init_t1_ui(self, tab): ''' Initialise l'onglet 1 @param : onglet 1 ''' self.tab = tab layout = QGridLayout(self) #Combobox prof/salle self.cb_filtre = QComboBox(self) self.cb_filtre.addItems(["Professeur", "Salle"]) self.cb_filtre.currentIndexChanged.connect(self.selectionchange) layout.addWidget(self.cb_filtre, 1, 1, 1, 1) #Combobox pr/salle self.cb_pr_salle = QComboBox(self) self.cb_pr_salle.addItems(self.df_param_pr) layout.addWidget(self.cb_pr_salle, 2, 1, 1, 1) #Textbox période validité self.box_dt_deb = QLineEdit(self) self.box_dt_deb.setPlaceholderText( "Début période validité - ex : 2020-01-01") layout.addWidget(self.box_dt_deb, 2, 2, 1, 1) self.box_dt_fin = QLineEdit(self) self.box_dt_fin.setPlaceholderText( "Fin période validité - ex : 2020-01-07") layout.addWidget(self.box_dt_fin, 2, 3, 1, 1) #Résultat self.result = QTextEdit(self) layout.addWidget(self.result, 4, 1, 5, 3) #Boutton validation self.button = QPushButton("Filtrer", self) layout.addWidget(self.button, 3, 1, 1, 1) self.button.clicked.connect(self.on_click_t1) self.tab.setLayout(layout) self.show()
def initUI(self): self.label1 = QLabel("Post Path") self.label1.setFont(QFont("Calibri", 10)) self.line1 = MyQLineEdit() self.line1.setFont(QFont("Calibri", 10)) self.line1.setPlaceholderText("Pick post path") self.btn1 = QPushButton("...") self.btn1.setFont(QFont("Calibri", 10)) self.btn1.clicked.connect(self.load_post) self.label2 = QLabel("Resutl Path") self.label2.setFont(QFont("Calibri", 10)) self.line2 = MyQLineEdit() self.line2.setFont(QFont("Calibri", 10)) self.line2.setPlaceholderText("Pick result path") self.btn2 = QPushButton("...") self.btn2.setFont(QFont("Calibri", 10)) self.btn2.clicked.connect(self.load_result) self.label3 = QLabel("Export Type") self.label3.setFont(QFont("Calibri", 10)) self.txt1 = QTextBrowser() self.cbx = QComboBox() self.cbx.setFont(QFont("Calibri", 10)) # self.cbx.addItem('All components') self.items = [ 'All Components', 'Blade', 'Pitch Bearing', 'Pitch Lock', 'Pitch System', 'Hub', 'Main Bearing', 'Main Shaft', 'Gearbox_64', 'Gearbox_144', 'Nacelle Acc', 'Yaw Bearing', 'Tower', 'Fatigue', 'Ultimate' ] self.cbx.addItems(self.items) self.cbx.currentTextChanged.connect(self.type_action) self.label4 = QLabel('LC Table') self.label4.setFont(QFont("Calibri", 10)) self.line3 = MyQLineEdit() self.line3.setFont(QFont("Calibri", 10)) # self.line3.setDisabled(True) self.btn3 = QPushButton("...") self.btn3.setFont(QFont("Calibri", 10)) self.btn3.clicked.connect(self.get_excel) # self.btn3.setDisabled(True) self.label5 = QLabel('Excel Name') self.label5.setFont(QFont("Calibri", 10)) self.line4 = MyQLineEdit() self.line4.setFont(QFont("Calibri", 10)) self.line4.setDisabled(True) self.label6 = QLabel('Time Step') self.label6.setFont(QFont("Calibri", 10)) self.line5 = MyQLineEdit() # self.line5.setText('0.05') self.line5.setFont(QFont("Calibri", 10)) # self.line5.setDisabled(True) self.btn4 = QPushButton("Write Excel") self.btn4.setFont(QFont("Calibri", 10)) self.btn4.clicked.connect(self.generate_excel) self.btn5 = QPushButton("Save Setting") self.btn5.setFont(QFont("Calibri", 10)) self.btn5.clicked.connect(self.save_setting) self.grid1 = QGridLayout() # 起始行,起始列,占用行,占用列 self.grid1.addWidget(self.label1, 0, 0, 1, 1) self.grid1.addWidget(self.line1, 0, 1, 1, 5) self.grid1.addWidget(self.btn1, 0, 6, 1, 1) self.grid1.addWidget(self.label2, 1, 0, 1, 1) self.grid1.addWidget(self.line2, 1, 1, 1, 5) self.grid1.addWidget(self.btn2, 1, 6, 1, 1) self.grid1.addWidget(self.label3, 2, 0, 1, 1) self.grid1.addWidget(self.cbx, 2, 1, 1, 5) self.grid1.addWidget(self.label4, 3, 0, 1, 1) self.grid1.addWidget(self.line3, 3, 1, 1, 5) self.grid1.addWidget(self.btn3, 3, 6, 1, 1) self.grid1.addWidget(self.label5, 5, 0, 1, 1) self.grid1.addWidget(self.line4, 5, 1, 1, 5) self.grid1.addWidget(self.label6, 4, 0, 1, 1) self.grid1.addWidget(self.line5, 4, 1, 1, 5) self.grid1.addWidget(self.btn5, 6, 0, 1, 3) self.grid1.addWidget(self.btn4, 6, 4, 1, 3) self.main_layout = QVBoxLayout() self.main_layout.addLayout(self.grid1) self.main_layout.addStretch(1) self.mywidget.setLayout(self.main_layout) self.setCentralWidget(self.mywidget)
def initUI(self): """combo_daq = [] for i in list(range(8)): exec("ch%d" % i) "ch%d"%i=QComboBox(self) "ch%d"%i.addItem("Not_use") #exec("ch%d.addItem('Ge')" % i) #exec("ch%d.addItem('CsI')" % i) #exec("ch%d.addItem('LqS')" % i) for i in list(range(8)): combo_daq[i]=QComboBox combo_daq[i].addItem("Not_use") combo_daq[i].addItem("Ge") combo_daq[i].addItem("CsI") combo_daq[i].addItem("LS") """ combo_daq = QComboBox(self) combo_daq.addItem("kill") combo_daq.addItem("Ge") combo_daq.addItem("CsI") combo_daq.addItem("Ls") combo_beam = QComboBox(self) combo_beam.addItem("30 MeV") combo_beam.addItem("246 MeV") combo_RI = QComboBox(self) combo_RI.addItem("137Cs") combo_RI.addItem("60Co") combo_RI.addItem("22Na") combo_RI.addItem("252Cf") combo_RI.addItem("241AmBe") combo_RI.addItem("Background") event = QLabel("n") time = QLabel("t") source = QLabel("Source") beam = QLabel("Beam") RI = QLabel("RI") event_edit = QLineEdit(self) time_edit = QLineEdit(self) Run = QPushButton("Run", self) Edit = QPushButton("Edit", self) Edit.clicked.connect(self.EditbuttonClicked) Stop = QPushButton("Stop", self) ch = list(range(8)) for i in list(range(8)): ch[i] = QLabel("ch%d" % i, self) layout = QGridLayout() """for i in list(range(8)): layout.addWidget(ch[i], i, 0) """ for i in list(range(8)): layout.addWidget(ch[i], i, 0) """layout.addWidget(ch, 0, 1) layout.addWidget(ch, 1, 1) layout.addWidget(ch, 2, 1) layout.addWidget(ch, 3, 1) layout.addWidget(ch, 4, 1) layout.addWidget(ch, 5, 1) layout.addWidget(ch, 6, 1) layout.addWidget(ch, 7, 1)""" layout.addWidget(combo_daq, 0, 1) layout.addWidget(combo_daq, 1, 1) layout.addWidget(combo_daq, 2, 1) layout.addWidget(combo_daq, 3, 1) layout.addWidget(combo_daq, 4, 1) layout.addWidget(combo_daq, 5, 1) layout.addWidget(combo_daq, 6, 1) layout.addWidget(combo_daq, 7, 1) layout.addWidget(event, 10, 0) layout.addWidget(event_edit, 10, 1) layout.addWidget(time, 11, 0) layout.addWidget(time_edit, 11, 1) layout.addWidget(source, 12, 0) layout.addWidget(beam, 13, 0) layout.addWidget(RI, 13, 1) layout.addWidget(combo_beam, 14, 0) layout.addWidget(combo_RI, 14, 1) layout.addWidget(Run, 15, 4) layout.addWidget(Edit, 15, 2) layout.addWidget(Stop, 15, 0) self.setLayout(layout) self.setGeometry(100, 200, 300, 400) self.show()
def __init__(self, parent=None): super(ResultHandler, self).__init__() self.setWindowTitle('Dash results') self.control_label = QLabel() self.rendered_label = QLabel() self.diff_label = QLabel() self.mask_label = QLabel() self.new_mask_label = QLabel() self.scrollArea = QScrollArea() self.widget = QWidget() self.test_name_label = QLabel() grid = QGridLayout() grid.addWidget(self.test_name_label, 0, 0) grid.addWidget(QLabel('Control'), 1, 0) grid.addWidget(QLabel('Rendered'), 1, 1) grid.addWidget(QLabel('Difference'), 1, 2) grid.addWidget(self.control_label, 2, 0) grid.addWidget(self.rendered_label, 2, 1) grid.addWidget(self.diff_label, 2, 2) grid.addWidget(QLabel('Current Mask'), 3, 0) grid.addWidget(QLabel('New Mask'), 3, 1) grid.addWidget(self.mask_label, 4, 0) grid.addWidget(self.new_mask_label, 4, 1) self.widget.setLayout(grid) self.scrollArea.setWidget(self.widget) v_layout = QVBoxLayout() v_layout.addWidget(self.scrollArea, 1) next_image_button = QPushButton() next_image_button.setText('Skip') next_image_button.pressed.connect(self.load_next) self.overload_spin = QDoubleSpinBox() self.overload_spin.setMinimum(1) self.overload_spin.setMaximum(255) self.overload_spin.setValue(1) self.overload_spin.valueChanged.connect( lambda: save_mask_button.setEnabled(False)) preview_mask_button = QPushButton() preview_mask_button.setText('Preview New Mask') preview_mask_button.pressed.connect(self.preview_mask) preview_mask_button.pressed.connect( lambda: save_mask_button.setEnabled(True)) save_mask_button = QPushButton() save_mask_button.setText('Save New Mask') save_mask_button.pressed.connect(self.save_mask) button_layout = QHBoxLayout() button_layout.addWidget(next_image_button) button_layout.addWidget(QLabel('Mask diff multiplier:')) button_layout.addWidget(self.overload_spin) button_layout.addWidget(preview_mask_button) button_layout.addWidget(save_mask_button) button_layout.addStretch() v_layout.addLayout(button_layout) self.setLayout(v_layout)
def __setup_ui__(self): self.setObjectName(DashboardMainWindowStyles.main_page_style[0]) self.setWindowModality(Qt.ApplicationModal) self.setContextMenuPolicy(Qt.NoContextMenu) self.setAcceptDrops(False) self.setAutoFillBackground(False) self.setDocumentMode(False) self.setDockNestingEnabled(False) self.setMouseTracking(True) self.central_widget = QWidget(self) self.central_widget.setStyleSheet(DashboardMainWindowStyles.central_widget_style) # Add Central Layout self.central_vlayout = QVBoxLayout(self.central_widget) self.central_vlayout.setContentsMargins(0, 0, 0, 0) self.central_vlayout.setObjectName("central_vlayout") # Add Containers self.containers = QFrame(self.central_widget) self.containers.setObjectName(DashboardMainWindowStyles.main_window_containers_style[0]) self.containers.setStyleSheet(DashboardMainWindowStyles.main_window_containers_style[1]) self.containers.setFrameShape(QFrame.NoFrame) self.containers.setFrameShadow(QFrame.Plain) self.containers.setLineWidth(0) # Add Containers Layout self.containers_gridlayout = QGridLayout(self.containers) self.containers_gridlayout.setContentsMargins(0, 0, 0, 0) self.containers_gridlayout.setSpacing(0) self.containers_gridlayout.setObjectName("containers_gridlayout") # Add Scroll Layout self.navigation_scroll_layout = QScrollArea(self.containers) self.navigation_scroll_layout.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.navigation_scroll_layout.setObjectName(DashboardMainWindowStyles.navigation_scroll_layout_style[0]) self.navigation_scroll_layout.setStyleSheet(DashboardMainWindowStyles.navigation_scroll_layout_style[1]) self.navigation_scroll_layout.setWidgetResizable(True) self.navigation_scroll_layout.setMinimumSize(QSize(71, 0)) self.navigation_scroll_layout.setMaximumSize(QSize(71, 16777215)) # add contents self.navigation_scroll_layout_contents = QWidget() self.navigation_scroll_layout_contents.setGeometry(QRect(0, 0, 71, self.height())) self.navigation_scroll_layout_contents.setObjectName("scroll_area_contents_page_containers") # َAdd navigation_layout self.navigation_grid_layout = QGridLayout(self.navigation_scroll_layout_contents) self.navigation_grid_layout.setContentsMargins(0, 0, 0, 0) self.navigation_grid_layout.setVerticalSpacing(0) self.navigation_grid_layout.setObjectName("navigation_grid_layout") # Add Navigation self.navigation_menu = QFrame(self.navigation_scroll_layout_contents) self.navigation_menu.setObjectName(DashboardMainWindowStyles.navigation_menu_style[0]) self.navigation_menu.setStyleSheet(DashboardMainWindowStyles.navigation_menu_style[1]) self.navigation_menu.setMaximumSize(QSize(71, 16777215)) self.navigation_menu.setFrameShape(QFrame.StyledPanel) self.navigation_menu.setFrameShadow(QFrame.Raised) # set Media Screen self.__media_screen__() # Add MainFrame self.main_frame = QFrame(self.containers) size_policy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth(self.main_frame.sizePolicy().hasHeightForWidth()) self.main_frame.setSizePolicy(size_policy) self.main_frame.setObjectName("main_frame") # Add MainFrameLayout self.main_frame_gridLayout = QGridLayout(self.main_frame) self.main_frame_gridLayout.setContentsMargins(8, 8, 8, 8) self.main_frame_gridLayout.setSpacing(0) self.main_frame_gridLayout.setObjectName("gridLayout") # Add pic_main_logo self.pic_main_logo = QLabel(self.navigation_menu) self.pic_main_logo.setGeometry(QRect(0, 35, 71, 71)) self.pic_main_logo.setAlignment(Qt.AlignCenter) self.pic_main_logo.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/kodiak_icon.svg")) self.pic_main_logo.setObjectName("pic_main_logo") # Add LblTime self.lbl_time = QLabel(self.navigation_menu) self.lbl_time.setGeometry(QRect(0, 120, 69, 20)) self.lbl_time.setObjectName(DashboardMainWindowStyles.lbl_time_style[0]) self.lbl_time.setStyleSheet(DashboardMainWindowStyles.lbl_time_style[1]) self.lbl_time.setAlignment(Qt.AlignCenter) # Add lblDate self.lbl_date = QLabel(self.navigation_menu) self.lbl_date.setGeometry(QRect(0, 140, 71, 21)) self.lbl_date.setObjectName(DashboardMainWindowStyles.lbl_date_style[0]) self.lbl_date.setStyleSheet(DashboardMainWindowStyles.lbl_date_style[1]) self.lbl_date.setAlignment(Qt.AlignCenter) self.navigation_item_vlayout = QWidget(self.navigation_menu) self.navigation_item_vlayout.setGeometry(QRect(0, 220, 64, 431)) self.navigation_item_vlayout.setObjectName("navigation_item_vlayout") # set li_hacktor_logo self.li_hacktor = QLabel(self.navigation_menu) self.li_hacktor.setAccessibleName("hacktor_logo") is_extra_screen, extra_screen_width, extra_screen_height = MediaScreen().is_extra_large() if is_extra_screen: if extra_screen_height <= 800: self.li_hacktor.hide() else: self.li_hacktor.setGeometry(QRect(25, self.height() - 80, 22, 33)) else: if extra_screen_height > 800: self.li_hacktor.setGeometry(QRect(25, self.height() - 80, 22, 33)) else: if extra_screen_height <= 600: self.li_hacktor.hide() else: self.li_hacktor.setGeometry(QRect(25, self.height(), 22, 33)) self.li_hacktor.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/hacktor_logo.svg")) self.li_hacktor.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.page_containers = QFrame(self.main_frame) self.page_containers.setFrameShape(QFrame.StyledPanel) self.page_containers.setFrameShadow(QFrame.Raised) self.page_containers.setObjectName("center_page_maker") self.page_containers.setMinimumSize(self.width() - 111, self.height() - 111) self.main_frame_gridLayout.addWidget(self.page_containers, 1, 0, 1, 4) self.page_containers_grid_layout = QGridLayout(self.page_containers) self.page_containers_grid_layout.setObjectName("page_containers_gridLayout") from ...components.menu_containers.menu_containers import MenuContainers self.menu = MenuContainers( self.page_containers_grid_layout, gui_concentrate_handler=self.gui_concentrate_handler ) self.menu.setup_ui( navigation_item_vlayout=self.navigation_item_vlayout, containers=self.containers, page_containers=self.page_containers ) from ...components.top_navigation_bar_containers.top_navigation_bar_containers import TopNavigationBarContainers TopNavigationBarContainers( gui_concentrate_handler=self.gui_concentrate_handler ).setup_ui(containers=self.main_frame, main_gridLayout=self.main_frame_gridLayout) main_icon = QIcon() main_icon.addPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/main_logo.ico")) self.setWindowIcon(main_icon) self.setAutoFillBackground(False) self.setStyleSheet(DashboardMainWindowStyles.main_page_style[1]) self.setDocumentMode(False) self.setDockNestingEnabled(False) self.navigation_grid_layout.addWidget(self.navigation_menu, 0, 0, 1, 1) self.containers_gridlayout.addWidget(self.navigation_scroll_layout, 2, 2, 1, 1) self.navigation_scroll_layout.setWidget(self.navigation_scroll_layout_contents) # self.central_widget = QWidget(self) # self.central_widget.setStyleSheet(DashboardMainWindowStyles.central_widget_style) self.central_vlayout.addWidget(self.containers) self.containers_gridlayout.addWidget(self.main_frame, 2, 1, 1, 1) self.setCentralWidget(self.central_widget) self.__retranslateUi__()
def init_t2_ui(self, tab): ''' Initialise l'onglet 2 @param : onglet 2 ''' self.tab = tab layout = QGridLayout(self) #Combobox jour self.cb_jour = QComboBox(self) self.cb_jour.addItems(self.df_jour) layout.addWidget(self.cb_jour, 2, 1, 1, 1) #Textbox période validité self.box_dt_deb_t2 = QLineEdit(self) self.box_dt_deb_t2.setPlaceholderText( "Début période validité - ex : 2020-01-01") layout.addWidget(self.box_dt_deb_t2, 2, 2, 1, 1) self.box_dt_fin_t2 = QLineEdit(self) self.box_dt_fin_t2.setPlaceholderText( "Fin période validité - ex : 2020-01-07") layout.addWidget(self.box_dt_fin_t2, 2, 3, 1, 1) #Textbox créneau self.box_cren_deb = QLineEdit(self) self.box_cren_deb.setPlaceholderText("Début du créneau - ex : 20:00") layout.addWidget(self.box_cren_deb, 3, 2, 1, 1) self.box_cren_fin = QLineEdit(self) self.box_cren_fin.setPlaceholderText("Fin du créneau - ex : 21:00") layout.addWidget(self.box_cren_fin, 3, 3, 1, 1) #Affichage résultat self.result_t2 = QTextEdit(self) layout.addWidget(self.result_t2, 5, 1, 4, 3) #Boutton validation self.button = QPushButton("Filtrer", self) layout.addWidget(self.button, 4, 1, 1, 1) self.button.clicked.connect(self.on_click_t2) self.tab.setLayout(layout) self.show()
def __init__(self, parent=None): super(QueryPage, self).__init__(parent) packagesGroup = QGroupBox("Look for packages") nameLabel = QLabel("Name:") nameEdit = QLineEdit() dateLabel = QLabel("Released after:") dateEdit = QDateTimeEdit(QDate.currentDate()) releasesCheckBox = QCheckBox("Releases") upgradesCheckBox = QCheckBox("Upgrades") hitsSpinBox = QSpinBox() hitsSpinBox.setPrefix("Return up to ") hitsSpinBox.setSuffix(" results") hitsSpinBox.setSpecialValueText("Return only the first result") hitsSpinBox.setMinimum(1) hitsSpinBox.setMaximum(100) hitsSpinBox.setSingleStep(10) startQueryButton = QPushButton("Start query") packagesLayout = QGridLayout() packagesLayout.addWidget(nameLabel, 0, 0) packagesLayout.addWidget(nameEdit, 0, 1) packagesLayout.addWidget(dateLabel, 1, 0) packagesLayout.addWidget(dateEdit, 1, 1) packagesLayout.addWidget(releasesCheckBox, 2, 0) packagesLayout.addWidget(upgradesCheckBox, 3, 0) packagesLayout.addWidget(hitsSpinBox, 4, 0, 1, 2) packagesGroup.setLayout(packagesLayout) mainLayout = QVBoxLayout() mainLayout.addWidget(packagesGroup) mainLayout.addSpacing(12) mainLayout.addWidget(startQueryButton) mainLayout.addStretch(1) self.setLayout(mainLayout)
def __init__(self): super().__init__() grid = QGridLayout() self.setLayout(grid) N_box = QHBoxLayout() self.N = QTextEdit() self.N.setFixedHeight(30) N_box.addStretch() N_box.addWidget(QLabel("N=", self)) N_box.addWidget(self.N) grid.addLayout(N_box, 0, 0) phi_N_box = QHBoxLayout() self.phi_N = QTextEdit() self.phi_N.setFixedHeight(30) phi_N_box.addStretch() phi_N_box.addWidget(QLabel("phi(N)=", self)) phi_N_box.addWidget(self.phi_N) grid.addLayout(phi_N_box, 0, 1) e_box = QHBoxLayout() self.e = QTextEdit() self.e.setFixedHeight(30) e_box.addStretch() e_box.addWidget(QLabel("e=", self)) e_box.addWidget(self.e) grid.addLayout(e_box, 1, 0) d_box = QHBoxLayout() self.d = QTextEdit() self.d.setFixedHeight(30) d_box.addStretch() d_box.addWidget(QLabel("d=", self)) d_box.addWidget(self.d) grid.addLayout(d_box, 1, 1) self.message = QTextEdit() self.message.setPlainText("message") grid.addWidget(self.message, 2, 0) self.result_text = QTextEdit() grid.addWidget(self.result_text, 2, 1) hbox = QHBoxLayout() encode_btn = QPushButton("encode") decode_btn = QPushButton("decode") generate_btn = QPushButton("generate") encode_btn.clicked.connect(self.on_encode_clicked) decode_btn.clicked.connect(self.on_decode_clicked) generate_btn.clicked.connect(self.on_generate_clicked) hbox.addStretch() hbox.addWidget(generate_btn) hbox.addWidget(decode_btn) hbox.addWidget(encode_btn) grid.addLayout(hbox, 3, 0, 1, 3) self.show()
def initGrid(self): if self.data is None: return # This needs to be generalized to handle multiple input and output types self.imageLabels = [] self.actionRows = [] self.actionLabels = [] for i in range(self.gridWidth): self.imageLabels.append(QLabel(self)) ot = self.data.outputTypes() for output in ot: oneRow = [] for i in range(self.gridWidth): labels = output[ "categories"] if "categories" in output else None cb = self.makeActionComboBox(atype=output["type"], labels=labels) oneRow.append(cb) self.actionLabels.append(cb) self.actionRows.append(oneRow) grid = QGridLayout() self.grid = grid grid.setSpacing(10) otypes = self.data.outputTypes() itypes = self.data.inputTypes() row = 1 grid.addWidget(QLabel("Index"), row, 0) self.indexes = [] for i in range(self.gridWidth): idx = QLabel(self) idx.setAlignment(Qt.AlignCenter) self.indexes.append(idx) for i in range(len(self.indexes)): grid.addWidget(self.indexes[i], row, i + 1) row += 1 grid.addWidget(QLabel(itypes[0]["name"]), row, 0) for i in range(len(self.imageLabels)): grid.addWidget(self.imageLabels[i], row, i + 1) for lr in range(len(self.actionRows)): arow = self.actionRows[lr] row += 1 grid.addWidget(QLabel(otypes[lr]["name"]), row, 0) for i in range(len(arow)): grid.addWidget(arow[i], row, i + 1) vlay = QVBoxLayout() vlay.addLayout(grid) row += 1 sld = QSlider(Qt.Horizontal, self) self.slider = sld sld.setFocusPolicy(Qt.NoFocus) sld.valueChanged[int].connect(self.changeValue) #grid.addWidget(sld, row, 0, 1, self.gridWidth+1) vlay.addWidget(sld) self.setCentralWidget(QWidget(self)) self.centralWidget().setLayout(vlay) if self.metaDock is None: self.metaDock = QDockWidget("Drive Info", self) self.addDockWidget(Qt.LeftDockWidgetArea, self.metaDock) self.metaText = QTextEdit(self) self.metaText.setEnabled(False) self.metaText.setReadOnly(True) #self.metaText.setMinimumWidth( 200.0 ) self.metaDock.setWidget(self.metaText) self.viewMenu.addAction(self.metaDock.toggleViewAction()) self.metaText.setText(self.data.metaString()) if self.statsDock is None: self.statsDock = QDockWidget("Action Stats", self) self.addDockWidget(Qt.LeftDockWidgetArea, self.statsDock) self.statsTable = QTableWidget(self) self.statsTable.setEnabled(False) self.statsTable.horizontalHeader().hide() self.statsTable.verticalHeader().setDefaultSectionSize(18) self.statsTable.verticalHeader().hide() self.statsTable.setShowGrid(False) self.statsDock.setWidget(self.statsTable) self.viewMenu.addAction(self.statsDock.toggleViewAction()) self.updateStats()
class DashboardMainWindow(QMainWindow): def __init__(self, gui_concentrate_handler, parent=None): super(DashboardMainWindow, self).__init__(parent) self.gui_concentrate_handler = gui_concentrate_handler self.__setup_ui__() def __setup_ui__(self): self.setObjectName(DashboardMainWindowStyles.main_page_style[0]) self.setWindowModality(Qt.ApplicationModal) self.setContextMenuPolicy(Qt.NoContextMenu) self.setAcceptDrops(False) self.setAutoFillBackground(False) self.setDocumentMode(False) self.setDockNestingEnabled(False) self.setMouseTracking(True) self.central_widget = QWidget(self) self.central_widget.setStyleSheet(DashboardMainWindowStyles.central_widget_style) # Add Central Layout self.central_vlayout = QVBoxLayout(self.central_widget) self.central_vlayout.setContentsMargins(0, 0, 0, 0) self.central_vlayout.setObjectName("central_vlayout") # Add Containers self.containers = QFrame(self.central_widget) self.containers.setObjectName(DashboardMainWindowStyles.main_window_containers_style[0]) self.containers.setStyleSheet(DashboardMainWindowStyles.main_window_containers_style[1]) self.containers.setFrameShape(QFrame.NoFrame) self.containers.setFrameShadow(QFrame.Plain) self.containers.setLineWidth(0) # Add Containers Layout self.containers_gridlayout = QGridLayout(self.containers) self.containers_gridlayout.setContentsMargins(0, 0, 0, 0) self.containers_gridlayout.setSpacing(0) self.containers_gridlayout.setObjectName("containers_gridlayout") # Add Scroll Layout self.navigation_scroll_layout = QScrollArea(self.containers) self.navigation_scroll_layout.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.navigation_scroll_layout.setObjectName(DashboardMainWindowStyles.navigation_scroll_layout_style[0]) self.navigation_scroll_layout.setStyleSheet(DashboardMainWindowStyles.navigation_scroll_layout_style[1]) self.navigation_scroll_layout.setWidgetResizable(True) self.navigation_scroll_layout.setMinimumSize(QSize(71, 0)) self.navigation_scroll_layout.setMaximumSize(QSize(71, 16777215)) # add contents self.navigation_scroll_layout_contents = QWidget() self.navigation_scroll_layout_contents.setGeometry(QRect(0, 0, 71, self.height())) self.navigation_scroll_layout_contents.setObjectName("scroll_area_contents_page_containers") # َAdd navigation_layout self.navigation_grid_layout = QGridLayout(self.navigation_scroll_layout_contents) self.navigation_grid_layout.setContentsMargins(0, 0, 0, 0) self.navigation_grid_layout.setVerticalSpacing(0) self.navigation_grid_layout.setObjectName("navigation_grid_layout") # Add Navigation self.navigation_menu = QFrame(self.navigation_scroll_layout_contents) self.navigation_menu.setObjectName(DashboardMainWindowStyles.navigation_menu_style[0]) self.navigation_menu.setStyleSheet(DashboardMainWindowStyles.navigation_menu_style[1]) self.navigation_menu.setMaximumSize(QSize(71, 16777215)) self.navigation_menu.setFrameShape(QFrame.StyledPanel) self.navigation_menu.setFrameShadow(QFrame.Raised) # set Media Screen self.__media_screen__() # Add MainFrame self.main_frame = QFrame(self.containers) size_policy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth(self.main_frame.sizePolicy().hasHeightForWidth()) self.main_frame.setSizePolicy(size_policy) self.main_frame.setObjectName("main_frame") # Add MainFrameLayout self.main_frame_gridLayout = QGridLayout(self.main_frame) self.main_frame_gridLayout.setContentsMargins(8, 8, 8, 8) self.main_frame_gridLayout.setSpacing(0) self.main_frame_gridLayout.setObjectName("gridLayout") # Add pic_main_logo self.pic_main_logo = QLabel(self.navigation_menu) self.pic_main_logo.setGeometry(QRect(0, 35, 71, 71)) self.pic_main_logo.setAlignment(Qt.AlignCenter) self.pic_main_logo.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/kodiak_icon.svg")) self.pic_main_logo.setObjectName("pic_main_logo") # Add LblTime self.lbl_time = QLabel(self.navigation_menu) self.lbl_time.setGeometry(QRect(0, 120, 69, 20)) self.lbl_time.setObjectName(DashboardMainWindowStyles.lbl_time_style[0]) self.lbl_time.setStyleSheet(DashboardMainWindowStyles.lbl_time_style[1]) self.lbl_time.setAlignment(Qt.AlignCenter) # Add lblDate self.lbl_date = QLabel(self.navigation_menu) self.lbl_date.setGeometry(QRect(0, 140, 71, 21)) self.lbl_date.setObjectName(DashboardMainWindowStyles.lbl_date_style[0]) self.lbl_date.setStyleSheet(DashboardMainWindowStyles.lbl_date_style[1]) self.lbl_date.setAlignment(Qt.AlignCenter) self.navigation_item_vlayout = QWidget(self.navigation_menu) self.navigation_item_vlayout.setGeometry(QRect(0, 220, 64, 431)) self.navigation_item_vlayout.setObjectName("navigation_item_vlayout") # set li_hacktor_logo self.li_hacktor = QLabel(self.navigation_menu) self.li_hacktor.setAccessibleName("hacktor_logo") is_extra_screen, extra_screen_width, extra_screen_height = MediaScreen().is_extra_large() if is_extra_screen: if extra_screen_height <= 800: self.li_hacktor.hide() else: self.li_hacktor.setGeometry(QRect(25, self.height() - 80, 22, 33)) else: if extra_screen_height > 800: self.li_hacktor.setGeometry(QRect(25, self.height() - 80, 22, 33)) else: if extra_screen_height <= 600: self.li_hacktor.hide() else: self.li_hacktor.setGeometry(QRect(25, self.height(), 22, 33)) self.li_hacktor.setPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/hacktor_logo.svg")) self.li_hacktor.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.page_containers = QFrame(self.main_frame) self.page_containers.setFrameShape(QFrame.StyledPanel) self.page_containers.setFrameShadow(QFrame.Raised) self.page_containers.setObjectName("center_page_maker") self.page_containers.setMinimumSize(self.width() - 111, self.height() - 111) self.main_frame_gridLayout.addWidget(self.page_containers, 1, 0, 1, 4) self.page_containers_grid_layout = QGridLayout(self.page_containers) self.page_containers_grid_layout.setObjectName("page_containers_gridLayout") from ...components.menu_containers.menu_containers import MenuContainers self.menu = MenuContainers( self.page_containers_grid_layout, gui_concentrate_handler=self.gui_concentrate_handler ) self.menu.setup_ui( navigation_item_vlayout=self.navigation_item_vlayout, containers=self.containers, page_containers=self.page_containers ) from ...components.top_navigation_bar_containers.top_navigation_bar_containers import TopNavigationBarContainers TopNavigationBarContainers( gui_concentrate_handler=self.gui_concentrate_handler ).setup_ui(containers=self.main_frame, main_gridLayout=self.main_frame_gridLayout) main_icon = QIcon() main_icon.addPixmap(QPixmap(AppPaths.GUI_ASSETS_ICONS_PATH + "/main_window/main_logo.ico")) self.setWindowIcon(main_icon) self.setAutoFillBackground(False) self.setStyleSheet(DashboardMainWindowStyles.main_page_style[1]) self.setDocumentMode(False) self.setDockNestingEnabled(False) self.navigation_grid_layout.addWidget(self.navigation_menu, 0, 0, 1, 1) self.containers_gridlayout.addWidget(self.navigation_scroll_layout, 2, 2, 1, 1) self.navigation_scroll_layout.setWidget(self.navigation_scroll_layout_contents) # self.central_widget = QWidget(self) # self.central_widget.setStyleSheet(DashboardMainWindowStyles.central_widget_style) self.central_vlayout.addWidget(self.containers) self.containers_gridlayout.addWidget(self.main_frame, 2, 1, 1, 1) self.setCentralWidget(self.central_widget) self.__retranslateUi__() def __retranslateUi__(self): """ this method for retranslate data in UI """ _translate = QCoreApplication.translate self.setWindowTitle(_translate("MainWindow", "Kodiak")) self.lbl_time.setText("04:20") self.lbl_date.setText("2020/15/19") def __media_screen__(self): """ this is private method for set a standard size window for Your monitor , Tablet or ... """ is_small_screen, small_screen_width, small_screen_height = MediaScreen().is_small() is_medium_screen, medium_screen_width, medium_screen_height = MediaScreen().is_medium() is_large_screen, large_screen_width, large_screen_height = MediaScreen().is_large() is_extra_large_screen, extra_large_screen_width, extra_large_screen_height = MediaScreen().is_extra_large() if is_extra_large_screen: if extra_large_screen_height <= 900: self.setMinimumSize(QSize(extra_large_screen_width - (extra_large_screen_width / 4), extra_large_screen_height - (extra_large_screen_height / 4) + 100)) else: self.setMinimumSize(QSize(extra_large_screen_width - (extra_large_screen_width / 4), extra_large_screen_height - (extra_large_screen_height / 6) + 50)) self.navigation_menu.setMinimumSize(QSize(71, 700)) elif is_large_screen: self.setMinimumSize(QSize(large_screen_width - 200, large_screen_height - 90)) self.navigation_menu.setMinimumSize(QSize(71, 550)) elif is_medium_screen: self.setMinimumSize(QSize(medium_screen_width - 100, medium_screen_height - 100)) self.navigation_menu.setMinimumSize(QSize(71, 700)) elif is_small_screen: self.setMinimumSize(QSize(small_screen_width - 150, small_screen_width - 250)) self.navigation_menu.setMinimumSize(QSize(71, 700)) else: # any thing else self.setMinimumSize(QSize(1150, 800)) self.navigation_menu.setMinimumSize(QSize(71, 700)) # Delete From Memory del is_small_screen, is_medium_screen, is_large_screen del small_screen_width, medium_screen_width, large_screen_width del small_screen_height, medium_screen_height, large_screen_height
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # os.chdir('./')# Set directory to current folder. self.setFont(QFont("Arial")) self.resize(265,130) self.setWindowTitle("FilterSliderWidget") self.layout = QGridLayout(self) #************************************************************************************************************************************** #-------------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------GUI for Filter movement---------------------------------------------------- #-------------------------------------------------------------------------------------------------------------------------------------- #************************************************************************************************************************************** ControlContainer = StylishQT.roundQGroupBox(title = 'Filter Control', background_color = 'azure') ControlContainerLayout = QGridLayout() ND_filtercontrolContainer = StylishQT.roundQGroupBox(title = '2P ND', background_color = 'azure') self.filtercontrolLayout = QGridLayout() self.filtercontrolLayout.setSpacing(2) self.FilterButtongroup_1 = QButtonGroup(self) self.filter1_pos0 = QPushButton('0') self.filter1_pos0.setCheckable(True) self.FilterButtongroup_1.addButton(self.filter1_pos0) self.filtercontrolLayout.addWidget(self.filter1_pos0, 0, 1) # self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0)) self.filter1_pos1 = QPushButton('1') self.filter1_pos1.setCheckable(True) self.FilterButtongroup_1.addButton(self.filter1_pos1) self.filtercontrolLayout.addWidget(self.filter1_pos1, 0, 2) # self.filter1_pos1.clicked.connect(lambda: self.filter_move_towards("COM9", 1)) self.filter1_pos2 = QPushButton('2') self.filter1_pos2.setCheckable(True) self.FilterButtongroup_1.addButton(self.filter1_pos2) self.filtercontrolLayout.addWidget(self.filter1_pos2, 0, 3) # self.filter1_pos2.clicked.connect(lambda: self.filter_move_towards("COM9", 2)) self.filter1_pos3 = QPushButton('3') self.filter1_pos3.setCheckable(True) self.FilterButtongroup_1.addButton(self.filter1_pos3) self.filtercontrolLayout.addWidget(self.filter1_pos3, 0, 4) # self.filter1_pos3.clicked.connect(lambda: self.filter_move_towards("COM9", 3)) self.FilterButtongroup_1.setExclusive(True) self.FilterButtongroup_1.buttonClicked[int].connect(self.DecodeFilterMove) self.FilterButtongroup_2 = QButtonGroup(self) self.filter2_pos0 = QPushButton('0') self.filter2_pos0.setCheckable(True) self.FilterButtongroup_2.addButton(self.filter2_pos0) self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 1) # self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0)) self.filter2_pos1 = QPushButton('0.1') self.filter2_pos1.setCheckable(True) self.FilterButtongroup_2.addButton(self.filter2_pos1) self.filtercontrolLayout.addWidget(self.filter2_pos1, 1, 2) # self.filter1_pos1.clicked.connect(lambda: self.filter_move_towards("COM9", 1)) self.filter2_pos2 = QPushButton('0.3') self.filter2_pos2.setCheckable(True) self.FilterButtongroup_2.addButton(self.filter2_pos2) self.filtercontrolLayout.addWidget(self.filter2_pos2, 1, 3) # self.filter1_pos2.clicked.connect(lambda: self.filter_move_towards("COM9", 2)) self.filter2_pos3 = QPushButton('0.5') self.filter2_pos3.setCheckable(True) self.FilterButtongroup_2.addButton(self.filter2_pos3) self.filtercontrolLayout.addWidget(self.filter2_pos3, 1, 4) # self.filter1_pos3.clicked.connect(lambda: self.filter_move_towards("COM9", 3)) self.FilterButtongroup_2.setExclusive(True) self.FilterButtongroup_2.buttonClicked[int].connect(self.DecodeFilterMove) # # self.filtercontrolLayout.addWidget(QLabel('Filter-1 pos: '), 0, 0) # # self.filtercontrolLayout.addWidget(QLabel('Filter-2 pos: '), 1, 0) # bGBackupFromIntExt_1 = QButtonGroup(self) # # self.filter2_pos0 = QPushButton('0') # self.filter2_pos0.setCheckable(True) # bGBackupFromIntExt_1.addButton(self.filter2_pos0) # self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 1) # self.filter2_pos0.clicked.connect(lambda: self.filter_move_towards("COM7", 0)) # # self.filter2_pos1 = QPushButton('0.1') # self.filter2_pos1.setCheckable(True) # bGBackupFromIntExt_1.addButton(self.filter2_pos1) # self.filtercontrolLayout.addWidget(self.filter2_pos1, 1, 2) # self.filter2_pos1.clicked.connect(lambda: self.filter_move_towards("COM7", 1)) # # self.filter2_pos2 = QPushButton('0.3') # self.filter2_pos2.setCheckable(True) # bGBackupFromIntExt_1.addButton(self.filter2_pos2) # self.filtercontrolLayout.addWidget(self.filter2_pos2, 1, 3) # self.filter2_pos2.clicked.connect(lambda: self.filter_move_towards("COM7", 2)) # # self.filter2_pos3 = QPushButton('0.5') # self.filter2_pos3.setCheckable(True) # bGBackupFromIntExt_1.addButton(self.filter2_pos3) # self.filtercontrolLayout.addWidget(self.filter2_pos3, 1, 4) # self.filter2_pos3.clicked.connect(lambda: self.filter_move_towards("COM7", 3)) #---------------------------------------------------------------------- # self.filter1_pos0 = QDial() # self.filter1_pos0.setMinimum(0) # self.filter1_pos0.setMaximum(3) # self.filter1_pos0.setValue(0) # self.filter1_pos0.setNotchesVisible(True) # self.filter1_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM9", self.filter1_pos0.value())) # self.filter2_pos0 = QDial() # self.filter2_pos0.setMinimum(0) # self.filter2_pos0.setMaximum(3) # self.filter2_pos0.setValue(0) # self.filter2_pos0.setNotchesVisible(True) # self.filter2_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM7", self.filter2_pos0.value())) # # self.filter3_pos0 = QDial() # self.filter3_pos0.setMinimum(0) # self.filter3_pos0.setMaximum(3) # self.filter3_pos0.setValue(0) # self.filter3_pos0.setNotchesVisible(True) # self.filter3_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM15", self.filter3_pos0.value())) #---------------------------------------------------------------------- # self.filter1_pos0 = QSlider(Qt.Horizontal) # self.filter1_pos0.setMinimum(0) # self.filter1_pos0.setMaximum(3) # self.filter1_pos0.setTickPosition(QSlider.TicksBothSides) # self.filter1_pos0.setTickInterval(1) # self.filter1_pos0.setSingleStep(1) # self.filter1_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM9", self.filter1_pos0.value())) # # self.filter2_pos0 = QSlider(Qt.Horizontal) # self.filter2_pos0.setMinimum(0) # self.filter2_pos0.setMaximum(3) # self.filter2_pos0.setTickPosition(QSlider.TicksBothSides) # self.filter2_pos0.setTickInterval(1) # self.filter2_pos0.setSingleStep(1) # self.filter2_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM7", self.filter2_pos0.value())) # # self.filter3_pos0 = QSlider(Qt.Vertical) # self.filter3_pos0.setMinimum(0) # self.filter3_pos0.setMaximum(1) # self.filter3_pos0.setTickPosition(QSlider.TicksBothSides) # self.filter3_pos0.setTickInterval(1) # self.filter3_pos0.setSingleStep(1) # self.filter3_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM15", self.filter3_pos0.value())) # self.filtercontrolLayout.addWidget(QLabel('ND 0 | 1 | 2 | 3'), 0, 1) # self.filtercontrolLayout.addWidget(self.filter1_pos0, 1, 1) # self.filtercontrolLayout.addWidget(QLabel('ND 0 | 0.1 | 0.3 | 0.5'), 0, 2) # self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 2) # self.filtercontrolLayout.addWidget(self.filter3_pos0, 1, 3) # oImage = QImage('./Icons/filtersliderpanel.png') ## sImage = oImage.scaled(QSize(292,208)) # resize Image to widgets size # palette = QPalette() # palette.setBrush(QPalette.Window, QBrush(oImage)) EM_filtercontrolContainer = StylishQT.roundQGroupBox(title = 'Emission', background_color = 'honeydew') self.EM_filtercontrolContainerLayout = QGridLayout() self.EM_filtercontrolContainerLayout.setSpacing(2) self.FilterButtongroup_3 = QButtonGroup(self) self.filter3_pos0 = QPushButton('Arch') self.filter3_pos0.setCheckable(True) self.FilterButtongroup_3.addButton(self.filter3_pos0) self.EM_filtercontrolContainerLayout.addWidget(self.filter3_pos0, 1, 0) # self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0)) self.filter3_pos1 = QPushButton('Citrine') self.filter3_pos1.setCheckable(True) self.FilterButtongroup_3.addButton(self.filter3_pos1) self.EM_filtercontrolContainerLayout.addWidget(self.filter3_pos1, 0, 0) self.FilterButtongroup_3.setExclusive(True) self.FilterButtongroup_3.buttonClicked[int].connect(self.DecodeFilterMove) EM_filtercontrolContainer.setLayout(self.EM_filtercontrolContainerLayout) EM_filtercontrolContainer.setFixedWidth(65) ND_filtercontrolContainer.setLayout(self.filtercontrolLayout) # ND_filtercontrolContainer.setFixedHeight(110) ND_filtercontrolContainer.setFixedWidth(200) # self.setPalette(palette) # self.setAutoFillBackground(True) ControlContainerLayout.addWidget(ND_filtercontrolContainer, 0, 0) ControlContainerLayout.addWidget(EM_filtercontrolContainer, 0, 1) ControlContainer.setLayout(ControlContainerLayout) self.layout.addWidget(ControlContainer, 0, 0)
def __init__(self, *args, **kwargs): QWidget.__init__(self, *args, **kwargs) self.setLayout(QGridLayout()) self.canvas = PlotCanvas() self.layout().setContentsMargins(0, 0, 0, 0) self.layout().addWidget(self.canvas)
def __init__(self, window, plugin, keystore, device_id): title = _("{} Settings").format(plugin.device) super(SettingsDialog, self).__init__(window, title) self.setMaximumWidth(540) devmgr = plugin.device_manager() config = devmgr.config handler = keystore.handler thread = keystore.thread hs_cols, hs_rows = (128, 64) def invoke_client(method, *args, **kw_args): unpair_after = kw_args.pop('unpair_after', False) def task(): client = devmgr.client_by_id(device_id) if not client: raise RuntimeError("Device not connected") if method: getattr(client, method)(*args, **kw_args) if unpair_after: devmgr.unpair_id(device_id) return client.features thread.add(task, on_success=update) def update(features): self.features = features set_label_enabled() if features.bootloader_hash: bl_hash = bh2u(features.bootloader_hash) bl_hash = "\n".join([bl_hash[:32], bl_hash[32:]]) else: bl_hash = "N/A" noyes = [_("No"), _("Yes")] endis = [_("Enable Passphrases"), _("Disable Passphrases")] disen = [_("Disabled"), _("Enabled")] setchange = [_("Set a PIN"), _("Change PIN")] version = "%d.%d.%d" % (features.major_version, features.minor_version, features.patch_version) device_label.setText(features.label) pin_set_label.setText(noyes[features.pin_protection]) passphrases_label.setText(disen[features.passphrase_protection]) bl_hash_label.setText(bl_hash) label_edit.setText(features.label) device_id_label.setText(features.device_id) initialized_label.setText(noyes[features.initialized]) version_label.setText(version) clear_pin_button.setVisible(features.pin_protection) clear_pin_warning.setVisible(features.pin_protection) pin_button.setText(setchange[features.pin_protection]) pin_msg.setVisible(not features.pin_protection) passphrase_button.setText(endis[features.passphrase_protection]) language_label.setText(features.language) def set_label_enabled(): label_apply.setEnabled(label_edit.text() != self.features.label) def rename(): invoke_client('change_label', label_edit.text()) def toggle_passphrase(): title = _("Confirm Toggle Passphrase Protection") currently_enabled = self.features.passphrase_protection if currently_enabled: msg = _("After disabling passphrases, you can only pair this " "Electrum wallet if it had an empty passphrase. " "If its passphrase was not empty, you will need to " "create a new wallet with the install wizard. You " "can use this wallet again at any time by re-enabling " "passphrases and entering its passphrase.") else: msg = _("Your current Electrum wallet can only be used with " "an empty passphrase. You must create a separate " "wallet with the install wizard for other passphrases " "as each one generates a new set of addresses.") msg += "\n\n" + _("Are you sure you want to proceed?") if not self.question(msg, title=title): return invoke_client('toggle_passphrase', unpair_after=currently_enabled) def change_homescreen(): dialog = QFileDialog(self, _("Choose Homescreen")) filename, __ = dialog.getOpenFileName() if not filename: return # user cancelled if filename.endswith('.toif'): img = open(filename, 'rb').read() if img[:8] != b'TOIf\x90\x00\x90\x00': handler.show_error( 'File is not a TOIF file with size of 144x144') return else: from PIL import Image # FIXME im = Image.open(filename) if im.size != (128, 64): handler.show_error('Image must be 128 x 64 pixels') return im = im.convert('1') pix = im.load() img = bytearray(1024) for j in range(64): for i in range(128): if pix[i, j]: o = (i + j * 128) img[o // 8] |= (1 << (7 - o % 8)) img = bytes(img) invoke_client('change_homescreen', img) def clear_homescreen(): invoke_client('change_homescreen', b'\x00') def set_pin(): invoke_client('set_pin', remove=False) def clear_pin(): invoke_client('set_pin', remove=True) def wipe_device(): wallet = window.wallet if wallet and sum(wallet.get_balance()): title = _("Confirm Device Wipe") msg = _("Are you SURE you want to wipe the device?\n" "Your wallet still has bitcoins in it!") if not self.question( msg, title=title, icon=QMessageBox.Critical): return invoke_client('wipe_device', unpair_after=True) def slider_moved(): mins = timeout_slider.sliderPosition() timeout_minutes.setText(_("{:2d} minutes").format(mins)) def slider_released(): config.set_session_timeout(timeout_slider.sliderPosition() * 60) # Information tab info_tab = QWidget() info_layout = QVBoxLayout(info_tab) info_glayout = QGridLayout() info_glayout.setColumnStretch(2, 1) device_label = QLabel() pin_set_label = QLabel() passphrases_label = QLabel() version_label = QLabel() device_id_label = QLabel() bl_hash_label = QLabel() bl_hash_label.setWordWrap(True) language_label = QLabel() initialized_label = QLabel() rows = [ (_("Device Label"), device_label), (_("PIN set"), pin_set_label), (_("Passphrases"), passphrases_label), (_("Firmware Version"), version_label), (_("Device ID"), device_id_label), (_("Bootloader Hash"), bl_hash_label), (_("Language"), language_label), (_("Initialized"), initialized_label), ] for row_num, (label, widget) in enumerate(rows): info_glayout.addWidget(QLabel(label), row_num, 0) info_glayout.addWidget(widget, row_num, 1) info_layout.addLayout(info_glayout) # Settings tab settings_tab = QWidget() settings_layout = QVBoxLayout(settings_tab) settings_glayout = QGridLayout() # Settings tab - Label label_msg = QLabel( _("Name this {}. If you have multiple devices " "their labels help distinguish them.").format(plugin.device)) label_msg.setWordWrap(True) label_label = QLabel(_("Device Label")) label_edit = QLineEdit() label_edit.setMinimumWidth(150) label_edit.setMaxLength(plugin.MAX_LABEL_LEN) label_apply = QPushButton(_("Apply")) label_apply.clicked.connect(rename) label_edit.textChanged.connect(set_label_enabled) settings_glayout.addWidget(label_label, 0, 0) settings_glayout.addWidget(label_edit, 0, 1, 1, 2) settings_glayout.addWidget(label_apply, 0, 3) settings_glayout.addWidget(label_msg, 1, 1, 1, -1) # Settings tab - PIN pin_label = QLabel(_("PIN Protection")) pin_button = QPushButton() pin_button.clicked.connect(set_pin) settings_glayout.addWidget(pin_label, 2, 0) settings_glayout.addWidget(pin_button, 2, 1) pin_msg = QLabel( _("PIN protection is strongly recommended. " "A PIN is your only protection against someone " "stealing your bitcoins if they obtain physical " "access to your {}.").format(plugin.device)) pin_msg.setWordWrap(True) pin_msg.setStyleSheet("color: red") settings_glayout.addWidget(pin_msg, 3, 1, 1, -1) # Settings tab - Homescreen homescreen_label = QLabel(_("Homescreen")) homescreen_change_button = QPushButton(_("Change...")) homescreen_clear_button = QPushButton(_("Reset")) homescreen_change_button.clicked.connect(change_homescreen) try: import PIL except ImportError: homescreen_change_button.setDisabled(True) homescreen_change_button.setToolTip( _("Required package 'PIL' is not available - Please install it." )) homescreen_clear_button.clicked.connect(clear_homescreen) homescreen_msg = QLabel( _("You can set the homescreen on your " "device to personalize it. You must " "choose a {} x {} monochrome black and " "white image.").format(hs_cols, hs_rows)) homescreen_msg.setWordWrap(True) settings_glayout.addWidget(homescreen_label, 4, 0) settings_glayout.addWidget(homescreen_change_button, 4, 1) settings_glayout.addWidget(homescreen_clear_button, 4, 2) settings_glayout.addWidget(homescreen_msg, 5, 1, 1, -1) # Settings tab - Session Timeout timeout_label = QLabel(_("Session Timeout")) timeout_minutes = QLabel() timeout_slider = QSlider(Qt.Horizontal) timeout_slider.setRange(1, 60) timeout_slider.setSingleStep(1) timeout_slider.setTickInterval(5) timeout_slider.setTickPosition(QSlider.TicksBelow) timeout_slider.setTracking(True) timeout_msg = QLabel( _("Clear the session after the specified period " "of inactivity. Once a session has timed out, " "your PIN and passphrase (if enabled) must be " "re-entered to use the device.")) timeout_msg.setWordWrap(True) timeout_slider.setSliderPosition(config.get_session_timeout() // 60) slider_moved() timeout_slider.valueChanged.connect(slider_moved) timeout_slider.sliderReleased.connect(slider_released) settings_glayout.addWidget(timeout_label, 6, 0) settings_glayout.addWidget(timeout_slider, 6, 1, 1, 3) settings_glayout.addWidget(timeout_minutes, 6, 4) settings_glayout.addWidget(timeout_msg, 7, 1, 1, -1) settings_layout.addLayout(settings_glayout) settings_layout.addStretch(1) # Advanced tab advanced_tab = QWidget() advanced_layout = QVBoxLayout(advanced_tab) advanced_glayout = QGridLayout() # Advanced tab - clear PIN clear_pin_button = QPushButton(_("Disable PIN")) clear_pin_button.clicked.connect(clear_pin) clear_pin_warning = QLabel( _("If you disable your PIN, anyone with physical access to your " "{} device can spend your bitcoins.").format(plugin.device)) clear_pin_warning.setWordWrap(True) clear_pin_warning.setStyleSheet("color: red") advanced_glayout.addWidget(clear_pin_button, 0, 2) advanced_glayout.addWidget(clear_pin_warning, 1, 0, 1, 5) # Advanced tab - toggle passphrase protection passphrase_button = QPushButton() passphrase_button.clicked.connect(toggle_passphrase) passphrase_msg = WWLabel(PASSPHRASE_HELP) passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN) passphrase_warning.setStyleSheet("color: red") advanced_glayout.addWidget(passphrase_button, 3, 2) advanced_glayout.addWidget(passphrase_msg, 4, 0, 1, 5) advanced_glayout.addWidget(passphrase_warning, 5, 0, 1, 5) # Advanced tab - wipe device wipe_device_button = QPushButton(_("Wipe Device")) wipe_device_button.clicked.connect(wipe_device) wipe_device_msg = QLabel( _("Wipe the device, removing all data from it. The firmware " "is left unchanged.")) wipe_device_msg.setWordWrap(True) wipe_device_warning = QLabel( _("Only wipe a device if you have the recovery seed written down " "and the device wallet(s) are empty, otherwise the bitcoins " "will be lost forever.")) wipe_device_warning.setWordWrap(True) wipe_device_warning.setStyleSheet("color: red") advanced_glayout.addWidget(wipe_device_button, 6, 2) advanced_glayout.addWidget(wipe_device_msg, 7, 0, 1, 5) advanced_glayout.addWidget(wipe_device_warning, 8, 0, 1, 5) advanced_layout.addLayout(advanced_glayout) advanced_layout.addStretch(1) tabs = QTabWidget(self) tabs.addTab(info_tab, _("Information")) tabs.addTab(settings_tab, _("Settings")) tabs.addTab(advanced_tab, _("Advanced")) dialog_vbox = QVBoxLayout(self) dialog_vbox.addWidget(tabs) dialog_vbox.addLayout(Buttons(CloseButton(self))) # Update information invoke_client(None)
def show_summary(self): h = self.parent.wallet.get_detailed_history()['summary'] if not h: self.parent.show_message(_("Nothing to summarize.")) return start_date = h.get('start_date') end_date = h.get('end_date') format_amount = lambda x: self.parent.format_amount( x.value) + ' ' + self.parent.base_unit() d = WindowModalDialog(self, _("Summary")) d.setMinimumSize(600, 150) vbox = QVBoxLayout() grid = QGridLayout() grid.addWidget(QLabel(_("Start")), 0, 0) grid.addWidget(QLabel(self.format_date(start_date)), 0, 1) grid.addWidget(QLabel(str(h.get('fiat_start_value')) + '/BTC'), 0, 2) grid.addWidget(QLabel(_("Initial balance")), 1, 0) grid.addWidget(QLabel(format_amount(h['start_balance'])), 1, 1) grid.addWidget(QLabel(str(h.get('fiat_start_balance'))), 1, 2) grid.addWidget(QLabel(_("End")), 2, 0) grid.addWidget(QLabel(self.format_date(end_date)), 2, 1) grid.addWidget(QLabel(str(h.get('fiat_end_value')) + '/BTC'), 2, 2) grid.addWidget(QLabel(_("Final balance")), 4, 0) grid.addWidget(QLabel(format_amount(h['end_balance'])), 4, 1) grid.addWidget(QLabel(str(h.get('fiat_end_balance'))), 4, 2) grid.addWidget(QLabel(_("Income")), 5, 0) grid.addWidget(QLabel(format_amount(h.get('incoming'))), 5, 1) grid.addWidget(QLabel(str(h.get('fiat_incoming'))), 5, 2) grid.addWidget(QLabel(_("Expenditures")), 6, 0) grid.addWidget(QLabel(format_amount(h.get('outgoing'))), 6, 1) grid.addWidget(QLabel(str(h.get('fiat_outgoing'))), 6, 2) grid.addWidget(QLabel(_("Capital gains")), 7, 0) grid.addWidget(QLabel(str(h.get('fiat_capital_gains'))), 7, 2) grid.addWidget(QLabel(_("Unrealized gains")), 8, 0) grid.addWidget(QLabel(str(h.get('fiat_unrealized_gains', ''))), 8, 2) vbox.addLayout(grid) vbox.addLayout(Buttons(CloseButton(d))) d.setLayout(vbox) d.exec_()
def __init__(self, parent, component): super().__init__(parent) self.parent = parent self.component = component self.name = QLabel("Particle", self) self.name.setAlignment(Qt.AlignHCenter) self.delete_btn = QPushButton("Delete", self) self.color = QLabel("Color", self) self.color_spins = [ QSpinBox(self), QSpinBox(self), QSpinBox(self), QSpinBox(self) ] self.color_picker = QPushButton("Color Picker") self.final_color = QLabel("Final Color") self.final_color_spins = [ QSpinBox(self), QSpinBox(self), QSpinBox(self), QSpinBox(self) ] self.final_color_picker = QPushButton("Color Picker") self.size_name = QLabel("Size", self) self.size_spins = [QSpinBox(self), QSpinBox(self)] self.final_size_name = QLabel("Final Size", self) self.final_size_spins = [QSpinBox(self), QSpinBox(self)] self.angle_range_name = QLabel("Angle", self) self.angle_range_spins = [QSpinBox(self), QSpinBox(self)] self.force_range_name = QLabel("Force", self) self.force_range_spins = [QSpinBox(self), QSpinBox(self)] self.offset_min_name = QLabel("Offset Minimum", self) self.offset_min_spins = [QSpinBox(self), QSpinBox(self)] self.offset_max_name = QLabel("Offset Maximum", self) self.offset_max_spins = [QSpinBox(self), QSpinBox(self)] self.lifetime = QLabel("Life Time") self.lifetime_spin = QSpinBox(self) self.spawn_time = QLabel("Spawn Time") self.spawn_time_spin = QDoubleSpinBox(self) self.spawn_number = QLabel("Spawn Number") self.spawn_number_spin = QSpinBox(self) self.color_picker.clicked.connect(self.select_color) self.lifetime_spin.setRange(-2147483648, 2147483647) self.lifetime_spin.setValue(self.component.lifetime) self.lifetime_spin.valueChanged.connect(self.change_value) self.spawn_time_spin.setRange(-2147483648, 2147483647) self.spawn_time_spin.setValue(self.component.spawn_time) self.spawn_time_spin.setSingleStep(0.01) self.spawn_time_spin.valueChanged.connect(self.change_value) self.spawn_number_spin.setRange(-2147483648, 2147483647) self.spawn_number_spin.setValue(self.component.spawn_number) self.spawn_number_spin.valueChanged.connect(self.change_value) for k, v in enumerate(component.color.rgba()): self.color_spins[k].setRange(0, 255) self.color_spins[k].setValue(v) self.color_spins[k].valueChanged.connect(self.change_value) self.final_color_picker.clicked.connect(self.select_final_color) for k, v in enumerate(component.final_color.rgba()): self.final_color_spins[k].setRange(0, 255) self.final_color_spins[k].setValue(v) self.final_color_spins[k].valueChanged.connect(self.change_value) for k, v in enumerate(self.component.size.coords()): self.size_spins[k].setRange(-2147483648, 2147483647) self.size_spins[k].setValue(v) for k, v in enumerate(self.component.final_size.coords()): self.final_size_spins[k].setRange(-2147483648, 2147483647) self.final_size_spins[k].setValue(v) for k, v in enumerate(self.component.angle_range.coords()): self.angle_range_spins[k].setRange(0, 359) self.angle_range_spins[k].setValue(v) for k, v in enumerate(self.component.force_range.coords()): self.force_range_spins[k].setRange(-2147483648, 2147483647) self.force_range_spins[k].setValue(v) for k, v in enumerate(self.component.offset_min.coords()): self.offset_min_spins[k].setRange(-2147483648, 2147483647) self.offset_min_spins[k].setValue(v) for k, v in enumerate(self.component.offset_max.coords()): self.offset_max_spins[k].setRange(-2147483648, 2147483647) self.offset_max_spins[k].setValue(v) spins = self.size_spins + self.final_size_spins + self.angle_range_spins + self.force_range_spins + \ self.offset_min_spins + self.offset_max_spins for spin in spins: spin.valueChanged.connect(self.change_value) self.delete_btn.clicked.connect(self.delete) self.layout = QGridLayout() self.layout.addWidget(self.name, 0, 1, 1, 3) self.layout.addWidget(self.delete_btn, 0, 4) self.layout.addWidget(self.color, 1, 0) for i in range(len(self.color_spins)): self.layout.addWidget(self.color_spins[i], 1, 1 + i) self.layout.addWidget(self.color_picker, 2, 0, 1, 5) self.layout.addWidget(self.final_color, 3, 0) for i in range(len(self.final_color_spins)): self.layout.addWidget(self.final_color_spins[i], 3, 1 + i) self.layout.addWidget(self.final_color_picker, 4, 0, 1, 5) self.layout.addWidget(self.size_name, 5, 0) self.layout.addWidget(self.size_spins[0], 5, 1, 1, 2) self.layout.addWidget(self.size_spins[1], 5, 3, 1, 2) self.layout.addWidget(self.final_size_name, 6, 0) self.layout.addWidget(self.final_size_spins[0], 6, 1, 1, 2) self.layout.addWidget(self.final_size_spins[1], 6, 3, 1, 2) self.layout.addWidget(self.angle_range_name, 7, 0) self.layout.addWidget(self.angle_range_spins[0], 7, 1, 1, 2) self.layout.addWidget(self.angle_range_spins[1], 7, 3, 1, 2) self.layout.addWidget(self.force_range_name, 8, 0) self.layout.addWidget(self.force_range_spins[0], 8, 1, 1, 2) self.layout.addWidget(self.force_range_spins[1], 8, 3, 1, 2) self.layout.addWidget(self.offset_min_name, 9, 0) self.layout.addWidget(self.offset_min_spins[0], 9, 1, 1, 2) self.layout.addWidget(self.offset_min_spins[1], 9, 3, 1, 2) self.layout.addWidget(self.offset_max_name, 10, 0) self.layout.addWidget(self.offset_max_spins[0], 10, 1, 1, 2) self.layout.addWidget(self.offset_max_spins[1], 10, 3, 1, 2) self.layout.addWidget(self.lifetime, 11, 0) self.layout.addWidget(self.lifetime_spin, 11, 1, 1, 4) self.layout.addWidget(self.spawn_time, 12, 0) self.layout.addWidget(self.spawn_time_spin, 12, 1, 1, 4) self.layout.addWidget(self.spawn_number, 13, 0) self.layout.addWidget(self.spawn_number_spin, 13, 1, 1, 4) self.setLayout(self.layout)
class FilterSliderWidgetUI(QWidget): # waveforms_generated = pyqtSignal(object, object, list, int) # SignalForContourScanning = pyqtSignal(int, int, int, np.ndarray, np.ndarray) # MessageBack = pyqtSignal(str) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # os.chdir('./')# Set directory to current folder. self.setFont(QFont("Arial")) self.resize(265,130) self.setWindowTitle("FilterSliderWidget") self.layout = QGridLayout(self) #************************************************************************************************************************************** #-------------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------GUI for Filter movement---------------------------------------------------- #-------------------------------------------------------------------------------------------------------------------------------------- #************************************************************************************************************************************** ControlContainer = StylishQT.roundQGroupBox(title = 'Filter Control', background_color = 'azure') ControlContainerLayout = QGridLayout() ND_filtercontrolContainer = StylishQT.roundQGroupBox(title = '2P ND', background_color = 'azure') self.filtercontrolLayout = QGridLayout() self.filtercontrolLayout.setSpacing(2) self.FilterButtongroup_1 = QButtonGroup(self) self.filter1_pos0 = QPushButton('0') self.filter1_pos0.setCheckable(True) self.FilterButtongroup_1.addButton(self.filter1_pos0) self.filtercontrolLayout.addWidget(self.filter1_pos0, 0, 1) # self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0)) self.filter1_pos1 = QPushButton('1') self.filter1_pos1.setCheckable(True) self.FilterButtongroup_1.addButton(self.filter1_pos1) self.filtercontrolLayout.addWidget(self.filter1_pos1, 0, 2) # self.filter1_pos1.clicked.connect(lambda: self.filter_move_towards("COM9", 1)) self.filter1_pos2 = QPushButton('2') self.filter1_pos2.setCheckable(True) self.FilterButtongroup_1.addButton(self.filter1_pos2) self.filtercontrolLayout.addWidget(self.filter1_pos2, 0, 3) # self.filter1_pos2.clicked.connect(lambda: self.filter_move_towards("COM9", 2)) self.filter1_pos3 = QPushButton('3') self.filter1_pos3.setCheckable(True) self.FilterButtongroup_1.addButton(self.filter1_pos3) self.filtercontrolLayout.addWidget(self.filter1_pos3, 0, 4) # self.filter1_pos3.clicked.connect(lambda: self.filter_move_towards("COM9", 3)) self.FilterButtongroup_1.setExclusive(True) self.FilterButtongroup_1.buttonClicked[int].connect(self.DecodeFilterMove) self.FilterButtongroup_2 = QButtonGroup(self) self.filter2_pos0 = QPushButton('0') self.filter2_pos0.setCheckable(True) self.FilterButtongroup_2.addButton(self.filter2_pos0) self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 1) # self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0)) self.filter2_pos1 = QPushButton('0.1') self.filter2_pos1.setCheckable(True) self.FilterButtongroup_2.addButton(self.filter2_pos1) self.filtercontrolLayout.addWidget(self.filter2_pos1, 1, 2) # self.filter1_pos1.clicked.connect(lambda: self.filter_move_towards("COM9", 1)) self.filter2_pos2 = QPushButton('0.3') self.filter2_pos2.setCheckable(True) self.FilterButtongroup_2.addButton(self.filter2_pos2) self.filtercontrolLayout.addWidget(self.filter2_pos2, 1, 3) # self.filter1_pos2.clicked.connect(lambda: self.filter_move_towards("COM9", 2)) self.filter2_pos3 = QPushButton('0.5') self.filter2_pos3.setCheckable(True) self.FilterButtongroup_2.addButton(self.filter2_pos3) self.filtercontrolLayout.addWidget(self.filter2_pos3, 1, 4) # self.filter1_pos3.clicked.connect(lambda: self.filter_move_towards("COM9", 3)) self.FilterButtongroup_2.setExclusive(True) self.FilterButtongroup_2.buttonClicked[int].connect(self.DecodeFilterMove) # # self.filtercontrolLayout.addWidget(QLabel('Filter-1 pos: '), 0, 0) # # self.filtercontrolLayout.addWidget(QLabel('Filter-2 pos: '), 1, 0) # bGBackupFromIntExt_1 = QButtonGroup(self) # # self.filter2_pos0 = QPushButton('0') # self.filter2_pos0.setCheckable(True) # bGBackupFromIntExt_1.addButton(self.filter2_pos0) # self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 1) # self.filter2_pos0.clicked.connect(lambda: self.filter_move_towards("COM7", 0)) # # self.filter2_pos1 = QPushButton('0.1') # self.filter2_pos1.setCheckable(True) # bGBackupFromIntExt_1.addButton(self.filter2_pos1) # self.filtercontrolLayout.addWidget(self.filter2_pos1, 1, 2) # self.filter2_pos1.clicked.connect(lambda: self.filter_move_towards("COM7", 1)) # # self.filter2_pos2 = QPushButton('0.3') # self.filter2_pos2.setCheckable(True) # bGBackupFromIntExt_1.addButton(self.filter2_pos2) # self.filtercontrolLayout.addWidget(self.filter2_pos2, 1, 3) # self.filter2_pos2.clicked.connect(lambda: self.filter_move_towards("COM7", 2)) # # self.filter2_pos3 = QPushButton('0.5') # self.filter2_pos3.setCheckable(True) # bGBackupFromIntExt_1.addButton(self.filter2_pos3) # self.filtercontrolLayout.addWidget(self.filter2_pos3, 1, 4) # self.filter2_pos3.clicked.connect(lambda: self.filter_move_towards("COM7", 3)) #---------------------------------------------------------------------- # self.filter1_pos0 = QDial() # self.filter1_pos0.setMinimum(0) # self.filter1_pos0.setMaximum(3) # self.filter1_pos0.setValue(0) # self.filter1_pos0.setNotchesVisible(True) # self.filter1_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM9", self.filter1_pos0.value())) # self.filter2_pos0 = QDial() # self.filter2_pos0.setMinimum(0) # self.filter2_pos0.setMaximum(3) # self.filter2_pos0.setValue(0) # self.filter2_pos0.setNotchesVisible(True) # self.filter2_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM7", self.filter2_pos0.value())) # # self.filter3_pos0 = QDial() # self.filter3_pos0.setMinimum(0) # self.filter3_pos0.setMaximum(3) # self.filter3_pos0.setValue(0) # self.filter3_pos0.setNotchesVisible(True) # self.filter3_pos0.valueChanged.connect(lambda: self.filter_move_towards("COM15", self.filter3_pos0.value())) #---------------------------------------------------------------------- # self.filter1_pos0 = QSlider(Qt.Horizontal) # self.filter1_pos0.setMinimum(0) # self.filter1_pos0.setMaximum(3) # self.filter1_pos0.setTickPosition(QSlider.TicksBothSides) # self.filter1_pos0.setTickInterval(1) # self.filter1_pos0.setSingleStep(1) # self.filter1_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM9", self.filter1_pos0.value())) # # self.filter2_pos0 = QSlider(Qt.Horizontal) # self.filter2_pos0.setMinimum(0) # self.filter2_pos0.setMaximum(3) # self.filter2_pos0.setTickPosition(QSlider.TicksBothSides) # self.filter2_pos0.setTickInterval(1) # self.filter2_pos0.setSingleStep(1) # self.filter2_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM7", self.filter2_pos0.value())) # # self.filter3_pos0 = QSlider(Qt.Vertical) # self.filter3_pos0.setMinimum(0) # self.filter3_pos0.setMaximum(1) # self.filter3_pos0.setTickPosition(QSlider.TicksBothSides) # self.filter3_pos0.setTickInterval(1) # self.filter3_pos0.setSingleStep(1) # self.filter3_pos0.sliderReleased.connect(lambda: self.filter_move_towards("COM15", self.filter3_pos0.value())) # self.filtercontrolLayout.addWidget(QLabel('ND 0 | 1 | 2 | 3'), 0, 1) # self.filtercontrolLayout.addWidget(self.filter1_pos0, 1, 1) # self.filtercontrolLayout.addWidget(QLabel('ND 0 | 0.1 | 0.3 | 0.5'), 0, 2) # self.filtercontrolLayout.addWidget(self.filter2_pos0, 1, 2) # self.filtercontrolLayout.addWidget(self.filter3_pos0, 1, 3) # oImage = QImage('./Icons/filtersliderpanel.png') ## sImage = oImage.scaled(QSize(292,208)) # resize Image to widgets size # palette = QPalette() # palette.setBrush(QPalette.Window, QBrush(oImage)) EM_filtercontrolContainer = StylishQT.roundQGroupBox(title = 'Emission', background_color = 'honeydew') self.EM_filtercontrolContainerLayout = QGridLayout() self.EM_filtercontrolContainerLayout.setSpacing(2) self.FilterButtongroup_3 = QButtonGroup(self) self.filter3_pos0 = QPushButton('Arch') self.filter3_pos0.setCheckable(True) self.FilterButtongroup_3.addButton(self.filter3_pos0) self.EM_filtercontrolContainerLayout.addWidget(self.filter3_pos0, 1, 0) # self.filter1_pos0.clicked.connect(lambda: self.filter_move_towards("COM9", 0)) self.filter3_pos1 = QPushButton('Citrine') self.filter3_pos1.setCheckable(True) self.FilterButtongroup_3.addButton(self.filter3_pos1) self.EM_filtercontrolContainerLayout.addWidget(self.filter3_pos1, 0, 0) self.FilterButtongroup_3.setExclusive(True) self.FilterButtongroup_3.buttonClicked[int].connect(self.DecodeFilterMove) EM_filtercontrolContainer.setLayout(self.EM_filtercontrolContainerLayout) EM_filtercontrolContainer.setFixedWidth(65) ND_filtercontrolContainer.setLayout(self.filtercontrolLayout) # ND_filtercontrolContainer.setFixedHeight(110) ND_filtercontrolContainer.setFixedWidth(200) # self.setPalette(palette) # self.setAutoFillBackground(True) ControlContainerLayout.addWidget(ND_filtercontrolContainer, 0, 0) ControlContainerLayout.addWidget(EM_filtercontrolContainer, 0, 1) ControlContainer.setLayout(ControlContainerLayout) self.layout.addWidget(ControlContainer, 0, 0) #************************************************************************************************************************************** #-------------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------Fucs for filter movement--------------------------------------------------- #-------------------------------------------------------------------------------------------------------------------------------------- #************************************************************************************************************************************** def run_in_thread(self, fn, *args, **kwargs): """ Send target function to thread. Usage: lambda: self.run_in_thread(self.fn) Parameters ---------- fn : function Target function to put in thread. Returns ------- thread : TYPE Threading handle. """ thread = threading.Thread(target=fn, args=args, kwargs=kwargs) thread.start() return thread def DecodeFilterMove(self): if self.FilterButtongroup_1.checkedId() == -2: self.run_in_thread(self.filter_move_towards("COM9", 0)) elif self.FilterButtongroup_1.checkedId() == -3: self.run_in_thread(self.filter_move_towards("COM9", 1)) elif self.FilterButtongroup_1.checkedId() == -4: self.run_in_thread(self.filter_move_towards("COM9", 2)) elif self.FilterButtongroup_1.checkedId() == -5: self.run_in_thread(self.filter_move_towards("COM9", 3)) if self.FilterButtongroup_2.checkedId() == -2: self.run_in_thread(self.filter_move_towards("COM7", 0)) elif self.FilterButtongroup_2.checkedId() == -3: self.run_in_thread(self.filter_move_towards("COM7", 1)) elif self.FilterButtongroup_2.checkedId() == -4: self.run_in_thread(self.filter_move_towards("COM7", 2)) elif self.FilterButtongroup_2.checkedId() == -5: self.run_in_thread(self.filter_move_towards("COM7", 3)) if self.FilterButtongroup_3.checkedId() == -2: # Move to Arch self.run_in_thread(self.filter_move_towards("COM15", 0)) elif self.FilterButtongroup_3.checkedId() == -3: self.run_in_thread(self.filter_move_towards("COM15", 1)) # def start_up_event(self): # ports = ["COM9", "COM7", "COM15"] # try: # for port in ports: # ELL9Filter_ins = ELL9Filter(port) # pos = def filter_move_towards(self, COMport, pos): ELL9Filter_ins = ELL9Filter(COMport) ELL9Filter_ins.moveToPosition(pos) def update_slider_current_pos(self, current_pos): # .setValue(current_pos) print('Slider current position: {}'.format(current_pos))
def __init__(self, cue, **kwargs): super().__init__(**kwargs) self.setGeometry(0, 0, self.parent().viewport().width(), 80) self.setFocusPolicy(Qt.NoFocus) self.setLayout(QHBoxLayout(self)) self.layout().setContentsMargins(0, 0, 0, 1) self._accurate_time = False self.cue = cue self.cue_time = CueTime(cue) self.cue_time.notify.connect(self._time_updated, Connection.QtQueued) # Use this to avoid transparent background self.gridLayoutWidget = QWidget(self) self.gridLayout = QGridLayout(self.gridLayoutWidget) self.gridLayout.setContentsMargins(3, 3, 3, 3) self.gridLayout.setSpacing(2) self.layout().addWidget(self.gridLayoutWidget) self.nameLabel = QLabel(self.gridLayoutWidget) self.nameLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.nameLabel.setText(cue.name) self.nameLabel.setToolTip(cue.name) self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 2) self.controlButtons = CueControlButtons(parent=self.gridLayoutWidget) self.gridLayout.addWidget(self.controlButtons, 1, 0) if CueAction.Stop in cue.CueActions: self.controlButtons.stopButton.clicked.connect(self._stop) else: self.controlButtons.stopButton.setEnabled(False) if CueAction.Pause in cue.CueActions: self.controlButtons.pauseButton.clicked.connect(self._pause) self.controlButtons.startButton.clicked.connect(self._restart) else: self.controlButtons.pauseButton.setEnabled(False) self.controlButtons.startButton.setEnabled(False) if CueAction.FadeIn in cue.CueActions: self.controlButtons.fadeInButton.clicked.connect(self._fadein) else: self.controlButtons.fadeInButton.setEnabled(False) if CueAction.FadeOut in cue.CueActions: self.controlButtons.fadeOutButton.clicked.connect(self._fadeout) else: self.controlButtons.fadeOutButton.setEnabled(False) if CueAction.Interrupt in cue.CueActions: self.controlButtons.interruptButton.clicked.connect( self._interrupt) else: self.controlButtons.interruptButton.setEnabled(False) self.timeDisplay = QLCDNumber(self.gridLayoutWidget) self.timeDisplay.setStyleSheet('background-color: transparent') self.timeDisplay.setSegmentStyle(QLCDNumber.Flat) self.timeDisplay.setDigitCount(8) self.timeDisplay.display(strtime(cue.duration)) self.gridLayout.addWidget(self.timeDisplay, 1, 1) self.gridLayout.setRowStretch(0, 1) self.gridLayout.setRowStretch(1, 3) self.gridLayout.setColumnStretch(0, 7) self.gridLayout.setColumnStretch(1, 5) cue.changed('name').connect(self.name_changed, Connection.QtQueued) cue.started.connect(self.controlButtons.pauseMode, Connection.QtQueued) cue.paused.connect(self.controlButtons.startMode, Connection.QtQueued) # Fade enter/exit cue.fadein_start.connect(self.enter_fadein, Connection.QtQueued) cue.fadein_end.connect(self.exit_fade, Connection.QtQueued) cue.fadeout_start.connect(self.enter_fadeout, Connection.QtQueued) cue.fadeout_end.connect(self.exit_fade, Connection.QtQueued)
def initUI(self): ''' # 标签1 lb1 = QLabel("源目录", self) #lb1.move(20,30) # 标签2 lb2=QLabel("目标目录",self) #lb2.move(20, 70) # 输入框1 self.ledit1 = QLineEdit(self) #self.ledit1.setGeometry(QtCore.QRect(110, 30, 200, 30)) # 输入框2 self.ledit2 = QLineEdit(self) #self.ledit2.setGeometry(QtCore.QRect(110, 70, 200, 30)) # 按钮1 btn_start=QPushButton('开始处理',self) #btn_start.move(20,120) btn_start.setToolTip('<b>开始合并CMO的版本</b>') btn_start.clicked.connect(self.process_dir) #按钮2 btn_quit = QPushButton('退出', self) #btn_quit.move(220, 120) btn_quit.setToolTip('<b>退出程序</b>') btn_quit.clicked.connect(qApp.quit) ''' srcdir = QLabel('源目录') destdir = QLabel('目标目录') self.srcdir_edit = QLineEdit() self.destdir_edit = QLineEdit() ok_button = QPushButton("开始处理") ok_button.setToolTip('<b>开始合并CMO的版本</b>') ok_button.clicked.connect(self.process_dir) quit_button = QPushButton("退出") quit_button.setToolTip('<b>退出程序</b>') quit_button.clicked.connect(qApp.quit) log_lab = QLabel('日志信息') self.log_edit = QTextEdit() grid = QGridLayout() grid.setSpacing(10) grid.addWidget(srcdir, 1, 0) grid.addWidget(self.srcdir_edit, 1, 1, 2, 1) grid.addWidget(destdir, 3, 0) grid.addWidget(self.destdir_edit, 3, 1, 2, 1) grid.addWidget(quit_button, 5, 0, 1, 1) grid.addWidget(ok_button, 5, 1, 1, 1) grid.addWidget(log_lab, 7, 0, 1, 1) grid.addWidget(self.log_edit, 7, 1, 1, 1) self.setLayout(grid) self.setGeometry(300, 300, 550, 450) self.setWindowTitle("版本预处理") self.setWindowIcon(QtGui.QIcon('./download.png')) self.show()
def __init__(self, msg, kind, OK_button, wallet=None, force_disable_encrypt_cb=False): self.wallet = wallet self.pw = QLineEdit() self.pw.setEchoMode(2) self.new_pw = QLineEdit() self.new_pw.setEchoMode(2) self.conf_pw = QLineEdit() self.conf_pw.setEchoMode(2) self.kind = kind self.OK_button = OK_button vbox = QVBoxLayout() label = QLabel(msg + "\n") label.setWordWrap(True) grid = QGridLayout() grid.setSpacing(8) grid.setColumnMinimumWidth(0, 150) grid.setColumnMinimumWidth(1, 100) grid.setColumnStretch(1, 1) if kind == PW_PASSPHRASE: vbox.addWidget(label) msgs = [_('Passphrase:'), _('Confirm Passphrase:')] else: logo_grid = QGridLayout() logo_grid.setSpacing(8) logo_grid.setColumnMinimumWidth(0, 70) logo_grid.setColumnStretch(1, 1) logo = QLabel() logo.setAlignment(Qt.AlignCenter) logo_grid.addWidget(logo, 0, 0) logo_grid.addWidget(label, 0, 1, 1, 2) vbox.addLayout(logo_grid) m1 = _('New Password:'******'Password:'******'Confirm Password:'******'Current Password:'******'Encrypt wallet file')) self.encrypt_cb.setEnabled(False) grid.addWidget(self.encrypt_cb, 4, 0, 1, 2) self.encrypt_cb.setVisible(kind != PW_PASSPHRASE) def enable_OK(): ok = self.new_pw.text() == self.conf_pw.text() OK_button.setEnabled(ok) self.encrypt_cb.setEnabled(ok and bool(self.new_pw.text()) and not force_disable_encrypt_cb) self.new_pw.textChanged.connect(enable_OK) self.conf_pw.textChanged.connect(enable_OK) self.vbox = vbox
class ParticleComponent(QWidget): def __init__(self, parent, component): super().__init__(parent) self.parent = parent self.component = component self.name = QLabel("Particle", self) self.name.setAlignment(Qt.AlignHCenter) self.delete_btn = QPushButton("Delete", self) self.color = QLabel("Color", self) self.color_spins = [ QSpinBox(self), QSpinBox(self), QSpinBox(self), QSpinBox(self) ] self.color_picker = QPushButton("Color Picker") self.final_color = QLabel("Final Color") self.final_color_spins = [ QSpinBox(self), QSpinBox(self), QSpinBox(self), QSpinBox(self) ] self.final_color_picker = QPushButton("Color Picker") self.size_name = QLabel("Size", self) self.size_spins = [QSpinBox(self), QSpinBox(self)] self.final_size_name = QLabel("Final Size", self) self.final_size_spins = [QSpinBox(self), QSpinBox(self)] self.angle_range_name = QLabel("Angle", self) self.angle_range_spins = [QSpinBox(self), QSpinBox(self)] self.force_range_name = QLabel("Force", self) self.force_range_spins = [QSpinBox(self), QSpinBox(self)] self.offset_min_name = QLabel("Offset Minimum", self) self.offset_min_spins = [QSpinBox(self), QSpinBox(self)] self.offset_max_name = QLabel("Offset Maximum", self) self.offset_max_spins = [QSpinBox(self), QSpinBox(self)] self.lifetime = QLabel("Life Time") self.lifetime_spin = QSpinBox(self) self.spawn_time = QLabel("Spawn Time") self.spawn_time_spin = QDoubleSpinBox(self) self.spawn_number = QLabel("Spawn Number") self.spawn_number_spin = QSpinBox(self) self.color_picker.clicked.connect(self.select_color) self.lifetime_spin.setRange(-2147483648, 2147483647) self.lifetime_spin.setValue(self.component.lifetime) self.lifetime_spin.valueChanged.connect(self.change_value) self.spawn_time_spin.setRange(-2147483648, 2147483647) self.spawn_time_spin.setValue(self.component.spawn_time) self.spawn_time_spin.setSingleStep(0.01) self.spawn_time_spin.valueChanged.connect(self.change_value) self.spawn_number_spin.setRange(-2147483648, 2147483647) self.spawn_number_spin.setValue(self.component.spawn_number) self.spawn_number_spin.valueChanged.connect(self.change_value) for k, v in enumerate(component.color.rgba()): self.color_spins[k].setRange(0, 255) self.color_spins[k].setValue(v) self.color_spins[k].valueChanged.connect(self.change_value) self.final_color_picker.clicked.connect(self.select_final_color) for k, v in enumerate(component.final_color.rgba()): self.final_color_spins[k].setRange(0, 255) self.final_color_spins[k].setValue(v) self.final_color_spins[k].valueChanged.connect(self.change_value) for k, v in enumerate(self.component.size.coords()): self.size_spins[k].setRange(-2147483648, 2147483647) self.size_spins[k].setValue(v) for k, v in enumerate(self.component.final_size.coords()): self.final_size_spins[k].setRange(-2147483648, 2147483647) self.final_size_spins[k].setValue(v) for k, v in enumerate(self.component.angle_range.coords()): self.angle_range_spins[k].setRange(0, 359) self.angle_range_spins[k].setValue(v) for k, v in enumerate(self.component.force_range.coords()): self.force_range_spins[k].setRange(-2147483648, 2147483647) self.force_range_spins[k].setValue(v) for k, v in enumerate(self.component.offset_min.coords()): self.offset_min_spins[k].setRange(-2147483648, 2147483647) self.offset_min_spins[k].setValue(v) for k, v in enumerate(self.component.offset_max.coords()): self.offset_max_spins[k].setRange(-2147483648, 2147483647) self.offset_max_spins[k].setValue(v) spins = self.size_spins + self.final_size_spins + self.angle_range_spins + self.force_range_spins + \ self.offset_min_spins + self.offset_max_spins for spin in spins: spin.valueChanged.connect(self.change_value) self.delete_btn.clicked.connect(self.delete) self.layout = QGridLayout() self.layout.addWidget(self.name, 0, 1, 1, 3) self.layout.addWidget(self.delete_btn, 0, 4) self.layout.addWidget(self.color, 1, 0) for i in range(len(self.color_spins)): self.layout.addWidget(self.color_spins[i], 1, 1 + i) self.layout.addWidget(self.color_picker, 2, 0, 1, 5) self.layout.addWidget(self.final_color, 3, 0) for i in range(len(self.final_color_spins)): self.layout.addWidget(self.final_color_spins[i], 3, 1 + i) self.layout.addWidget(self.final_color_picker, 4, 0, 1, 5) self.layout.addWidget(self.size_name, 5, 0) self.layout.addWidget(self.size_spins[0], 5, 1, 1, 2) self.layout.addWidget(self.size_spins[1], 5, 3, 1, 2) self.layout.addWidget(self.final_size_name, 6, 0) self.layout.addWidget(self.final_size_spins[0], 6, 1, 1, 2) self.layout.addWidget(self.final_size_spins[1], 6, 3, 1, 2) self.layout.addWidget(self.angle_range_name, 7, 0) self.layout.addWidget(self.angle_range_spins[0], 7, 1, 1, 2) self.layout.addWidget(self.angle_range_spins[1], 7, 3, 1, 2) self.layout.addWidget(self.force_range_name, 8, 0) self.layout.addWidget(self.force_range_spins[0], 8, 1, 1, 2) self.layout.addWidget(self.force_range_spins[1], 8, 3, 1, 2) self.layout.addWidget(self.offset_min_name, 9, 0) self.layout.addWidget(self.offset_min_spins[0], 9, 1, 1, 2) self.layout.addWidget(self.offset_min_spins[1], 9, 3, 1, 2) self.layout.addWidget(self.offset_max_name, 10, 0) self.layout.addWidget(self.offset_max_spins[0], 10, 1, 1, 2) self.layout.addWidget(self.offset_max_spins[1], 10, 3, 1, 2) self.layout.addWidget(self.lifetime, 11, 0) self.layout.addWidget(self.lifetime_spin, 11, 1, 1, 4) self.layout.addWidget(self.spawn_time, 12, 0) self.layout.addWidget(self.spawn_time_spin, 12, 1, 1, 4) self.layout.addWidget(self.spawn_number, 13, 0) self.layout.addWidget(self.spawn_number_spin, 13, 1, 1, 4) self.setLayout(self.layout) def delete(self): self.parent.remove_component(comp=self.component.name) def select_color(self): color = QColorDialog.getColor(QColor(*self.component.color.rgba()), parent=self) if color.isValid(): self.color_spins[0].setValue(color.red()) self.color_spins[1].setValue(color.green()) self.color_spins[2].setValue(color.blue()) self.color_spins[3].setValue(color.alpha()) self.change_value(color=[ color.red(), color.green(), color.blue(), color.alpha() ]) def select_final_color(self): color = QColorDialog.getColor( QColor(*self.component.final_color.rgba()), parent=self) if color.isValid(): self.final_color_spins[0].setValue(color.red()) self.final_color_spins[1].setValue(color.green()) self.final_color_spins[2].setValue(color.blue()) self.final_color_spins[3].setValue(color.alpha()) self.change_value(final_color=[ color.red(), color.green(), color.blue(), color.alpha() ]) def change_value(self, _=None, color=None, final_color=None): if color is None: self.component.color = Color.from_rgba( *(i.value() for i in self.color_spins)) else: self.component.color = Color.from_rgba(*color) if final_color is None: self.component.final_color = Color.from_rgba( *(i.value() for i in self.final_color_spins)) else: self.component.final_color = Color.from_rgba(*final_color) self.component.size = Vec2(*(i.value() for i in self.size_spins)) self.component.final_size = Vec2(*(i.value() for i in self.final_size_spins)) self.component.angle_range = Vec2(*(i.value() for i in self.angle_range_spins)) self.component.force_range = Vec2(*(i.value() for i in self.force_range_spins)) self.component.offset_min = Vec2(*(i.value() for i in self.offset_min_spins)) self.component.offset_max = Vec2(*(i.value() for i in self.offset_max_spins)) self.component.lifetime = self.lifetime_spin.value() self.component.spawn_time = self.spawn_time_spin.value() self.component.spawn_number = self.spawn_number_spin.value() self.parent.parent.project.save() self.parent.parent.viewport.update_screen()
def __init__(self, msg, wallet=None): self.wallet = wallet vbox = QVBoxLayout() label = QLabel(msg + "\n") label.setWordWrap(True) grid = QGridLayout() grid.setSpacing(8) grid.setColumnMinimumWidth(0, 150) grid.setColumnMinimumWidth(1, 100) grid.setColumnStretch(1, 1) logo_grid = QGridLayout() logo_grid.setSpacing(8) logo_grid.setColumnMinimumWidth(0, 70) logo_grid.setColumnStretch(1, 1) logo = QLabel() logo.setAlignment(Qt.AlignCenter) logo_grid.addWidget(logo, 0, 0) logo_grid.addWidget(label, 0, 1, 1, 2) vbox.addLayout(logo_grid) if wallet and wallet.has_storage_encryption(): lockfile = "lock.png" else: lockfile = "unlock.png" logo.setPixmap( QPixmap(icon_path(lockfile)).scaledToWidth( 36, mode=Qt.SmoothTransformation)) vbox.addLayout(grid) self.encrypt_cb = QCheckBox(_('Encrypt wallet file')) grid.addWidget(self.encrypt_cb, 1, 0, 1, 2) self.vbox = vbox
class RunningCueWidget(QWidget): def __init__(self, cue, **kwargs): super().__init__(**kwargs) self.setGeometry(0, 0, self.parent().viewport().width(), 80) self.setFocusPolicy(Qt.NoFocus) self.setLayout(QHBoxLayout(self)) self.layout().setContentsMargins(0, 0, 0, 1) self._accurate_time = False self.cue = cue self.cue_time = CueTime(cue) self.cue_time.notify.connect(self._time_updated, Connection.QtQueued) # Use this to avoid transparent background self.gridLayoutWidget = QWidget(self) self.gridLayout = QGridLayout(self.gridLayoutWidget) self.gridLayout.setContentsMargins(3, 3, 3, 3) self.gridLayout.setSpacing(2) self.layout().addWidget(self.gridLayoutWidget) self.nameLabel = QLabel(self.gridLayoutWidget) self.nameLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.nameLabel.setText(cue.name) self.nameLabel.setToolTip(cue.name) self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 2) self.controlButtons = CueControlButtons(parent=self.gridLayoutWidget) self.gridLayout.addWidget(self.controlButtons, 1, 0) if CueAction.Stop in cue.CueActions: self.controlButtons.stopButton.clicked.connect(self._stop) else: self.controlButtons.stopButton.setEnabled(False) if CueAction.Pause in cue.CueActions: self.controlButtons.pauseButton.clicked.connect(self._pause) self.controlButtons.startButton.clicked.connect(self._restart) else: self.controlButtons.pauseButton.setEnabled(False) self.controlButtons.startButton.setEnabled(False) if CueAction.FadeIn in cue.CueActions: self.controlButtons.fadeInButton.clicked.connect(self._fadein) else: self.controlButtons.fadeInButton.setEnabled(False) if CueAction.FadeOut in cue.CueActions: self.controlButtons.fadeOutButton.clicked.connect(self._fadeout) else: self.controlButtons.fadeOutButton.setEnabled(False) if CueAction.Interrupt in cue.CueActions: self.controlButtons.interruptButton.clicked.connect( self._interrupt) else: self.controlButtons.interruptButton.setEnabled(False) self.timeDisplay = QLCDNumber(self.gridLayoutWidget) self.timeDisplay.setStyleSheet('background-color: transparent') self.timeDisplay.setSegmentStyle(QLCDNumber.Flat) self.timeDisplay.setDigitCount(8) self.timeDisplay.display(strtime(cue.duration)) self.gridLayout.addWidget(self.timeDisplay, 1, 1) self.gridLayout.setRowStretch(0, 1) self.gridLayout.setRowStretch(1, 3) self.gridLayout.setColumnStretch(0, 7) self.gridLayout.setColumnStretch(1, 5) cue.changed('name').connect(self.name_changed, Connection.QtQueued) cue.started.connect(self.controlButtons.pauseMode, Connection.QtQueued) cue.paused.connect(self.controlButtons.startMode, Connection.QtQueued) # Fade enter/exit cue.fadein_start.connect(self.enter_fadein, Connection.QtQueued) cue.fadein_end.connect(self.exit_fade, Connection.QtQueued) cue.fadeout_start.connect(self.enter_fadeout, Connection.QtQueued) cue.fadeout_end.connect(self.exit_fade, Connection.QtQueued) def enter_fadein(self): p = self.timeDisplay.palette() p.setColor(p.Text, QColor(0, 255, 0)) self.timeDisplay.setPalette(p) def enter_fadeout(self): p = self.timeDisplay.palette() p.setColor(p.Text, QColor(255, 50, 50)) self.timeDisplay.setPalette(p) def exit_fade(self): self.timeDisplay.setPalette(self.palette()) def name_changed(self, name): self.nameLabel.setText(name) self.nameLabel.setToolTip(name) def set_accurate_time(self, enable): self._accurate_time = enable def _time_updated(self, time): if not self.visibleRegion().isEmpty(): # If the given value is the duration or < 0 set the time to 0 if time == self.cue.duration or time < 0: time = 0 self._update_timers(time) def _update_timers(self, time): self.timeDisplay.display( strtime(self.cue.duration - time, accurate=self._accurate_time)) def _pause(self): self.cue.pause(fade=config['ListLayout'].getboolean('PauseCueFade')) def _restart(self): self.cue.restart( fade=config['ListLayout'].getboolean('RestartCueFade')) def _stop(self): self.cue.stop(fade=config['ListLayout'].getboolean('StopCueFade')) def _interrupt(self): self.cue.interrupt( fade=config['ListLayout'].getboolean('InterruptCueFade')) def _fadeout(self): self.cue.execute(CueAction.FadeOut) def _fadein(self): self.cue.execute(CueAction.FadeIn)