def __init__(self): """ Constructor for the main application class. Creates the GUI and sets up the initial state. """ super().__init__() self.player_thread = threading.Thread() self.output_screen_size = 32 # Center master window self.resize(400, 200) self.center_widget(self, 0) # Create widgets self.display_widget = DisplayWidget() self.media_preview_stack = QStackedWidget() open_button = QPushButton("Open") clear_button = QPushButton("Clear") next_button = QPushButton(QIcon("next.svg"), "") previous_button = QPushButton(QIcon("previous.svg"), "") preview_label = QLabel() self.nav_widget = QWidget() self.size_widget = QWidget() self.size_checkbox = QCheckBox("Autosize") size_lineedit = QLineEdit(str(self.output_screen_size)) # Configure preview_label.setScaledContents(True) preview_label.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) open_button.setToolTip("Choose a media file to display") clear_button.setToolTip( "Clear the current media and turn off the display") size_lineedit.setInputMask("D0 \\i\\n") self.nav_widget.setEnabled(False) self.media_preview_stack.addWidget(QSvgWidget("blank.svg")) self.media_preview_stack.addWidget(preview_label) self.display_widget.setScaledContents(True) self.display_widget.setStyleSheet("background-color: rgb(20, 20, 20);") self.display_widget.closed.connect(self.close) self.size_checkbox.setChecked(True) self.size_checkbox.setEnabled(False) self.size_checkbox.setToolTip( "Use automatic screen dimensions for drawing") # Set up connections open_button.clicked.connect(self.choose_media) clear_button.clicked.connect(self.clear_media) next_button.clicked.connect(lambda: self.advance_media(1)) previous_button.clicked.connect(lambda: self.advance_media(-1)) size_lineedit.editingFinished.connect(self.size_changed) self.size_checkbox.stateChanged.connect(self.set_dimensions_visibility) # Set shortcuts makeShortcut = lambda hotkey: QShortcut( QKeySequence(hotkey), self, context=Qt.ApplicationShortcut) open_shortcut = makeShortcut("O") clear_shortcut = makeShortcut("C") close_shortcut = makeShortcut("Ctrl+Q") self.next_shortcut = makeShortcut("N") self.previous_shortcut = makeShortcut("P") self.dimensions_shortcut = makeShortcut("A") self.next_shortcut.setEnabled(False) self.previous_shortcut.setEnabled(False) self.dimensions_shortcut.setEnabled(False) open_shortcut.activated.connect(self.choose_media) clear_shortcut.activated.connect(self.clear_media) close_shortcut.activated.connect(self.close) self.next_shortcut.activated.connect(lambda: self.advance_media(1)) self.previous_shortcut.activated.connect( lambda: self.advance_media(-1)) self.dimensions_shortcut.activated.connect(self.size_checkbox.toggle) # Pack layouts vbox = QVBoxLayout() hbox = QHBoxLayout() nav_hbox = QHBoxLayout() size_hbox = QHBoxLayout() nav_hbox.addWidget(previous_button) nav_hbox.addWidget(next_button) size_hbox.addWidget(QLabel("Size:")) size_hbox.addWidget(size_lineedit) vbox.addWidget(open_button) vbox.addWidget(clear_button) vbox.addWidget(self.nav_widget) vbox.addWidget(self.size_checkbox) vbox.addWidget(self.size_widget) vbox.addStretch() hbox.addLayout(vbox) hbox.addWidget(self.media_preview_stack) hbox.setSpacing(20) hbox.setContentsMargins(20, 20, 20, 20) vbox.setSpacing(10) nav_hbox.setContentsMargins(0, 0, 0, 0) size_hbox.setContentsMargins(0, 0, 0, 0) self.nav_widget.setLayout(nav_hbox) self.size_widget.setLayout(size_hbox) # Create slave window desktop_widget = QDesktopWidget() if desktop_widget.screenCount() != 2: QMessageBox.warning(self, "Warning", "Cannot find a second screen, " \ "display will be on primary screen.") self.display_widget.showMaximized() else: self.center_widget(self.display_widget, 1) self.display_widget.showFullScreen() # Set default values in the screen dimension widgets display_geometry = desktop_widget.screenGeometry(self.display_widget) self.size_widget.hide() self.display_widget.setWindowTitle("Polo - Display") self.setLayout(hbox) self.setWindowTitle("Polo") self.show()
def setup(self): # definition of all button TogOff = self.icon + 'Toggle_Off.png' TogOn = self.icon + 'Toggle_On.png' TogOff = pathlib.Path(TogOff) TogOff = pathlib.PurePosixPath(TogOff) TogOn = pathlib.Path(TogOn) TogOn = pathlib.PurePosixPath(TogOn) self.setStyleSheet("QCheckBox::indicator{width: 30px;height: 30px;}" "QCheckBox::indicator:unchecked { image : url(%s);}" "QCheckBox::indicator:checked { image: url(%s);}" "QCheckBox{font :10pt;}" % (TogOff, TogOn)) vbox1 = QVBoxLayout() self.hbox0 = QHBoxLayout() vbox1.addLayout(self.hbox0) hbox1 = QHBoxLayout() self.checkBoxPlot = QCheckBox('CROSS', self) self.checkBoxPlot.setChecked(False) self.label_CrossValue = QLabel() self.label_CrossValue.setStyleSheet("font:13pt") hbox1.addWidget(self.checkBoxPlot) hbox1.addWidget(self.label_CrossValue) hbox2 = QHBoxLayout() self.label_Cross = QLabel() #self.label_Cross.setMaximumHeight(20) self.label_Cross.setMaximumWidth(170) self.label_Cross.setStyleSheet("font:12pt") hbox2.addWidget(self.label_Cross) vbox1.addLayout(hbox1) vbox1.addLayout(hbox2) self.ZoomLabel = QLabel('Zoom') vbox1.addWidget(self.ZoomLabel) self.checkBoxZoom = QSlider(Qt.Horizontal) self.checkBoxZoom.setMaximumWidth(250) self.checkBoxZoom.setMinimum(0) self.checkBoxZoom.setMaximum(200) self.checkBoxZoom.setValue(0) vbox1.addWidget(self.checkBoxZoom) self.checkBoxScale = QCheckBox('Auto Scale', self) self.checkBoxScale.setChecked(True) self.checkBoxScale.setMaximumWidth(100) self.checkBoxColor = QCheckBox('Color', self) self.checkBoxColor.setChecked(True) self.checkBoxHist = QCheckBox('Hist', self) self.checkBoxHist.setChecked(False) self.maxGraphBox = QCheckBox('Max', self) hbox3 = QHBoxLayout() grid_layout = QGridLayout() grid_layout.setVerticalSpacing(0) grid_layout.setHorizontalSpacing(10) grid_layout.addWidget(self.checkBoxScale, 0, 0) grid_layout.addWidget(self.checkBoxColor, 1, 0) grid_layout.addWidget(self.checkBoxHist, 0, 1) #grid_layout.addWidget(self.checkBoxZoom, 1, 0) grid_layout.addWidget(self.maxGraphBox, 1, 1) hbox3.addLayout(grid_layout) vbox1.addLayout(hbox3) hbox4 = QHBoxLayout() if self.meas == 'on': self.MeasButton = QPushButton('Meas.') hbox4.addWidget(self.MeasButton) vbox1.addLayout(hbox4) vbox1.addStretch(1) self.winImage = pg.GraphicsLayoutWidget() #self.winImage.setContentsMargins(1,1,1,1) self.winImage.setAspectLocked(True) self.winImage.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) #self.winImage.ci.setContentsMargins(1,1,1,1) vbox2 = QVBoxLayout() # self.dockImage=QDockWidget(self) # self.dockImage.setWidget(self.winImage) # self.dockImage.setFeatures(QDockWidget.DockWidgetFloatable) #vbox2.addWidget(self.dockImage) vbox2.addWidget(self.winImage) vbox2.setContentsMargins(0, 0, 0, 0) self.p1 = self.winImage.addPlot() self.imh = pg.ImageItem() self.axeX = self.p1.getAxis('bottom') self.axeY = self.p1.getAxis('left') self.p1.addItem(self.imh) self.p1.setMouseEnabled(x=False, y=False) self.p1.setContentsMargins(0, 0, 0, 0) self.p1.setAspectLocked(True, ratio=1) self.p1.showAxis('right', show=False) self.p1.showAxis('top', show=False) self.p1.showAxis('left', show=True) self.p1.showAxis('bottom', show=True) if self.bloqKeyboard == True: self.vLine = pg.InfiniteLine(angle=90, movable=False, pen='r') self.hLine = pg.InfiniteLine(angle=0, movable=False, pen='r') else: self.vLine = pg.InfiniteLine(angle=90, movable=False, pen='y') self.hLine = pg.InfiniteLine(angle=0, movable=False, pen='y') self.xc = int(self.conf.value(self.name + "/xc")) self.yc = int(self.conf.value(self.name + "/yc")) self.rx = int(self.conf.value(self.name + "/rx")) self.ry = int(self.conf.value(self.name + "/ry")) self.vLine.setPos(self.xc) self.hLine.setPos(self.yc) self.ro1 = pg.EllipseROI([self.xc, self.yc], [self.rx, self.ry], pen='y', movable=False, maxBounds=QtCore.QRectF( 0, 0, self.rx, self.ry)) self.ro1.setPos([self.xc - (self.rx / 2), self.yc - (self.ry / 2)]) # text for fwhm on p1 self.textX = pg.TextItem(angle=-90) self.textY = pg.TextItem() #histogram self.hist = pg.HistogramLUTItem() self.hist.setImageItem(self.imh) self.hist.autoHistogramRange() self.hist.gradient.loadPreset('flame') ## XY graph self.curve2 = pg.PlotCurveItem() self.curve3 = pg.PlotCurveItem() ## main layout hMainLayout = QHBoxLayout() if self.aff == 'right': hMainLayout.addLayout(vbox2) hMainLayout.addLayout(vbox1) else: hMainLayout.addLayout(vbox1) hMainLayout.addLayout(vbox2) hMainLayout.setContentsMargins(1, 1, 1, 1) hMainLayout.setSpacing(1) hMainLayout.setStretch(10, 1) self.setLayout(hMainLayout) self.setContentsMargins(1, 1, 1, 1)
def init_ui(self): # Кнопка Старт self.start_btn = self.start_btn_init() # Кнопка выхода self.quit_btn = self.quit_btn_init() ############################################################################################################### # Кнопка выбора файла базы данных self.select_db_btn = self.select_db_btn_init() self.lbl_db_path = QLabel(self) self.lbl_db_path.setStatusTip('Путь к файлу базы данных') ############################################################################################################### # Кнопка выбора файла ГТС self.select_GTS_btn = self.select_GTS_btn_init() self.lbl_GTS_path = QLabel(self) self.lbl_GTS_path.setStatusTip('Путь к файлу ГТС') self.chk_revers = QCheckBox('Реверс бит в байте') self.chk_revers.setStatusTip( 'Если файл ГТС уже был обработан, то реверс был произведен') self.chk_revers.setChecked(True) self.chk_revers.adjustSize() ############################################################################################################### # Выбор исследуемого источника self.gbox_object = QGroupBox('Выбор исследуемого источника', self) self.gbox_object.setStatusTip( 'Последовательно выберите каждый из критериев классификации источников' ) self.lbl_object = QLabel(self) self.lbl_type = QLabel(self) self.lbl_subtype = QLabel(self) self.lbl_country = QLabel(self) self.combo_obj = QComboBox(self) self.combo_obj.setMinimumWidth(80) self.combo_obj.setStatusTip('Выберите объект') self.combo_type = QComboBox(self) self.combo_type.setMinimumWidth(50) self.combo_type.setStatusTip('Выберите тип источника') self.combo_subtype = QComboBox(self) self.combo_subtype.setMinimumWidth(80) self.combo_subtype.setStatusTip('Выберите подтип источника') self.combo_country = QComboBox(self) self.combo_country.setMinimumWidth(150) self.combo_country.setStatusTip( 'Выберите страну, которой принадлежит исследуемый объект') ############################################################################################################### # Выбор радиолинии self.gbox_rl = QGroupBox('Выбор радиолинии ', self) self.gbox_rl.setStatusTip( 'Выберите одну из радиолиний, принадлежащих указанному источнику') self.lbl_rlname = QLabel(self) self.combo_rlname = QComboBox(self) self.combo_rlname.setMinimumWidth(250) ############################################################################################################### # Отображение параметров основного коммутатора self.gbox_fr_prm = QGroupBox('Характеристики основного коммутатора', self) self.gbox_fr_prm.setStatusTip('Характеристики основного коммутатора') self.lbl_fr_name = QLabel(self) self.lbl_fr_len = QLabel(self) self.lbl_fr_wlen = QLabel(self) self.lbl_fr_freq = QLabel(self) ############################################################################################################### # Выбор коммутатора для демультиплексирования self.gbox_sel_chan = QGroupBox('Выбор демультиплексируемого канала', self) self.gbox_sel_chan.setStatusTip( 'Сначала выберите тип, а затем имя демультиплексируемого канала') self.lbl_type_chan = QLabel(self) self.lbl_type_chan.setMinimumWidth(100) self.lbl_name_chan = QLabel(self) self.lbl_type_chan.setMinimumWidth(150) self.combo_chtype = QComboBox(self) self.combo_chtype.setMinimumWidth(100) self.combo_chtype.setStatusTip('Выберите тип канала') self.combo_chname = QComboBox(self) self.combo_chname.setMinimumWidth(200) self.combo_chname.setStatusTip('Выберите имя канала') ################################################################################################################ # Отображение параметров выбранного для демультиплексирования канала self.gbox_chan_prm = QGroupBox( 'Характеристики демультиплексируемого канала', self) self.gbox_chan_prm.setStatusTip( 'Характеристики демультиплексируемого канала') self.lbl_chan_frlen = QLabel(self) self.lbl_chan_wlen = QLabel(self) # Прогресс БАР self.progrbar_dmx = QProgressBar() self.progrbar_dmx.setStatusTip('Прогресс выполнения декоммутации') ############################ self.combo_obj_rm() # Управление макетом self.cur_layout = self.layout_init() self.setLayout(self.cur_layout)
def relSelect(self, relnum): self.windowtitle(self.relList.currentText()) self.initData() self.rinfo = self.disc.parse(relnum) if self.rinfo['infotype'] == 'cdstub': msg = "This data is from a cdstub, not a proper Musicbrainz entry. Would you like to add this disc?" elif self.rinfo['infotype'] == 'manual': msg = "No information for this disc found. Submit to Musicbrainz?" if self.rinfo['infotype'] != 'musicbrainz': u = self.disc.url() print(u) q = QMessageBox.question(self, 'Please help', msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if q == QMessageBox.Yes: webbrowser.open_new_tab(u) tracklist = self.rinfo['tracklist'] self.artistEdit = QLineEdit(self.rinfo['artist']) self.albumEdit = QLineEdit(self.rinfo['album']) self.dateEdit = QLineEdit(self.rinfo['date']) self.dateEdit.setMaxLength(10) self.discnumEdit = QLineEdit(self.rinfo['discnum']) self.discnumEdit.setMaxLength(2) self.coverEdit = QLineEdit() self.coverEdit.setPlaceholderText("File path or URL") self.multiToggle = QCheckBox('Multidisc') self.multiToggle.setChecked(self.rinfo['multidisc']) ripBtn = QPushButton("Make FLAC", self) reloadBtn = QPushButton("Reload", self) noCovBtn = QPushButton("No Cover", self) self.upCovBtn = QPushButton("Ch Cover", self) if self.rinfo['cover']: self.coverPix.setPixmap( QPixmap(self.rinfo['cover']).scaled(375, 375, Qt.KeepAspectRatio)) self.update() self.grid.addWidget(self.upCovBtn, 13, 0) self.grid.addWidget(self.coverEdit, 13, 1) self.grid.addWidget(QLabel('Artist'), 2, 0) self.grid.addWidget(self.artistEdit, 2, 1) self.grid.addWidget(QLabel('Album'), 3, 0) self.grid.addWidget(self.albumEdit, 3, 1) self.grid.addWidget(QLabel('Date'), 4, 0) self.grid.addWidget(self.dateEdit, 5, 0) self.grid.addWidget(QLabel('Disc #'), 6, 0) self.grid.addWidget(self.discnumEdit, 7, 0) self.grid.addWidget(self.multiToggle, 8, 0) self.grid.addWidget(ripBtn, 10, 0) self.grid.addWidget(reloadBtn, 11, 0) self.grid.addWidget(noCovBtn, 12, 0) self.grid.addWidget(self.coverPix, 4, 1, 9, 1) for x in range(len(tracklist)): tnum = x + 1 trow = x + 2 self.tracksEdit.append( (QLabel(f'Track {tnum:02d}'), QLineEdit(tracklist[x]))) self.grid.addWidget(self.tracksEdit[x][0], trow, 2) self.grid.addWidget(self.tracksEdit[x][1], trow, 3) self.statbar.showMessage('Ready.') ripBtn.clicked.connect(self.makeflac) reloadBtn.clicked.connect(self.reloadDev) noCovBtn.clicked.connect(self.remCover) self.upCovBtn.clicked.connect(self.chCover)
def __init__(self, parent=None): super().__init__(parent) self.mThread = None self.layout = QVBoxLayout() # 最上层的文本框 self.tbox_log = QTextEdit() self.tbox_log.setFontPointSize(10) # 按钮及下拉框 line_1 = QHBoxLayout() self.serial_cb = QComboBox() self.baudRate_cb = QComboBox() self.baudRate_cb.addItem("9600") self.baudRate_cb.addItem("115200") self.baudRate_cb.addItem("500000") self.baudRate_cb.addItem("921600") btn_refresh_p = QPushButton("刷新串口") btn_recv_cnt = QPushButton("收") btn_send_cnt = QPushButton("发") btn_clean_scn = QPushButton("清除窗口") self.btn_Open = QPushButton("打开串口") btn_refresh_p.clicked.connect(self.refresh_p_fn) btn_clean_scn.clicked.connect(self.clean_screen_fn) self.btn_Open.clicked.connect(self.OpenSerial) line_1.addWidget(self.serial_cb) line_1.addWidget(btn_refresh_p) line_1.addWidget(self.baudRate_cb) line_1.addWidget(self.btn_Open) line_1.addWidget(btn_recv_cnt) line_1.addWidget(btn_send_cnt) line_1.addWidget(btn_clean_scn) line_1.setContentsMargins(0, 0, 0, 0) # 发送文本框及发送按钮 line_2 = QHBoxLayout() self.cbox_sendData = QComboBox() self.cbox_sendData.setEditable(True) self.checkBox_Hex = QCheckBox("HEX发送") self.checkBox_Hex.setEnabled(False) self.checkBox_CF = QCheckBox("加回车换行") self.checkBox_CF.setChecked(True) btn_Send = QPushButton("发送数据") btn_Send.clicked.connect(lambda: self.send_btn_fn()) line_2.addWidget(self.cbox_sendData) line_2.addWidget(self.checkBox_Hex) line_2.addWidget(self.checkBox_CF) line_2.addWidget(btn_Send) line_2.setStretch(0, 42) line_2.setStretch(1, 10) line_2.setStretch(2, 10) line_2.setStretch(3, 10) # 预定义的AT指令按键矩阵 line_3 = QGridLayout() names = [ 'AT', 'AT+GMR', 'AT+RST', 'AT+SLEEP', 'AT+RESTORE', 'AT+SCAN', 'AT+DISCONNECT', 'AT+NAME?', 'AT+BAUD?', 'AT+MAC?', 'AT+ADDR?', 'AT+MODE?', 'AT+STATE?', 'AT+MESHNAME?' ] positions = [(i, j) for i in range(2) for j in range(7)] for name, position in zip(names, positions): if name == ' ': continue button = QPushButton(name) button.clicked.connect(lambda: self.grid_btn_fn()) line_3.addWidget(button, *position) self.layout.addWidget(self.tbox_log) self.layout.addLayout(line_1) self.layout.addLayout(line_2) self.layout.addLayout(line_3) self.setLayout(self.layout) self.refresh_p_fn()
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.resize(950, 700) screenRect = QDesktopWidget().screenGeometry() if globalSettings.windowGeometry: self.restoreGeometry(globalSettings.windowGeometry) else: self.move((screenRect.width()-self.width())/2, (screenRect.height()-self.height())/2) if not screenRect.contains(self.geometry()): self.showMaximized() if sys.platform.startswith('darwin'): # https://github.com/retext-project/retext/issues/198 searchPaths = QIcon.themeSearchPaths() searchPaths.append('/opt/local/share/icons') searchPaths.append('/usr/local/share/icons') QIcon.setThemeSearchPaths(searchPaths) if globalSettings.iconTheme: QIcon.setThemeName(globalSettings.iconTheme) if QIcon.themeName() in ('hicolor', ''): if not QFile.exists(getBundledIcon('document-new')): QIcon.setThemeName(get_icon_theme()) if QFile.exists(getBundledIcon('retext')): self.setWindowIcon(QIcon(getBundledIcon('retext'))) elif QFile.exists('/usr/share/pixmaps/retext.png'): self.setWindowIcon(QIcon('/usr/share/pixmaps/retext.png')) else: self.setWindowIcon(QIcon.fromTheme('retext', QIcon.fromTheme('accessories-text-editor'))) self.tabWidget = QTabWidget(self) self.initTabWidget() self.setCentralWidget(self.tabWidget) self.tabWidget.currentChanged.connect(self.changeIndex) self.tabWidget.tabCloseRequested.connect(self.closeTab) self.toolBar = QToolBar(self.tr('File toolbar'), self) self.addToolBar(Qt.TopToolBarArea, self.toolBar) self.editBar = QToolBar(self.tr('Edit toolbar'), self) self.addToolBar(Qt.TopToolBarArea, self.editBar) self.searchBar = QToolBar(self.tr('Search toolbar'), self) self.addToolBar(Qt.BottomToolBarArea, self.searchBar) self.toolBar.setVisible(not globalSettings.hideToolBar) self.editBar.setVisible(not globalSettings.hideToolBar) self.actionNew = self.act(self.tr('New'), 'document-new', self.createNew, shct=QKeySequence.New) self.actionNew.setPriority(QAction.LowPriority) self.actionOpen = self.act(self.tr('Open'), 'document-open', self.openFile, shct=QKeySequence.Open) self.actionOpen.setPriority(QAction.LowPriority) self.actionSetEncoding = self.act(self.tr('Set encoding'), trig=self.showEncodingDialog) self.actionSetEncoding.setEnabled(False) self.actionReload = self.act(self.tr('Reload'), 'view-refresh', lambda: self.currentTab.readTextFromFile()) self.actionReload.setEnabled(False) self.actionSave = self.act(self.tr('Save'), 'document-save', self.saveFile, shct=QKeySequence.Save) self.actionSave.setEnabled(False) self.actionSave.setPriority(QAction.LowPriority) self.actionSaveAs = self.act(self.tr('Save as'), 'document-save-as', self.saveFileAs, shct=QKeySequence.SaveAs) self.actionNextTab = self.act(self.tr('Next tab'), 'go-next', lambda: self.switchTab(1), shct=Qt.CTRL+Qt.Key_PageDown) self.actionPrevTab = self.act(self.tr('Previous tab'), 'go-previous', lambda: self.switchTab(-1), shct=Qt.CTRL+Qt.Key_PageUp) self.actionCloseCurrentTab = self.act(self.tr('Close tab'), 'window-close', lambda: self.closeTab(self.ind), shct=QKeySequence.Close) self.actionPrint = self.act(self.tr('Print'), 'document-print', self.printFile, shct=QKeySequence.Print) self.actionPrint.setPriority(QAction.LowPriority) self.actionPrintPreview = self.act(self.tr('Print preview'), 'document-print-preview', self.printPreview) self.actionViewHtml = self.act(self.tr('View HTML code'), 'text-html', self.viewHtml) self.actionChangeEditorFont = self.act(self.tr('Change editor font'), trig=self.changeEditorFont) self.actionChangePreviewFont = self.act(self.tr('Change preview font'), trig=self.changePreviewFont) self.actionSearch = self.act(self.tr('Find text'), 'edit-find', self.search, shct=QKeySequence.Find) self.actionGoToLine = self.act(self.tr('Go to line'), trig=self.goToLine, shct=Qt.CTRL+Qt.Key_G) self.searchBar.visibilityChanged.connect(self.searchBarVisibilityChanged) self.actionPreview = self.act(self.tr('Preview'), shct=Qt.CTRL+Qt.Key_E, trigbool=self.preview) if QIcon.hasThemeIcon('document-preview'): self.actionPreview.setIcon(QIcon.fromTheme('document-preview')) elif QIcon.hasThemeIcon('preview-file'): self.actionPreview.setIcon(QIcon.fromTheme('preview-file')) elif QIcon.hasThemeIcon('x-office-document'): self.actionPreview.setIcon(QIcon.fromTheme('x-office-document')) else: self.actionPreview.setIcon(QIcon(getBundledIcon('document-preview'))) self.actionLivePreview = self.act(self.tr('Live preview'), shct=Qt.CTRL+Qt.Key_L, trigbool=self.enableLivePreview) menuPreview = QMenu() menuPreview.addAction(self.actionLivePreview) self.actionPreview.setMenu(menuPreview) self.actionInsertTable = self.act(self.tr('Insert table'), trig=lambda: self.insertFormatting('table')) self.actionTableMode = self.act(self.tr('Table editing mode'), shct=Qt.CTRL+Qt.Key_T, trigbool=lambda x: self.currentTab.editBox.enableTableMode(x)) if ReTextFakeVimHandler: self.actionFakeVimMode = self.act(self.tr('FakeVim mode'), shct=Qt.CTRL+Qt.ALT+Qt.Key_V, trigbool=self.enableFakeVimMode) if globalSettings.useFakeVim: self.actionFakeVimMode.setChecked(True) self.enableFakeVimMode(True) self.actionFullScreen = self.act(self.tr('Fullscreen mode'), 'view-fullscreen', shct=Qt.Key_F11, trigbool=self.enableFullScreen) self.actionFullScreen.setChecked(self.isFullScreen()) self.actionFullScreen.setPriority(QAction.LowPriority) self.actionConfig = self.act(self.tr('Preferences'), icon='preferences-system', trig=self.openConfigDialog) self.actionConfig.setMenuRole(QAction.PreferencesRole) self.actionSaveHtml = self.act('HTML', 'text-html', self.saveFileHtml) self.actionPdf = self.act('PDF', 'application-pdf', self.savePdf) self.actionOdf = self.act('ODT', 'x-office-document', self.saveOdf) self.getExportExtensionsList() self.actionQuit = self.act(self.tr('Quit'), 'application-exit', shct=QKeySequence.Quit) self.actionQuit.setMenuRole(QAction.QuitRole) self.actionQuit.triggered.connect(self.close) self.actionUndo = self.act(self.tr('Undo'), 'edit-undo', lambda: self.currentTab.editBox.undo(), shct=QKeySequence.Undo) self.actionRedo = self.act(self.tr('Redo'), 'edit-redo', lambda: self.currentTab.editBox.redo(), shct=QKeySequence.Redo) self.actionCopy = self.act(self.tr('Copy'), 'edit-copy', lambda: self.currentTab.editBox.copy(), shct=QKeySequence.Copy) self.actionCut = self.act(self.tr('Cut'), 'edit-cut', lambda: self.currentTab.editBox.cut(), shct=QKeySequence.Cut) self.actionPaste = self.act(self.tr('Paste'), 'edit-paste', lambda: self.currentTab.editBox.paste(), shct=QKeySequence.Paste) self.actionPasteImage = self.act(self.tr('Paste image'), 'edit-paste', lambda: self.currentTab.editBox.pasteImage(), shct=Qt.CTRL+Qt.SHIFT+Qt.Key_V) self.actionMoveUp = self.act(self.tr('Move line up'), 'go-up', lambda: self.currentTab.editBox.moveLineUp(), shct=Qt.ALT+Qt.Key_Up) self.actionMoveDown = self.act(self.tr('Move line down'), 'go-down', lambda: self.currentTab.editBox.moveLineDown(), shct=Qt.ALT+Qt.Key_Down) self.actionUndo.setEnabled(False) self.actionRedo.setEnabled(False) self.actionCopy.setEnabled(False) self.actionCut.setEnabled(False) qApp = QApplication.instance() qApp.clipboard().dataChanged.connect(self.clipboardDataChanged) self.clipboardDataChanged() if enchant is not None: self.actionEnableSC = self.act(self.tr('Enable'), trigbool=self.enableSpellCheck) self.actionSetLocale = self.act(self.tr('Set locale'), trig=self.changeLocale) self.actionWebKit = self.act(self.tr('Use WebKit renderer'), trigbool=self.enableWebKit) if ReTextWebKitPreview is None: globalSettings.useWebKit = False self.actionWebKit.setEnabled(False) self.actionWebKit.setChecked(globalSettings.useWebKit) self.actionWebEngine = self.act(self.tr('Use WebEngine (Chromium) renderer'), trigbool=self.enableWebEngine) if ReTextWebEnginePreview is None: globalSettings.useWebEngine = False self.actionWebEngine.setChecked(globalSettings.useWebEngine) self.actionShow = self.act(self.tr('Show directory'), 'system-file-manager', self.showInDir) self.actionFind = self.act(self.tr('Next'), 'go-next', self.find, shct=QKeySequence.FindNext) self.actionFindPrev = self.act(self.tr('Previous'), 'go-previous', lambda: self.find(back=True), shct=QKeySequence.FindPrevious) self.actionReplace = self.act(self.tr('Replace'), 'edit-find-replace', lambda: self.find(replace=True)) self.actionReplaceAll = self.act(self.tr('Replace all'), trig=self.replaceAll) menuReplace = QMenu() menuReplace.addAction(self.actionReplaceAll) self.actionReplace.setMenu(menuReplace) self.actionCloseSearch = self.act(self.tr('Close'), 'window-close', lambda: self.searchBar.setVisible(False), shct=QKeySequence.Cancel) self.actionCloseSearch.setPriority(QAction.LowPriority) self.actionHelp = self.act(self.tr('Get help online'), 'help-contents', self.openHelp) self.aboutWindowTitle = self.tr('About ReText') self.actionAbout = self.act(self.aboutWindowTitle, 'help-about', self.aboutDialog) self.actionAbout.setMenuRole(QAction.AboutRole) self.actionAboutQt = self.act(self.tr('About Qt')) self.actionAboutQt.setMenuRole(QAction.AboutQtRole) self.actionAboutQt.triggered.connect(qApp.aboutQt) availableMarkups = markups.get_available_markups() if not availableMarkups: print('Warning: no markups are available!') if len(availableMarkups) > 1: self.chooseGroup = QActionGroup(self) markupActions = [] for markup in availableMarkups: markupAction = self.act(markup.name, trigbool=self.markupFunction(markup)) if markup.name == globalSettings.defaultMarkup: markupAction.setChecked(True) self.chooseGroup.addAction(markupAction) markupActions.append(markupAction) self.actionBold = self.act(self.tr('Bold'), shct=QKeySequence.Bold, trig=lambda: self.insertFormatting('bold')) self.actionItalic = self.act(self.tr('Italic'), shct=QKeySequence.Italic, trig=lambda: self.insertFormatting('italic')) self.actionUnderline = self.act(self.tr('Underline'), shct=QKeySequence.Underline, trig=lambda: self.insertFormatting('underline')) self.usefulTags = ('header', 'italic', 'bold', 'underline', 'numbering', 'bullets', 'image', 'link', 'inline code', 'code block', 'blockquote', 'table') self.usefulChars = ('deg', 'divide', 'euro', 'hellip', 'laquo', 'larr', 'lsquo', 'mdash', 'middot', 'minus', 'nbsp', 'ndash', 'raquo', 'rarr', 'rsquo', 'times') self.formattingBox = QComboBox(self.editBar) self.formattingBox.addItem(self.tr('Formatting')) self.formattingBox.addItems(self.usefulTags) self.formattingBox.activated[str].connect(self.insertFormatting) self.symbolBox = QComboBox(self.editBar) self.symbolBox.addItem(self.tr('Symbols')) self.symbolBox.addItems(self.usefulChars) self.symbolBox.activated.connect(self.insertSymbol) self.updateStyleSheet() menubar = self.menuBar() menuFile = menubar.addMenu(self.tr('File')) menuEdit = menubar.addMenu(self.tr('Edit')) menuHelp = menubar.addMenu(self.tr('Help')) menuFile.addAction(self.actionNew) menuFile.addAction(self.actionOpen) self.menuRecentFiles = menuFile.addMenu(self.tr('Open recent')) self.menuRecentFiles.aboutToShow.connect(self.updateRecentFiles) menuFile.addAction(self.actionShow) menuFile.addAction(self.actionSetEncoding) menuFile.addAction(self.actionReload) menuFile.addSeparator() menuFile.addAction(self.actionSave) menuFile.addAction(self.actionSaveAs) menuFile.addSeparator() menuFile.addAction(self.actionNextTab) menuFile.addAction(self.actionPrevTab) menuFile.addAction(self.actionCloseCurrentTab) menuFile.addSeparator() menuExport = menuFile.addMenu(self.tr('Export')) menuExport.addAction(self.actionSaveHtml) menuExport.addAction(self.actionOdf) menuExport.addAction(self.actionPdf) if self.extensionActions: menuExport.addSeparator() for action, mimetype in self.extensionActions: menuExport.addAction(action) menuExport.aboutToShow.connect(self.updateExtensionsVisibility) menuFile.addAction(self.actionPrint) menuFile.addAction(self.actionPrintPreview) menuFile.addSeparator() menuFile.addAction(self.actionQuit) menuEdit.addAction(self.actionUndo) menuEdit.addAction(self.actionRedo) menuEdit.addSeparator() menuEdit.addAction(self.actionCut) menuEdit.addAction(self.actionCopy) menuEdit.addAction(self.actionPaste) menuEdit.addAction(self.actionPasteImage) menuEdit.addSeparator() menuEdit.addAction(self.actionMoveUp) menuEdit.addAction(self.actionMoveDown) menuEdit.addSeparator() if enchant is not None: menuSC = menuEdit.addMenu(self.tr('Spell check')) menuSC.addAction(self.actionEnableSC) menuSC.addAction(self.actionSetLocale) menuEdit.addAction(self.actionSearch) menuEdit.addAction(self.actionGoToLine) menuEdit.addAction(self.actionChangeEditorFont) menuEdit.addAction(self.actionChangePreviewFont) menuEdit.addSeparator() if len(availableMarkups) > 1: self.menuMode = menuEdit.addMenu(self.tr('Default markup')) for markupAction in markupActions: self.menuMode.addAction(markupAction) menuFormat = menuEdit.addMenu(self.tr('Formatting')) menuFormat.addAction(self.actionBold) menuFormat.addAction(self.actionItalic) menuFormat.addAction(self.actionUnderline) if ReTextWebKitPreview is not None or ReTextWebEnginePreview is None: menuEdit.addAction(self.actionWebKit) else: menuEdit.addAction(self.actionWebEngine) menuEdit.addSeparator() menuEdit.addAction(self.actionViewHtml) menuEdit.addAction(self.actionPreview) menuEdit.addAction(self.actionInsertTable) menuEdit.addAction(self.actionTableMode) if ReTextFakeVimHandler: menuEdit.addAction(self.actionFakeVimMode) menuEdit.addSeparator() menuEdit.addAction(self.actionFullScreen) menuEdit.addAction(self.actionConfig) menuHelp.addAction(self.actionHelp) menuHelp.addSeparator() menuHelp.addAction(self.actionAbout) menuHelp.addAction(self.actionAboutQt) self.toolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.toolBar.addAction(self.actionNew) self.toolBar.addSeparator() self.toolBar.addAction(self.actionOpen) self.toolBar.addAction(self.actionSave) self.toolBar.addAction(self.actionPrint) self.toolBar.addSeparator() self.toolBar.addAction(self.actionPreview) self.toolBar.addAction(self.actionFullScreen) self.editBar.addAction(self.actionUndo) self.editBar.addAction(self.actionRedo) self.editBar.addSeparator() self.editBar.addAction(self.actionCut) self.editBar.addAction(self.actionCopy) self.editBar.addAction(self.actionPaste) self.editBar.addSeparator() self.editBar.addWidget(self.formattingBox) self.editBar.addWidget(self.symbolBox) self.searchEdit = QLineEdit(self.searchBar) self.searchEdit.setPlaceholderText(self.tr('Search')) self.searchEdit.returnPressed.connect(self.find) self.replaceEdit = QLineEdit(self.searchBar) self.replaceEdit.setPlaceholderText(self.tr('Replace with')) self.replaceEdit.returnPressed.connect(self.find) self.csBox = QCheckBox(self.tr('Case sensitively'), self.searchBar) self.searchBar.addWidget(self.searchEdit) self.searchBar.addWidget(self.replaceEdit) self.searchBar.addSeparator() self.searchBar.addWidget(self.csBox) self.searchBar.addAction(self.actionFindPrev) self.searchBar.addAction(self.actionFind) self.searchBar.addAction(self.actionReplace) self.searchBar.addAction(self.actionCloseSearch) self.searchBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.searchBar.setVisible(False) self.autoSaveEnabled = globalSettings.autoSave if self.autoSaveEnabled: timer = QTimer(self) timer.start(60000) timer.timeout.connect(self.saveAll) self.ind = None if enchant is not None: self.sl = globalSettings.spellCheckLocale try: enchant.Dict(self.sl or None) except enchant.errors.Error as e: warnings.warn(str(e), RuntimeWarning) globalSettings.spellCheck = False if globalSettings.spellCheck: self.actionEnableSC.setChecked(True) self.fileSystemWatcher = QFileSystemWatcher() self.fileSystemWatcher.fileChanged.connect(self.fileChanged)
def _add_advanced_options(self, adv_vbox: QVBoxLayout) -> None: self.cb_rbf = QCheckBox(_('Keep Replace-By-Fee enabled')) self.cb_rbf.setChecked(True) adv_vbox.addWidget(self.cb_rbf)
def __init__(self, iface, layer, tree, dlg): QTreeWidgetItem.__init__(self) self.iface = iface self.layer = layer self.setText(0, layer.name()) self.setIcon(0, self.layerIcon) project = QgsProject.instance() if project.layerTreeRoot().findLayer(layer.id()).isVisible(): self.setCheckState(0, Qt.Checked) else: self.setCheckState(0, Qt.Unchecked) self.visibleItem = QTreeWidgetItem(self) self.visibleCheck = QCheckBox() vis = layer.customProperty("qgis2web/Visible", True) if (vis == 0 or unicode(vis).lower() == "false"): self.visibleCheck.setChecked(False) else: self.visibleCheck.setChecked(True) self.visibleItem.setText(0, "Visible") self.addChild(self.visibleItem) tree.setItemWidget(self.visibleItem, 1, self.visibleCheck) if layer.type() == layer.VectorLayer: if layer.providerType() == 'WFS': self.jsonItem = QTreeWidgetItem(self) self.jsonCheck = QCheckBox() if layer.customProperty("qgis2web/Encode to JSON") == 2: self.jsonCheck.setChecked(True) self.jsonItem.setText(0, "Encode to JSON") self.jsonCheck.stateChanged.connect(self.changeJSON) self.addChild(self.jsonItem) tree.setItemWidget(self.jsonItem, 1, self.jsonCheck) if layer.geometryType() == QgsWkbTypes.PointGeometry: self.clusterItem = QTreeWidgetItem(self) self.clusterCheck = QCheckBox() if layer.customProperty("qgis2web/Cluster") == 2: self.clusterCheck.setChecked(True) self.clusterItem.setText(0, "Cluster") self.clusterCheck.stateChanged.connect(self.changeCluster) self.addChild(self.clusterItem) tree.setItemWidget(self.clusterItem, 1, self.clusterCheck) self.popupItem = QTreeWidgetItem(self) self.popupItem.setText(0, "Popup fields") options = [] fields = self.layer.fields() for f in fields: fieldIndex = fields.indexFromName(unicode(f.name())) editorWidget = layer.editorWidgetSetup(fieldIndex).type() if editorWidget == 'Hidden': continue options.append(f.name()) for option in options: self.attr = QTreeWidgetItem(self) self.attrWidget = QComboBox() self.attrWidget.addItem("no label") self.attrWidget.addItem("inline label") self.attrWidget.addItem("header label") custProp = layer.customProperty("qgis2web/popup/" + option) if (custProp != "" and custProp is not None): self.attrWidget.setCurrentIndex( self.attrWidget.findText( layer.customProperty("qgis2web/popup/" + option))) self.attr.setText(1, option) self.popupItem.addChild(self.attr) tree.setItemWidget(self.attr, 2, self.attrWidget) self.addChild(self.popupItem) else: if layer.providerType() == 'wms': self.getFeatureInfoItem = QTreeWidgetItem(self) self.getFeatureInfoCheck = QCheckBox() if layer.customProperty("qgis2web/GetFeatureInfo") == 2: self.getFeatureInfoCheck.setChecked(True) self.getFeatureInfoItem.setText(0, "Enable GetFeatureInfo?") self.getFeatureInfoCheck.stateChanged.connect( self.changeGetFeatureInfo) self.addChild(self.getFeatureInfoItem) tree.setItemWidget(self.getFeatureInfoItem, 1, self.getFeatureInfoCheck)
def __init__(self, lowerBandwidth, upperBandwidth, dspCutoffFreq, dspEnabled, sampleRate, parent): super().__init__(parent) dspFreqGroupBox = QGroupBox("DSP Offset Removal Cutoff Frequency") lowFreqGroupBox = QGroupBox("Low Frequency Bandwidth") highFreqGroupBox = QGroupBox("High Frequency Bandwidth") dspFreqLayout = QVBoxLayout() lowFreqLayout = QVBoxLayout() highFreqLayout = QVBoxLayout() dspFreqSelectLayout = QHBoxLayout() lowFreqSelectLayout = QHBoxLayout() highFreqSelectLayout = QHBoxLayout() dspEnableLayout = QHBoxLayout() self.dspEnableCheckBox = QCheckBox() self.dspEnableCheckBox.toggled.connect(self.onDspCheckBoxChanged) dspRangeText = "DSP Cutoff Range at " dspRangeText += "%.2f" % (sampleRate / 1000.0) dspRangeText += " kS/s: " dspRangeText += "%.3f" % (0.000004857 * sampleRate) dspRangeText += " Hz to " dspRangeText += "%.0f" % (0.1103 * sampleRate) dspRangeText += " Hz." self.dspRangeLabel = QLabel(dspRangeText) self.lowRangeLabel = QLabel("Lower Bandwidth Range: 0.1 Hz to 500 Hz.") self.highRangeLabel = QLabel( "Upper Bandwidth Range: 100 Hz to 20 kHz.") self.dspFreqLineEdit = QLineEdit("%.2f" % dspCutoffFreq) self.dspFreqLineEdit.setValidator( QDoubleValidator(0.001, 9999.999, 3, self)) self.dspFreqLineEdit.textChanged.connect(self.onLineEditTextChanged) self.lowFreqLineEdit = QLineEdit("%.2f" % lowerBandwidth) self.lowFreqLineEdit.setValidator(QDoubleValidator( 0.1, 500.0, 3, self)) self.lowFreqLineEdit.textChanged.connect(self.onLineEditTextChanged) self.highFreqLineEdit = QLineEdit("%.0f" % upperBandwidth) self.highFreqLineEdit.setValidator( QDoubleValidator(100.0, 20000.0, 0, self)) self.highFreqLineEdit.textChanged.connect(self.onLineEditTextChanged) dspFreqSelectLayout.addWidget(QLabel("DSP Cutoff Frequency")) dspFreqSelectLayout.addWidget(self.dspFreqLineEdit) dspFreqSelectLayout.addWidget(QLabel("Hz")) dspFreqSelectLayout.addStretch() lowFreqSelectLayout.addWidget(QLabel("Amplifier Lower Bandwidth")) lowFreqSelectLayout.addWidget(self.lowFreqLineEdit) lowFreqSelectLayout.addWidget(QLabel("Hz")) lowFreqSelectLayout.addStretch() highFreqSelectLayout.addWidget(QLabel("Amplifier Upper Bandwidth")) highFreqSelectLayout.addWidget(self.highFreqLineEdit) highFreqSelectLayout.addWidget(QLabel("Hz")) highFreqSelectLayout.addStretch() dspEnableLayout.addWidget(self.dspEnableCheckBox) dspEnableLayout.addWidget( QLabel("Enable On-Chip DSP Offset Removal Filter")) dspEnableLayout.addStretch() lowFreqLayout.addLayout(lowFreqSelectLayout) lowFreqLayout.addWidget(self.lowRangeLabel) dspFreqLayout.addLayout(dspEnableLayout) dspFreqLayout.addLayout(dspFreqSelectLayout) dspFreqLayout.addWidget(self.dspRangeLabel) highFreqLayout.addLayout(highFreqSelectLayout) highFreqLayout.addWidget(self.highRangeLabel) dspFreqGroupBox.setLayout(dspFreqLayout) lowFreqGroupBox.setLayout(lowFreqLayout) highFreqGroupBox.setLayout(highFreqLayout) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) mainLayout = QVBoxLayout() mainLayout.addWidget(dspFreqGroupBox) mainLayout.addWidget(lowFreqGroupBox) mainLayout.addWidget(highFreqGroupBox) mainLayout.addWidget(self.buttonBox) self.setLayout(mainLayout) self.setWindowTitle("Select Amplifier Bandwidth") self.onLineEditTextChanged() self.dspEnableCheckBox.setChecked(dspEnabled) self.onDspCheckBoxChanged(dspEnabled)
def initUI(self): """Creates widgets and sets properties""" # Setup screen self.setGeometry(self.SCREEN_OFFSET_X, self.SCREEN_OFFSET_Y, self.SCREEN_X, self.SCREEN_Y) self.setWindowTitle(self.WINDOW_TITLE) self.setStyleSheet("background-color: #DAD7D7;") # Setup select folder button self.directory_button = QPushButton('Select Downloaded Spotify Data Folder', self) self.directory_button.setFont(QFont(self.BUTTON_FONT, 18)) self.directory_button.adjustSize() self.directory_button.move(int((self.SCREEN_X*.5) - (self.directory_button.size().width()*.5)), self.DIRECTORY_BUTTON_Y) self.directory_button.clicked.connect(self.select_file_btn) # Sets default path self.selected_directory_path = None # Setup Success Label self.success_label = QLabel("Selected Folder: Unsucessful", self) self.success_label.setStyleSheet("color: #F61313; font-size: 15px;") self.success_label.adjustSize() self.success_label.move(self.SUCCESS_LABEL_X, self.SUCCESS_LABEL_Y) # Setup Total time Label total_listened_ms_ms_ms self.total_time_label = QLabel("Total time listened: 0 hours", self) self.total_time_label.adjustSize() self.total_time_label.move(self.TOTAL_TIME_LABEL_X, self.TOTAL_TIME_LABEL_Y) # Creates 3 checkboxes self.option1_cbx = QCheckBox("Most Played Artist", self) self.option1_cbx.setGeometry(self.CBX_X, self.CBX_Y_1, self.CBX_WIDTH, self.CBX_HEIGHT) self.option2_cbx = QCheckBox("Artist then Track", self) self.option2_cbx.setGeometry(self.CBX_X, self.CBX_Y_2, self.CBX_WIDTH, self.CBX_HEIGHT) self.option3_cbx = QCheckBox("Track then Artist", self) self.option3_cbx.setGeometry(self.CBX_X, self.CBX_Y_3, self.CBX_WIDTH, self.CBX_HEIGHT) self.option4_cbx = QCheckBox("Time per Artist", self) self.option4_cbx.setGeometry(self.CBX_X, self.CBX_Y_4, self.CBX_WIDTH, self.CBX_HEIGHT) # Calls update method to uncheck other boxes self.option1_cbx.stateChanged.connect(self.cbx_update) self.option2_cbx.stateChanged.connect(self.cbx_update) self.option3_cbx.stateChanged.connect(self.cbx_update) self.option4_cbx.stateChanged.connect(self.cbx_update) # Setup Display button self.display_button = QPushButton('Display Data', self) self.display_button.setFont(QFont(self.BUTTON_FONT, 20)) self.display_button.adjustSize() self.display_button.move(self.DISPLAY_BUTTON_X, self.DISPLAY_BUTTON_Y) self.display_button.clicked.connect(self.file_display) # Creates Scroll label self.scroll_label = ScrollLabel(self) self.scroll_label.setGeometry(self.SCROLL_DISPLAY_X, self.SCROLL_DISPLAY_Y, self.SCROLL_DISPLAY_WIDTH, self.SCROLL_DISPLAY_HEIGHT) # ComboBox selector self.time_combox = QComboBox(self) self.time_combox.addItem("Seconds") self.time_combox.addItem("Hours") self.time_combox.addItem("Days") self.time_combox.setGeometry(self.COMBOX_X, self.COMBOX_Y, self.COMBOX_WIDTH, self.COMBOX_HEIGHT) self.time_combox.activated[str].connect(self.combox_update) # Sort toggle button self.toggle_button = QPushButton('Descending Sort', self) self.toggle_button.setGeometry(self.TOGGLE_BUTTON_X, self.TOGGLE_BUTTON_Y, self.TOGGLE_BUTTON_WIDTH, self.TOGGLE_BUTTON_HEIGHT) self.toggle_button.setCheckable(True) self.toggle_button.clicked.connect(self.toggle_btn_update) self.toggle_button.setStyleSheet("background-color : lightgrey")
def __init__(self, Notebook, MainWindow, Parent): # Store Parameters self.Notebook = Notebook self.MainWindow = MainWindow self.Parent = Parent # Create Markdown Parser self.Renderer = MarkdownRenderers.Renderer(self.Notebook) self.MarkdownParser = mistune.Markdown(renderer=self.Renderer) # QDialog Init super().__init__(parent=self.Parent) # Variables self.InsertAccepted = False self.InsertSubPageLinks = False self.SubPageLinksSeparator = None self.InsertIndexPath = None self.AddToolTip = None self.ToolTipText = None self.InsertIndexPaths = None self.Separators = {} self.Separators["Paragraph"] = "\n\n" self.Separators["New Line"] = " \n" self.Width = max(self.Parent.width() - 100, 100) self.Height = max(self.Parent.height() - 100, 100) # Search Line Edit self.SearchLineEdit = SearchLineEdit(self) self.SearchLineEdit.setPlaceholderText("Search") self.SearchLineEdit.textChanged.connect(self.PopulateNotebookDisplay) self.SearchLineEdit.setFocus() # Match Case Check Box self.MatchCaseCheckBox = QCheckBox("Match Case") self.MatchCaseCheckBox.stateChanged.connect(self.PopulateNotebookDisplay) # Notebook Display self.NotebookDisplay = NotebookDisplay(self) self.NotebookDisplay.setHeaderHidden(True) self.NotebookDisplay.header().setStretchLastSection(False) self.NotebookDisplay.header().setSectionResizeMode(QHeaderView.ResizeToContents) self.NotebookDisplay.itemSelectionChanged.connect(self.UpdatePreview) # Preview Text Edit self.PreviewTextEdit = QTextEdit() self.PreviewTextEdit.setReadOnly(True) # Insert Sub Page Links Check Box self.InsertSubPageLinksCheckBox = QCheckBox("Insert Sub Page Links") # Sub Page Links Separator self.SubPageLinksSeparatorLabel = QLabel("Sub Page Links Separator: ") self.SubPageLinksSeparatorComboBox = QComboBox() self.SubPageLinksSeparatorComboBox.addItems(["Paragraph", "New Line"]) self.SubPageLinksSeparatorComboBox.setEditable(False) # Tool Tip self.AddToolTipCheckBox = QCheckBox("Add Tool Tip") self.AddToolTipCheckBox.setChecked(True) self.ToolTipTextLabel = QLabel("Tool Tip Text:") self.ToolTipTextLineEdit = QLineEdit() self.ToolTipTextLineEdit.setPlaceholderText("Page Name") # Buttons self.InsertButton = QPushButton("Insert") self.InsertButton.clicked.connect(self.Insert) self.CancelButton = QPushButton("Cancel") self.CancelButton.clicked.connect(self.Cancel) # Create, Populate, and Set Layout self.Layout = QGridLayout() self.SearchLayout = QGridLayout() self.SearchLayout.addWidget(self.SearchLineEdit, 0, 0) self.SearchLayout.addWidget(self.MatchCaseCheckBox, 0, 1) self.Layout.addLayout(self.SearchLayout, 0, 0, 1, 6) self.NotebookDisplayLayout = QGridLayout() self.NotebookDisplayLayout.addWidget(self.NotebookDisplay, 0, 0) self.NotebookDisplayLayout.addWidget(self.PreviewTextEdit, 0, 1) self.NotebookDisplayLayout.setColumnStretch(1, 1) self.Layout.addLayout(self.NotebookDisplayLayout, 1, 0, 1, 6) self.Layout.addWidget(self.AddToolTipCheckBox, 2, 0) self.Layout.addWidget(self.ToolTipTextLabel, 2, 1) self.Layout.addWidget(self.ToolTipTextLineEdit, 2, 2) self.Layout.addWidget(self.InsertSubPageLinksCheckBox, 2, 3) self.Layout.addWidget(self.SubPageLinksSeparatorLabel, 2, 4) self.Layout.addWidget(self.SubPageLinksSeparatorComboBox, 2, 5) self.ButtonsLayout = QGridLayout() self.ButtonsLayout.addWidget(self.InsertButton, 0, 0) self.ButtonsLayout.addWidget(self.CancelButton, 0, 1) self.Layout.addLayout(self.ButtonsLayout, 3, 0, 1, 6) self.Layout.setColumnStretch(2, 1) self.setLayout(self.Layout) # Set Window Title and Icon self.setWindowTitle("Insert Link(s)") self.setWindowIcon(self.MainWindow.WindowIcon) # Window Resize self.Resize() # Populate Notebook Display self.PopulateNotebookDisplay() # Execute Dialog self.exec_()
def __init__(self, auxOutEnabledIn, auxOutChannelIn, parent): super().__init__(parent) self.auxOutEnabled = [0]*4 self.auxOutChannel = [0]*4 for port in range(4): self.auxOutEnabled[port] = auxOutEnabledIn[port] self.auxOutChannel[port] = auxOutChannelIn[port] enablePortACheckBox = QCheckBox( "Control auxiliary digital output on Port A from") enablePortACheckBox.toggled.connect(self.enablePortAChanged) enablePortACheckBox.setChecked(self.auxOutEnabled[0]) enablePortBCheckBox = QCheckBox( "Control auxiliary digital output on Port B from") enablePortBCheckBox.toggled.connect(self.enablePortBChanged) enablePortBCheckBox.setChecked(self.auxOutEnabled[1]) enablePortCCheckBox = QCheckBox( "Control auxiliary digital output on Port C from") enablePortCCheckBox.toggled.connect(self.enablePortCChanged) enablePortCCheckBox.setChecked(self.auxOutEnabled[2]) enablePortDCheckBox = QCheckBox( "Control auxiliary digital output on Port D from") enablePortDCheckBox.toggled.connect(self.enablePortDChanged) enablePortDCheckBox.setChecked(self.auxOutEnabled[3]) channelPortAComboBox = QComboBox() channelPortAComboBox.addItem("Digital Input 0") channelPortAComboBox.addItem("Digital Input 1") channelPortAComboBox.addItem("Digital Input 2") channelPortAComboBox.addItem("Digital Input 3") channelPortAComboBox.addItem("Digital Input 4") channelPortAComboBox.addItem("Digital Input 5") channelPortAComboBox.addItem("Digital Input 6") channelPortAComboBox.addItem("Digital Input 7") channelPortAComboBox.addItem("Digital Input 8") channelPortAComboBox.addItem("Digital Input 9") channelPortAComboBox.addItem("Digital Input 10") channelPortAComboBox.addItem("Digital Input 11") channelPortAComboBox.addItem("Digital Input 12") channelPortAComboBox.addItem("Digital Input 13") channelPortAComboBox.addItem("Digital Input 14") channelPortAComboBox.addItem("Digital Input 15") channelPortAComboBox.currentIndexChanged.connect( self.channelPortAChanged) channelPortAComboBox.setCurrentIndex(self.auxOutChannel[0]) channelPortBComboBox = QComboBox() channelPortBComboBox.addItem("Digital Input 0") channelPortBComboBox.addItem("Digital Input 1") channelPortBComboBox.addItem("Digital Input 2") channelPortBComboBox.addItem("Digital Input 3") channelPortBComboBox.addItem("Digital Input 4") channelPortBComboBox.addItem("Digital Input 5") channelPortBComboBox.addItem("Digital Input 6") channelPortBComboBox.addItem("Digital Input 7") channelPortBComboBox.addItem("Digital Input 8") channelPortBComboBox.addItem("Digital Input 9") channelPortBComboBox.addItem("Digital Input 10") channelPortBComboBox.addItem("Digital Input 11") channelPortBComboBox.addItem("Digital Input 12") channelPortBComboBox.addItem("Digital Input 13") channelPortBComboBox.addItem("Digital Input 14") channelPortBComboBox.addItem("Digital Input 15") channelPortBComboBox.currentIndexChanged.connect( self.channelPortBChanged) channelPortBComboBox.setCurrentIndex(self.auxOutChannel[1]) channelPortCComboBox = QComboBox() channelPortCComboBox.addItem("Digital Input 0") channelPortCComboBox.addItem("Digital Input 1") channelPortCComboBox.addItem("Digital Input 2") channelPortCComboBox.addItem("Digital Input 3") channelPortCComboBox.addItem("Digital Input 4") channelPortCComboBox.addItem("Digital Input 5") channelPortCComboBox.addItem("Digital Input 6") channelPortCComboBox.addItem("Digital Input 7") channelPortCComboBox.addItem("Digital Input 8") channelPortCComboBox.addItem("Digital Input 9") channelPortCComboBox.addItem("Digital Input 10") channelPortCComboBox.addItem("Digital Input 11") channelPortCComboBox.addItem("Digital Input 12") channelPortCComboBox.addItem("Digital Input 13") channelPortCComboBox.addItem("Digital Input 14") channelPortCComboBox.addItem("Digital Input 15") channelPortCComboBox.currentIndexChanged.connect( self.channelPortCChanged) channelPortCComboBox.setCurrentIndex(self.auxOutChannel[2]) channelPortDComboBox = QComboBox() channelPortDComboBox.addItem("Digital Input 0") channelPortDComboBox.addItem("Digital Input 1") channelPortDComboBox.addItem("Digital Input 2") channelPortDComboBox.addItem("Digital Input 3") channelPortDComboBox.addItem("Digital Input 4") channelPortDComboBox.addItem("Digital Input 5") channelPortDComboBox.addItem("Digital Input 6") channelPortDComboBox.addItem("Digital Input 7") channelPortDComboBox.addItem("Digital Input 8") channelPortDComboBox.addItem("Digital Input 9") channelPortDComboBox.addItem("Digital Input 10") channelPortDComboBox.addItem("Digital Input 11") channelPortDComboBox.addItem("Digital Input 12") channelPortDComboBox.addItem("Digital Input 13") channelPortDComboBox.addItem("Digital Input 14") channelPortDComboBox.addItem("Digital Input 15") channelPortDComboBox.currentIndexChanged.connect( self.channelPortDChanged) channelPortDComboBox.setCurrentIndex(self.auxOutChannel[3]) buttonBox = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) portALayout = QHBoxLayout() portALayout.addWidget(enablePortACheckBox) portALayout.addWidget(channelPortAComboBox) portALayout.addStretch(1) portBLayout = QHBoxLayout() portBLayout.addWidget(enablePortBCheckBox) portBLayout.addWidget(channelPortBComboBox) portBLayout.addStretch(1) portCLayout = QHBoxLayout() portCLayout.addWidget(enablePortCCheckBox) portCLayout.addWidget(channelPortCComboBox) portCLayout.addStretch(1) portDLayout = QHBoxLayout() portDLayout.addWidget(enablePortDCheckBox) portDLayout.addWidget(channelPortDComboBox) portDLayout.addStretch(1) label1 = QLabel( "All RHD2000 chips have an auxiliary digital output pin <b>auxout</b> that " "can be controlled via the SPI interface. This pin is brought out to a solder " "point <b>DO</b> on some RHD2000 amplifier boards. This dialog enables real-time " "control of this pin from a user-selected digital input on the USB interface board. " "A logic signal on the selected digital input will control the selected <b>auxout</b> " "pin with a latency of 4-5 amplifier sampling periods. For example, if the sampling " "frequency is 20 kS/s, the control latency will be 200-250 microseconds.") label1.setWordWrap(True) label2 = QLabel( "Note that the auxiliary output pin will only be controlled while data " "acquisition is running, and will be pulled to ground when acquisition stops.") label2.setWordWrap(True) label3 = QLabel( "The <b>auxout</b> pin is capable of driving up to 2 mA of current from the 3.3V " "supply. An external transistor can be added for additional current drive or voltage " "range.") label3.setWordWrap(True) controlLayout = QVBoxLayout() controlLayout.addLayout(portALayout) controlLayout.addLayout(portBLayout) controlLayout.addLayout(portCLayout) controlLayout.addLayout(portDLayout) controlBox = QGroupBox() controlBox.setLayout(controlLayout) mainLayout = QVBoxLayout() mainLayout.addWidget(label1) mainLayout.addWidget(controlBox) mainLayout.addWidget(label2) mainLayout.addWidget(label3) mainLayout.addWidget(buttonBox) self.setLayout(mainLayout) self.setWindowTitle("Configure Auxiliary Digital Output Control")
def __init__(self, parent=None): super(LiderConsolePage, self).__init__(parent) self.liderdb_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), '../../dist/liderdb.json') self.server_list_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), '../../dist/server_list.json') self.log_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), '../../dist/installer.log') if not os.path.exists( os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../dist')): os.makedirs( os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../dist')) self.status = StatusPage() self.im = InstallManager() self.msg_box = MessageBox() self.data = None ## repository parameters self.repoMainBox = QCheckBox("Ana Paket Deposu") self.repoTestBox = QCheckBox("Test Paket Deposu") self.repoMainBox.setChecked(True) self.repoLabel = QLabel("Depo Adresi:") self.repo_addr = QLineEdit( "deb [arch=amd64] http://repo.liderahenk.org/liderahenk stable main" ) self.repoKeyLdabel = QLabel("Depo Key Dosyası:") self.repo_key = QLineEdit( "http://repo.liderahenk.org/liderahenk-archive-keyring.asc") self.repoMainBox.stateChanged.connect(self.main_repo) self.repoTestBox.stateChanged.connect(self.test_repo) ## Repository Layout self.repoGroup = QGroupBox("Lider Ahenk Paket Deposu Ayarları") self.repoLayout = QGridLayout() self.repoLayout.addWidget(self.repoMainBox, 0, 0) self.repoLayout.addWidget(self.repoTestBox, 0, 1) self.repoLayout.addWidget(self.repoLabel, 1, 0) self.repoLayout.addWidget(self.repo_addr, 1, 1) self.repoLayout.addWidget(self.repoKeyLdabel, 2, 0) self.repoLayout.addWidget(self.repo_key, 2, 1) self.repoGroup.setLayout(self.repoLayout) #self.serverIpLabel = QLabel("Sunucu Adresi:") #self.server_ip = QLineEdit() #self.server_ip.setPlaceholderText("192.168.*.*") self.usernameLabel = QLabel("Kullanıcı Adı:") self.username = QLineEdit() self.username.setPlaceholderText("lider") self.passwordLabel = QLabel("Kullanıcı Parolası:") self.password = QLineEdit() self.password.setPlaceholderText("****") self.password.setEchoMode(QLineEdit.Password) self.addButton = QPushButton("Ekle") #self.checkControlButton = QPushButton("Bağlantıyı Kontrol Et") self.saveButton = QPushButton("Ayarları Kaydet") # disabled by default saveButton # self.saveButton.setDisabled(True) self.addButton.setVisible(False) ## Connect Layout self.connectGroup = QGroupBox("Lider Arayüz Erişim Bilgileri") self.connectLayout = QGridLayout() #self.connectLayout.addWidget(self.serverIpLabel, 2, 0) #self.connectLayout.addWidget(self.server_ip, 2, 1) self.connectLayout.addWidget(self.usernameLabel, 3, 0) self.connectLayout.addWidget(self.username, 3, 1) self.connectLayout.addWidget(self.passwordLabel, 4, 0) self.connectLayout.addWidget(self.password, 4, 1) self.connectLayout.addWidget(self.addButton, 5, 2) #self.connectLayout.addWidget(self.checkControlButton, 5, 1) self.connectGroup.setLayout(self.connectLayout) self.installButton = QPushButton("Kuruluma Başla") # Install Status Layout #self.statusGroup = QGroupBox() #self.status.statusLabel.setText("Lİder Arayüz Kurulum Durumu:") #self.statusGroup.setLayout(self.status.statusLayout) self.mainLayout = QVBoxLayout() self.mainLayout.addWidget(self.repoGroup) self.mainLayout.addWidget(self.connectGroup) self.mainLayout.addSpacing(12) self.mainLayout.addWidget(self.installButton) #self.mainLayout.addWidget(self.statusGroup) self.mainLayout.addStretch(1) self.setLayout(self.mainLayout) self.installButton.clicked.connect(self.install_lider_console)
def __init__(self, parent = None): super(SettingsWidget, self).__init__(parent) self.mainLayout = QVBoxLayout(self) self.mainLayout.setContentsMargins(0,0,0,0) self.resetting = False #flag to avoid double emission of signals during reset. @TODO find better solution ################ buttons ################ self.buttonsWidget = QWidget(self) self.buttonsLayout = QHBoxLayout(self.buttonsWidget) self.buttonsLayout.setContentsMargins(0,0,0,0) # reset button self.resetButton = QPushButton("&Reset") self.resetButton.clicked.connect(self.reset) # save as default button self.saveAsDefaultButton = QPushButton("&Save") self.saveAsDefaultButton.clicked.connect(util.saveSettings) #OK button self.OKButton = QPushButton("&OK") self.OKButton.setDefault(True) self.buttonsLayout.addWidget(self.saveAsDefaultButton) self.buttonsLayout.addWidget(self.resetButton) self.buttonsLayout.addWidget(self.OKButton) ###################### tabs ################ self.tabs = QTabWidget(self) self.tabs.setStyleSheet(f"QTabWidget::tab-bar {{alignment: center;}} .QTabBar::tab {{height: 50px; width: {int(320/3)}px;}}") #######--------> Color <--------####### self.ColorTab = QWidget(self.tabs) self.tabs.addTab(self.ColorTab, "Color") self.ColorLayout = QGridLayout(self.ColorTab) # sliders and labels# self.ColorSliders = {} self.ColorLabels = {} #### LED ##### for i, name in enumerate(["Red", "Green", "Blue", "Brigh"]): slid = QSlider(Qt.Vertical) slid.setMaximum(255) slid.setValue(constants.settings["Color"][f"LED_{name}"]) slid.valueChanged.connect(self.updateLEDColors) label = QLabel(f"{name}\n{slid.value()}" , alignment = Qt.AlignCenter) self.ColorLayout.addWidget(label, 0, i) self.ColorLayout.addWidget(slid , 1, i) self.ColorSliders[name] = slid self.ColorLabels [name] = label #### capture ##### slid = util.IntervalSlider(Qt.Vertical, maxValue = 1000, interval = 25) slid.setValue(constants.settings["Color"]["exposureTime"]) label = QLabel(f"Exp\n{slid.value()}" , alignment = Qt.AlignCenter) slid.valueChanged.connect(lambda val, label = label: label.setText(f"Exp\n{val}")) slid.sliderReleased.connect(lambda : self.updateExposure("Color")) self.ColorLayout.addWidget(label, 0, len(self.ColorSliders)) self.ColorLayout.addWidget(slid , 1, len(self.ColorSliders)) self.ColorSliders["Exp"] = slid self.ColorLabels ["Exp"] = label #######--------> UV <--------####### self.UVTab = QWidget(self.tabs) self.tabs.addTab(self.UVTab, "UV") self.UVLayout = QGridLayout(self.UVTab) # sliders and labels# self.UVSliders = {} self.UVLabels = {} #### LED ##### slid = QSlider(Qt.Vertical) slid.setMaximum(100) slid.setValue(constants.settings["Color"]["LED_Brigh"]) slid.valueChanged.connect(self.updateLEDUV) label = QLabel(f"Brigh\n{slid.value()}" , alignment = Qt.AlignCenter) self.UVLayout.addWidget(label, 0, 0) self.UVLayout.addWidget(slid , 1, 0) self.UVSliders["Brigh"] = slid self.UVLabels ["Brigh"] = label #### capture ##### slid = util.IntervalSlider(Qt.Vertical, maxValue = 6000, interval = 100) slid.setValue(constants.settings["UV"]["exposureTime"]) label = QLabel(f"Exp\n{slid.value()}" , alignment = Qt.AlignCenter) slid.valueChanged.connect(lambda val, label = label: label.setText(f"Exp\n{val}")) slid.sliderReleased.connect(lambda : self.updateExposure("UV")) self.UVLayout.addWidget(label, 0, 1) self.UVLayout.addWidget(slid , 1, 1) self.UVSliders["Exp"] = slid self.UVLabels ["Exp"] = label #######--------> show <--------####### self.showTab = QWidget(self.tabs) self.tabs.addTab(self.showTab, "Show") self.showLayout = QVBoxLayout(self.showTab) self.showColorCheckboxes = {} for i, name in enumerate(["Red", "Green", "Blue"]): widget = QWidget(self.showTab) layout = QHBoxLayout(widget) layout.setContentsMargins(0,0,0,0) label = QLabel(f"Show {name}", widget) # label.setFixedWidth(150) layout.addWidget(label) checkbox = QCheckBox(widget) checkbox.setChecked(constants.settings["show"][name]) checkbox.setStyleSheet("QCheckBox::indicator { width:50px; height: 50px;}") checkbox.stateChanged.connect(self.updateShow) layout.addWidget(checkbox) self.showLayout.addWidget(widget) self.showColorCheckboxes[name] = checkbox self.showLayout.addStretch() #@TODO move up self.mainLayout.addWidget(self.tabs) self.mainLayout.addWidget(self.buttonsWidget)
def add_ps_ks_tab(self): psman = self.psman if not psman.is_hw_ks: return self.ps_ks_tab = QWidget() grid = QGridLayout() self.ps_ks_tab.setLayout(grid) grid.addWidget(QLabel(_('Master Public Key')), 0, 0) mpk = psman.ps_keystore.get_master_public_key() mpk_text = ShowQRTextEdit() mpk_text.setMaximumHeight(150) mpk_text.addCopyButton(self.mwin.app) mpk_text.setText(mpk) grid.addWidget(mpk_text, 1, 0) grid.setRowStretch(2, 1) self.seed_btn = QPushButton(_('Show Seed')) def show_ps_ks_seed_dlg(): self.show_ps_ks_seed_dialog(mwin=self.mwin, parent=self) self.seed_btn.clicked.connect(show_ps_ks_seed_dlg) grid.addWidget(self.seed_btn, 3, 0) if psman.is_ps_ks_encrypted(): pwd_btn_text = _('Change Password') else: pwd_btn_text = _('Set Password') self.password_btn = QPushButton(pwd_btn_text) self.password_btn.clicked.connect(self.change_ps_ks_password_dialog) grid.addWidget(self.password_btn, 4, 0) self.export_privk_btn = QPushButton(_('Export Private Keys')) def export_ps_ks_privkeys_dlg(): self.mwin.export_privkeys_dialog(ps_ks_only=True, mwin=self.mwin, parent=self) self.export_privk_btn.clicked.connect(export_ps_ks_privkeys_dlg) grid.addWidget(self.export_privk_btn, 5, 0) if psman.is_hw_ks: send_funds_to_main_txt = _('Send all coins to hardware wallet') else: send_funds_to_main_txt = _('Send all coins to main keystore') self.send_funds_to_main_btn = QPushButton(send_funds_to_main_txt) def send_funds_to_main_ks(): self.mwin.send_funds_to_main_ks(mwin=self.mwin, parent=self) self.send_funds_to_main_btn.clicked.connect(send_funds_to_main_ks) grid.addWidget(self.send_funds_to_main_btn, 6, 0) warn_ps_ks_cb = QCheckBox(psman.warn_ps_ks_data()) warn_ps_ks_cb.setChecked(psman.show_warn_ps_ks) def on_warn_ps_ks_changed(x): psman.show_warn_ps_ks = (x == Qt.Checked) warn_ps_ks_cb.stateChanged.connect(on_warn_ps_ks_changed) grid.addWidget(warn_ps_ks_cb, 7, 0) self.tabs.addTab(self.ps_ks_tab, _('PS Keystore'))
def __init__(self): super().__init__() self.ch = QCheckBox("Do you want to save?") self.l1 = QLabel() self.init_ui()
def __init__(self, msg, kind, OK_button, wallet=None, force_disable_encrypt_cb=False): self.wallet = wallet self.pw = PasswordLineEdit() self.new_pw = PasswordLineEdit() self.conf_pw = PasswordLineEdit() 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) if kind == PW_PASSPHRASE: self.encrypt_cb.setVisible(False) 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
def initUI(self): self.setGeometry(300, 300, 300, 300) self.setWindowTitle('LinLog | Settings') self.setWindowIcon(QIcon('logo.png')) style = "QWidget{background-color:" + self.settingsDict[ 'background-color'] + "; color:" + self.settingsDict['color'] + ";}" self.setStyleSheet(style) # declaration tab self.tab = QtWidgets.QTabWidget() self.general_tab = QWidget() self.cluster_tab = QWidget() self.tci_tab = QWidget() self.io_tab = QWidget() self.service_widget = QWidget() # self.tab.addTab(self.general_tab, "General") self.tab.addTab(self.cluster_tab, "Cluster") self.tab.addTab(self.tci_tab, "TCI") self.tab.addTab(self.io_tab, "Log file") self.tab.addTab(self.service_widget, "Services") # create General Tab formstyle = "background: "+self.settingsDict['form-background']+"; color: "+\ self.settingsDict['color-table']+"; " self.general_tab.layout = QVBoxLayout(self) # create vertical lay self.call_label = QLabel("You Callsign") self.call_input = QLineEdit() self.call_input.setFixedWidth(100) self.call_input.setStyleSheet(formstyle) self.dlg = QColorDialog(self) self.back_color_label = QLabel("Window color") self.back_color_label.setStyleSheet(self.label_style) self.back_color_input = QPushButton() self.back_color_input.clicked.connect(self.back_color_select) self.back_color_input.setFixedWidth(70) self.back_color_input.setStyleSheet( "background:" + self.settingsDict['background-color'] + "; color:" + self.settingsDict['background-color'] + ";") self.back_color_input.setText(self.settingsDict['background-color']) #self.back_color_input.setStyleSheet(formstyle) self.text_color_label = QLabel("Text color") self.text_color_label.setStyleSheet(self.label_style) self.text_color_input = QPushButton() self.text_color_input.clicked.connect(self.text_color_select) self.text_color_input.setFixedWidth(70) self.text_color_input.setStyleSheet("background:" + self.settingsDict['color'] + "; color:" + self.settingsDict['color'] + ";") self.text_color_input.setText(self.settingsDict['color']) #self.text_color_input.setStyleSheet(formstyle) self.form_color_label = QLabel("Form background color") self.form_color_label.setStyleSheet(self.label_style) self.form_color_input = QPushButton() self.form_color_input.clicked.connect(self.form_color_select) self.form_color_input.setFixedWidth(70) self.form_color_input.setStyleSheet( "background: " + self.settingsDict['form-background'] + "; color:" + self.settingsDict['form-background'] + ";") self.form_color_input.setText(self.settingsDict['form-background']) # self.text_form_color_label = QLabel("Form text color") self.text_form_color_label.setStyleSheet(self.label_style) self.text_form_color_button = QPushButton() self.text_form_color_button.clicked.connect( self.form_text_color_select) self.text_form_color_button.setFixedWidth(70) self.text_form_color_button.setStyleSheet( "background: " + self.settingsDict['color-table'] + "; color: " + self.settingsDict['color-table'] + ";") self.text_form_color_button.setText(self.settingsDict['color-table']) # setup all elements to vertical lay self.general_tab.layout.addWidget(self.call_label) self.general_tab.layout.addWidget(self.call_input) self.general_tab.layout.addSpacing(20) self.general_tab.layout.addWidget(self.back_color_label) self.general_tab.layout.addWidget(self.back_color_input) self.general_tab.layout.addSpacing(20) self.general_tab.layout.addWidget(self.text_color_label) self.general_tab.layout.addWidget(self.text_color_input) self.general_tab.layout.addSpacing(20) self.general_tab.layout.addWidget(self.form_color_label) self.general_tab.layout.addWidget(self.form_color_input) self.general_tab.layout.addWidget(self.text_form_color_label) self.general_tab.layout.addWidget(self.text_form_color_button) self.general_tab.setLayout(self.general_tab.layout) # create Cluster tab self.cluster_tab.layout = QVBoxLayout(self) self.cluster_host = QLabel("Cluster host:") self.cluster_host_input = QLineEdit() self.cluster_host_input.setFixedWidth(150) self.cluster_host_input.setStyleSheet(formstyle) self.cluster_port = QLabel("Cluster port:") self.cluster_port_input = QLineEdit() self.cluster_port_input.setFixedWidth(50) self.cluster_port_input.setStyleSheet(formstyle) self.host_port_lay = QHBoxLayout() # create host:port lay self.host_lay = QVBoxLayout() self.host_lay.addWidget(self.cluster_host) self.host_lay.addWidget(self.cluster_host_input) self.port_lay = QVBoxLayout() self.port_lay.addWidget(self.cluster_port) self.port_lay.addWidget(self.cluster_port_input) self.host_port_lay.addLayout(self.host_lay) self.host_port_lay.addLayout(self.port_lay) # Create calibrate cluster self.calibrate_lay = QHBoxLayout() ## Create text label self.text_and_button_Vlay = QVBoxLayout() text = "Press \"Start claibrate\" and select Callsign and Freq \n" \ "from the received line from the telnet cluster" self.message_label = QLabel(text) self.message_label.setStyleSheet("font: 12px;") self.text_and_button_Vlay.addWidget(self.message_label) self.button_and_combo = QHBoxLayout() ## Create group from button and combobox self.cluster_start_calibrate_button = QPushButton( "Start \n callibrate") self.cluster_start_calibrate_button.setFixedWidth(100) self.cluster_start_calibrate_button.setFixedHeight(60) self.button_and_combo.addWidget(self.cluster_start_calibrate_button) self.combo_lay = QVBoxLayout() self.call_H = QHBoxLayout() self.call_H.setAlignment(Qt.AlignRight) self.cluster_call_label = QLabel("Call:") self.cluster_combo_call = QComboBox() self.freq_H = QHBoxLayout() self.freq_H.setAlignment(Qt.AlignRight) self.cluster_freq_label = QLabel("Freq:") self.cluster_combo_freq = QComboBox() self.call_H.addWidget(self.cluster_call_label) self.call_H.addWidget(self.cluster_combo_call) self.freq_H.addWidget(self.cluster_freq_label) self.freq_H.addWidget(self.cluster_combo_freq) self.combo_lay.addLayout(self.call_H) self.combo_lay.addLayout(self.freq_H) self.button_and_combo.addLayout(self.combo_lay) self.text_and_button_Vlay.addLayout(self.button_and_combo) self.calibrate_lay.addLayout(self.text_and_button_Vlay) ## Create filter band self.cluster_filter_band_combo = QCheckBox("Filter BAND") self.cluster_filter_band_combo.setStyleSheet( "QCheckBox{ color:" + self.settingsDict['color'] + "; font-size: 12px;}") self.cluster_filter_band_input = QLineEdit() self.cluster_filter_band_input.setFixedWidth(80) self.cluster_filter_band_input.setFixedHeight(20) self.cluster_filter_band_input.setStyleSheet( "background-color:" + self.settingsDict['form-background'] + "; font-size: 12px") text = "Bands in m." self.message_label_band = QLabel(text) self.message_label_band.setStyleSheet("font: 12px;") self.filter_band_lay = QVBoxLayout() self.filter_band_lay.addWidget(self.cluster_filter_band_combo) self.filter_band_lay.addWidget(self.message_label_band) self.filter_band_lay.addWidget(self.cluster_filter_band_input) ## Create filter spot self.cluster_filter_spot_combo = QCheckBox("Filter SPOT") self.cluster_filter_spot_combo.setStyleSheet( "QCheckBox{ color:" + self.settingsDict['color'] + "; font-size: 12px;}") self.cluster_filter_spot_input = QLineEdit() self.cluster_filter_spot_input.setFixedWidth(80) self.cluster_filter_spot_input.setFixedHeight(20) self.cluster_filter_spot_input.setStyleSheet( "background-color:" + self.settingsDict['form-background'] + "; font-size: 12px") text = "Spot prefixes" self.message_label_spot = QLabel(text) self.message_label_spot.setStyleSheet("font: 12px;") self.filter_spot_lay = QVBoxLayout() self.filter_spot_lay.addWidget(self.cluster_filter_spot_combo) self.filter_spot_lay.addWidget(self.message_label_spot) self.filter_spot_lay.addWidget(self.cluster_filter_spot_input) ## create filter spotter self.cluster_filter_spotter_combo = QCheckBox("Filter SPOTTER") self.cluster_filter_spotter_combo.setStyleSheet( "QCheckBox{ color:" + self.settingsDict['color'] + "; font-size: 12px;}") self.cluster_filter_spotter_input = QLineEdit() self.cluster_filter_spotter_input.setFixedWidth(80) self.cluster_filter_spotter_input.setFixedHeight(20) self.cluster_filter_spotter_input.setStyleSheet( "background-color:" + self.settingsDict['form-background'] + "; font-size: 12px") text = "Spotter prefixes" self.message_label_spotter = QLabel(text) self.message_label_spotter.setStyleSheet("font: 12px;") self.filter_spotter_lay = QVBoxLayout() self.filter_spotter_lay.addWidget(self.cluster_filter_spotter_combo) self.filter_spotter_lay.addWidget(self.message_label_spotter) self.filter_spotter_lay.addWidget(self.cluster_filter_spotter_input) text = "All value separate by comma" self.filter_message_label = QLabel(text) self.filter_message_label.setStyleSheet("font: 12px;") self.filters_Hlay = QHBoxLayout() self.filters_Hlay.addLayout(self.filter_band_lay) self.filters_Hlay.addLayout(self.filter_spot_lay) self.filters_Hlay.addLayout(self.filter_spotter_lay) self.filters_lay = QVBoxLayout() self.filters_lay.addSpacing(10) self.filters_lay.setAlignment(Qt.AlignCenter) self.filters_lay.addLayout(self.filters_Hlay) self.filters_lay.addWidget(self.filter_message_label) self.filters_lay.addSpacing(10) Separador = QFrame() Separador.setFrameShape(QFrame.HLine) Separador.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) Separador.setLineWidth(1) self.filters_lay.addWidget(Separador) ## Create List view for input string from cluster self.line_text = QLabel() self.line_text.setFixedHeight(50) # Set all layers to window self.cluster_tab.layout.addLayout(self.host_port_lay) self.cluster_tab.layout.addSpacing(10) self.cluster_tab.layout.addLayout(self.filters_lay) self.cluster_tab.layout.addLayout(self.calibrate_lay) self.cluster_tab.layout.addWidget(self.line_text) ## install lay to main tab (Cluster) self.cluster_tab.setLayout(self.cluster_tab.layout) # create TCI Tab self.tci_enable_combo_lay = QHBoxLayout() self.tci_enable_combo_lay.setAlignment(Qt.AlignCenter) self.tci_enable_combo = QCheckBox("TCI Enable") self.tci_enable_combo.setStyleSheet("QCheckBox{" + self.settingsDict['color'] + "}") self.tci_enable_combo_lay.addWidget(self.tci_enable_combo) self.tci_tab.layout = QVBoxLayout(self) self.tci_host = QLabel("TCI host:") self.tci_host_input = QLineEdit() self.tci_host_input.setFixedWidth(150) self.tci_host_input.setStyleSheet(formstyle) self.tci_port = QLabel("TCI port:") self.tci_port_input = QLineEdit() self.tci_port_input.setFixedWidth(50) self.tci_port_input.setStyleSheet(formstyle) self.host_port_lay = QHBoxLayout() # create host:port lay self.host_lay = QVBoxLayout() self.host_lay.addWidget(self.tci_host) self.host_lay.addWidget(self.tci_host_input) self.port_lay = QVBoxLayout() self.port_lay.addWidget(self.tci_port) self.port_lay.addWidget(self.tci_port_input) self.host_port_lay.addLayout(self.host_lay) self.host_port_lay.addLayout(self.port_lay) self.tci_tab.layout.addLayout(self.tci_enable_combo_lay) self.tci_tab.layout.addLayout(self.host_port_lay) self.tci_tab.layout.addSpacing(250) self.tci_tab.setLayout(self.tci_tab.layout) # Create io_tab self.io_tab_lay = QVBoxLayout() self.io_tab_lay.setAlignment(Qt.AlignCenter) self.import_button = QPushButton("Import") self.import_button.setFixedSize(100, 30) self.import_button.clicked.connect(self.import_adi) self.import_button.setStyleSheet("width: 100px;") self.export_button = QPushButton("Export") self.export_button.clicked.connect(self.export_adi) self.export_button.setFixedSize(100, 30) self.io_tab_lay.addWidget(self.import_button) self.io_tab_lay.addWidget(self.export_button) self.io_tab.setLayout(self.io_tab_lay) # Create Services tab self.service_tab = QVBoxLayout() self.service_tab.setAlignment(Qt.AlignCenter) # create elements form self.eqsl_lay = QVBoxLayout() self.eqsl_lay.setAlignment(Qt.AlignCenter) self.eqsl_activate = QHBoxLayout() self.eqsl_chekBox = QCheckBox("eQSL") self.eqsl_chekBox.setStyleSheet( "{ color:" + self.settingsDict['color'] + "; font-size: 12px; border-color: white }") self.eqsl_activate.addWidget(self.eqsl_chekBox) #self.eqsl_activate.addWidget(QLabel("eQSL.cc")) self.eqsl_lay.addLayout(self.eqsl_activate) self.text_eqsl_small = QLabel("Automatic send eQSL after enter QSO") self.text_eqsl_small.setStyleSheet("font: 10px; font-style: italic;") self.eqsl_lay.addWidget(self.text_eqsl_small) self.eqsl_form = QVBoxLayout() self.login = QHBoxLayout() self.login.addWidget(QLabel("Login:"******"Password:"******"font: 12px;" self.button_save = QPushButton("Save and Exit") self.button_save.setStyleSheet(button_style) self.button_save.clicked.connect(self.save_and_exit_button) self.button_apply = QPushButton("Apply") self.button_apply.setStyleSheet(button_style) self.button_apply.clicked.connect(self.apply_button) self.button_cancel = QPushButton("Cancel") self.button_cancel.setStyleSheet(button_style) self.button_cancel.clicked.connect(self.cancel_button) self.button_cancel.setFixedWidth(60) self.button_panel.addWidget(self.button_cancel) self.button_panel.addWidget(self.button_apply) self.button_panel.addWidget(self.button_save) self.mainLayout = QVBoxLayout() self.mainLayout.addWidget(self.tab) self.mainLayout.addLayout(self.button_panel) #self.mainLayout.addWidget(self.tab) self.setLayout(self.mainLayout)
def initUI(self): mainLayout = QVBoxLayout() layH1 = QHBoxLayout() layH2 = QHBoxLayout() layH1.addWidget(self.leftList) layH1.addWidget(self.rightStack) self.cancelbtn = QPushButton(self.tr("Cancel")) self.okbtn = QPushButton(self.tr("OK")) # self.cancelbtn.setVisible(False) self.okbtn.setDefault(True) layH2.addStretch(1) layH2.addWidget(self.cancelbtn) layH2.addWidget(self.okbtn) mainLayout.addLayout(layH1) mainLayout.addLayout(layH2) self.setLayout(mainLayout) # left list self.leftList.addItem(self.tr("General")) self.leftList.addItem(self.tr("Editor")) self.leftList.addItem(self.tr("Update")) self.leftList.setMaximumWidth(150) # right stack w = QWidget() layw = QVBoxLayout() # general g = QGroupBox(self.tr("General")) glayout = QFormLayout() label1 = QLabel(self.tr("select UI language:")) self.langCombo = QComboBox() self.fillLangItems(self.langCombo) # .addItems(self.getLangList()) self.langCombo.setMinimumWidth(150) label2 = QLabel(self.tr("Number of recent files:")) self.recentcountspin = QSpinBox() self.recentcountspin.setMinimum(1) self.recentcountspin.setMaximum(30) glayout.addRow(label1, self.langCombo) glayout.addRow(label2, self.recentcountspin) g.setLayout(glayout) layw.addWidget(g) # advanced g2 = QGroupBox(self.tr("Advanced")) labeladv1 = QLabel(self.tr("Export qss When save qsst:")) self.checkboxAutoExportQss = QCheckBox() self.checkboxAutoExportQss.setToolTip( self. tr("Option for whether export qss when save qsst file each time.")) layh1 = QHBoxLayout() layh1.addWidget(labeladv1) layh1.addStretch(1) layh1.addWidget(self.checkboxAutoExportQss) g2layout = QVBoxLayout() g2layout.addLayout(layh1) g2.setLayout(g2layout) layw.addWidget(g2) # advanced g3 = QGroupBox(self.tr("UI Skin")) labeladv1 = QLabel(self.tr("Select the ui skin:")) self.skinCombo = QComboBox() self.skinCombo.setToolTip(self.tr("Select the ui skin.")) self.skindir = os.path.join(os.path.dirname(__file__), "skin") for f in os.listdir(self.skindir): if f.endswith(".qss") or f.endswith(".QSS"): self.skinCombo.addItem(os.path.basename(f)) layh1 = QHBoxLayout() layh1.addWidget(labeladv1) layh1.addStretch(1) layh1.addWidget(self.skinCombo) labelskin2 = QLabel(self.tr("Manage skins:")) skinaddr = QPushButton(self.tr("Skin Management")) skinaddr.setToolTip(self.tr("Open the skin directory.")) skinaddr.clicked.connect(lambda: os.startfile(self.skindir)) layh2 = QHBoxLayout() layh2.addWidget(labelskin2) layh2.addStretch(1) layh2.addWidget(skinaddr) g3layout = QVBoxLayout() g3layout.addLayout(layh1) g3layout.addLayout(layh2) g3.setLayout(g3layout) layw.addWidget(g3) layw.addStretch(1) w.setLayout(layw) self.rightStack.addWidget(w) # CodeEditor SettingPannel self.rightStack.addWidget(self.win.editor.settings.settingPanel()) # right stack for update w3 = QWidget() layw3 = QVBoxLayout() # update setting g31 = QGroupBox(self.tr("update check")) self.checkboxUpdate = QCheckBox(self.tr("auto check for update")) labtmp = QLabel(self.tr("update checking frequency:")) self.updateCombo = QComboBox() self.updateCombo.setToolTip( self.tr("setup frequency for checking update")) self.updateCombo.addItem(self.tr("Each startup"), "start") self.updateCombo.addItem(self.tr("Every day"), "day") self.updateCombo.addItem(self.tr("Every week"), "week") self.updateCombo.addItem(self.tr("Every month"), "month") self.updateCombo.setEnabled(False) self.checkboxUpdate.stateChanged.connect(self.updateCombo.setEnabled) ltmpv = QVBoxLayout() ltmph = QHBoxLayout() ltmpv.addWidget(self.checkboxUpdate) ltmpv.addLayout(ltmph) ltmph.addWidget(labtmp) ltmph.addStretch(1) ltmph.addWidget(self.updateCombo) g31.setLayout(ltmpv) tmp1 = self.win.config["update.autocheck"] tmp2 = self.win.config["update.checkfreq"] if not isinstance(tmp1, bool): tmp1 = True self.checkboxUpdate.setChecked(tmp1) if not tmp2: tmp2 = "start" tmpi = self.updateCombo.findData(tmp2) if tmpi: self.updateCombo.setCurrentIndex(tmpi) layw3.addWidget(g31) layw3.addStretch(1) w3.setLayout(layw3) self.rightStack.addWidget(w3) # action for dialog self.leftList.currentRowChanged.connect( self.rightStack.setCurrentIndex) self.cancelbtn.clicked.connect(lambda: (self.cancel(), self.close())) self.okbtn.clicked.connect(lambda: (self.apply(), self.close())) # actions self.recentcountspin.valueChanged.connect( lambda x: self.changedOptions.__setitem__("file.recentcount", x)) self.langCombo.currentIndexChanged.connect( lambda i: self.changedOptions.__setitem__( "general.language", self.langCombo.itemData(i))) self.checkboxUpdate.stateChanged.connect( lambda b: self.changedOptions.update({"update.autocheck": b})) self.updateCombo.currentIndexChanged.connect( lambda i: self.changedOptions.__setitem__( "update.checkfreq", self.updateCombo.itemData(i))) self.checkboxAutoExportQss.stateChanged.connect( lambda b: self.changedOptions.update({"advance.autoexportqss": b})) self.skinCombo.currentTextChanged.connect(lambda t: (self.applyskin( t), self.changedOptions.update({"general.skin": t})))
def __init__(self, parent: 'ElectrumWindow', config: 'SimpleConfig'): WindowModalDialog.__init__(self, parent, _('Preferences')) self.config = config self.window = parent self.need_restart = False self.fx = self.window.fx self.wallet = self.window.wallet vbox = QVBoxLayout() tabs = QTabWidget() gui_widgets = [] tx_widgets = [] oa_widgets = [] # language lang_help = _('Select which language is used in the GUI (after restart).') lang_label = HelpLabel(_('Language') + ':', lang_help) lang_combo = QComboBox() lang_combo.addItems(list(languages.values())) lang_keys = list(languages.keys()) lang_cur_setting = self.config.get("language", '') try: index = lang_keys.index(lang_cur_setting) except ValueError: # not in list index = 0 lang_combo.setCurrentIndex(index) if not self.config.is_modifiable('language'): for w in [lang_combo, lang_label]: w.setEnabled(False) def on_lang(x): lang_request = list(languages.keys())[lang_combo.currentIndex()] if lang_request != self.config.get('language'): self.config.set_key("language", lang_request, True) self.need_restart = True lang_combo.currentIndexChanged.connect(on_lang) gui_widgets.append((lang_label, lang_combo)) nz_help = _('Number of zeros displayed after the decimal point. For example, if this is set to 2, "1." will be displayed as "1.00"') nz_label = HelpLabel(_('Zeros after decimal point') + ':', nz_help) nz = QSpinBox() nz.setMinimum(0) nz.setMaximum(self.config.decimal_point) nz.setValue(self.config.num_zeros) if not self.config.is_modifiable('num_zeros'): for w in [nz, nz_label]: w.setEnabled(False) def on_nz(): value = nz.value() if self.config.num_zeros != value: self.config.num_zeros = value self.config.set_key('num_zeros', value, True) self.window.history_list.update() self.window.address_list.update() nz.valueChanged.connect(on_nz) gui_widgets.append((nz_label, nz)) use_rbf = bool(self.config.get('use_rbf', True)) use_rbf_cb = QCheckBox(_('Use Replace-By-Fee')) use_rbf_cb.setChecked(use_rbf) use_rbf_cb.setToolTip( _('If you check this box, your transactions will be marked as non-final,') + '\n' + \ _('and you will have the possibility, while they are unconfirmed, to replace them with transactions that pay higher fees.') + '\n' + \ _('Note that some merchants do not accept non-final transactions until they are confirmed.')) def on_use_rbf(x): self.config.set_key('use_rbf', bool(x)) batch_rbf_cb.setEnabled(bool(x)) use_rbf_cb.stateChanged.connect(on_use_rbf) tx_widgets.append((use_rbf_cb, None)) batch_rbf_cb = QCheckBox(_('Batch RBF transactions')) batch_rbf_cb.setChecked(bool(self.config.get('batch_rbf', False))) batch_rbf_cb.setEnabled(use_rbf) batch_rbf_cb.setToolTip( _('If you check this box, your unconfirmed transactions will be consolidated into a single transaction.') + '\n' + \ _('This will save fees.')) def on_batch_rbf(x): self.config.set_key('batch_rbf', bool(x)) batch_rbf_cb.stateChanged.connect(on_batch_rbf) tx_widgets.append((batch_rbf_cb, None)) # lightning lightning_widgets = [] if self.wallet.lnworker and self.wallet.lnworker.has_deterministic_node_id(): help_recov = _(messages.MSG_RECOVERABLE_CHANNELS) recov_cb = QCheckBox(_("Create recoverable channels")) recov_cb.setToolTip(help_recov) recov_cb.setChecked(bool(self.config.get('use_recoverable_channels', True))) def on_recov_checked(x): self.config.set_key('use_recoverable_channels', bool(x)) recov_cb.stateChanged.connect(on_recov_checked) recov_cb.setEnabled(not bool(self.config.get('lightning_listen'))) lightning_widgets.append((recov_cb, None)) help_gossip = _("""If this option is enabled, Electrum will download the network channels graph and compute payment path locally, instead of using trampoline payments. """) gossip_cb = QCheckBox(_("Enable gossip (disable trampoline)")) gossip_cb.setToolTip(help_gossip) gossip_cb.setChecked(bool(self.config.get('use_gossip', False))) def on_gossip_checked(x): use_gossip = bool(x) self.config.set_key('use_gossip', use_gossip) if use_gossip: self.window.network.start_gossip() else: self.window.network.run_from_another_thread( self.window.network.stop_gossip()) util.trigger_callback('ln_gossip_sync_progress') # FIXME: update all wallet windows util.trigger_callback('channels_updated', self.wallet) gossip_cb.stateChanged.connect(on_gossip_checked) lightning_widgets.append((gossip_cb, None)) help_local_wt = _("""If this option is checked, Electrum will run a local watchtower and protect your channels even if your wallet is not open. For this to work, your computer needs to be online regularly.""") local_wt_cb = QCheckBox(_("Run a local watchtower")) local_wt_cb.setToolTip(help_local_wt) local_wt_cb.setChecked(bool(self.config.get('run_local_watchtower', False))) def on_local_wt_checked(x): self.config.set_key('run_local_watchtower', bool(x)) local_wt_cb.stateChanged.connect(on_local_wt_checked) lightning_widgets.append((local_wt_cb, None)) help_persist = _("""If this option is checked, Electrum will persist after you close all your wallet windows, and the Electrum icon will be visible in the taskbar. Use this if you want your local watchtower to keep running after you close your wallet.""") persist_cb = QCheckBox(_("Persist after all windows are closed")) persist_cb.setToolTip(help_persist) persist_cb.setChecked(bool(self.config.get('persist_daemon', False))) def on_persist_checked(x): self.config.set_key('persist_daemon', bool(x)) persist_cb.stateChanged.connect(on_persist_checked) lightning_widgets.append((persist_cb, None)) help_remote_wt = _("""To use a remote watchtower, enter the corresponding URL here""") remote_wt_cb = QCheckBox(_("Use a remote watchtower")) remote_wt_cb.setToolTip(help_remote_wt) remote_wt_cb.setChecked(bool(self.config.get('use_watchtower', False))) def on_remote_wt_checked(x): self.config.set_key('use_watchtower', bool(x)) self.watchtower_url_e.setEnabled(bool(x)) remote_wt_cb.stateChanged.connect(on_remote_wt_checked) watchtower_url = self.config.get('watchtower_url') self.watchtower_url_e = QLineEdit(watchtower_url) self.watchtower_url_e.setEnabled(self.config.get('use_watchtower', False)) def on_wt_url(): url = self.watchtower_url_e.text() or None watchtower_url = self.config.set_key('watchtower_url', url) self.watchtower_url_e.editingFinished.connect(on_wt_url) lightning_widgets.append((remote_wt_cb, self.watchtower_url_e)) msg = _('OpenAlias record, used to receive coins and to sign payment requests.') + '\n\n'\ + _('The following alias providers are available:') + '\n'\ + '\n'.join(['https://cryptoname.co/', 'http://xmr.link']) + '\n\n'\ + 'For more information, see https://openalias.org' alias_label = HelpLabel(_('OpenAlias') + ':', msg) alias = self.config.get('alias','') self.alias_e = QLineEdit(alias) self.set_alias_color() self.alias_e.editingFinished.connect(self.on_alias_edit) oa_widgets.append((alias_label, self.alias_e)) # units units = base_units_list msg = (_('Base unit of your wallet.') + '\n1 BTC = 1000 mBTC. 1 mBTC = 1000 bits. 1 bit = 100 sat.\n' + _('This setting affects the Send tab, and all balance related fields.')) unit_label = HelpLabel(_('Base unit') + ':', msg) unit_combo = QComboBox() unit_combo.addItems(units) unit_combo.setCurrentIndex(units.index(self.window.base_unit())) def on_unit(x, nz): unit_result = units[unit_combo.currentIndex()] if self.window.base_unit() == unit_result: return edits = self.window.amount_e, self.window.receive_amount_e amounts = [edit.get_amount() for edit in edits] self.config.set_base_unit(unit_result) nz.setMaximum(self.config.decimal_point) self.window.update_tabs() for edit, amount in zip(edits, amounts): edit.setAmount(amount) self.window.update_status() unit_combo.currentIndexChanged.connect(lambda x: on_unit(x, nz)) gui_widgets.append((unit_label, unit_combo)) system_cameras = qrscanner._find_system_cameras() qr_combo = QComboBox() qr_combo.addItem("Default","default") for camera, device in system_cameras.items(): qr_combo.addItem(camera, device) #combo.addItem("Manually specify a device", config.get("video_device")) index = qr_combo.findData(self.config.get("video_device")) qr_combo.setCurrentIndex(index) msg = _("Install the zbar package to enable this.") qr_label = HelpLabel(_('Video Device') + ':', msg) qr_combo.setEnabled(qrscanner.libzbar is not None) on_video_device = lambda x: self.config.set_key("video_device", qr_combo.itemData(x), True) qr_combo.currentIndexChanged.connect(on_video_device) gui_widgets.append((qr_label, qr_combo)) colortheme_combo = QComboBox() colortheme_combo.addItem(_('Light'), 'default') colortheme_combo.addItem(_('Dark'), 'dark') index = colortheme_combo.findData(self.config.get('qt_gui_color_theme', 'default')) colortheme_combo.setCurrentIndex(index) colortheme_label = QLabel(_('Color theme') + ':') def on_colortheme(x): self.config.set_key('qt_gui_color_theme', colortheme_combo.itemData(x), True) self.need_restart = True colortheme_combo.currentIndexChanged.connect(on_colortheme) gui_widgets.append((colortheme_label, colortheme_combo)) updatecheck_cb = QCheckBox(_("Automatically check for software updates")) updatecheck_cb.setChecked(bool(self.config.get('check_updates', False))) def on_set_updatecheck(v): self.config.set_key('check_updates', v == Qt.Checked, save=True) updatecheck_cb.stateChanged.connect(on_set_updatecheck) gui_widgets.append((updatecheck_cb, None)) filelogging_cb = QCheckBox(_("Write logs to file")) filelogging_cb.setChecked(bool(self.config.get('log_to_file', False))) def on_set_filelogging(v): self.config.set_key('log_to_file', v == Qt.Checked, save=True) self.need_restart = True filelogging_cb.stateChanged.connect(on_set_filelogging) filelogging_cb.setToolTip(_('Debug logs can be persisted to disk. These are useful for troubleshooting.')) gui_widgets.append((filelogging_cb, None)) preview_cb = QCheckBox(_('Advanced preview')) preview_cb.setChecked(bool(self.config.get('advanced_preview', False))) preview_cb.setToolTip(_("Open advanced transaction preview dialog when 'Pay' is clicked.")) def on_preview(x): self.config.set_key('advanced_preview', x == Qt.Checked) preview_cb.stateChanged.connect(on_preview) tx_widgets.append((preview_cb, None)) usechange_cb = QCheckBox(_('Use change addresses')) usechange_cb.setChecked(self.window.wallet.use_change) if not self.config.is_modifiable('use_change'): usechange_cb.setEnabled(False) def on_usechange(x): usechange_result = x == Qt.Checked if self.window.wallet.use_change != usechange_result: self.window.wallet.use_change = usechange_result self.window.wallet.db.put('use_change', self.window.wallet.use_change) multiple_cb.setEnabled(self.window.wallet.use_change) usechange_cb.stateChanged.connect(on_usechange) usechange_cb.setToolTip(_('Using change addresses makes it more difficult for other people to track your transactions.')) tx_widgets.append((usechange_cb, None)) def on_multiple(x): multiple = x == Qt.Checked if self.wallet.multiple_change != multiple: self.wallet.multiple_change = multiple self.wallet.db.put('multiple_change', multiple) multiple_change = self.wallet.multiple_change multiple_cb = QCheckBox(_('Use multiple change addresses')) multiple_cb.setEnabled(self.wallet.use_change) multiple_cb.setToolTip('\n'.join([ _('In some cases, use up to 3 change addresses in order to break ' 'up large coin amounts and obfuscate the recipient address.'), _('This may result in higher transactions fees.') ])) multiple_cb.setChecked(multiple_change) multiple_cb.stateChanged.connect(on_multiple) tx_widgets.append((multiple_cb, None)) def fmt_docs(key, klass): lines = [ln.lstrip(" ") for ln in klass.__doc__.split("\n")] return '\n'.join([key, "", " ".join(lines)]) choosers = sorted(coinchooser.COIN_CHOOSERS.keys()) if len(choosers) > 1: chooser_name = coinchooser.get_name(self.config) msg = _('Choose coin (UTXO) selection method. The following are available:\n\n') msg += '\n\n'.join(fmt_docs(*item) for item in coinchooser.COIN_CHOOSERS.items()) chooser_label = HelpLabel(_('Coin selection') + ':', msg) chooser_combo = QComboBox() chooser_combo.addItems(choosers) i = choosers.index(chooser_name) if chooser_name in choosers else 0 chooser_combo.setCurrentIndex(i) def on_chooser(x): chooser_name = choosers[chooser_combo.currentIndex()] self.config.set_key('coin_chooser', chooser_name) chooser_combo.currentIndexChanged.connect(on_chooser) tx_widgets.append((chooser_label, chooser_combo)) def on_unconf(x): self.config.set_key('confirmed_only', bool(x)) conf_only = bool(self.config.get('confirmed_only', False)) unconf_cb = QCheckBox(_('Spend only confirmed coins')) unconf_cb.setToolTip(_('Spend only confirmed inputs.')) unconf_cb.setChecked(conf_only) unconf_cb.stateChanged.connect(on_unconf) tx_widgets.append((unconf_cb, None)) def on_outrounding(x): self.config.set_key('coin_chooser_output_rounding', bool(x)) enable_outrounding = bool(self.config.get('coin_chooser_output_rounding', True)) outrounding_cb = QCheckBox(_('Enable output value rounding')) outrounding_cb.setToolTip( _('Set the value of the change output so that it has similar precision to the other outputs.') + '\n' + _('This might improve your privacy somewhat.') + '\n' + _('If enabled, at most 100 satoshis might be lost due to this, per transaction.')) outrounding_cb.setChecked(enable_outrounding) outrounding_cb.stateChanged.connect(on_outrounding) tx_widgets.append((outrounding_cb, None)) block_explorers = sorted(util.block_explorer_info().keys()) BLOCK_EX_CUSTOM_ITEM = _("Custom URL") if BLOCK_EX_CUSTOM_ITEM in block_explorers: # malicious translation? block_explorers.remove(BLOCK_EX_CUSTOM_ITEM) block_explorers.append(BLOCK_EX_CUSTOM_ITEM) msg = _('Choose which online block explorer to use for functions that open a web browser') block_ex_label = HelpLabel(_('Online Block Explorer') + ':', msg) block_ex_combo = QComboBox() block_ex_custom_e = QLineEdit(self.config.get('block_explorer_custom') or '') block_ex_combo.addItems(block_explorers) block_ex_combo.setCurrentIndex( block_ex_combo.findText(util.block_explorer(self.config) or BLOCK_EX_CUSTOM_ITEM)) def showhide_block_ex_custom_e(): block_ex_custom_e.setVisible(block_ex_combo.currentText() == BLOCK_EX_CUSTOM_ITEM) showhide_block_ex_custom_e() def on_be_combo(x): if block_ex_combo.currentText() == BLOCK_EX_CUSTOM_ITEM: on_be_edit() else: be_result = block_explorers[block_ex_combo.currentIndex()] self.config.set_key('block_explorer_custom', None, False) self.config.set_key('block_explorer', be_result, True) showhide_block_ex_custom_e() block_ex_combo.currentIndexChanged.connect(on_be_combo) def on_be_edit(): val = block_ex_custom_e.text() try: val = ast.literal_eval(val) # to also accept tuples except: pass self.config.set_key('block_explorer_custom', val) block_ex_custom_e.editingFinished.connect(on_be_edit) block_ex_hbox = QHBoxLayout() block_ex_hbox.setContentsMargins(0, 0, 0, 0) block_ex_hbox.setSpacing(0) block_ex_hbox.addWidget(block_ex_combo) block_ex_hbox.addWidget(block_ex_custom_e) block_ex_hbox_w = QWidget() block_ex_hbox_w.setLayout(block_ex_hbox) tx_widgets.append((block_ex_label, block_ex_hbox_w)) # Fiat Currency hist_checkbox = QCheckBox() hist_capgains_checkbox = QCheckBox() fiat_address_checkbox = QCheckBox() ccy_combo = QComboBox() ex_combo = QComboBox() def update_currencies(): if not self.window.fx: return currencies = sorted(self.fx.get_currencies(self.fx.get_history_config())) ccy_combo.clear() ccy_combo.addItems([_('None')] + currencies) if self.fx.is_enabled(): ccy_combo.setCurrentIndex(ccy_combo.findText(self.fx.get_currency())) def update_history_cb(): if not self.fx: return hist_checkbox.setChecked(self.fx.get_history_config()) hist_checkbox.setEnabled(self.fx.is_enabled()) def update_fiat_address_cb(): if not self.fx: return fiat_address_checkbox.setChecked(self.fx.get_fiat_address_config()) def update_history_capgains_cb(): if not self.fx: return hist_capgains_checkbox.setChecked(self.fx.get_history_capital_gains_config()) hist_capgains_checkbox.setEnabled(hist_checkbox.isChecked()) def update_exchanges(): if not self.fx: return b = self.fx.is_enabled() ex_combo.setEnabled(b) if b: h = self.fx.get_history_config() c = self.fx.get_currency() exchanges = self.fx.get_exchanges_by_ccy(c, h) else: exchanges = self.fx.get_exchanges_by_ccy('USD', False) ex_combo.blockSignals(True) ex_combo.clear() ex_combo.addItems(sorted(exchanges)) ex_combo.setCurrentIndex(ex_combo.findText(self.fx.config_exchange())) ex_combo.blockSignals(False) def on_currency(hh): if not self.fx: return b = bool(ccy_combo.currentIndex()) ccy = str(ccy_combo.currentText()) if b else None self.fx.set_enabled(b) if b and ccy != self.fx.ccy: self.fx.set_currency(ccy) update_history_cb() update_exchanges() self.window.update_fiat() def on_exchange(idx): exchange = str(ex_combo.currentText()) if self.fx and self.fx.is_enabled() and exchange and exchange != self.fx.exchange.name(): self.fx.set_exchange(exchange) def on_history(checked): if not self.fx: return self.fx.set_history_config(checked) update_exchanges() self.window.history_model.refresh('on_history') if self.fx.is_enabled() and checked: self.fx.trigger_update() update_history_capgains_cb() def on_history_capgains(checked): if not self.fx: return self.fx.set_history_capital_gains_config(checked) self.window.history_model.refresh('on_history_capgains') def on_fiat_address(checked): if not self.fx: return self.fx.set_fiat_address_config(checked) self.window.address_list.refresh_headers() self.window.address_list.update() update_currencies() update_history_cb() update_history_capgains_cb() update_fiat_address_cb() update_exchanges() ccy_combo.currentIndexChanged.connect(on_currency) hist_checkbox.stateChanged.connect(on_history) hist_capgains_checkbox.stateChanged.connect(on_history_capgains) fiat_address_checkbox.stateChanged.connect(on_fiat_address) ex_combo.currentIndexChanged.connect(on_exchange) fiat_widgets = [] fiat_widgets.append((QLabel(_('Fiat currency')), ccy_combo)) fiat_widgets.append((QLabel(_('Source')), ex_combo)) fiat_widgets.append((QLabel(_('Show history rates')), hist_checkbox)) fiat_widgets.append((QLabel(_('Show capital gains in history')), hist_capgains_checkbox)) fiat_widgets.append((QLabel(_('Show Fiat balance for addresses')), fiat_address_checkbox)) tabs_info = [ (gui_widgets, _('General')), (tx_widgets, _('Transactions')), (lightning_widgets, _('Lightning')), (fiat_widgets, _('Fiat')), (oa_widgets, _('OpenAlias')), ] for widgets, name in tabs_info: tab = QWidget() tab_vbox = QVBoxLayout(tab) grid = QGridLayout() for a,b in widgets: i = grid.rowCount() if b: if a: grid.addWidget(a, i, 0) grid.addWidget(b, i, 1) else: grid.addWidget(a, i, 0, 1, 2) tab_vbox.addLayout(grid) tab_vbox.addStretch(1) tabs.addTab(tab, name) vbox.addWidget(tabs) vbox.addStretch(1) vbox.addLayout(Buttons(CloseButton(self))) self.setLayout(vbox)
def __init__(self, parent=None): super(Gui, self).__init__(parent) self.trainDir = "" self.validationDir = "" self.predictDir = "" self.algorithmFlag = 0 #menu bar self.menuBar = self.menuBar() fileMenu = self.menuBar.addMenu('File') loadAction = QAction('Load data', self) loadAction.triggered.connect(self.open_data_window) fileMenu.addAction(loadAction) resetAction = QAction('Reset', self) resetAction.triggered.connect(self.reset) #fileMenu.addAction(resetAction) self.menuBar.addAction(resetAction) #left panel self.algorithmLabel = QLabel('Select first algorithm to compare') self.algorithmLabel.setFixedHeight(30) self.simpleCNN = QCheckBox('Simple CNN') self.simpleCNN.stateChanged.connect(self.uncheckFirst) self.knn = QCheckBox('K Nearest Neighbours') self.knn.stateChanged.connect(self.uncheckFirst) self.customCNN = QCheckBox('Custom CNN') self.customCNN.stateChanged.connect(self.uncheckFirst) self.createButton = QPushButton('Create model') self.createButton.clicked.connect(self.createClick) self.createButton.setFixedWidth(150) self.createButton.setEnabled(False) self.trainButton = QPushButton('Train model') self.trainButton.clicked.connect(self.trainClick) self.trainButton.setFixedWidth(150) self.trainButton.setEnabled(False) self.saveModelButton = QPushButton('Save model') self.saveModelButton.clicked.connect(self.saveModelClick) self.saveModelButton.setFixedWidth(150) self.saveModelButton.setEnabled(False) self.loadModelButton = QPushButton('Load model') self.loadModelButton.clicked.connect(self.loadModelClick) self.loadModelButton.setFixedWidth(150) self.loadModelButton.setEnabled(False) self.evaluateButton = QPushButton('Evaluate') self.evaluateButton.clicked.connect(self.evaluateClick) self.evaluateButton.setFixedWidth(150) self.evaluateButton.setEnabled(False) self.parameterLabel = QLabel('Parameter k/epochs:') self.parameter = QLineEdit() self.parameter.setFixedWidth(150) self.parameter.setPlaceholderText('parameter') self.parameter.setValidator(QIntValidator()) self.errorLabel = QLabel('Please choose a parameter') self.errorLabel.setStyleSheet("color: red") self.errorLabel.setVisible(False) self.optimizerLabel = QLabel('Optimizer: ') self.optimizer = QComboBox() self.optimizer.addItem('adam') self.optimizer.addItem('rmsprop') #right panel self.graphs = GraphsTabs() #bottom panel self.consolePrint = QTextBrowser() self.consolePrint.setReadOnly(True) self.consolePrint.setPlaceholderText('console print') self.consolePrint.setMinimumHeight(50) self.consolePrint.setMaximumHeight(300) self.consolePrint.setAlignment(Qt.AlignTop) self.prepare_gui() self.show()
def request_trezor_init_settings(self, wizard, method, device): vbox = QVBoxLayout() next_enabled = True label = QLabel(_("Enter a label to name your device:")) name = QLineEdit() hl = QHBoxLayout() hl.addWidget(label) hl.addWidget(name) hl.addStretch(1) vbox.addLayout(hl) def clean_text(widget): text = widget.toPlainText().strip() return ' '.join(text.split()) if method in [TIM_NEW, TIM_RECOVER]: gb = QGroupBox() hbox1 = QHBoxLayout() gb.setLayout(hbox1) # KeepKey recovery doesn't need a word count if method == TIM_NEW: vbox.addWidget(gb) gb.setTitle(_("Select your seed length:")) bg = QButtonGroup() for i, count in enumerate([12, 18, 24]): rb = QRadioButton(gb) rb.setText(_("{} words").format(count)) bg.addButton(rb) bg.setId(rb, i) hbox1.addWidget(rb) rb.setChecked(True) cb_pin = QCheckBox(_('Enable PIN protection')) cb_pin.setChecked(True) else: text = QTextEdit() text.setMaximumHeight(60) if method == TIM_MNEMONIC: msg = _("Enter your BIP39 mnemonic:") else: msg = _("Enter the master private key beginning with xprv:") def set_enabled(): from electrum_exos.bip32 import is_xprv wizard.next_button.setEnabled(is_xprv(clean_text(text))) text.textChanged.connect(set_enabled) next_enabled = False vbox.addWidget(QLabel(msg)) vbox.addWidget(text) pin = QLineEdit() pin.setValidator(QRegExpValidator(QRegExp('[1-9]{0,9}'))) pin.setMaximumWidth(100) hbox_pin = QHBoxLayout() hbox_pin.addWidget(QLabel(_("Enter your PIN (digits 1-9):"))) hbox_pin.addWidget(pin) hbox_pin.addStretch(1) if method in [TIM_NEW, TIM_RECOVER]: vbox.addWidget(WWLabel(RECOMMEND_PIN)) vbox.addWidget(cb_pin) else: vbox.addLayout(hbox_pin) passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT) passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN) passphrase_warning.setStyleSheet("color: red") cb_phrase = QCheckBox(_('Enable passphrases')) cb_phrase.setChecked(False) vbox.addWidget(passphrase_msg) vbox.addWidget(passphrase_warning) vbox.addWidget(cb_phrase) wizard.exec_layout(vbox, next_enabled=next_enabled) if method in [TIM_NEW, TIM_RECOVER]: item = bg.checkedId() pin = cb_pin.isChecked() else: item = ' '.join(str(clean_text(text)).split()) pin = str(pin.text()) return (item, name.text(), pin, cb_phrase.isChecked())
def add_tx_stats(self, vbox): hbox_stats = QHBoxLayout() # left column vbox_left = QVBoxLayout() self.tx_desc = TxDetailLabel(word_wrap=True) vbox_left.addWidget(self.tx_desc) self.status_label = TxDetailLabel() vbox_left.addWidget(self.status_label) self.date_label = TxDetailLabel() vbox_left.addWidget(self.date_label) self.amount_label = TxDetailLabel() vbox_left.addWidget(self.amount_label) self.ln_amount_label = TxDetailLabel() vbox_left.addWidget(self.ln_amount_label) fee_hbox = QHBoxLayout() self.fee_label = TxDetailLabel() fee_hbox.addWidget(self.fee_label) self.fee_warning_icon = QLabel() pixmap = QPixmap(icon_path("warning")) pixmap_size = round(2 * char_width_in_lineedit()) pixmap = pixmap.scaled(pixmap_size, pixmap_size, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.fee_warning_icon.setPixmap(pixmap) self.fee_warning_icon.setVisible(False) fee_hbox.addWidget(self.fee_warning_icon) fee_hbox.addStretch(1) vbox_left.addLayout(fee_hbox) vbox_left.addStretch(1) hbox_stats.addLayout(vbox_left, 50) # vertical line separator line_separator = QFrame() line_separator.setFrameShape(QFrame.VLine) line_separator.setFrameShadow(QFrame.Sunken) line_separator.setLineWidth(1) hbox_stats.addWidget(line_separator) # right column vbox_right = QVBoxLayout() self.size_label = TxDetailLabel() vbox_right.addWidget(self.size_label) self.rbf_label = TxDetailLabel() vbox_right.addWidget(self.rbf_label) self.rbf_cb = QCheckBox(_('Replace by fee')) self.rbf_cb.setChecked(bool(self.config.get('use_rbf', True))) vbox_right.addWidget(self.rbf_cb) self.locktime_final_label = TxDetailLabel() vbox_right.addWidget(self.locktime_final_label) locktime_setter_hbox = QHBoxLayout() locktime_setter_hbox.setContentsMargins(0, 0, 0, 0) locktime_setter_hbox.setSpacing(0) locktime_setter_label = TxDetailLabel() locktime_setter_label.setText("LockTime: ") self.locktime_e = LockTimeEdit() locktime_setter_hbox.addWidget(locktime_setter_label) locktime_setter_hbox.addWidget(self.locktime_e) locktime_setter_hbox.addStretch(1) self.locktime_setter_widget = QWidget() self.locktime_setter_widget.setLayout(locktime_setter_hbox) vbox_right.addWidget(self.locktime_setter_widget) self.block_height_label = TxDetailLabel() vbox_right.addWidget(self.block_height_label) vbox_right.addStretch(1) hbox_stats.addLayout(vbox_right, 50) vbox.addLayout(hbox_stats) # below columns self.block_hash_label = TxDetailLabel(word_wrap=True) vbox.addWidget(self.block_hash_label) # set visibility after parenting can be determined by Qt self.rbf_label.setVisible(self.finalized) self.rbf_cb.setVisible(not self.finalized) self.locktime_final_label.setVisible(self.finalized) self.locktime_setter_widget.setVisible(not self.finalized)
def init_ui(self): # ******* This is the gui status text for the program (Need to change design) ******* self.gui_status = QTextEdit('<b>Live</b>', self) self.gui_status.setReadOnly(True) self.gui_status.setAlignment(Qt.AlignCenter) self.gui_status.setToolTip('This is a <b>Status</b> text') self.gui_status.resize(80, 30) self.gui_status.move(5, 5) # ******* This is the state text which can change ******* self.state_txt = QTextEdit('<h2>State:</h2> ', self) self.state_txt.setReadOnly(True) self.state_txt.setToolTip('This is a <b>State</b> text') self.state_txt.resize(200, 35) self.state_txt.move(100, 5) # ******* This is our pod dynamics table (May change things in the future) ******* # Adjusting the text box for Pod Dynamics self.pod_dyn_txt = QTextEdit('<b>POD DYNAMICS</b> ', self) self.pod_dyn_txt.setAlignment(Qt.AlignCenter) self.pod_dyn_txt.setReadOnly(True) self.pod_dyn_txt.resize(425, 30) self.pod_dyn_txt.move(5, 390) # Adjusting the table for Pod Dynamics self.pod_dyn_table = QTableWidget(self) self.pod_dyn_table.setRowCount(22) self.pod_dyn_table.setColumnCount(4) self.pod_dyn_table.resize(425, 320) self.pod_dyn_table.move(5, 420) self.pod_dyn_table.resizeRowsToContents() # ******* This is the time and Met text which will change values ******* self.time_txt = QTextEdit('', self) self.time_txt.append('<h2>Time:</h2> \n <h2>MET:</h2>') self.time_txt.setReadOnly(True) self.time_txt.setToolTip('This is a <b>Time</b> text') self.time_txt.resize(200, 80) self.time_txt.move(320, 5) # ******* This is the brake vent close button for the program (Need to change design) ******* self.bv_close = QPushButton('Brake Vent \n CLOSE', self) self.bv_close.setToolTip('This is a <b>Brake Vent Close</b> button') self.bv_close.setEnabled(False) self.bv_close.resize(120, 50) self.bv_close.move(0, 60) self.bv_close.clicked.connect(self.bv_close_handler) self.bv_close.update() # ******* This is the brake vent open button for the program (Need to change design) ******* self.bv_open = QPushButton('Brake Vent \n OPEN', self) self.bv_open.setToolTip('This is a <b>Brake Vent Open</b> button') self.bv_open.resize(120, 50) self.bv_open.move(120, 60) self.bv_open.clicked.connect(self.bv_open_handler) self.bv_open.update() # ******* This is the res #1 close button for the program (Need to change design) ******* self.res1_close = QPushButton('Res #1 \n CLOSE', self) self.res1_close.setToolTip('This is a <b>Res #1 Close</b> button') self.res1_close.setEnabled(False) self.res1_close.resize(120, 50) self.res1_close.move(0, 110) self.res1_close.clicked.connect(self.res1_close_handler) self.res1_close.update() # ******* This is the res #1 open button for the program (Need to change design) ******* self.res1_open = QPushButton('Res #1 \n OPEN', self) self.res1_open.setToolTip('This is a <b>Res #1 Open</b> button') self.res1_open.resize(120, 50) self.res1_open.move(120, 110) self.res1_open.clicked.connect(self.res1_open_handler) self.res1_open.update() # ******* This is the res #2 close button for the program (Need to change design) ******* self.res2_close = QPushButton('Res #2 \n CLOSE', self) self.res2_close.setToolTip('This is a <b>Res #2 Close</b> button') self.res2_close.setEnabled(False) self.res2_close.resize(120, 50) self.res2_close.move(0, 160) self.res2_close.clicked.connect(self.res2_close_handler) self.res2_close.update() # ******* This is the res #2 open button for the program (Need to change design) ******* self.res2_open = QPushButton('Res #2 \n OPEN', self) self.res2_open.setToolTip('This is a <b>Res #2 Open</b> button') self.res2_open.resize(120, 50) self.res2_open.move(120, 160) self.res2_open.clicked.connect(self.res2_open_handler) self.res2_open.update() # ******* This is the hv+ off button for the program (Need to change design) ******* self.hv_plus_off = QPushButton('HV (+) \n OFF', self) self.hv_plus_off.setToolTip('This is a <b>HV plus OFF</b> button') self.hv_plus_off.setEnabled(False) self.hv_plus_off.resize(120, 50) self.hv_plus_off.move(0, 210) self.hv_plus_off.clicked.connect(self.hv_plus_off_handler) self.hv_plus_off.update() # ******* This is the hv+ on button for the program (Need to change design) ******* self.hv_plus_on = QPushButton('HV (+) \n ON', self) self.hv_plus_on.setToolTip('This is a <b>HV plus ON</b> button') self.hv_plus_on.resize(120, 50) self.hv_plus_on.move(120, 210) self.hv_plus_on.clicked.connect(self.hv_plus_on_handler) self.hv_plus_on.update() # ******* This is the hv- off button for the program (Need to change design) ******* self.hv_minus_off = QPushButton('HV (-) \n OFF', self) self.hv_minus_off.setToolTip('This is a <b>HV minus OFF</b> button') self.hv_minus_off.setEnabled(False) self.hv_minus_off.resize(120, 50) self.hv_minus_off.move(0, 260) self.hv_minus_off.clicked.connect(self.hv_minus_off_handler) self.hv_minus_off.update() # ******* This is the hv- on button for the program (Need to change design) ******* self.hv_minus_on = QPushButton('HV (-) \n ON', self) self.hv_minus_on.setToolTip('This is a <b>HV minus ON</b> button') self.hv_minus_on.resize(120, 50) self.hv_minus_on.move(120, 260) self.hv_minus_on.clicked.connect(self.hv_minus_on_handler) self.hv_minus_on.update() # ******* This is the manual throttle checkbox ******* self.mt_chkbox = QCheckBox('Manual Throttle', self) self.mt_chkbox.setToolTip( 'This is the <b>Manual Throttle</b> Checkbox') self.mt_chkbox.move(35, 330) # ******* This is the manual throttle slider ******* self.mt_chkslider = QSlider(Qt.Horizontal, self) self.mt_chkslider.setFocusPolicy(Qt.NoFocus) self.mt_chkslider.setGeometry(35, 350, 110, 30) # ******* This is the LAUNCH button for the program (Need to change design) ******* self.launch_bttn = QPushButton('LAUNCH', self) self.launch_bttn.setToolTip('This is the <b>LAUNCH</b> button') self.launch_bttn.resize(90, 90) self.launch_bttn.move(250, 90) # When you click the launch button you start the thread self.launch_bttn.clicked.connect(self.start) # ******* This is the ABORT button for the program (Need to change design) ******* self.abort_bttn = QPushButton('ABORT', self) self.abort_bttn.setToolTip('This is the <b>ABORT</b> button') self.abort_bttn.resize(90, 90) self.abort_bttn.move(250, 180) # When you click abort button you stop the thread self.abort_bttn.clicked.connect(self.stop) # ******* This is the log text box ******* # Creating the Log Text box self.pd_val_txt = QTextEdit('<b>Pod Value</b>', self) self.pd_val_txt.setAlignment(Qt.AlignCenter) self.pd_val_txt.setReadOnly(True) self.pd_val_txt.resize(150, 230) self.pd_val_txt.move(550, 5) # ******* This is the pod health table ******* # Creating the Pod Health text self.pod_hlth_txt = QTextEdit('<b>Pod Health</b>', self) self.pod_hlth_txt.setAlignment(Qt.AlignCenter) self.pod_hlth_txt.setReadOnly(True) self.pod_hlth_txt.resize(325, 30) self.pod_hlth_txt.move(950, 5) # Creating the table for Pod Health self.pod_hlth_table = QTableWidget(self) self.pod_hlth_table.setRowCount(24) self.pod_hlth_table.setColumnCount(3) self.pod_hlth_table.setHorizontalHeaderLabels( ["LOW", "ACTUAL", "HIGH"]) self.pod_hlth_table.resize(325, 380) self.pod_hlth_table.move(950, 35) self.pod_hlth_table.resizeRowsToContents() # ******* This is the Environmentals table ******* # Creating the Environmentals text self.env_txt = QTextEdit('<b>Environmentals</b>', self) self.env_txt.setAlignment(Qt.AlignCenter) self.env_txt.setReadOnly(True) self.env_txt.resize(321, 30) self.env_txt.move(950, 420) # Creating the table for Environmentals self.env_table = QTableWidget(self) self.env_table.setRowCount(9) self.env_table.setColumnCount(3) self.env_table.setHorizontalHeaderLabels(["LOW", "ACTUAL", "HIGH"]) self.env_table.resize(321, 295) self.env_table.move(950, 450) # setGeometry has 4 values to pass in the first two are window position in relation to your computer (x, y) # the second two values are the size of the window itself (width, height) self.setGeometry(0, 0, 2000, 1000) # Sets the title of the window self.setWindowTitle('HyperLynx GUI')
def __init__(self, persepolis_setting): super().__init__() icon = QtGui.QIcon() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("setting_ui_tr", 'Preferences')) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) global icons icons = ':/' + str( self.persepolis_setting.value('settings/icons')) + '/' self.verticalLayout_2 = QVBoxLayout(self) self.setting_tabWidget = QTabWidget(self) # download_options_tab self.download_options_tab = QWidget() self.layoutWidget = QWidget(self.download_options_tab) self.download_options_verticalLayout = QVBoxLayout(self.layoutWidget) self.download_options_verticalLayout.setContentsMargins(21, 21, 0, 0) self.download_options_verticalLayout.setObjectName( "download_options_verticalLayout") self.horizontalLayout_5 = QHBoxLayout() # tries_label self.tries_label = QLabel(self.layoutWidget) self.horizontalLayout_5.addWidget(self.tries_label) # tries_spinBox self.tries_spinBox = QSpinBox(self.layoutWidget) self.tries_spinBox.setMinimum(1) self.horizontalLayout_5.addWidget(self.tries_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_5) self.horizontalLayout_4 = QHBoxLayout() # wait_label self.wait_label = QLabel(self.layoutWidget) self.horizontalLayout_4.addWidget(self.wait_label) # wait_spinBox self.wait_spinBox = QSpinBox(self.layoutWidget) self.horizontalLayout_4.addWidget(self.wait_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_4) self.horizontalLayout_3 = QHBoxLayout() # time_out_label self.time_out_label = QLabel(self.layoutWidget) self.horizontalLayout_3.addWidget(self.time_out_label) # time_out_spinBox self.time_out_spinBox = QSpinBox(self.layoutWidget) self.horizontalLayout_3.addWidget(self.time_out_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_3) self.horizontalLayout_2 = QHBoxLayout() # connections_label self.connections_label = QLabel(self.layoutWidget) self.horizontalLayout_2.addWidget(self.connections_label) # connections_spinBox self.connections_spinBox = QSpinBox(self.layoutWidget) self.connections_spinBox.setMinimum(1) self.connections_spinBox.setMaximum(16) self.horizontalLayout_2.addWidget(self.connections_spinBox) self.download_options_verticalLayout.addLayout(self.horizontalLayout_2) # rpc_port_label self.rpc_port_label = QLabel(self.layoutWidget) self.rpc_horizontalLayout = QHBoxLayout() self.rpc_horizontalLayout.addWidget(self.rpc_port_label) # rpc_port_spinbox self.rpc_port_spinbox = QSpinBox(self.layoutWidget) self.rpc_port_spinbox.setMinimum(1024) self.rpc_port_spinbox.setMaximum(65535) self.rpc_horizontalLayout.addWidget(self.rpc_port_spinbox) self.download_options_verticalLayout.addLayout( self.rpc_horizontalLayout) # wait_queue wait_queue_horizontalLayout = QHBoxLayout() self.wait_queue_label = QLabel(self.layoutWidget) wait_queue_horizontalLayout.addWidget(self.wait_queue_label) self.wait_queue_time = QDateTimeEdit(self.layoutWidget) self.wait_queue_time.setDisplayFormat('H:mm') wait_queue_horizontalLayout.addWidget(self.wait_queue_time) self.download_options_verticalLayout.addLayout( wait_queue_horizontalLayout) # change aria2 path aria2_path_verticalLayout = QVBoxLayout() self.aria2_path_checkBox = QCheckBox(self.layoutWidget) aria2_path_verticalLayout.addWidget(self.aria2_path_checkBox) aria2_path_horizontalLayout = QHBoxLayout() self.aria2_path_lineEdit = QLineEdit(self.layoutWidget) aria2_path_horizontalLayout.addWidget(self.aria2_path_lineEdit) self.aria2_path_pushButton = QPushButton(self.layoutWidget) aria2_path_horizontalLayout.addWidget(self.aria2_path_pushButton) aria2_path_verticalLayout.addLayout(aria2_path_horizontalLayout) self.download_options_verticalLayout.addLayout( aria2_path_verticalLayout) self.setting_tabWidget.addTab(self.download_options_tab, "") # save_as_tab self.save_as_tab = QWidget() self.layoutWidget1 = QWidget(self.save_as_tab) self.save_as_verticalLayout = QVBoxLayout(self.layoutWidget1) self.save_as_verticalLayout.setContentsMargins(20, 30, 0, 0) self.download_folder_horizontalLayout = QHBoxLayout() # download_folder_label self.download_folder_label = QLabel(self.layoutWidget1) self.download_folder_horizontalLayout.addWidget( self.download_folder_label) # download_folder_lineEdit self.download_folder_lineEdit = QLineEdit(self.layoutWidget1) self.download_folder_horizontalLayout.addWidget( self.download_folder_lineEdit) # download_folder_pushButton self.download_folder_pushButton = QPushButton(self.layoutWidget1) self.download_folder_horizontalLayout.addWidget( self.download_folder_pushButton) self.save_as_verticalLayout.addLayout( self.download_folder_horizontalLayout) self.temp_horizontalLayout = QHBoxLayout() # temp_download_label self.temp_download_label = QLabel(self.layoutWidget1) self.temp_horizontalLayout.addWidget(self.temp_download_label) # temp_download_lineEdit self.temp_download_lineEdit = QLineEdit(self.layoutWidget1) self.temp_horizontalLayout.addWidget(self.temp_download_lineEdit) # temp_download_pushButton self.temp_download_pushButton = QPushButton(self.layoutWidget1) self.temp_horizontalLayout.addWidget(self.temp_download_pushButton) self.save_as_verticalLayout.addLayout(self.temp_horizontalLayout) # create subfolder checkBox self.subfolder_checkBox = QCheckBox(self.layoutWidget1) self.save_as_verticalLayout.addWidget(self.subfolder_checkBox) self.setting_tabWidget.addTab(self.save_as_tab, "") # notifications_tab self.notifications_tab = QWidget() self.layoutWidget2 = QWidget(self.notifications_tab) self.verticalLayout_4 = QVBoxLayout(self.layoutWidget2) self.verticalLayout_4.setContentsMargins(21, 21, 0, 0) # enable_notifications_checkBox self.enable_notifications_checkBox = QCheckBox(self.layoutWidget2) self.verticalLayout_4.addWidget(self.enable_notifications_checkBox) # sound_frame self.sound_frame = QFrame(self.layoutWidget2) self.sound_frame.setFrameShape(QFrame.StyledPanel) self.sound_frame.setFrameShadow(QFrame.Raised) self.verticalLayout = QVBoxLayout(self.sound_frame) # volume_label self.volume_label = QLabel(self.sound_frame) self.verticalLayout.addWidget(self.volume_label) # volume_dial self.volume_dial = QDial(self.sound_frame) self.volume_dial.setProperty("value", 100) self.verticalLayout.addWidget(self.volume_dial) self.verticalLayout_4.addWidget(self.sound_frame) self.setting_tabWidget.addTab(self.notifications_tab, "") # style_tab self.style_tab = QWidget() self.layoutWidget3 = QWidget(self.style_tab) self.verticalLayout_3 = QVBoxLayout(self.layoutWidget3) self.verticalLayout_3.setContentsMargins(21, 21, 0, 0) self.horizontalLayout_8 = QHBoxLayout() # style_label self.style_label = QLabel(self.layoutWidget3) self.horizontalLayout_8.addWidget(self.style_label) # style_comboBox self.style_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_8.addWidget(self.style_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_8) self.horizontalLayout_7 = QHBoxLayout() # language_combox self.lang_label = QLabel(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.lang_label) self.lang_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.lang_comboBox) # language_label self.verticalLayout_3.addLayout(self.horizontalLayout_7) self.horizontalLayout_7 = QHBoxLayout() self.lang_label.setText( QCoreApplication.translate("setting_ui_tr", "Language:")) # color_label self.color_label = QLabel(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.color_label) # color_comboBox self.color_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_7.addWidget(self.color_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_7) # icon_label self.horizontalLayout_12 = QHBoxLayout() self.icon_label = QLabel(self.layoutWidget3) self.horizontalLayout_12.addWidget(self.icon_label) # icon_comboBox self.icon_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_12.addWidget(self.icon_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_12) # icons_size_comboBox self.icons_size_horizontalLayout = QHBoxLayout() self.icons_size_label = QLabel(self.layoutWidget3) self.icons_size_horizontalLayout.addWidget(self.icons_size_label) self.icons_size_comboBox = QComboBox(self.layoutWidget3) self.icons_size_horizontalLayout.addWidget(self.icons_size_comboBox) self.verticalLayout_3.addLayout(self.icons_size_horizontalLayout) self.horizontalLayout_6 = QHBoxLayout() # notification_label self.horizontalLayout_13 = QHBoxLayout() self.notification_label = QLabel(self.layoutWidget3) self.horizontalLayout_13.addWidget(self.notification_label) # notification_comboBox self.notification_comboBox = QComboBox(self.layoutWidget3) self.horizontalLayout_13.addWidget(self.notification_comboBox) self.verticalLayout_3.addLayout(self.horizontalLayout_13) # font_checkBox self.font_checkBox = QCheckBox(self.layoutWidget3) self.horizontalLayout_6.addWidget(self.font_checkBox) # fontComboBox self.fontComboBox = QFontComboBox(self.layoutWidget3) self.horizontalLayout_6.addWidget(self.fontComboBox) # font_size_label self.font_size_label = QLabel(self.layoutWidget3) self.horizontalLayout_6.addWidget(self.font_size_label) # font_size_spinBox self.font_size_spinBox = QSpinBox(self.layoutWidget3) self.font_size_spinBox.setMinimum(1) self.horizontalLayout_6.addWidget(self.font_size_spinBox) self.verticalLayout_3.addLayout(self.horizontalLayout_6) self.setting_tabWidget.addTab(self.style_tab, "") self.verticalLayout_2.addWidget(self.setting_tabWidget) self.horizontalLayout = QHBoxLayout() spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) # Enable system tray icon self.enable_system_tray_checkBox = QCheckBox(self.layoutWidget3) self.verticalLayout_3.addWidget(self.enable_system_tray_checkBox) # after_download dialog self.after_download_checkBox = QCheckBox() self.verticalLayout_3.addWidget(self.after_download_checkBox) # show_menubar_checkbox self.show_menubar_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.show_menubar_checkbox) # show_sidepanel_checkbox self.show_sidepanel_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.show_sidepanel_checkbox) # hide progress window self.show_progress_window_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.show_progress_window_checkbox) # add persepolis to startup self.startup_checkbox = QCheckBox() self.verticalLayout_3.addWidget(self.startup_checkbox) # keep system awake self.keep_awake_checkBox = QCheckBox() self.verticalLayout_3.addWidget(self.keep_awake_checkBox) # columns_tab self.columns_tab = QWidget() layoutWidget4 = QWidget(self.columns_tab) column_verticalLayout = QVBoxLayout(layoutWidget4) column_verticalLayout.setContentsMargins(21, 21, 0, 0) # creating checkBox for columns self.show_column_label = QLabel() self.column0_checkBox = QCheckBox() self.column1_checkBox = QCheckBox() self.column2_checkBox = QCheckBox() self.column3_checkBox = QCheckBox() self.column4_checkBox = QCheckBox() self.column5_checkBox = QCheckBox() self.column6_checkBox = QCheckBox() self.column7_checkBox = QCheckBox() self.column10_checkBox = QCheckBox() self.column11_checkBox = QCheckBox() self.column12_checkBox = QCheckBox() column_verticalLayout.addWidget(self.show_column_label) column_verticalLayout.addWidget(self.column0_checkBox) column_verticalLayout.addWidget(self.column1_checkBox) column_verticalLayout.addWidget(self.column2_checkBox) column_verticalLayout.addWidget(self.column3_checkBox) column_verticalLayout.addWidget(self.column4_checkBox) column_verticalLayout.addWidget(self.column5_checkBox) column_verticalLayout.addWidget(self.column6_checkBox) column_verticalLayout.addWidget(self.column7_checkBox) column_verticalLayout.addWidget(self.column10_checkBox) column_verticalLayout.addWidget(self.column11_checkBox) column_verticalLayout.addWidget(self.column12_checkBox) self.setting_tabWidget.addTab(self.columns_tab, '') # video_finder_tab self.video_finder_tab = QWidget() self.layoutWidgetYTD = QWidget(self.video_finder_tab) self.video_finder_layout = QVBoxLayout(self.layoutWidgetYTD) self.video_finder_layout.setContentsMargins(20, 30, 0, 0) self.video_finder_verticalLayout = QVBoxLayout() # Whether to enable video link capturing. self.enable_video_finder_checkbox = QCheckBox(self.layoutWidgetYTD) self.video_finder_layout.addWidget(self.enable_video_finder_checkbox) # If we should hide videos with no audio self.hide_no_audio_checkbox = QCheckBox(self.layoutWidgetYTD) self.video_finder_verticalLayout.addWidget(self.hide_no_audio_checkbox) # If we should hide audios without video self.hide_no_video_checkbox = QCheckBox(self.layoutWidgetYTD) self.video_finder_verticalLayout.addWidget(self.hide_no_video_checkbox) self.max_links_horizontalLayout = QHBoxLayout() # max_links_label self.max_links_label = QLabel(self.layoutWidgetYTD) self.max_links_horizontalLayout.addWidget(self.max_links_label) # max_links_spinBox self.max_links_spinBox = QSpinBox(self.layoutWidgetYTD) self.max_links_spinBox.setMinimum(1) self.max_links_spinBox.setMaximum(16) self.max_links_horizontalLayout.addWidget(self.max_links_spinBox) self.video_finder_verticalLayout.addLayout( self.max_links_horizontalLayout) self.video_finder_dl_path_horizontalLayout = QHBoxLayout() self.video_finder_frame = QFrame(self.video_finder_tab) self.video_finder_frame.setLayout(self.video_finder_verticalLayout) self.video_finder_layout.addWidget(self.video_finder_frame) self.setting_tabWidget.addTab(self.video_finder_tab, "") # defaults_pushButton self.defaults_pushButton = QPushButton(self) self.horizontalLayout.addWidget(self.defaults_pushButton) # cancel_pushButton self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) self.horizontalLayout.addWidget(self.cancel_pushButton) # ok_pushButton self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) self.horizontalLayout.addWidget(self.ok_pushButton) self.verticalLayout_2.addLayout(self.horizontalLayout) self.setting_tabWidget.setCurrentIndex(3) self.setWindowTitle( QCoreApplication.translate("setting_ui_tr", "Preferences")) self.tries_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set number of tries if download failed.</p></body></html>" )) self.tries_label.setText( QCoreApplication.translate("setting_ui_tr", "Number of tries: ")) self.tries_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set number of tries if download failed.</p></body></html>" )) self.wait_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set the seconds to wait between retries. Download manager will retry downloads when the HTTP server returns a 503 response.</p></body></html>" )) self.wait_label.setText( QCoreApplication.translate("setting_ui_tr", "Wait between retries (seconds): ")) self.wait_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set the seconds to wait between retries. Download manager will retry downloads when the HTTP server returns a 503 response.</p></body></html>" )) self.time_out_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set timeout in seconds. </p></body></html>" )) self.time_out_label.setText( QCoreApplication.translate("setting_ui_tr", "Timeout (seconds): ")) self.time_out_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set timeout in seconds. </p></body></html>" )) self.connections_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>" )) self.connections_label.setText( QCoreApplication.translate("setting_ui_tr", "Number of connections: ")) self.connections_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>" )) self.rpc_port_label.setText( QCoreApplication.translate("setting_ui_tr", "RPC port number: ")) self.rpc_port_spinbox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p> Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible Values: 1024 - 65535 Default: 6801 </p></body></html>" )) self.wait_queue_label.setText( QCoreApplication.translate( "setting_ui_tr", 'Wait between every downloads in queue:')) self.aria2_path_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Change Aria2 default path')) self.aria2_path_pushButton.setText( QCoreApplication.translate("setting_ui_tr", 'Change')) aria2_path_tooltip = QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Attention: Wrong path may have caused problem! Do it carefully or don't change default setting!</p></body></html>" ) self.aria2_path_checkBox.setToolTip(aria2_path_tooltip) self.aria2_path_lineEdit.setToolTip(aria2_path_tooltip) self.aria2_path_pushButton.setToolTip(aria2_path_tooltip) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.download_options_tab), QCoreApplication.translate("setting_ui_tr", "Download Options")) self.download_folder_label.setText( QCoreApplication.translate("setting_ui_tr", "Download Folder: ")) self.download_folder_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Change")) self.temp_download_label.setText( QCoreApplication.translate("setting_ui_tr", "Temporary Download Folder: ")) self.temp_download_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Change")) self.subfolder_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Create subfolders for Music,Videos,... in default download folder" )) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.save_as_tab), QCoreApplication.translate("setting_ui_tr", "Save as")) self.enable_notifications_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Enable notification sounds")) self.volume_label.setText( QCoreApplication.translate("setting_ui_tr", "Volume: ")) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.notifications_tab), QCoreApplication.translate("setting_ui_tr", "Notifications")) self.style_label.setText( QCoreApplication.translate("setting_ui_tr", "Style: ")) self.color_label.setText( QCoreApplication.translate("setting_ui_tr", "Color scheme: ")) self.icon_label.setText( QCoreApplication.translate("setting_ui_tr", "Icons: ")) self.icons_size_label.setText( QCoreApplication.translate("setting_ui_tr", "Toolbar's icons size: ")) self.notification_label.setText( QCoreApplication.translate("setting_ui_tr", "Notification type: ")) self.font_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Font: ")) self.font_size_label.setText( QCoreApplication.translate("setting_ui_tr", "Size: ")) self.enable_system_tray_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Enable system tray icon.")) self.after_download_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Show download complete dialog when download has finished.")) self.show_menubar_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Show menubar.")) self.show_sidepanel_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Show side panel.")) self.show_progress_window_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Show download's progress window")) self.startup_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Run Persepolis at startup")) self.keep_awake_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Keep system awake!")) self.keep_awake_checkBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>This option is preventing system from going to sleep.\ This is necessary if your power manager is suspending system automatically. </p></body></html>" )) self.wait_queue_time.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Format HH:MM</p></body></html>")) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.style_tab), QCoreApplication.translate("setting_ui_tr", "Preferences")) # columns_tab self.show_column_label.setText( QCoreApplication.translate("setting_ui_tr", 'Show this columns:')) self.column0_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'File Name')) self.column1_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Status')) self.column2_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Size')) self.column3_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Downloaded')) self.column4_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Percentage')) self.column5_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Connections')) self.column6_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Transfer rate')) self.column7_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Estimated time left')) self.column10_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'First try date')) self.column11_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Last try date')) self.column12_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Category')) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.columns_tab), QCoreApplication.translate("setting_ui_tr", "Columns customization")) # Video Finder options tab self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.video_finder_tab), QCoreApplication.translate("setting_ui_tr", "Video Finder Options")) self.enable_video_finder_checkbox.setText( QCoreApplication.translate("setting_ui_tr", 'Enable Video Finder')) self.hide_no_audio_checkbox.setText( QCoreApplication.translate("setting_ui_tr", 'Hide videos with no audio')) self.hide_no_video_checkbox.setText( QCoreApplication.translate("setting_ui_tr", 'Hide audios with no video')) self.max_links_label.setText( QCoreApplication.translate( "setting_ui_tr", 'Maximum number of links to capture:<br/>' '<small>(If browser sends multiple video links at a time)</small>' )) # window buttons self.defaults_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Defaults")) self.cancel_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Cancel")) self.ok_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "OK"))
def __init__(self, parent=None): super(RDGgui, self).__init__(parent) self.mode_dict = { "infinite forward": (ModuleWrapper, wrapper_args), "object detection": (ModuleWrapperDet, wrapper_args_det) } modeComboBox = QComboBox() modeComboBox.addItems(self.mode_dict.keys()) modeLabel = QLabel("&Mode:") modeLabel.setBuddy(modeComboBox) modeComboBox.activated[str].connect(self.changeMode) startButton = QPushButton("Start", self) startButton.clicked.connect(self.startRun) self.stopButton = QPushButton("Stop", self) self.stopButton.clicked.connect(self.stop_thread) #self.stopButton.clicked.connect(self.stopRun) monitorCheckBox = QCheckBox("Monitor", self) monitorCheckBox.stateChanged.connect(self.checkMonitor) voiceCheckBox = QCheckBox("Voice", self) voiceCheckBox.stateChanged.connect(self.checkVoice) bagCheckBox = QCheckBox("Bagfile", self) bagCheckBox.stateChanged.connect(self.checkBag) self.progLabel = QLabel("Choose a function.") self.rgbLabel = QLabel(self) self.depLabel = QLabel(self) self.mapLabel = QLabel(self) self.dirLabel = QLabel(self) topLayout = QHBoxLayout() topLayout.addWidget(modeLabel) topLayout.addWidget(modeComboBox) topLayout.addWidget(startButton) topLayout.addWidget(self.stopButton) topLayout.addWidget(monitorCheckBox) topLayout.addWidget(voiceCheckBox) topLayout.addWidget(bagCheckBox) topLeftLayout = QHBoxLayout() topLeftLayout.addWidget(self.rgbLabel) topRightLayout = QHBoxLayout() topRightLayout.addWidget(self.depLabel) botLeftLayout = QHBoxLayout() botLeftLayout.addWidget(self.mapLabel) botRightLayout = QHBoxLayout() botRightLayout.addWidget(self.dirLabel) botLayout = QHBoxLayout() botLayout.addWidget(self.progLabel) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addLayout(topLeftLayout, 1, 0) mainLayout.addLayout(topRightLayout, 1, 1) mainLayout.addLayout(botLeftLayout, 2, 0) mainLayout.addLayout(botRightLayout, 2, 1) mainLayout.addLayout(botLayout, 3, 0, 1, 2) self.setLayout(mainLayout) self.run_flag = False self.pause_flag = False self.monitor_flag = False self.voice_flag = False self.bag_flag = False self.funcName = None
def run_from_line(P, W, ACTION, STATUS, linuxcnc): inData, outData, newFile, params = [], [], [], [] g2, g4, g6, g9, g9arc, d3, d2, a3, material, x, y, code, rflSpindle = '', '', '', '', '', '', '', '', '', '', '', '', '' oSub = False count = 0 tmpMat = False head = _translate('HandlerClass', 'GCODE ERROR') with open(P.lastLoadedProgram, 'r') as inFile: for line in inFile: if count < P.startLine: inData.append(line.lower()) else: if count == P.startLine: if 'g21' in line: newFile.append('g21') elif 'g20' in line: newFile.append('g20') outData.append(line.lower()) count += 1 cutComp = False for line in inData: if line.startswith('('): if line.startswith('(o='): material = line.strip() continue if line.startswith('#'): params.append(line.strip()) continue if line.startswith('m190'): mat = line.split('p')[1] try: if '(' in mat: num = int(mat.split('(')[0]) else: num = int(mat) except: head = _translate('HandlerClass', 'G-CODE ERROR') msg0 = _translate('HandlerClass', 'is an invalid material number') msg1 = _translate('HandlerClass', 'Material #0 will be selected') STATUS.emit('error', linuxcnc.OPERATOR_ERROR, '{}:\n"{}" {}\n{}\n'.format(head, mat, msg0, msg1)) num = 0 if num >= 1000000: tmpMat = True else: material = line.strip() continue if line.replace(' ', '').startswith('m66p3') and tmpMat: tmpMat = False continue for t1 in [ 'g20', 'g21', 'g40', 'g41.1', 'g42.1', 'g61', 'g61.1', 'g64', 'g90', 'g90.1', 'g91', 'g91.1' ]: if t1 in line: if t1[1] == '2': g2 = t1 elif t1[1] == '4': g4 = t1 if t1 != 'g40': cutComp = True else: cutComp = False elif t1[1] == '6': g6 = t1 if t1 == 'g64': tmp = line.split('64')[1] if tmp[0] == 'p': p = '' tmp = tmp[1:] while 1: if tmp[0] in '.0123456789q': p += tmp[0] tmp = tmp[1:] else: break g6 = 'g64p{}'.format(p) elif t1 == 'g90' and not 'g90.1' in line: g9 = 'g90' elif t1 == 'g91' and not 'g91.1' in line: g9 = 'g91' elif t1 == 'g90.1' in line: g9arc = 'g90.1' elif t1 == 'g91.1' in line: g9arc = 'g91.1' if 'g0' in line: code = 'g0' if 'g1' in line: tmp = line.split('g1')[1] if tmp[0] not in '0123456789': code = 'g1' if 'g2' in line: tmp = line.split('g2')[1] if tmp[0] not in '0123456789': code = 'g2' if 'g3' in line: tmp = line.split('g3')[1] if tmp[0] not in '0123456789': code = 'g3' if 'x' in line: x = get_rfl_pos(line.strip(), x, 'x') if 'y' in line: y = get_rfl_pos(line.strip(), y, 'y') if 'm3' in line: rflSpindle = 'm3' tmp = line.split('m3')[1] while 1: if tmp[0] in '0123456789s$': rflSpindle += tmp[0] tmp = tmp[1:] else: break if 'm5' in line: rflSpindle = '' if 'm62p3' in line.replace(' ', ''): d3 = 'm62p3 (Disable Torch)' elif 'm63p3' in line.replace(' ', ''): d3 = 'm63p3 (Enable Torch)' elif 'm64p3' in line.replace(' ', ''): d3 = 'm64p3 (Disable Torch)' elif 'm65p3' in line.replace(' ', ''): print("M65 P2 found in", line.strip()) d3 = 'm65p3 (Enable Torch)' if 'm62p2' in line.replace(' ', ''): print("M62 P2 found in", line.strip()) d2 = 'm62p2 (Disable THC)' elif 'm63p2' in line.replace(' ', ''): d2 = 'm63p2 (Enable THC)' elif 'm64p2' in line.replace(' ', ''): d2 = 'm64p2 (Disable THC)' elif 'm65p2' in line.replace(' ', ''): d2 = 'm65p2 (Enable THC)' if 'm67e3q' in line.replace(' ', ''): a3 = 'm67e3q' tmp = line.replace(' ', '').split('m67e3q')[1] while 1: if tmp[0] in '-.0123456789': a3 += tmp[0] tmp = tmp[1:] else: break pc = int(a3.split('m67e3q')[1]) pc = pc if pc > 0 else 100 a3 += ' (Velocity {}%)'.format(pc) if 'm68e3q' in line.replace(' ', ''): print("M68 E3 Q found in", line.strip()) a3 = 'm68e3q' tmp = line.replace(' ', '').split('m68e3q')[1] bb = 1 while 1: if tmp[0] in '-.0123456789': a3 += tmp[0] tmp = tmp[1:] else: break pc = int(a3.split('m68e3q')[1]) pc = pc if pc > 0 else 100 a3 += ' (Velocity {}%)'.format(pc) if line.startswith('o'): if 'end' in line: oSub = False else: oSub = True if cutComp or oSub: if cutComp: msg0 = _translate('HandlerClass', 'Cannot run from line while') msg1 = _translate('HandlerClass', 'cutter compensation is active') elif oSub: msg0 = _translate('HandlerClass', 'Cannot do run from line') msg1 = _translate('HandlerClass', 'inside a subroutine') STATUS.emit('error', linuxcnc.OPERATOR_ERROR, '{}:\n{}\n{}\n'.format(head, msg0, msg1)) P.rflActive = False P.set_run_button_state() P.startLine = 0 return # show the dialog rFl = QDialog(W) rFl.setWindowTitle(_translate('HandlerClass', 'RUN FROM LINE')) lbl1 = QLabel(_translate('HandlerClass', 'USE LEADIN:')) lbl2 = QLabel(_translate('HandlerClass', 'LEADIN LENGTH:')) lbl3 = QLabel(_translate('HandlerClass', 'LEADIN ANGLE:')) lbl4 = QLabel('') leadinDo = QCheckBox() leadinLength = QDoubleSpinBox() leadinAngle = QDoubleSpinBox() buttons = QDialogButtonBox.Ok | QDialogButtonBox.Cancel buttonBox = QDialogButtonBox(buttons) buttonBox.accepted.connect(rFl.accept) buttonBox.rejected.connect(rFl.reject) buttonBox.button(QDialogButtonBox.Ok).setText( _translate('HandlerClass', 'LOAD')) buttonBox.button(QDialogButtonBox.Ok).setIcon(QIcon()) buttonBox.button(QDialogButtonBox.Cancel).setText( _translate('HandlerClass', 'CANCEL')) buttonBox.button(QDialogButtonBox.Cancel).setIcon(QIcon()) layout = QGridLayout() layout.addWidget(lbl1, 0, 0) layout.addWidget(lbl2, 1, 0) layout.addWidget(lbl3, 2, 0) layout.addWidget(lbl4, 3, 0) layout.addWidget(leadinDo, 0, 1) layout.addWidget(leadinLength, 1, 1) layout.addWidget(leadinAngle, 2, 1) layout.addWidget(buttonBox, 4, 0, 1, 2) rFl.setLayout(layout) lbl1.setAlignment(Qt.AlignRight | Qt.AlignBottom) lbl2.setAlignment(Qt.AlignRight | Qt.AlignBottom) lbl3.setAlignment(Qt.AlignRight | Qt.AlignBottom) if P.units == 'inch': leadinLength.setDecimals(2) leadinLength.setSingleStep(0.05) leadinLength.setSuffix(' inch') leadinLength.setMinimum(0.05) else: leadinLength.setDecimals(0) leadinLength.setSingleStep(1) leadinLength.setSuffix(' mm') leadinLength.setMinimum(1) leadinAngle.setDecimals(0) leadinAngle.setSingleStep(1) leadinAngle.setSuffix(' deg') leadinAngle.setRange(-359, 359) leadinAngle.setWrapping(True) result = rFl.exec_() # cancel from dialog if not result: P.rflActive = False P.set_run_button_state() P.startLine = 0 W.gcode_display.setCursorPosition(0, 0) return # run from dialog for param in params: if param: newFile.append(param) scale = 1 zMax = '' if P.unitsPerMm == 1: if g2 == 'g20': scale = 0.03937 zMax = 'g53 g0z[[#<_ini[axis_z]max_limit> - 5] * 0.03937]' else: zMax = 'g53 g0z[#<_ini[axis_z]max_limit> - 5]' elif P.unitsPerMm == 0.03937: if g2 == 'g21': scale = 25.4 zMax = 'g53 g0z[[#<_ini[axis_z]max_limit> * 25.4] - 5]' else: zMax = 'g53 g0z[#<_ini[axis_z]max_limit> - 0.02]' if g2: newFile.append(g2) if g4: newFile.append(g4) if g6: newFile.append(g6) if g9: newFile.append(g9) if g9arc: newFile.append(g9arc) newFile.append('M52 P1') if d3: newFile.append(d3) if d2: newFile.append(d2) if a3: newFile.append(a3) if zMax: newFile.append(zMax) if material: newFile.append(material) if not '(o=' in material: newFile.append('m66p3l3q1') # don't scale feedrate, parameters should be set correctly in material file newFile.append('f#<_hal[plasmac.cut-feed-rate]>') xL = x yL = y try: if leadinDo.isChecked(): if x[-1] == ']': xL = '{}[[{}]+{:0.6f}]'.format( x[:1], x[1:], (leadinLength.value() * scale) * math.cos(math.radians(leadinAngle.value()))) yL = '{}[[{}]+{:0.6f}]'.format( y[:1], y[1:], (leadinLength.value() * scale) * math.sin(math.radians(leadinAngle.value()))) else: xL = float(x) + ((leadinLength.value() * scale) * math.cos(math.radians(leadinAngle.value()))) yL = float(y) + ((leadinLength.value() * scale) * math.sin(math.radians(leadinAngle.value()))) except: msg0 = _translate('HandlerClass', 'Unable to calculate a leadin for this cut') msg1 = _translate( 'HandlerClass', 'Program will run from selected line with no leadin applied') STATUS.emit('error', linuxcnc.OPERATOR_ERROR, '{}:\n{}\n{}\n'.format(head, msg0, msg1)) if xL != x and yL != y: newFile.append('G0 X{} Y{}'.format(xL, yL)) rflLead = [x, y] else: if x and y: newFile.append('G0 X{} Y{}'.format(x, y)) elif x: newFile.append('G0 X{}'.format(x)) elif y: newFile.append('G0 Y{}'.format(y)) rflLead = None if rflSpindle: newFile.append(rflSpindle) if rflLead: newFile.append('G1 X{} Y{}'.format(rflLead[0], rflLead[1])) for line in outData: if outData.index(line) == 0 and (line.startswith('x') or line.startswith('y')): line = '{}{}'.format(code, line) elif line.startswith('m190'): mat = line.split('p')[1] if '(' in mat: num = int(mat.split('(')[0]) else: num = int(mat) if num >= 1000000: tmpMat = True continue elif line.replace(' ', '').startswith('m66p3') and tmpMat: tmpMat = False continue newFile.append(line.strip()) rflFile = '{}rfl.ngc'.format(P.tmpPath) with open(rflFile, 'w') as outFile: for line in newFile: outFile.write('{}\n'.format(line)) if ACTION.prefilter_path or P.lastLoadedProgram != 'None': P.preRflFile = ACTION.prefilter_path or P.lastLoadedProgram ACTION.OPEN_PROGRAM(rflFile) ACTION.prefilter_path = P.preRflFile P.set_run_button_state() txt0 = _translate('HandlerClass', 'RUN FROM LINE') txt1 = _translate('HandlerClass', 'CYCLE START') P.runText = '{}\n{}'.format(txt0, txt1) W.gcodegraphics.highlight_graphics(None)
def add_mixing_tab(self): self.mixing_tab = QWidget() grid = QGridLayout(self.mixing_tab) psman = self.psman # warn_electrumx warn_ex_text = psman.warn_electrumx_data() warn_ex_help = psman.warn_electrumx_data(full_txt=True) def get_show_warn_electrumx_value(): return not psman.show_warn_electrumx def on_show_warn_electrumx_changed(x): psman.show_warn_electrumx = (x != Qt.Checked) warn_cb_text = _('Do not show this on PrivateSend dialog open.') self.warn_ex_label = WarnLabel(warn_ex_text, warn_ex_help, warn_cb_text, get_show_warn_electrumx_value, on_show_warn_electrumx_changed) i = grid.rowCount() grid.addWidget(self.warn_ex_label, i, 0, 1, -1) # keep_amount keep_amount_text = psman.keep_amount_data() keep_amount_help = psman.keep_amount_data(full_txt=True) keep_amount_label = HelpLabel(keep_amount_text + ':', keep_amount_help) self.keep_amount_sb = AxeSpinBox() self.keep_amount_sb.setMinimum(psman.min_keep_amount) self.keep_amount_sb.setMaximum(psman.max_keep_amount) self.keep_amount_sb.setValue(psman.keep_amount) def on_keep_amount_change(): psman.keep_amount = self.keep_amount_sb.value() self.update_balances() self.keep_amount_sb.valueChanged.connect(on_keep_amount_change) i = grid.rowCount() grid.addWidget(keep_amount_label, i, 0) grid.addWidget(self.keep_amount_sb, i, 2) # mix_rounds mix_rounds_text = psman.mix_rounds_data() mix_rounds_help = psman.mix_rounds_data(full_txt=True) mix_rounds_label = HelpLabel(mix_rounds_text + ':', mix_rounds_help) self.mix_rounds_sb = QSpinBox() self.mix_rounds_sb.setMinimum(psman.min_mix_rounds) self.mix_rounds_sb.setMaximum(psman.max_mix_rounds) self.mix_rounds_sb.setValue(psman.mix_rounds) def on_mix_rounds_change(): psman.mix_rounds = self.mix_rounds_sb.value() self.update_balances() self.mix_rounds_sb.valueChanged.connect(on_mix_rounds_change) i = grid.rowCount() grid.addWidget(mix_rounds_label, i, 0) grid.addWidget(self.mix_rounds_sb, i, 2) # mixing control self.mixing_ctl_btn = QPushButton(psman.mixing_control_data()) def mixing_ctl_btn_pressed(): if psman.state == PSStates.Ready: need_new_kp, prev_kp_state = psman.check_need_new_keypairs() if need_new_kp: self.start_mixing(prev_kp_state) else: psman.start_mixing(None) elif psman.state == PSStates.Mixing: psman.stop_mixing() elif psman.state == PSStates.Disabled: psman.enable_ps() self.mixing_ctl_btn.clicked.connect(mixing_ctl_btn_pressed) i = grid.rowCount() grid.addWidget(self.mixing_ctl_btn, i, 0, 1, -1) # mixing progress mix_progress_text = psman.mixing_progress_data() mix_progress_help = psman.mixing_progress_data(full_txt=True) mix_progress_label = \ HelpLabel(mix_progress_text + ':', mix_progress_help) self.mix_progress_bar = QProgressBar() i = grid.rowCount() grid.addWidget(mix_progress_label, i, 0) grid.addWidget(self.mix_progress_bar, i, 2) # ps balance ps_balance_text = psman.ps_balance_data() ps_balance_help = psman.ps_balance_data(full_txt=True) ps_balance_label = HelpLabel(ps_balance_text + ':', ps_balance_help) self.ps_balance_amount = QLabel() i = grid.rowCount() grid.addWidget(ps_balance_label, i, 0) grid.addWidget(self.ps_balance_amount, i, 2) # denominated balance dn_balance_text = psman.dn_balance_data() dn_balance_help = psman.dn_balance_data(full_txt=True) dn_balance_label = HelpLabel(dn_balance_text + ':', dn_balance_help) self.dn_balance_amount = QLabel() i = grid.rowCount() grid.addWidget(dn_balance_label, i, 0) grid.addWidget(self.dn_balance_amount, i, 2) # create_sm_denoms self.create_sm_denoms_bnt = QPushButton(psman.create_sm_denoms_data()) def on_create_sm_denoms(x): denoms_by_vals = psman.calc_denoms_by_values() if (not denoms_by_vals or not psman.check_big_denoms_presented(denoms_by_vals)): msg = psman.create_sm_denoms_data(no_denoms_txt=True) self.show_error(msg) else: if psman.check_enough_sm_denoms(denoms_by_vals): q = psman.create_sm_denoms_data(enough_txt=True) else: q = psman.create_sm_denoms_data(confirm_txt=True) if self.question(q): self.mwin.create_small_denoms(denoms_by_vals, self) self.create_sm_denoms_bnt.clicked.connect(on_create_sm_denoms) i = grid.rowCount() grid.addWidget(self.create_sm_denoms_bnt, i, 0, 1, -1) # max_sessions max_sessions_text = psman.max_sessions_data() max_sessions_help = psman.max_sessions_data(full_txt=True) max_sessions_label = \ HelpLabel(max_sessions_text + ':', max_sessions_help) self.max_sessions_sb = QSpinBox() self.max_sessions_sb.setMinimum(psman.min_max_sessions) self.max_sessions_sb.setMaximum(psman.max_max_sessions) self.max_sessions_sb.setValue(psman.max_sessions) def on_max_sessions_change(): psman.max_sessions = self.max_sessions_sb.value() self.max_sessions_sb.valueChanged.connect(on_max_sessions_change) i = grid.rowCount() grid.addWidget(max_sessions_label, i, 0) grid.addWidget(self.max_sessions_sb, i, 2) # kp_timeout kp_timeout_text = psman.kp_timeout_data() kp_timeout_help = psman.kp_timeout_data(full_txt=True) kp_timeout_label = HelpLabel(kp_timeout_text + ':', kp_timeout_help) self.kp_timeout_sb = QSpinBox() self.kp_timeout_sb.setMinimum(psman.min_kp_timeout) self.kp_timeout_sb.setMaximum(psman.max_kp_timeout) self.kp_timeout_sb.setValue(psman.kp_timeout) def on_kp_timeout_change(): psman.kp_timeout = self.kp_timeout_sb.value() self.kp_timeout_sb.valueChanged.connect(on_kp_timeout_change) i = grid.rowCount() grid.addWidget(kp_timeout_label, i, 0) grid.addWidget(self.kp_timeout_sb, i, 2) # group_history group_hist_cb = QCheckBox(psman.group_history_data(full_txt=True)) group_hist_cb.setChecked(psman.group_history) def on_group_hist_state_changed(x): psman.group_history = (x == Qt.Checked) self.mwin.history_model.refresh('on_grouping_change') group_hist_cb.stateChanged.connect(on_group_hist_state_changed) i = grid.rowCount() grid.addWidget(group_hist_cb, i, 0, 1, -1) # notify_ps_txs notify_txs_cb = QCheckBox(psman.notify_ps_txs_data(full_txt=True)) notify_txs_cb.setChecked(psman.notify_ps_txs) def on_notify_txs_state_changed(x): psman.notify_ps_txs = (x == Qt.Checked) notify_txs_cb.stateChanged.connect(on_notify_txs_state_changed) i = grid.rowCount() grid.addWidget(notify_txs_cb, i, 0, 1, -1) # subscribe_spent sub_spent_cb = QCheckBox(psman.subscribe_spent_data(full_txt=True)) sub_spent_cb.setChecked(psman.subscribe_spent) def on_sub_spent_state_changed(x): psman.subscribe_spent = (x == Qt.Checked) sub_spent_cb.stateChanged.connect(on_sub_spent_state_changed) i = grid.rowCount() grid.addWidget(sub_spent_cb, i, 0, 1, -1) # allow_others allow_others_cb = QCheckBox(psman.allow_others_data(full_txt=True)) allow_others_cb.setChecked(psman.allow_others) def on_allow_others_changed(x): if x == Qt.Checked: q = psman.allow_others_data(qt_question=True) if self.question(q): psman.allow_others = True else: allow_others_cb.setCheckState(Qt.Unchecked) else: psman.allow_others = False self.mwin.update_avalaible_amount() allow_others_cb.stateChanged.connect(on_allow_others_changed) i = grid.rowCount() grid.addWidget(allow_others_cb, i, 0, 1, -1) # final tab setup i = grid.rowCount() grid.setRowStretch(i, 1) grid.setColumnStretch(1, 1) grid.setColumnStretch(2, 1) self.tabs.addTab(self.mixing_tab, _('Mixing'))
def __init__(self, main): # init QWidget.__init__(self) self.main = main self.lang = main.lang # setup window self.setWindowIcon(QIcon(SETTINGS)) self.setWindowTitle(self.lang['settings_title']) self.resize(410, 240) # setup vars self._palette = QPalette() self._palette.setColor(QPalette.WindowText, main._palette.color(QPalette.WindowText)) # setup update label self.update_label = QLabel(self.lang['update_label'], self) self.update_label.setToolTip(self.lang['update_label_tt']) # setup update spinbox self.update_spinbox = QSpinBox(self) self.update_spinbox.setToolTip(self.lang['update_spinbox_tt']) self.update_spinbox.setMinimum(500) self.update_spinbox.setMaximum(86400000) self.update_spinbox.setValue(main._update) # setup round label self.round_label = QLabel(self.lang['round_label']) self.round_label.setToolTip(self.lang['round_label_tt']) # setup round spinbox self.round_spinbox = QSpinBox(self) self.round_spinbox.setToolTip(self.lang['round_spinbox_tt']) self.round_spinbox.setMinimum(1) self.round_spinbox.setMaximum(100) self.round_spinbox.setValue(main._round) # setup font size spinbox self.size_spinbox = QSpinBox() self.size_spinbox.setToolTip(self.lang['size_spinbox_tt']) self.size_spinbox.setMinimum(8) self.size_spinbox.setMaximum(80) self.size_spinbox.setValue(main._font.pointSize()) # setup ram checkbox self.ram_checkbox = QCheckBox(self.lang['ram_checkbox'], self) self.ram_checkbox.setToolTip(self.lang['ram_checkbox_tt']) self.ram_checkbox.setChecked(main._ram) # setup swap checkbox self.swap_checkbox = QCheckBox(self.lang['swap_checkbox'], self) self.swap_checkbox.setToolTip(self.lang['swap_checkbox_tt']) self.swap_checkbox.setChecked(main._swap) # setup mbytes checkbox self.mb_checkbox = QCheckBox(self.lang['mb_checkbox'], self) self.mb_checkbox.setToolTip(self.lang['mb_checkbox_tt']) self.mb_checkbox.setChecked(main._mb) # setup labels checkbox self.labels_checkbox = QCheckBox(self.lang['labels_checkbox'], self) self.labels_checkbox.setToolTip(self.lang['labels_checkbox_tt']) self.labels_checkbox.setChecked(main._labels) # setup text checkbox self.text_checkbox = QCheckBox(self.lang['text_checkbox'], self) self.text_checkbox.setToolTip(self.lang['text_checkbox_tt']) self.text_checkbox.setChecked(main._text) # setup bold checkbox self.bold_checkbox = QCheckBox(self.lang['bold_checkbox'], self) self.bold_checkbox.setToolTip(self.lang['bold_checkbox_tt']) self.bold_checkbox.setChecked(main._font.bold()) # setup color button self.color_button = QPushButton(self.lang['color_button'], self) self.color_button.setToolTip(self.lang['color_button_tt']) self.color_button.clicked.connect(self._color) # setup save button self.save_button = QPushButton(self.lang['save_button'], self) self.save_button.setToolTip(self.lang['save_button_tt']) self.save_button.clicked.connect(self._save) # setup cancel button self.cancel_button = QPushButton(self.lang['cancel_button'], self) self.cancel_button.setToolTip(self.lang['cancel_button_tt']) self.cancel_button.clicked.connect(self.close) # setup buttons h box layout self.h_box = QHBoxLayout() self.h_box.addWidget(self.save_button) self.h_box.addWidget(self.cancel_button) # setup layout layout self.grid = QGridLayout(self) self.grid.addWidget(self.update_label, 0, 0) self.grid.addWidget(self.update_spinbox, 0, 1) self.grid.addWidget(self.round_label, 1, 0) self.grid.addWidget(self.round_spinbox, 1, 1) self.grid.addWidget(self.ram_checkbox, 2, 0) self.grid.addWidget(self.swap_checkbox, 2, 1) self.grid.addWidget(self.mb_checkbox, 3, 0) self.grid.addWidget(self.labels_checkbox, 3, 1) self.grid.addWidget(self.text_checkbox, 4, 0) self.grid.addWidget(self.color_button, 4, 1) self.grid.addWidget(self.size_spinbox, 5, 0) self.grid.addWidget(self.bold_checkbox, 5, 1) self.grid.addLayout(self.h_box, 6, 0, 1, 2) # show self.show()
def initUI(self): self.Name_label = QLabel('Machine Vision System V1') self.live_checkbox = QCheckBox('Live On/Off') self.serial_btn = QPushButton('Serial Connect') self.model_load_btn = QPushButton('Model Load') self.Opencv_checkbox = QCheckBox('Opencv On/OFF') self.Dnn_infer_checkbox = QCheckBox('DNN Infer On/OFF') self.image_label = QLabel('image view') self.edge_label = QLabel('Edge view') self.detect_label0 = QLabel('detect view0') self.detect_label1 = QLabel('detect view1') self.detect_label2 = QLabel('detect view2') self.detect_label3 = QLabel('detect view3') self.detect_label4 = QLabel('detect view4') self.detect_label5 = QLabel('detect view5') self.logwindow = QTextEdit() self.logwindow.setAcceptRichText(False) self.logwindow.setPlainText("Log start !!!") Name_label_font = self.Name_label.font() Name_label_font.setBold(True) Name_label_font.setPointSize(20) self.Name_label.setFont(Name_label_font) self.image_label.resize(640, 480) self.edge_label.resize(640, 480) self.detect_label0.resize(100, 100) self.detect_label1.resize(100, 100) self.detect_label2.resize(100, 100) self.detect_label3.resize(100, 100) self.detect_label4.resize(100, 100) self.detect_label5.resize(100, 100) base_img = cv2.imread('keras.jpg') base_img = cv2.cvtColor(base_img, cv2.COLOR_BGR2RGB) base_img = cv2.resize(base_img, dsize=(640, 480), interpolation=cv2.INTER_AREA) base_h, base_w, base_c = base_img.shape base_qImg = QtGui.QImage(base_img.data, base_w, base_h, base_w*base_c, QtGui.QImage.Format_RGB888) base_pixmap = QtGui.QPixmap.fromImage(base_qImg) self.image_label.setPixmap(base_pixmap) grid = QGridLayout() grid.addWidget(self.detect_label0, 0,0) grid.addWidget(self.detect_label1, 0,1) grid.addWidget(self.detect_label2, 0,2) grid.addWidget(self.detect_label3, 1,0) grid.addWidget(self.detect_label4, 1,1) grid.addWidget(self.detect_label5, 1,2) hbox1 = QHBoxLayout() hbox1.addWidget(self.Name_label) hbox1.addStretch(2) hbox2 = QHBoxLayout() hbox2.addWidget(self.live_checkbox) hbox2.addWidget(self.serial_btn) hbox2.addWidget(self.model_load_btn) hbox2.addWidget(self.Opencv_checkbox) hbox2.addWidget(self.Dnn_infer_checkbox) hbox2.addStretch(2) hbox3 = QHBoxLayout() hbox3.addWidget(self.image_label) hbox3.addWidget(self.logwindow) hbox4 = QHBoxLayout() hbox4.addWidget(self.edge_label) hbox4.addLayout(grid) vbox = QVBoxLayout() vbox.addStretch(0.1) vbox.addLayout(hbox1) vbox.addLayout(hbox2) vbox.addLayout(hbox3) vbox.addLayout(hbox4) vbox.addStretch(1) self.setLayout(vbox) self.live_checkbox.stateChanged.connect(self.change_mode) self.serial_btn.clicked.connect(self.serial_connect) self.model_load_btn.clicked.connect(self.model_load) self.Opencv_checkbox.stateChanged.connect(self.opencv_apply) self.Dnn_infer_checkbox.stateChanged.connect(self.Dnn_infer_apply) self.setWindowTitle('Machine Vision System') self.setGeometry(300, 100, 1000, 900) self.show()