当前位置: 首页>>代码示例>>Python>>正文


Python wx.FontDialog方法代码示例

本文整理汇总了Python中wx.FontDialog方法的典型用法代码示例。如果您正苦于以下问题:Python wx.FontDialog方法的具体用法?Python wx.FontDialog怎么用?Python wx.FontDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wx的用法示例。


在下文中一共展示了wx.FontDialog方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OnChangeFont

# 需要导入模块: import wx [as 别名]
# 或者: from wx import FontDialog [as 别名]
def OnChangeFont(self, event):
        fname = self.fontsLb.GetClientData(self.fontsLb.GetSelection())
        nfont = getattr(self.cfg, fname)

        fd = wx.FontData()
        nfi = wx.NativeFontInfo()
        nfi.FromString(nfont)
        font = wx.FontFromNativeInfo(nfi)
        fd.SetInitialFont(font)

        dlg = wx.FontDialog(self, fd)
        if dlg.ShowModal() == wx.ID_OK:
            font = dlg.GetFontData().GetChosenFont()
            if util.isFixedWidth(font):
                setattr(self.cfg, fname, font.GetNativeFontInfo().ToString())

                self.cfg.fontYdelta = util.getFontHeight(font)

                self.cfg2gui()
                self.updateFontLb()
            else:
                wx.MessageBox("The selected font is not fixed width and"
                              " can not be used.", "Error", wx.OK, cfgFrame)

        dlg.Destroy() 
开发者ID:trelby,项目名称:trelby,代码行数:27,代码来源:cfgdlg.py

示例2: OnButton

# 需要导入模块: import wx [as 别名]
# 或者: from wx import FontDialog [as 别名]
def OnButton(self, event):
        fontData = wx.FontData()
        fontData.EnableEffects(False)
        if self.value is not None:
            font = wx.FontFromNativeInfoString(self.value)
            fontData.SetInitialFont(font)
        else:
            fontData.SetInitialFont(
                wx.SystemSettings_GetFont(wx.SYS_ANSI_VAR_FONT)
            )
        dialog = wx.FontDialog(self.GetParent(), fontData)
        if dialog.ShowModal() == wx.ID_OK:
            fontData = dialog.GetFontData()
            font = fontData.GetChosenFont()
            self.value = font.GetNativeFontInfo().ToString()
            event.Skip()
        dialog.Destroy()
        evt = eg.ValueChangedEvent(self.GetId(), value = self.value)
        wx.PostEvent(self, evt) 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:21,代码来源:FontSelectButton.py

示例3: on_button_choose_font

# 需要导入模块: import wx [as 别名]
# 或者: from wx import FontDialog [as 别名]
def on_button_choose_font(self, event):  # wxGlade: TextProperty.<event_handler>
        font_data = wx.FontData()
        try:
            font_data.SetInitialFont(self.element.wxfont)
            font_data.SetColour(wx.Colour(swizzlecolor(self.element.fill)))
            dialog = wx.FontDialog(None, font_data)
        except AttributeError:
            dialog = wx.FontDialog(None, font_data)
        if dialog.ShowModal() == wx.ID_OK:
            data = dialog.GetFontData()
            font = data.GetChosenFont()
            color = data.GetColour()
            rgb = color.GetRGB()
            color = swizzlecolor(rgb)
            color = Color(color, 1.0)
            self.element.wxfont = font
            self.element.fill = color
            self.update_label()
            self.refresh()
        dialog.Destroy()
        event.Skip() 
开发者ID:meerk40t,项目名称:meerk40t,代码行数:23,代码来源:TextProperty.py

示例4: _FileOptionsMenu

# 需要导入模块: import wx [as 别名]
# 或者: from wx import FontDialog [as 别名]
def _FileOptionsMenu(self, event):
        oldfont = self.frame.FindWindowById(self.text_id).GetFont()

        def _ChooseFontButton(event2):
            text = self.frame.FindWindowById(self.text_id)
            font_data = wx.FontData()
            font_data.SetInitialFont(text.GetFont())
            dialog = wx.FontDialog(self.options_dialog, font_data)
            if dialog.ShowModal() == wx.ID_OK:
                font = dialog.GetFontData().GetChosenFont()
                self._SetFont(font)
            dialog.Destroy()
        self.Bind(wx.EVT_BUTTON, _ChooseFontButton, id=self.choose_font_id)
        if self.options_dialog.ShowModal() != wx.ID_OK:
            self._SetFont(oldfont) 
开发者ID:cmpilato,项目名称:thotkeeper,代码行数:17,代码来源:app.py

示例5: choose_specific_font

