Python wx.FontData() Examples
The following are 7
code examples of wx.FontData().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: cfgdlg.py From trelby with GNU General Public License v2.0 | 6 votes |
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()
Example #2
Source File: FontSelectButton.py From EventGhost with GNU General Public License v2.0 | 6 votes |
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)
Example #3
Source File: TextProperty.py From meerk40t with MIT License | 6 votes |
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()
Example #4
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #5
Source File: font_dialog.py From wxGlade with MIT License | 5 votes |
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)
Example #6
Source File: displayDialog.py From Zulu with GNU Affero General Public License v3.0 | 5 votes |
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()
Example #7
Source File: params.py From admin4 with Apache License 2.0 | 4 votes |
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() ################################################################################