def get_font(self): try: conf = self.get_console_config() return QFontDialog.getFont(conf) #return pango.FontDescription(conf['font.type']) except KeyError: return QFontDialog.setFont(QFont="Liberation Sans")
def on_bTest_clicked(self): """ Private method to test the selected options. """ if self.font is None: QFontDialog.getFont() else: QFontDialog.getFont(self.font)
def on_fontButton_clicked(self): """ Private slot to handle the button press to select a font via a font selection dialog. """ if self.font is None: font, ok = QFontDialog.getFont() else: font, ok = QFontDialog.getFont(self.font) if ok: self.font = font else: self.font = None
def showFont(self): font, flag = QFontDialog.getFont() if flag: self.label.setFont(font) else: self.label.setText("선택 되지 않았어요! 다시 한번 선택해주세요!")
def fontButtonClicked(self): ok = True font = QFontDialog.getFont(self) if font[1]: self.changeFontButton.setText('{0} {1}'.format( font[0].family(), font[0].pointSize())) self.fontChangeTrigger.emit(font[0])
def fontSetting(self): font, ok = QFontDialog.getFont() info = font.toString().split(',') # QFont Object => list if ok: self.data['set_data']['font'] = info[0] self.data['set_data']['font_size'] = int(info[1]) self.data['set_data']['font_bold'] = info[10]
def __setFont(self): font, succeed = QFontDialog.getFont() if succeed: for o in self.__object: if o.objectName() == self.lineEdit_ObjectName.text(): o.setFont(font) self.__objectdict[o.objectName()]['Font'] = font.key()
def showDialog(self): font, ok = QFontDialog.getFont() print(font.family()) print(font.pointSize()) if ok: self.lbl.setFont(font)
def showDialogSetFont(self): # 在这儿我们弹出一个字体对话框。 # getFont()方法返回字体名字和布尔值。 # 如果用户点击了OK,布尔值为True;否则为False。 font, ok = QFontDialog.getFont() if ok: self.label1.setFont(font)
def myfont(self): try: #self.font=QFontDialog() self.edition.setFont(QFontDialog.getFont()[0]) self.edition.repaint() except: pass
def do_mouseDoubleClick(self,point): ##鼠标双击 pt=self.view.mapToScene(point) #转换到Scene坐标,QPointF item=self.scene.itemAt(pt,self.view.transform()) #获取光标下的绘图项 if (item == None): return className=str(type(item)) #将类名称转换为字符串 ## print(className) if (className.find("QGraphicsRectItem") >=0): #矩形框 self.__setBrushColor(item) elif (className.find("QGraphicsEllipseItem")>=0): #椭圆和圆都是 QGraphicsEllipseItem self.__setBrushColor(item) elif (className.find("QGraphicsPolygonItem")>=0): #梯形和三角形 self.__setBrushColor(item) elif (className.find("QGraphicsLineItem")>=0): #直线,设置线条颜色 pen=item.pen() color=item.pen().color() color=QColorDialog.getColor(color,self,"选择线条颜色") if color.isValid(): pen.setColor(color) item.setPen(pen) elif (className.find("QGraphicsTextItem")>=0): #文字,设置字体 font=item.font() font,OK=QFontDialog.getFont(font) if OK: item.setFont(font)
def _ask_for_change_font(self): self.app_font, ok_ = QFontDialog.getFont(self.ui.dirTree.font(), self.ui.dirTree) if ok_: self._change_font() settings = QSettings() settings.setValue("FONT", self.app_font)
def selectFont(self): font, ok = QFontDialog.getFont( self.font(), self, ) if ok: self.setFont(font)
def changeFont(self): ''' docstring: 修改字体 ''' font, ok = QFontDialog.getFont(self.currentfont, caption="选择字体") if ok: self.setFont(font) self.currentfont = font self.adjustSize()
def _onClicked(self): """Button click handler. Open font dialog """ font, accepted = QFontDialog.getFont(self.editControl.font(), self.dialog) if accepted: self.editControl.setFont(font)
def pick_font(self): font, ok = QFontDialog.getFont() self.style_dic['font'].clear() #加粗 if font.bold(): self.style_dic['font'].append('bold') #斜体 if font.italic(): self.style_dic['font'].append('italic') # 字体 self.style_dic['font'].append(str('"' + font.family() + '"')) self.style_dic['font-size'] = int(font.pointSizeF()) #删除线 下划线 if font.strikeOut() and font.underline(): self.style_dic['text-decoration'] = "line-through underline" elif font.strikeOut() == 1 and font.underline() == 0: self.style_dic['text-decoration'] = 'line-through' elif font.strikeOut() == 0 and font.underline() == 1: self.style_dic['text-decoration'] = 'underline' else: self.style_dic['text-decoration'] = '' self.change_style_in_preview_text() return font.family(), font.bold(), font.italic(), font.pointSizeF( ), font.strikeOut(), font.underline()
def selectFont(self): current = self.text_field.currentFont() #font, ok = QFontDialog.getFont(QFont("Helvetica", 10), self) font, ok = QFontDialog.getFont( current, self) # MacOs - , options=QFontDialog.DontUseNativeDialog if ok: self.text_field.setCurrentFont(font)
def setOASFontSlogan(self): current_font = self.ExampleFont_Slogan.font() new_font, ok = QFontDialog.getFont(current_font) if ok: print(new_font.toString()) self.ExampleFont_Slogan.setFont(new_font) self.ExampleFont_Slogan.setText(f"{new_font.family()}, {new_font.pointSize()}pt")
def showDialog(self): font, ok = QFontDialog.getFont( ) # 새 창을 띄워 폰트 선택. 각 변수에는 폰트 정보가 담긴 클래스와, 확인 버튼 클릭 여부를 저장. if ok: # 확인 버튼을 눌렀을 경우 해당 폰트 업데이트 self.lbl.setFont(font)
def showDialog(self): # 弹出一个字体选择对话框。getFont()方法返回一个字体名称和状态信息。状态信息有OK和其他两种 font, ok = QFontDialog.getFont() # 如果点击OK,标签的字体就会随之更改 if ok: self.lbl.setFont(font)
def fontSelect(self): # 弹出一个字体选择对话框。getFont()方法 # 返回一个字体名称和状态信息。状态信息有OK和其他两种 font, ok = QFontDialog.getFont() if ok: self.lbl.setFont(font)
def choicefont(self): ''' 字体选择对话框 ''' font, ok = QFontDialog.getFont() if ok: self.tx.setCurrentFont(font)
def font_choice(self): font, valid = QFontDialog.getFont() if valid: font.setPointSize(20) font.setBold(True) self.textEdit.setFont(font) self.textBrowser.setFont(font)
def chooseFont(self): fontDialog = QFontDialog() fontDialog.setCurrentFont( QFont(self.chatFont.text(), int(self.chatFontSize.text()), -1, False)) fontDialog.exec() self.chatFont.setText(fontDialog.currentFont().family()) self.chatFontSize.setText( str(int(fontDialog.currentFont().pointSizeF())))
def showDialog(self): font, ok = QFontDialog.getFont() if ok: self.lbl.setFont(font) print('选择的字体是', end="") print(font) print(type(font))
def button_font_clicked(self): font, ok = QFontDialog.getFont(self.data.getQFont(), self, "Select a font...") if not ok: return self.data.font_string = font.toString() self.button_font.setText(self.get_font_name()) self.save()
def standard_font_choice(self, callback=None): new_font, valid = QFontDialog.getFont() if not valid: return self.current_font = new_font self.edit_control.setFont(new_font) if callback: callback(new_font)
def choose_font(self): # Получение шрифта, выбранного пользователем font, ok_pressed = QFontDialog.getFont() # Возможно, что пользователь нажал Cancel, # поэтому идёт проверка, нажал ли пользователь на OK if ok_pressed: self.text_font = font self.update_font()
def on_rtfFontButton_clicked(self): """ Private method used to select the font for the RTF export. """ font, ok = QFontDialog.getFont(self.rtfFont) if ok: self.rtfFontSample.setFont(font) self.rtfFont = font
def run(self): gg = data font, ok = QFontDialog.getFont() if ok: data.setFont(font) a = (re.findall(r'(.{100})', data)) r = textwrap.fill(a, width=83) self.label.setText(r)
def SetFont(self): # 创建了一个有一个按钮和一个标签的QFontDialog的对话框, 我们可以使用这个功能修改字体样式 # 弹出一个字体选择对话框, getFont()方法返回一个字体名称和状态信息。状态信息有OK和其他两种 font, ok = QFontDialog.getFont() # 如果点击OK, 标签的字体就会随之更改 if ok: self.chatInput.setFont(font) self.display.setFont(font)
def __init__(self, name, dataSlot=None, parent=None): """ Constructor """ super(NFontConverterWidget, self).__init__(parent) self.settings = QSettings('NeilLab', 'NGL Font') # load main ui window uifile = pkg_resources.resource_filename('ngl_utils.nfont', 'qtres/ngl_font.ui') self.uic = uic.loadUi(uifile, self) self.nfont_view = CodeView_Window(self) self.sysFont_dialog = QFontDialog(self) # def sysfont and font name self.font = QFont('Times', 8) self.NGL_Font = None fname = NGL_Font.formatName(self.font.family(), self.font.pointSize(), self.font.bold()) self.lineEdit_fontName.setText(fname) # generates chars set for combobox self._charstersRangesInit() # font edit widget self.edit_view = NFontEditWidget('__util__') # connect signals / slots self.tBtn_Font.clicked.connect(self._selectFont_slot) self.tBtn_AddChars.clicked.connect(self._add_chars_slot) self.tBtn_Convert.clicked.connect(self._convert_slot) self.tBtn_Save.clicked.connect(self._saveAs_slot) self.tBtn_ViewOut.clicked.connect(self._view_out_slot) self.tBtn_Edit.clicked.connect(self._edit_font_slot) if name == '__main__': self.tBtn_Close.setText('Close') self.tBtn_Close.clicked.connect(self._close_slot) else: self.tBtn_Close.setText('Add') self.tBtn_Close.clicked.connect(self._ok_slot) self.connectDataReadySlot(dataSlot) # set window to center and show self.frameGeometry().moveCenter( QDesktopWidget().availableGeometry().center())
def changeFont(self, *args, **kwargs): '''Ask for a text style and change it.''' font, ok = QFontDialog.getFont() if ok: self.font = font self.updateFont() return
def selectFont(self): selected = self.table.selectedItems() if not selected: return font, ok = QFontDialog.getFont(self.font(), self) if not ok: return for i in selected: i and i.setFont(font)
def msg(self): color = QColorDialog.getColor(Qt.blue, self, "Select Color") if color.isValid(): print(color.name(),color) self.myButton.setPalette(QPalette(color))#给按钮填充背景色 self.myButton.setAutoFillBackground(True) font, ok = QFontDialog.getFont() if ok: print(font.key) self.myButton.setFont(font)
def changeFont(self): if not self.font: self.font = QFont() fd = QFontDialog.getFont(self.font, self) if fd[1]: self.font = QFont() self.font.setFamily(fd[0].family()) settings.setValue('font', fd[0].family()) self.font.setPointSize(fd[0].pointSize()) settings.setValue('fontSize', fd[0].pointSize()) self.updatePreviewBox()
def _load_editor_font(self): try: font, ok = QFontDialog.getFont(self._font, self) if ok: self._font = font btnText = ', '.join(self._font.toString().split(',')[0:2]) self._btnEditorFont.setText(btnText) except: QMessageBox.warning( self, translations.TR_PREFERENCES_EDITOR_GENERAL_FONT_MESSAGE_TITLE, translations.TR_PREFERENCES_EDITOR_GENERAL_FONT_MESSAGE_BODY)
def on_select_font(self): action = self._font_menu.exec_(QCursor.pos()) if action is None: return if action == self._font_menu_text: name = 'text_font' font_options = () elif action == self._font_menu_strokes: name = 'strokes_font' font_options = (QFontDialog.MonospacedFonts,) font = self._get_font(name) font, ok = QFontDialog.getFont(font, self, '', *font_options) if ok: self._set_font(name, font)
def choose_font(mono=True, parent=None): fonts_logger.debug('choose_font mono={0}'.format(mono)) if mono : caption = _TR('fonts.py', 'Select a monospaced font for editing' 'Font choice dialog caption') initial = _MONO_QFONT else : caption = _TR('fonts.py', 'Select the font for titles, menus, and buttons', 'Font choice dialog caption') initial = _GENL_QFONT (new_font, ok) = QFontDialog.getFont(initial,parent,caption) if ok : return new_font else: return None
def _baseDialog(self, parent, initialValue): """ Adapter: !!! the value returned by QFontDialog.getFont() is a tuple. Adapt (flip) to tuple required by Super """ # Use overloaded PyQt signature whose first parameter is initial, not a keyword. assert isinstance(initialValue, QFont) result, ok = QFontDialog.getFont(initialValue, parent=parent) assert isinstance(ok, bool), str(type(ok)) assert result is None or isinstance(result, QFont), str(type(result)) """ Qt docs say: ok==False implies canceled and result is Qt's default font But doesn't work??? assert isinstance(result, QFont) """ return ok, result
def selectFont(self, fontSample, fontVar, showFontInfo=False): """ Public method used by the font selection buttons. @param fontSample reference to the font sample widget (QLineEdit) @param fontVar reference to the variable containing the font (QFont) @param showFontInfo flag indicating to show some font info as the sample (boolean) @return selected font (QFont) """ font, ok = QFontDialog.getFont(fontVar) if ok: fontSample.setFont(font) if showFontInfo: fontSample.setText( "{0} {1}".format(font.family(), font.pointSize())) else: font = fontVar return font
def __change_font(self): font = CONFIG.get("fontFamily") size = CONFIG.get("fontSize") if font is None: font, size = CONFIG._get_font() font, ok = QFontDialog.getFont(QFont(font, size), self) if ok: CONFIG.set_value("fontFamily", font.family()) CONFIG.set_value("fontSize", font.pointSize()) central = Pireal.get_service("central") mcontainer = central.get_active_db() if mcontainer is not None: query_widget = mcontainer.query_container.currentWidget() if query_widget is not None: weditor = query_widget.get_editor() if weditor is not None: weditor.set_font(font.family(), font.pointSize()) # Cambio el texto en la interfáz QML self.__root.setFontFamily(font.family(), font.pointSize())
def changePreviewFont(self): font, ok = QFontDialog.getFont(globalSettings.font, self) if ok: globalSettings.font = font for tab in self.iterateTabs(): tab.updatePreviewBox()
def changeEditorFont(self): font, ok = QFontDialog.getFont(globalSettings.editorFont, self) if ok: globalSettings.editorFont = font for tab in self.iterateTabs(): tab.editBox.updateFont()
def __init__(self, parent=None): """Init class.""" super(MainWindow, self).__init__() # self.statusBar().showMessage(__doc__.strip().capitalize()) self.setWindowTitle(__doc__.strip().capitalize()) self.setMinimumSize(600, 200) self.setMaximumSize(800, 400) self.resize(self.minimumSize()) self.setWindowIcon(QIcon.fromTheme("preferences-system")) self.center() QShortcut("Ctrl+q", self, activated=lambda: self.close()) self.menuBar().addMenu("&File").addAction("Exit", exit) windowMenu = self.menuBar().addMenu("&Window") windowMenu.addAction("Minimize", lambda: self.showMinimized()) windowMenu.addAction("Maximize", lambda: self.showMaximized()) windowMenu.addAction("FullScreen", lambda: self.showFullScreen()) windowMenu.addAction("Restore", lambda: self.showNormal()) windowMenu.addAction("Center", lambda: self.center()) windowMenu.addAction("Top-Left", lambda: self.move(0, 0)) windowMenu.addAction("To Mouse", lambda: self.move_to_mouse_position()) windowMenu.addSeparator() windowMenu.addAction( "Increase size", lambda: self.resize(self.size().width() * 1.4, self.size().height() * 1.4)) windowMenu.addAction("Decrease size", lambda: self.resize( self.size().width() // 1.4, self.size().height() // 1.4)) windowMenu.addAction("Minimum size", lambda: self.resize(self.minimumSize())) windowMenu.addAction("Maximum size", lambda: self.resize(self.maximumSize())) windowMenu.addAction("Horizontal Wide", lambda: self.resize( self.maximumSize().width(), self.minimumSize().height())) windowMenu.addAction("Vertical Tall", lambda: self.resize( self.minimumSize().width(), self.maximumSize().height())) windowMenu.addSeparator() windowMenu.addAction("Disable Resize", lambda: self.setFixedSize(self.size())) windowMenu.addAction("Set Interface Font...", lambda: self.setFont(QFontDialog.getFont()[0])) helpMenu = self.menuBar().addMenu("&Help") helpMenu.addAction("About Qt 5", lambda: QMessageBox.aboutQt(self)) helpMenu.addAction("About Python 3", lambda: open_new_tab('https://www.python.org')) helpMenu.addAction("About" + __doc__, lambda: QMessageBox.about(self, __doc__, HELP)) helpMenu.addSeparator() helpMenu.addAction( "Keyboard Shortcut", lambda: QMessageBox.information(self, __doc__, "<b>Quit = CTRL+Q")) helpMenu.addAction("View Source Code", lambda: call('xdg-open ' + __file__, shell=True)) helpMenu.addAction("View GitHub Repo", lambda: open_new_tab(__url__)) helpMenu.addAction("Check Updates", lambda: Downloader(self)) container = QWidget() container_layout = QVBoxLayout(container) self.setCentralWidget(container) # widgets group0, group1 = QGroupBox("Message to QR Code"), QGroupBox("Options") container_layout.addWidget(group0) container_layout.addWidget(group1) # message self.message = QLineEdit() self.message.setPlaceholderText("{} type a message!".format(getuser())) self.message.setToolTip("Message Text to encode as QR Code Image") QHBoxLayout(group0).addWidget(self.message) # options self.background, self.foreground = QComboBox(), QComboBox() self.qrcodesize, self.qrerrorlvl = QSpinBox(), QSpinBox() self.background.setToolTip("Background Color") self.foreground.setToolTip("Foreground Color") self.qrcodesize.setToolTip("QR Code Size") self.qrerrorlvl.setToolTip("QR Code Error Tolerance Level") self.background.addItems(STANDARD_NAMED_COLORS) self.foreground.addItems(STANDARD_NAMED_COLORS) self.foreground.setCurrentIndex(randint(0, self.background.count())) self.qrcodesize.setRange(2, 20) self.qrcodesize.setValue(2) self.qrcodesize.setSingleStep(2) self.qrerrorlvl.setRange(0, 3) self.qrerrorlvl.setValue(1) self.qrerrorlvl.setSingleStep(1) opt_layout = QHBoxLayout(group1) opt_layout.addWidget(QLabel("<b>Background")) opt_layout.addWidget(self.background) opt_layout.addWidget(QLabel("<b>Foreground")) opt_layout.addWidget(self.foreground) opt_layout.addWidget(QLabel("<b>Size")) opt_layout.addWidget(self.qrcodesize) opt_layout.addWidget(QLabel("<b>Error Tolerance")) opt_layout.addWidget(self.qrerrorlvl) self.bt = QDialogButtonBox(self) self.bt.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Close) self.bt.rejected.connect(exit) self.bt.accepted.connect(self.run) container_layout.addWidget(self.bt)
def __init__(self, parent=None): """Init class.""" super(MainWindow, self).__init__() self.setWindowTitle(__doc__.strip().capitalize()) self.statusBar().showMessage(" Choose one App and move the sliders !") self.setMinimumSize(480, 240) self.setMaximumSize(640, 2048) self.setWindowIcon(QIcon.fromTheme("preferences-system")) self.center() QShortcut("Ctrl+q", self, activated=lambda: self.close()) self.menuBar().addMenu("&File").addAction("Exit", exit) windowMenu = self.menuBar().addMenu("&Window") windowMenu.addAction("Minimize", lambda: self.showMinimized()) windowMenu.addAction("Maximize", lambda: self.showMaximized()) windowMenu.addAction("Restore", lambda: self.showNormal()) windowMenu.addAction("FullScreen", lambda: self.showFullScreen()) windowMenu.addAction("Center", lambda: self.center()) windowMenu.addAction("Top-Left", lambda: self.move(0, 0)) windowMenu.addAction("To Mouse", lambda: self.move_to_mouse_position()) windowMenu.addSeparator() windowMenu.addAction( "Increase size", lambda: self.resize(self.size().width() * 1.4, self.size().height() * 1.4)) windowMenu.addAction("Decrease size", lambda: self.resize( self.size().width() // 1.4, self.size().height() // 1.4)) windowMenu.addAction("Minimum size", lambda: self.resize(self.minimumSize())) windowMenu.addAction("Maximum size", lambda: self.resize(self.maximumSize())) windowMenu.addAction("Horizontal Wide", lambda: self.resize( self.maximumSize().width(), self.minimumSize().height())) windowMenu.addAction("Vertical Tall", lambda: self.resize( self.minimumSize().width(), self.maximumSize().height())) windowMenu.addSeparator() windowMenu.addAction("Disable Resize", lambda: self.setFixedSize(self.size())) windowMenu.addAction("Set Interface Font...", lambda: self.setFont(QFontDialog.getFont()[0])) helpMenu = self.menuBar().addMenu("&Help") helpMenu.addAction("About Qt 5", lambda: QMessageBox.aboutQt(self)) helpMenu.addAction("About Python 3", lambda: open_new_tab('https://www.python.org')) helpMenu.addAction("About" + __doc__, lambda: QMessageBox.about(self, __doc__, HELP)) helpMenu.addSeparator() helpMenu.addAction( "Keyboard Shortcut", lambda: QMessageBox.information(self, __doc__, "<b>Quit = CTRL+Q")) helpMenu.addAction("View Source Code", lambda: call('xdg-open ' + __file__, shell=True)) helpMenu.addAction("View GitHub Repo", lambda: open_new_tab(__url__)) helpMenu.addAction("Report Bugs", lambda: open_new_tab( 'https://github.com/juancarlospaco/pyority/issues?state=open')) helpMenu.addAction("Check Updates", lambda: Downloader(self)) container, child_container = QWidget(), QWidget() container_layout = QVBoxLayout(container) child_layout = QHBoxLayout(child_container) self.setCentralWidget(container) # widgets group0 = QGroupBox("My Apps") group1, group2 = QGroupBox("CPU Priority"), QGroupBox("HDD Priority") child_layout.addWidget(group0) child_layout.addWidget(group1) child_layout.addWidget(group2) container_layout.addWidget(child_container) # table self.table = QTableWidget() self.table.setColumnCount(1) self.table.verticalHeader().setVisible(True) self.table.horizontalHeader().setVisible(False) self.table.setShowGrid(False) self.table.setAlternatingRowColors(True) self.table.setIconSize(QSize(64, 64)) self.table.setSelectionMode(QAbstractItemView.SingleSelection) self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) # Graphic effect glow = QGraphicsDropShadowEffect(self) glow.setOffset(0) glow.setBlurRadius(9) glow.setColor(QColor(99, 255, 255)) self.table.setGraphicsEffect(glow) glow.setEnabled(True) processes = self.generate_process_list() self.table.setRowCount(len(processes)) for index, process in enumerate(processes): item = QTableWidgetItem( QIcon.fromTheme(process.name().split()[0].split('/')[0]), process.name().split()[0].split('/')[0].strip()) item.setData(Qt.UserRole, process) item.setToolTip("{}, {}, {}, {}".format( process.name(), process.nice(), process.ionice()[1], process.pid)) self.table.setItem(index, 0, item) self.table.clicked.connect(lambda: self.sliderhdd.setDisabled(False)) self.table.clicked.connect(lambda: self.slidercpu.setDisabled(False)) self.table.clicked.connect(lambda: self.slidercpu.setValue( int(tuple(self.table.currentItem().toolTip().split(","))[1]))) self.table.clicked.connect(lambda: self.sliderhdd.setValue( int(tuple(self.table.currentItem().toolTip().split(","))[2]))) self.table.resizeColumnsToContents() # self.table.resizeRowsToContents() # sliders self.slidercpu = QSlider() self.slidercpu.setRange(0, 19) self.slidercpu.setSingleStep(1) self.slidercpu.setTickPosition(3) self.slidercpu.setDisabled(True) self.slidercpu.setInvertedAppearance(True) self.slidercpu.setInvertedControls(True) self.slidercpu.valueChanged.connect(self.set_cpu_value) self.slidercpu.valueChanged.connect( lambda: self.slidercpu.setToolTip(str(self.slidercpu.value()))) # Timer to start self.slidercpu_timer = QTimer(self) self.slidercpu_timer.setSingleShot(True) self.slidercpu_timer.timeout.connect(self.on_slidercpu_timer_timeout) QLabel(self.slidercpu).setPixmap( QIcon.fromTheme("list-add").pixmap(16)) QVBoxLayout(group1).addWidget(self.slidercpu) self.sliderhdd = QSlider() self.sliderhdd.setRange(0, 7) self.sliderhdd.setSingleStep(1) self.sliderhdd.setTickPosition(3) self.sliderhdd.setDisabled(True) self.sliderhdd.setInvertedAppearance(True) self.sliderhdd.setInvertedControls(True) self.sliderhdd.valueChanged.connect(self.set_hdd_value) self.sliderhdd.valueChanged.connect( lambda: self.sliderhdd.setToolTip(str(self.sliderhdd.value()))) # Timer to start self.sliderhdd_timer = QTimer(self) self.sliderhdd_timer.setSingleShot(True) self.sliderhdd_timer.timeout.connect(self.on_sliderhdd_timer_timeout) QLabel(self.sliderhdd).setPixmap( QIcon.fromTheme("list-add").pixmap(16)) QVBoxLayout(group2).addWidget(self.sliderhdd) QVBoxLayout(group0).addWidget(self.table)
def __changeFont(self, doAll, familyOnly, sizeOnly): """ Private slot to change the highlighter font. @param doAll flag indicating to change the font for all styles (boolean) @param familyOnly flag indicating to set the font family only (boolean) @param sizeOnly flag indicating to set the font size only (boolean """ def setFont(font, style, familyOnly, sizeOnly): """ Local function to set the font. @param font font to be set (QFont) @param style style to set the font for (integer) @param familyOnly flag indicating to set the font family only (boolean) @param sizeOnly flag indicating to set the font size only (boolean """ if familyOnly or sizeOnly: newFont = QFont(self.lexer.font(style)) if familyOnly: newFont.setFamily(font.family()) if sizeOnly: newFont.setPointSize(font.pointSize()) self.lexer.setFont(newFont, style) else: self.lexer.setFont(font, style) def setSampleFont(font, familyOnly, sizeOnly): """ Local function to set the font of the sample text. @param font font to be set (QFont) @param familyOnly flag indicating to set the font family only (boolean) @param sizeOnly flag indicating to set the font size only (boolean """ if familyOnly or sizeOnly: newFont = QFont(self.lexer.font(self.style)) if familyOnly: newFont.setFamily(font.family()) if sizeOnly: newFont.setPointSize(font.pointSize()) self.sampleText.setFont(newFont) else: self.sampleText.setFont(font) if self.monospacedButton.isChecked(): options = MonospacedFontsOption else: options = NoFontsOption font, ok = QFontDialog.getFont(self.lexer.font(self.style), self, "", options) if ok: setSampleFont(font, familyOnly, sizeOnly) if doAll: for style in list(self.lexer.ind2style.values()): setFont(font, style, familyOnly, sizeOnly) self.__styleAllItems() elif len(self.styleElementList.selectedItems()) > 1: for selItem in self.styleElementList.selectedItems(): style = self.lexer.ind2style[ self.styleElementList.row(selItem)] setFont(font, style, familyOnly, sizeOnly) itmFont = self.lexer.font(style) selItem.setFont(itmFont) else: setFont(font, self.style, familyOnly, sizeOnly) itmFont = self.lexer.font(self.style) self.styleElementList.currentItem().setFont(itmFont)
def __init__(self, parent=None): """Init class.""" super(MainWindow, self).__init__() QNetworkProxyFactory.setUseSystemConfiguration(True) self.statusBar().showMessage(__doc__ + get_nuitka_version()) self.setWindowTitle(__doc__.strip().capitalize()) self.setMinimumSize(480, 400) self.setMaximumSize(1024, 800) self.resize(self.minimumSize()) self.setWindowIcon(QIcon.fromTheme("python")) self.center() QShortcut("Ctrl+q", self, activated=lambda: self.close()) self.menuBar().addMenu("&File").addAction("Exit", lambda: self.close()) windowMenu = self.menuBar().addMenu("&Window") windowMenu.addAction("Minimize", lambda: self.showMinimized()) windowMenu.addAction("Maximize", lambda: self.showMaximized()) windowMenu.addAction("Restore", lambda: self.showNormal()) windowMenu.addAction("FullScreen", lambda: self.showFullScreen()) windowMenu.addAction("Center", lambda: self.center()) windowMenu.addAction("Top-Left", lambda: self.move(0, 0)) windowMenu.addAction("To Mouse", lambda: self.move_to_mouse_position()) windowMenu.addSeparator() windowMenu.addAction( "Increase size", lambda: self.resize(self.size().width() * 1.4, self.size().height() * 1.4)) windowMenu.addAction("Decrease size", lambda: self.resize( self.size().width() // 1.4, self.size().height() // 1.4)) windowMenu.addAction("Minimum size", lambda: self.resize(self.minimumSize())) windowMenu.addAction("Maximum size", lambda: self.resize(self.maximumSize())) windowMenu.addAction("Horizontal Wide", lambda: self.resize( self.maximumSize().width(), self.minimumSize().height())) windowMenu.addAction("Vertical Tall", lambda: self.resize( self.minimumSize().width(), self.maximumSize().height())) windowMenu.addSeparator() windowMenu.addAction("Disable Resize", lambda: self.setFixedSize(self.size())) windowMenu.addAction("Set Interface Font...", lambda: self.setFont(QFontDialog.getFont()[0])) windowMenu.addAction( "Load .qss Skin", lambda: self.setStyleSheet(self.skin())) helpMenu = self.menuBar().addMenu("&Help") helpMenu.addAction("About Qt 5", lambda: QMessageBox.aboutQt(self)) helpMenu.addAction("About Python 3", lambda: open_new_tab('https://www.python.org')) helpMenu.addAction("About " + __doc__, lambda: QMessageBox.about(self, __doc__, HELP)) helpMenu.addSeparator() helpMenu.addAction( "Keyboard Shortcut", lambda: QMessageBox.information(self, __doc__, "<b>Quit = CTRL+Q")) if sys.platform.startswith('linux'): helpMenu.addAction("View Source Code", lambda: call('xdg-open ' + __file__, shell=True)) helpMenu.addAction("View GitHub Repo", lambda: open_new_tab(__url__)) helpMenu.addAction("Check Updates", lambda: Downloader(self)) # process self.process = QProcess() self.process.readyReadStandardOutput.connect(self._read_output) self.process.readyReadStandardError.connect(self._read_errors) self.process.finished.connect(self._process_finished) self.process.error.connect(self._process_failed) # widgets self.group0, self.group1 = QGroupBox("Options"), QGroupBox("Paths") self.group4, self.group5 = QGroupBox("Details"), QGroupBox("Miscs") g0grid, g1vlay = QGridLayout(self.group0), QGridLayout(self.group1) g5vlay, g4vlay = QVBoxLayout(self.group5), QVBoxLayout(self.group4) # group 0 the options self.module = QCheckBox("Create compiled extension module") self.standalone = QCheckBox("Standalone executable binary output") self.nofreeze = QCheckBox("No freeze all modules of standard library") self.python_debug = QCheckBox("Use Python Debug") self.warning = QCheckBox("Warnings for implicit exceptions at compile") self.recurse_std = QCheckBox("Recursive compile the standard library") self.recurse_not = QCheckBox("Force No recursive compiling") self.execute = QCheckBox("Execute the created binary after compiling") self.pythonpath = QCheckBox("Keep pythonpath when executing") self.enhaced = QCheckBox("Enhaced compile, Not CPython compatible") self.nolineno = QCheckBox("No Statements line numbers on compile") self.rmbuilddir = QCheckBox("Remove build directory after compile.") self.nuitka_debug = QCheckBox("Use Nuitka Debug") self.keep_debug = QCheckBox("Keep debug info on compile for GDB") self.traced = QCheckBox("Traced execution output") self.plusplus = QCheckBox("Compile C++ Only on generated source files") self.experimental = QCheckBox("Experimental features") self.force_clang = QCheckBox("Force use of CLang") self.force_mingw = QCheckBox("Force use of MinGW on MS Windows") self.force_lto = QCheckBox("Use link time optimizations LTO") self.show_scons = QCheckBox("Show Scons executed commands") self.show_progress = QCheckBox("Show progress info and statistics") self.show_summary = QCheckBox("Show final summary of included modules") self.disable_console = QCheckBox("Disable the Console on MS Windows") for i, widget in enumerate(( self.module, self.standalone, self.nofreeze, self.python_debug, self.warning, self.recurse_std, self.recurse_not, self.execute, self.pythonpath, self.enhaced, self.nolineno, self.rmbuilddir, self.nuitka_debug, self.keep_debug, self.traced, self.plusplus, self.experimental, self.force_clang, self.force_mingw, self.force_lto, self.show_scons, self.show_progress, self.show_summary, self.disable_console)): widget.setToolTip(widget.text()) g0grid.addWidget(widget, i if i < i + 1 else i - (i - 1), i % 2) # group 1 paths self.target = QLineEdit() self.outdir = QLineEdit(os.path.expanduser("~")) self.t_icon = QLineEdit() self.target.setToolTip("Python App file you want to Compile to Binary") self.outdir.setToolTip("Folder to write Compiled Output Binary files") self.t_icon.setToolTip("Icon image file to embed for your Python App") self.target.setPlaceholderText("/full/path/to/target/python_app.py") self.outdir.setPlaceholderText("/full/path/to/output/folder/") self.t_icon.setPlaceholderText("/full/path/to/python_app/icon.png") self.completer, self.dirs = QCompleter(self), QDirModel(self) self.completer.setModel(self.dirs) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.setCompletionMode(QCompleter.PopupCompletion) self.completer.popup().setStyleSheet("border: 1px solid gray") self.completer.popup().setVerticalScrollBarPolicy( Qt.ScrollBarAlwaysOff) self.outdir.setCompleter(self.completer) self.t_icon.setCompleter(self.completer) self.target.setCompleter(self.completer) self.clear_1 = QPushButton(QIcon.fromTheme("edit-clear"), "", self, clicked=lambda: self.target.clear()) self.clear_2 = QPushButton(QIcon.fromTheme("edit-clear"), "", self, clicked=lambda: self.t_icon.clear()) self.clear_3 = QPushButton(QIcon.fromTheme("edit-clear"), "", self, clicked=lambda: self.outdir.clear()) self.open_1 = QPushButton( QIcon.fromTheme("folder-open"), "", self, clicked=lambda: self.target.setText(str(QFileDialog.getOpenFileName( self, __doc__, os.path.expanduser("~"), """Python (*.py);; Python for Windows (*.pyw);;All (*.*)""")[0]))) self.open_2 = QPushButton( QIcon.fromTheme("folder-open"), "", self, clicked=lambda: self.t_icon.setText(str(QFileDialog.getOpenFileName( self, __doc__, os.path.expanduser("~"), "PNG (*.png);;JPG (*.jpg);;ICO (*.ico);;All (*.*)")[0]))) self.open_3 = QPushButton( QIcon.fromTheme("folder-open"), "", self, clicked=lambda: self.outdir.setText(str(QFileDialog.getExistingDirectory( self, __doc__, os.path.expanduser("~"))))) self.l_icon = QLabel("Target Icon") g1vlay.addWidget(QLabel("<b>Target Python"), 0, 0) g1vlay.addWidget(self.target, 0, 1) g1vlay.addWidget(self.clear_1, 0, 2) g1vlay.addWidget(self.open_1, 0, 3) g1vlay.addWidget(self.l_icon, 1, 0) g1vlay.addWidget(self.t_icon, 1, 1) g1vlay.addWidget(self.clear_2, 1, 2) g1vlay.addWidget(self.open_2, 1, 3) g1vlay.addWidget(QLabel("<b>Output Folder"), 2, 0) g1vlay.addWidget(self.outdir, 2, 1) g1vlay.addWidget(self.clear_3, 2, 2) g1vlay.addWidget(self.open_3, 2, 3) # group 4 the dome view mode self.jobs = QSpinBox() self.jobs.setRange(1, cpu_count()) self.jobs.setValue(cpu_count()) self.jobs.setToolTip("Backend Worker Jobs Processes") self.python_version = QComboBox() self.python_version.addItems(["2.7", "3.2", "3.3", "3.4"]) self.python_version.setToolTip("Python version to use with Nuitka") self.display_tree = QPushButton("Display Tree") self.display_tree.clicked.connect( lambda: call(NUITKA + " --display-tree {}".format( self.target.text()), shell=True)) self.dump_tree = QPushButton( "View Docs", clicked=lambda: open_new_tab("http://nuitka.net/doc/user-manual.html")) self.open_log = QPushButton("View Logs") _log = os.path.join(gettempdir(), "nuitka-gui.log") _open = "xdg-open " if sys.platform.startswith("lin") else "open " self.open_log.clicked.connect(lambda: call(_open + _log, shell=True)) self.open_folder = QPushButton("Open Build Folder") self.open_folder.clicked.connect(lambda: call( _open + str(self.outdir.text()).strip(), shell=True)) # self.display_tree.clicked.connect(self._display_tree) g4vlay.addWidget(QLabel("<b>Worker Jobs")) g4vlay.addWidget(self.jobs) g4vlay.addWidget(QLabel("<b>Python Version")) g4vlay.addWidget(self.python_version) g4vlay.addWidget(QLabel("<b>Actions")) g4vlay.addWidget(self.display_tree) g4vlay.addWidget(self.dump_tree) g4vlay.addWidget(self.open_log) g4vlay.addWidget(self.open_folder) # group 5 miscelaneous stuff self.debug, self.scr = QCheckBox("Use Debug"), QCheckBox("Make Script") self.chrt, self.ionice = QCheckBox("Slow CPU"), QCheckBox("Slow HDD") self.minimi = QCheckBox("Auto Minimize") self.chrt.setToolTip("Use Low CPU speed priority (Linux only)") self.ionice.setToolTip("Use Low HDD speed priority (Linux only)") self.scr.setToolTip("Generate a Bash Script to Compile with Nuitka") self.debug.setToolTip("Use Debug Verbose mode") self.minimi.setToolTip("Automatically Minimize when compiling starts") self.scr.setChecked(True) self.chrt.setChecked(True) self.ionice.setChecked(True) self.minimi.setChecked(True) g5vlay.addWidget(self.debug) g5vlay.addWidget(self.scr) g5vlay.addWidget(self.chrt) g5vlay.addWidget(self.ionice) g5vlay.addWidget(self.minimi) # option to show or hide some widgets on the gui self.guimode = QComboBox() self.guimode.addItems(('Full UX / UI', 'Simple UX / UI')) self.guimode.setCurrentIndex(1) self._set_guimode() self.guimode.setStyleSheet("""QComboBox{background:transparent; margin-left:25px;color:gray;text-decoration:underline;border:0}""") self.guimode.currentIndexChanged.connect(self._set_guimode) # buttons from bottom to close or proceed self.bt = QDialogButtonBox(self) self.bt.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Close) self.bt.rejected.connect(self.close) self.bt.accepted.connect(self.run) if not sys.platform.startswith('lin'): self.scr.setChecked(False) self.chrt.setChecked(False) self.ionice.setChecked(False) self.scr.hide() self.chrt.hide() self.ionice.hide() if not sys.platform.startswith('win'): self.l_icon.hide() self.t_icon.hide() self.clear_2.hide() self.open_2.hide() if sys.platform.startswith('win'): self.display_tree.hide() # container for all groups of widgets container = QWidget() container_layout = QGridLayout(container) # Y, X container_layout.addWidget(self.guimode, 0, 1) container_layout.addWidget(self.group0, 1, 1) container_layout.addWidget(self.group1, 2, 1) container_layout.addWidget(self.group4, 1, 2) container_layout.addWidget(self.group5, 2, 2) container_layout.addWidget(self.bt, 3, 1) self.setCentralWidget(container)
def on_click(self): font, ok = QFontDialog.getFont() if ok: print(font.toString())
def choose_font(self): tup = QFontDialog.getFont(self) font = tup[0] if tup[1]: self.font_lbl.setText(font.family()) self.font_size_lbl.setValue(font.pointSize())
def font_dialog(self): font, ok = QFontDialog.getFont(self.font, self) if ok: self.font = font self.update_values()
def setFont(self): font, ok = QFontDialog.getFont(QFont(self.fontLabel.text()), self) if ok: self.fontLabel.setText(font.key()) self.fontLabel.setFont(font)
def showDialog(self): # ユーザにフォントを選ばせる font, ok = QFontDialog.getFont() if ok: self.lbl.setFont(font)
def changePreviewFont(self): font, ok = QFontDialog.getFont(globalSettings.font, self) if ok: globalSettings.font = font self.updatePreviewBox()
def fontDialog(self): font, ok = QFontDialog.getFont() if ok: self.tedit.setFont(font)
def showDialog(self): font, ok = QFontDialog.getFont() if ok: self.lbl.setFont(font)
def on_select_font(self): font, ok = QFontDialog.getFont(self.header.font(), self, '', QFontDialog.MonospacedFonts) if ok: self.header.setFont(font) self.tape.setFont(font)
def _load_editor_font(self): font, ok = QFontDialog.getFont(self._font, self) if ok: self._font = font btn_text = ', '.join(self._font.toString().split(',')[0:2]) self._btn_editor_font.setText(btn_text)