當前位置: 首頁>>代碼示例>>Python>>正文


Python QFontComboBox.currentFont方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QFontComboBox.currentFont方法的典型用法代碼示例。如果您正苦於以下問題:Python QFontComboBox.currentFont方法的具體用法?Python QFontComboBox.currentFont怎麽用?Python QFontComboBox.currentFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui.QFontComboBox的用法示例。


在下文中一共展示了QFontComboBox.currentFont方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: FontLayout

# 需要導入模塊: from PyQt4.QtGui import QFontComboBox [as 別名]
# 或者: from PyQt4.QtGui.QFontComboBox import currentFont [as 別名]
class FontLayout(QHBoxLayout):
    """Font selection"""
    def __init__(self, value, parent=None):
        QHBoxLayout.__init__(self)
        font = tuple_to_qfont(value)
        assert font is not None

        # Font family
        self.family = QFontComboBox(parent)
        self.family.setCurrentFont(font)
        self.addWidget(self.family)

        # Font size
        self.size = QComboBox(parent)
        self.size.setEditable(True)
        sizelist = list(itertools.chain(range(6, 12), range(12, 30, 2), [36, 48, 72]))
        size = font.pointSize()
        if size not in sizelist:
            sizelist.append(size)
            sizelist.sort()
        self.size.addItems([str(s) for s in sizelist])
        self.size.setCurrentIndex(sizelist.index(size))
        self.addWidget(self.size)

    def get_font(self):
        font = self.family.currentFont()
        font.setPointSize(int(self.size.currentText()))
        return qfont_to_tuple(font)
開發者ID:rainerf,項目名稱:ricodebug,代碼行數:30,代碼來源:formlayout.py

示例2: FontLayout

# 需要導入模塊: from PyQt4.QtGui import QFontComboBox [as 別名]
# 或者: from PyQt4.QtGui.QFontComboBox import currentFont [as 別名]
class FontLayout(QGridLayout):

    """Font selection"""

    def __init__(self, value, parent=None):
        QGridLayout.__init__(self)
        font = tuple_to_qfont(value)
        assert font is not None

        # Font family
        self.family = QFontComboBox(parent)
        self.addWidget(self.family, 0, 0, 1, -1)

        # Font size
        self.size = QComboBox(parent)
        self.size.setEditable(True)
        sizelist = list(range(6, 12)) + list(range(12, 30, 2)) + [36, 48, 72]
        size = font.pointSize()
        if size not in sizelist:
            sizelist.append(size)
            sizelist.sort()
        self.size.addItems([str(s) for s in sizelist])
        self.addWidget(self.size, 1, 0)

        # Italic or not
        self.italic = QCheckBox(self.tr("Italic"), parent)
        self.addWidget(self.italic, 1, 1)

        # Bold or not
        self.bold = QCheckBox(self.tr("Bold"), parent)
        self.addWidget(self.bold, 1, 2)
        self.set_font(font)

    def set_font(self, font):
        self.family.setCurrentFont(font)
        size = font.pointSize()
        i = self.size.findText(str(size))
        if i >= 0:
            self.size.setCurrentIndex(i)
        self.italic.setChecked(font.italic())
        self.bold.setChecked(font.bold())

    def get_font(self):
        font = self.family.currentFont()
        font.setItalic(self.italic.isChecked())
        font.setBold(self.bold.isChecked())
        font.setPointSize(int(self.size.currentText()))
        return qfont_to_tuple(font)
開發者ID:fabioz,項目名稱:pyvmmonitor-qt,代碼行數:50,代碼來源:formlayout.py

示例3: Browser