# 需要导入模块: import wx [as 别名]
# 或者: from wx import FontDialog [as 别名]
def choose_specific_font(self, event):
        data = wx.FontData()
        try:
            family = self.font_families_to[self.value[1]]
            style = self.font_styles_to[self.value[2]]
            weight = self.font_weights_to[self.value[3]]
            font = wx.Font( self.value[0], family, style, weight, self.value[4], self.value[5] )
            data.SetInitialFont(font)
        except AttributeError:
            pass

        dialog = wx.FontDialog(self, data)
        res = dialog.ShowModal()
        font = dialog.GetFontData().GetChosenFont()
        dialog.Destroy()
        if res != wx.ID_OK:
            return

        family = font.GetFamily()
        #for f in (wx.VARIABLE, wx.FIXED):
        #    if family & f: family = family ^ f
        self.value = (font.GetPointSize(),
                      self.font_families_from[family],
                      self.font_styles_from[font.GetStyle()],
                      self.font_weights_from[font.GetWeight()],
                      font.GetUnderlined() and 1 or 0, font.GetFaceName())
        self.EndModal(wx.ID_OK) 
开发者ID:wxGlade,项目名称:wxGlade,代码行数:29,代码来源:font_dialog.py

示例6: onFont

# 需要导入模块: import wx [as 别名]
# 或者: from wx import FontDialog [as 别名]
def onFont(self, event): # wxGlade: DisplayDialog.<event_handler>
        data = wx.FontData()
        data.EnableEffects(True)
        #data.SetColour(self.curClr)         # set colour
        if self.parent.settings.font is not None:
            data.SetInitialFont(self.parent.settings.font)
        dlg = wx.FontDialog(self, data)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetFontData()
            self.font = data.GetChosenFont()
            self.parent.settings.font = self.font
            self.parent.updateTextctrl()
        dlg.Destroy() 
开发者ID:nccgroup,项目名称:Zulu,代码行数:15,代码来源:displayDialog.py

示例7: OnButtonSelect

# 需要导入模块: import wx [as 别名]
# 或者: from wx import FontDialog [as 别名]
def OnButtonSelect(self, evt):
        if self.textModified:           # text has newer value
            try:
                self.value = eval(self.text.GetValue())
            except SyntaxError:
                wx.LogError('Syntax error in parameter value: ' + self.GetName())
                self.value = self._defaultValue()
        # Make initial font
        # Default values
        size = g._sysFont.GetPointSize()
        family = wx.DEFAULT
        style = weight = wx.NORMAL
        underlined = 0
        face = ''
        enc = wx.FONTENCODING_DEFAULT
        # Fall back to default if exceptions
        error = False
        try:
            try: size = int(self.value[0])
            except ValueError: error = True; wx.LogError('Invalid size specification')
            try: family = fontFamiliesXml2wx[self.value[1]]
            except KeyError: error = True; wx.LogError('Invalid family specification')
            try: style = fontStylesXml2wx[self.value[2]]
            except KeyError: error = True; wx.LogError('Invalid style specification')
            try: weight = fontWeightsXml2wx[self.value[3]]
            except KeyError: error = True; wx.LogError('Invalid weight specification')
            try: underlined = bool(self.value[4])
            except ValueError: error = True; wx.LogError('Invalid underlined flag specification')
            face = self.value[5]
        except IndexError:
            error = True
        mapper = wx.FontMapper()
        if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6])
            
        if error: wx.LogError('Invalid font specification')
        if enc == wx.FONTENCODING_DEFAULT: enc = wx.FONTENCODING_SYSTEM
        font = wx.Font(size, family, style, weight, underlined, face, enc)
        data = wx.FontData()
        data.SetInitialFont(font)
        dlg = wx.FontDialog(self, data)
        if dlg.ShowModal() == wx.ID_OK:
            font = dlg.GetFontData().GetChosenFont()
            if font.GetEncoding() == wx.FONTENCODING_SYSTEM:
                encName = ''
            else:
                encName = wx.FontMapper.GetEncodingName(font.GetEncoding()).encode()
            value = [str(font.GetPointSize()),
                     fontFamiliesWx2Xml.get(font.GetFamily(), "default"),
                     fontStylesWx2Xml.get(font.GetStyle(), "normal"),
                     fontWeightsWx2Xml.get(font.GetWeight(), "normal"),
                     str(int(font.GetUnderlined())),
                     font.GetFaceName().encode(),
                     encName
                     ]
            self.SetValue(value)
            self.SetModified()
            self.textModified = False
        dlg.Destroy()

################################################################################ 
开发者ID:andreas-p,项目名称:admin4,代码行数:62,代码来源:params.py


注:本文中的wx.FontDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。