# 需要導入模塊: from PyQt4.QtGui import QFontComboBox [as 別名]
# 或者: from PyQt4.QtGui.QFontComboBox import currentFont [as 別名]
class Browser(preferences.Group):
    def __init__(self, page):
        super(Browser, self).__init__(page)
        
        layout = QGridLayout()
        self.setLayout(layout)
        
        self.languagesLabel = QLabel()
        self.languages = QComboBox(currentIndexChanged=self.changed)
        layout.addWidget(self.languagesLabel, 0, 0)
        layout.addWidget(self.languages, 0, 1)
        
        items = ['', '']
        items.extend(language_names.languageName(l, l) for l in lilydoc.translations)
        self.languages.addItems(items)
        
        self.fontLabel = QLabel()
        self.fontChooser = QFontComboBox(currentFontChanged=self.changed)
        self.fontSize = QSpinBox(valueChanged=self.changed)
        self.fontSize.setRange(6, 32)
        self.fontSize.setSingleStep(1)
        
        layout.addWidget(self.fontLabel, 1, 0)
        layout.addWidget(self.fontChooser, 1, 1)
        layout.addWidget(self.fontSize, 1, 2)
        
        app.translateUI(self)
    
    def translateUI(self):
        self.setTitle(_("Documentation Browser"))
        self.languagesLabel.setText(_("Preferred Language:"))
        self.languages.setItemText(0, _("Default"))
        self.languages.setItemText(1, _("English (untranslated)"))
        self.fontLabel.setText(_("Font:"))
        
    def loadSettings(self):
        s = QSettings()
        s.beginGroup("documentation")
        lang = s.value("language", "default", type(""))
        if lang in lilydoc.translations:
            i = lilydoc.translations.index(lang) + 2
        elif lang == "C":
            i = 1
        else:
            i = 0
        self.languages.setCurrentIndex(i)
        
        font = self.font()
        family = s.value("fontfamily", "", type(""))
        if family:
            font.setFamily(family)
        size = s.value("fontsize", 16, int)
        with qutil.signalsBlocked(self.fontChooser, self.fontSize):
            self.fontChooser.setCurrentFont(font)
            self.fontSize.setValue(size)

    def saveSettings(self):
        s = QSettings()
        s.beginGroup("documentation")
        langs = ['default', 'C'] + lilydoc.translations
        s.setValue("language", langs[self.languages.currentIndex()])
        s.setValue("fontfamily", self.fontChooser.currentFont().family())
        s.setValue("fontsize", self.fontSize.value())
開發者ID:WedgeLeft,項目名稱:frescobaldi,代碼行數:65,代碼來源:documentation.py

示例4: GeneralSection

# 需要導入模塊: from PyQt4.QtGui import QFontComboBox [as 別名]
# 或者: from PyQt4.QtGui.QFontComboBox import currentFont [as 別名]

#.........這裏部分代碼省略.........
        lcd_caret = QLCDNumber()
        lcd_caret.setSegmentStyle(QLCDNumber.Flat)
        box.addWidget(lcd_caret, 2, 3)

        # Font
        group_typo = QGroupBox(self.tr("Fuente:"))
        box = QGridLayout(group_typo)
        box.setContentsMargins(20, 5, 20, 5)
        box.addWidget(QLabel(self.tr("Familia:")), 0, 0)
        self.combo_font = QFontComboBox()
        self.combo_font.setFixedWidth(350)
        box.addWidget(self.combo_font, 0, 1)
        self._load_font()
        box.addWidget(QLabel(self.tr("Tamaño:")), 1, 0)
        self.spin_size_font = QSpinBox()
        self.spin_size_font.setValue(settings.get_setting('editor/size-font'))
        self.spin_size_font.setFixedWidth(350)
        box.addWidget(self.spin_size_font, 1, 1)
        box.setAlignment(Qt.AlignLeft)

        # Scheme
        group_scheme = QGroupBox(self.tr("Tema:"))
        box = QVBoxLayout(group_scheme)
        box.setContentsMargins(20, 5, 20, 5)
        self.combo_scheme = QComboBox()
        self.combo_scheme.setFixedWidth(350)
        self.combo_scheme.addItems(['Dark Edis', 'White Edis'])
        scheme = settings.get_setting('editor/scheme')
        index = 0
        if scheme != 'dark':
            index = 1
        self.combo_scheme.setCurrentIndex(index)
        box.addWidget(self.combo_scheme)
        box.addWidget(QLabel(self.tr("Requiere reiniciar Edis")))

        ## Agrupación
        main_container.addWidget(group_indentation)
        main_container.addWidget(group_minimap)
        main_container.addWidget(group_caret)
        main_container.addWidget(group_typo)
        main_container.addWidget(group_scheme)
        main_container.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding,
                               QSizePolicy.Expanding))

        EditorConfiguration.install_widget(self.tr("General"), self)

        # Conexiones
        self.combo_scheme.currentIndexChanged['const QString&'].connect(
            self._change_scheme)
        self.combo_caret.currentIndexChanged[int].connect(
            self._caret_type_changed)
        self.slider_caret_period.valueChanged[int].connect(
            lcd_caret.display)

        self.slider_caret_period.setValue(
            settings.get_setting('editor/cursor-period'))

    def _change_scheme(self, theme):
        theme = theme.split()[0].lower()
        editor_container = Edis.get_component("principal")
        editor = editor_container.get_active_editor()
        if editor is not None:
            # Restyle
            pass

    def _caret_type_changed(self, index):
        self.spin_caret_width.setEnabled(bool(index))

    def _load_font(self):

        font = settings.get_setting('editor/font')
        self.combo_font.setCurrentFont(QFont(font))

    def save(self):
        """ Guarda las configuraciones del Editor. """

        use_tabs = bool(self.combo_tabs.currentIndex())
        settings.set_setting('editor/usetabs', use_tabs)
        auto_indent = self.check_autoindent.isChecked()
        settings.set_setting('editor/indent', auto_indent)
        settings.set_setting('editor/minimap', self.check_minimap.isChecked())
        #settings.set_setting('editor/minimap-animation',
                             #self.check_minimap_animation.isChecked())
        font = self.combo_font.currentFont().family()
        settings.set_setting('editor/font', font)
        font_size = self.spin_size_font.value()
        settings.set_setting('editor/size-font', font_size)
        scheme = self.combo_scheme.currentText().split()[0].lower()
        settings.set_setting('editor/scheme', scheme)
        settings.set_setting('editor/cursor',
                             self.combo_caret.currentIndex())
        settings.set_setting('editor/caret-width',
                             self.spin_caret_width.value())
        settings.set_setting('editor/cursor-period',
                             self.slider_caret_period.value())
        editor_container = Edis.get_component("principal")
        editor = editor_container.get_active_editor()
        if editor is not None:
            editor.setIndentationsUseTabs(use_tabs)
            editor.load_font(font, font_size)
開發者ID:Garjy,項目名稱:edis,代碼行數:104,代碼來源:editor_configuration.py

示例5: FontsColors

# 需要導入模塊: from PyQt4.QtGui import QFontComboBox [as 別名]
# 或者: from PyQt4.QtGui.QFontComboBox import currentFont [as 別名]
class FontsColors(preferences.Page):
    def __init__(self, dialog):
        super(FontsColors, self).__init__(dialog)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
        
        self.scheme = SchemeSelector(self)
        layout.addWidget(self.scheme)
        
        self.printScheme = QCheckBox()
        layout.addWidget(self.printScheme)
        
        hbox = QHBoxLayout()
        self.tree = QTreeWidget(self)
        self.tree.setHeaderHidden(True)
        self.tree.setAnimated(True)
        self.stack = QStackedWidget(self)
        hbox.addWidget(self.tree)
        hbox.addWidget(self.stack)
        layout.addLayout(hbox)
        
        hbox = QHBoxLayout()
        self.fontLabel = QLabel()
        self.fontChooser = QFontComboBox()
        self.fontSize = QDoubleSpinBox()
        self.fontSize.setRange(6.0, 32.0)
        self.fontSize.setSingleStep(0.5)
        self.fontSize.setDecimals(1)
        hbox.addWidget(self.fontLabel)
        hbox.addWidget(self.fontChooser, 1)
        hbox.addWidget(self.fontSize)
        layout.addLayout(hbox)
        
        # add the items to our list
        self.baseColorsItem = i = QTreeWidgetItem()
        self.tree.addTopLevelItem(i)
        self.defaultStylesItem = i = QTreeWidgetItem()
        self.tree.addTopLevelItem(i)
        
        self.defaultStyles = {}
        for name in textformats.defaultStyles:
            self.defaultStyles[name] = i = QTreeWidgetItem()
            self.defaultStylesItem.addChild(i)
            i.name = name
        self.defaultStylesItem.setExpanded(True)
        
        self.allStyles = {}
        for group, styles in ly.colorize.default_mapping():
            i = QTreeWidgetItem()
            children = {}
            self.allStyles[group] = (i, children)
            self.tree.addTopLevelItem(i)
            i.group = group
            for name, base, clss in styles:
                j = QTreeWidgetItem()
                j.name = name
                j.base = base
                i.addChild(j)
                children[name] = j
        
        self.baseColorsWidget = BaseColors(self)
        self.customAttributesWidget = CustomAttributes(self)
        self.emptyWidget = QWidget(self)
        self.stack.addWidget(self.baseColorsWidget)
        self.stack.addWidget(self.customAttributesWidget)
        self.stack.addWidget(self.emptyWidget)
        
        self.tree.currentItemChanged.connect(self.currentItemChanged)
        self.tree.setCurrentItem(self.baseColorsItem)
        self.scheme.currentChanged.connect(self.currentSchemeChanged)
        self.scheme.changed.connect(self.changed)
        self.baseColorsWidget.changed.connect(self.baseColorsChanged)
        self.customAttributesWidget.changed.connect(self.customAttributesChanged)
        self.fontChooser.currentFontChanged.connect(self.fontChanged)
        self.fontSize.valueChanged.connect(self.fontChanged)
        self.printScheme.clicked.connect(self.printSchemeChanged)
        
        app.translateUI(self)
        
    def translateUI(self):
        self.printScheme.setText(_("Use this scheme for printing"))
        self.fontLabel.setText(_("Font:"))
        self.baseColorsItem.setText(0, _("Base Colors"))
        self.defaultStylesItem.setText(0, _("Default Styles"))
        
        self.defaultStyleNames = defaultStyleNames()
        self.allStyleNames = allStyleNames()
        
        for name in textformats.defaultStyles:
            self.defaultStyles[name].setText(0, self.defaultStyleNames[name])
        for group, styles in ly.colorize.default_mapping():
            self.allStyles[group][0].setText(0, self.allStyleNames[group][0])
            for name, base, clss in styles:
                self.allStyles[group][1][name].setText(0, self.allStyleNames[group][1][name])
            
    def currentItemChanged(self, item, previous):
        if item is self.baseColorsItem:
            self.stack.setCurrentWidget(self.baseColorsWidget)
#.........這裏部分代碼省略.........
開發者ID:EdwardBetts,項目名稱:frescobaldi,代碼行數:103,代碼來源:fontscolors.py

示例6: ToolBar

# 需要導入模塊: from PyQt4.QtGui import QFontComboBox [as 別名]
# 或者: from PyQt4.QtGui.QFontComboBox import currentFont [as 別名]

#.........這裏部分代碼省略.........
        self.openFile = self.addAction(QIcon("icons/document-open.svg"), "Open File")
        self.saveFile = self.addAction(QIcon("icons/document-save.svg"), "Save File")
        self.addSeparator()
        self.undo = self.addAction(QIcon("icons/undo.svg"), "Undo")
        self.redo = self.addAction(QIcon("icons/redo.svg"), "Redo")
        self.addSeparator()
        self.cut = self.addAction(QIcon("icons/edit-cut.png"), "Cut")
        self.copy = self.addAction(QIcon("icons/edit-copy.png"), "Copy")
        self.paste = self.addAction(QIcon("icons/edit-paste.png"), "Paste")
        self.selectAll = self.addAction(QIcon("icons/edit-select-all.svg"), "Select All")
        self.addSeparator()
        self.justifyLeft = self.addAction(QIcon("icons/align-horizontal-left.svg"), "Justify Left")
        self.justifyCenter = self.addAction(QIcon("icons/align-horizontal-center.svg"), "Justify Center")
        self.justifyRight = self.addAction(QIcon("icons/align-horizontal-right.svg"), "Justify Right")
        self.addSeparator()
        self.bold = self.addAction(QIcon("icons/format-text-bold.png"), "Bold")
        self.italic = self.addAction(QIcon("icons/format-text-italic.png"), "Italic")
        self.underline = self.addAction(QIcon("icons/format-text-underline.png"), "Underline")
        self.addWidget(self.fontComboBox)
        self.addWidget(self.fontSize)
        self.fontColor = self.addAction(QIcon("icons/color.svg"),  "Font Color")
        self.addSeparator()
        self.addWidget(self.searchBox)
        self.addAction(QIcon("icons/stock_properties.svg"), "Settings")
        self.saveFile.setEnabled(False)
        self.cut.setEnabled(False)
        self.undo.setEnabled(False)
        self.redo.setEnabled(False)
        self.doc.textChanged.connect(self.EnableActions)
            
    def EnableActions(self):
        self.saveFile.setEnabled(True)
        self.cut.setEnabled(True)
        self.undo.setEnabled(True)
        self.redo.setEnabled(True)
        
    def DisableActions(self):
        self.saveFile.setEnabled(False)
        self.cut.setEnabled(False)
        self.undo.setEnabled(False)
        self.redo.setEnabled(False)

    def StartNewWindow(self):
#        main()
	 self.mainWindow.tabs.addNewTab()
        
    def fontColorDialog(self):
        self.cDialog = QColorDialog()
        colorDialog = QColorDialog.open(self.cDialog,self.FormatFontColor)
        
    def OpenFile(self):
        if self.doc.fileName != None:
            #new Window
            pass
        elif self.doc.fileName == None:
            self.doc.fileName = QFileDialog.getOpenFileName(self,"Open File")
            f = open(self.doc.fileName, "r")
            data = f.read()
            self.doc.setText(data)
            f.close()
            fileNameOnly = self.getFileName()
            self.mainWindow.setWindowTitle(self.mainWindow.windowTitle()+" => "+fileNameOnly)
            self.DisableActions()
    
    def getFileName(self):
        fileinit = self.doc.fileName.split("/")
        fileNameOnly = fileinit[-1:]
        fileNameOnly = fileNameOnly[0]
        return fileNameOnly

    def Signals(self):        
        self.newFile.activated.connect(self.StartNewWindow)
        self.openFile.activated.connect(self.OpenFile)
        self.saveFile.activated.connect(self.doc.SaveDocument)
        self.saveFile.activated.connect(lambda: self.saveFile.setEnabled(False))
        self.undo.activated.connect(self.doc.undo)
        self.redo.activated.connect(self.doc.redo)
        self.copy.activated.connect(self.doc.copy)
        self.cut.activated.connect(self.doc.cut)
        self.paste.activated.connect(self.doc.paste)
        self.selectAll.activated.connect(self.doc.selectAll)
        self.justifyLeft.activated.connect(lambda: self.doc.setAlignment(Qt.AlignLeft))
        self.justifyCenter.activated.connect(lambda: self.doc.setAlignment(Qt.AlignCenter))
        self.justifyRight.activated.connect(lambda: self.doc.setAlignment(Qt.AlignRight))
        self.bold.activated.connect(self.doc.FormatBold)
        self.italic.activated.connect(self.doc.FormatItalic)
        self.underline.activated.connect(self.doc.FormatUnderline)
        self.fontComboBox.currentFontChanged.connect(lambda: self.doc.setFont(self.fontComboBox.currentFont()))
        self.fontSize.currentIndexChanged.connect(lambda: self.doc.setFontPointSize(int(self.fontSize.currentText())) )
        self.fontColor.activated.connect(self.fontColorDialog)
        self.searchBox.textChanged.connect(self.Search)
        
    def Search(self):
        searchFor  = self.searchBox.text()
        result = self.doc.find(searchFor)
        if result == True:
            self.doc.setTextBackgroundColor(QColor("#ccc"))

    def FormatFontColor(self):
        self.doc.setTextColor(self.cDialog.currentColor())
開發者ID:aoken1,項目名稱:pyqt-simple-notepad,代碼行數:104,代碼來源:toolbar.py

示例7: GlobalFontDialog

# 需要導入模塊: from PyQt4.QtGui import QFontComboBox [as 別名]
# 或者: from PyQt4.QtGui.QFontComboBox import currentFont [as 別名]
class GlobalFontDialog(widgets.dialog.Dialog):
    def __init__(self, parent=None):
        super(GlobalFontDialog, self).__init__(parent)
        self._messageLabel.setWordWrap(True)
        
        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.mainWidget().setLayout(layout)
        
        self.romanLabel = QLabel()
        self.romanCombo = QFontComboBox()
        self.sansLabel = QLabel()
        self.sansCombo = QFontComboBox()
        self.typewriterLabel = QLabel()
        self.typewriterCombo = QFontComboBox(fontFilters=QFontComboBox.MonospacedFonts)
        
        layout.addWidget(self.romanLabel, 0, 0)
        layout.addWidget(self.romanCombo, 0, 1, 1, 2)
        layout.addWidget(self.sansLabel, 1, 0)
        layout.addWidget(self.sansCombo, 1, 1, 1, 2)
        layout.addWidget(self.typewriterLabel, 2, 0)
        layout.addWidget(self.typewriterCombo, 2, 1, 1, 2)
        
        self.loadSettings()
        self.finished.connect(self.saveSettings)
        app.translateUI(self)
        
    def translateUI(self):
        self.setWindowTitle(app.caption(_("Global Fonts")))
        self.setMessage(_(
            "Please select the three global fonts to use for "
            r"<code>\roman</code>, <code>\sans</code>, and <code>\typewriter</code> "
            "respectively."))
        self.romanLabel.setText(_("Roman Font:"))
        self.sansLabel.setText(_("Sans Font:"))
        self.typewriterLabel.setText(_("Typewriter Font:"))
    
    def romanFont(self):
        return self.romanCombo.currentFont().family()
    
    def setromanFont(self, family):
        self.romanCombo.setCurrentFont(QFont(family))
    
    def sansFont(self):
        return self.sansCombo.currentFont().family()
    
    def setSansFont(self, family):
        self.sansCombo.setCurrentFont(QFont(family))
    
    def typewriterFont(self):
        return self.typewriterCombo.currentFont().family()
    
    def settypewriterFont(self, family):
        self.typewriterCombo.setCurrentFont(QFont(family))
    
    def loadSettings(self):
        s = QSettings()
        s.beginGroup("global_font_dialog")
        roman = s.value("roman", "Century Schoolbook L", type(""))
        self.romanCombo.setCurrentFont(QFont(roman))
        sans = s.value("sans", "sans-serif", type(""))
        self.sansCombo.setCurrentFont(QFont(sans))
        typewriter = s.value("typewriter", "monospace", type(""))
        self.typewriterCombo.setCurrentFont(QFont(typewriter))
    
    def saveSettings(self):
        s = QSettings()
        s.beginGroup("global_font_dialog")
        s.setValue("roman", self.romanCombo.currentFont().family())
        s.setValue("sans", self.sansCombo.currentFont().family())
        s.setValue("typewriter", self.typewriterCombo.currentFont().family())
開發者ID:EdwardBetts,項目名稱:frescobaldi,代碼行數:73,代碼來源:globalfontdialog.py


注:本文中的PyQt4.QtGui.QFontComboBox.currentFont方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。