def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, -1) e = wx.FontEnumerator() e.EnumerateFacenames() list = e.GetFacenames() list.sort() self.lb1 = wx.ListBox(self, -1, wx.DefaultPosition, (200, 250), list, wx.LB_SINGLE) self.Bind(wx.EVT_LISTBOX, self.OnSelect, id=self.lb1.GetId()) self.txt = wx.StaticText(self, -1, "Sample text...", (285, 50)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.txt, 0, wx.EXPAND) sizer.Add(self.lb1, 0, wx.EXPAND | wx.TOP, 20) self.SetSizer(sizer) self.Fit() self.Layout() dprint(self.GetSize()) self.lb1.SetSelection(0) self.OnSelect(None) wx.FutureCall(300, self.SetTextSize)
def createFontTool(self): enum = wx.FontEnumerator() enum.EnumerateFacenames() style_choices = enum.GetFacenames() style_choices.sort() font_style = wx.ComboBox(self, -1, "", choices=style_choices, size=(150, -1), style=wx.CB_DROPDOWN) self.AddControl(font_style, '字体') self.Bind(wx.EVT_COMBOBOX, self.OnFontFace, font_style) size_choices = [ '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '24', '28', '30', '32', '64' ] font_size = wx.ComboBox(self, -1, "", choices=size_choices, size=(50, -1), style=wx.CB_DROPDOWN) self.AddControl(font_size, '字体大小') self.Bind(wx.EVT_COMBOBOX, self.OnFontSize, font_size) self.AddSeparator()
def __init__(self, name, designer, cmpn, obj, ownerPW): HelperDTC.__init__(self, name, designer, cmpn, obj, ownerPW) self.editors = {'FaceName' : PropertyEditors.EnumPropEdit, 'Family' : PropertyEditors.EnumPropEdit, 'Style' : PropertyEditors.EnumPropEdit, 'Weight' : PropertyEditors.EnumPropEdit, 'Underlined': PropertyEditors.BoolPropEdit,} fontEnum = wx.FontEnumerator() fontEnum.EnumerateFacenames() fontNameList = fontEnum.GetFacenames() fontFaceName = [] fontFaceNameNames = {} for fnt in fontNameList: fontFaceName.append(fnt) fontFaceNameNames[fnt] = fnt fontFaceName.sort() self.options = {'FaceName' : fontFaceName, 'Family' : fontFamily, 'Style' : fontStyle, 'Weight' : fontWeight,} self.names = {'FaceName' : fontFaceNameNames, 'Family' : fontFamilyNames, 'Style' : fontStyleNames, 'Weight' : fontWeightNames,}
def ConfigAvailFonts(self): """Determine fonts that are available in both wx.Python and ImageMagick.""" # Find out what fonts are available in ImageMagick strIMFonts = [] fIMOutput = os.popen( "convert -list type | grep -v \"^$\|^Name\|^Path:\|^--\" | sort", 'r') # Read ImageMagick's output and append to strIMFonts curLine = fIMOutput.readline().strip('\n ') while curLine != "": strIMFonts.append(curLine) curLine = fIMOutput.readline().strip('\n ') fIMOutput.close() # Get fonts available to wx.Python enuWXFonts = wx.FontEnumerator() enuWXFonts.EnumerateFacenames() strWXFonts = enuWXFonts.GetFacenames() strWXFonts.sort() # For each font in wx.Python, see if it's also available in # ImageMagick. If so, append it to a new list for wxfont in range(len(strWXFonts)): for im in range(len(strIMFonts)): if strIMFonts[im].find(strWXFonts[wxfont]) != -1: self.strAvailFonts.append(strWXFonts[wxfont]) break
def get_font_list(self): e = wx.FontEnumerator() e.EnumerateFacenames() font_list = e.GetFacenames() font_list.sort() #print font_list return font_list
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) e = wx.FontEnumerator() e.EnumerateFacenames() list = e.GetFacenames() list.sort() s1 = wx.StaticText(self, -1, "Face names:") self.lb1 = wx.ListBox(self, -1, wx.DefaultPosition, (200, 250), list, wx.LB_SINGLE) self.Bind(wx.EVT_LISTBOX, self.OnSelect, id=self.lb1.GetId()) self.txt = wx.StaticText(self, -1, "Sample text...", (285, 50)) row = wx.BoxSizer(wx.HORIZONTAL) row.Add(s1, 0, wx.ALL, 5) row.Add(self.lb1, 0, wx.ALL, 5) row.Add(self.txt, 0, wx.ALL | wx.ADJUST_MINSIZE, 5) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(row, 0, wx.ALL, 30) self.SetSizer(sizer) self.Layout() self.lb1.SetSelection(0) self.OnSelect(None) wx.FutureCall(300, self.SetTextSize)
def _read_fonts(self): f = wx.FontEnumerator() f.EnumerateFacenames() names = f.GetFacenames(fixedWidthOnly=True) names = [n for n in names if not n.startswith('@')] names.sort() return names
def initDefaultFonts(self): """Initialize default fonts. """ fontEnum = wx.FontEnumerator() fontEnum.EnumerateFacenames() faceList = fontEnum.GetFacenames() if 'Utopia' in faceList: self.defaultStimFont = wx.Font(pointSize=196, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=False, faceName='Utopia') self.defaultFeedFont = wx.Font(pointSize=32, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=True, faceName='Utopia') else: self.defaultStimFont = wx.Font(pointSize=196, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=False) self.defaultFeedFont = wx.Font(pointSize=32, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=True)
def ReadFonts(fixed=False): """Returns list with fixed width fonts""" f = wx.FontEnumerator() f.EnumerateFacenames() names = f.GetFacenames(fixedWidthOnly=fixed) names = [n for n in names if not n.startswith('@')] names.sort() return names
def ReadFonts(): '''Returns list with fixed width fonts''' f = wx.FontEnumerator() f.EnumerateFacenames() names = f.GetFacenames(fixedWidthOnly=True) names = [n for n in names if not n.startswith('@')] names.sort() return names
def getBestFont(): e = wx.FontEnumerator() e.EnumerateFacenames() fontnames = e.GetFacenames(fixedWidthOnly=True) for name in ['DejaVu Sans Mono', 'Courier New']: if name in fontnames: return name return None
def get_chinese_fonts(): e = wx.FontEnumerator() e.EnumerateFacenames() fonts = [] for name in (f for f in e.GetFacenames() if not f.startswith('@')): if name.lower().startswith(CHINESE_FONTS): fonts.append(name) return fonts
def __init__(self): fontsEnum = wx.FontEnumerator() fontsEnum.EnumerateFacenames() self.fontNames = fontsEnum.GetFacenames() self.fontNames.sort() self.colorNames = ZCssColor.COLOR_NAMES.keys() self.cssFontSizeList = [] self.cssFontSizeList.extend(ZCssFontSizes.CSS_SIZES)
def get_font_list(): """Returns a sorted list of all system font names""" font_enum = wx.FontEnumerator() font_enum.EnumerateFacenames(wx.FONTENCODING_SYSTEM) font_list = font_enum.GetFacenames() font_list.sort() return font_list
def __init__(self, parent, model): # model is instance of ZFontModel. self.model = model fontsEnum = wx.FontEnumerator() fontsEnum.EnumerateFacenames() self.systemFontNames = fontsEnum.GetFacenames() self.systemFontNames.sort() ZBaseDialog.__init__(self, parent, wx.ID_ANY, _extstr(u"fontdialog.DialogTitle"), style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name = u"ZFontDialog") #$NON-NLS-1$ #$NON-NLS-2$
def getBuiltinValuesForKey(attrKey): # Handle exceptions here if attrKey == "icon": return list(wx.GetApp().getIconCache().iconLookupCache.keys()) elif attrKey == "font" or attrKey == "global.font": fenum = wx.FontEnumerator() fenum.EnumerateFacenames() return fenum.GetFacenames() else: return _BUILTINS.get(attrKey)
def __init__(self, *args, **kwds): wx.Frame.__init__(self, *args, **kwds) # font list self.lblFonts = wx.StaticText(self, wx.ID_ANY, "Font Family") e = wx.FontEnumerator() e.EnumerateFacenames() flist = e.GetFacenames() self.lbxFonts = wx.ListBox(self, -1, wx.DefaultPosition, (300, 100), flist, wx.LB_SINGLE) # family self.lblFamily = wx.StaticText(self, -1, "Family") self.choFamily = wx.Choice(self, -1, choices=[ 'Default', 'Decorative', 'Roman', 'Script', 'Swiss', 'Modern', 'Teletype' ]) self.choFamily.SetSelection(0) # FIXME: this has no meaning for now self.lblFamily.Show(False) self.choFamily.Show(False) # style self.lblStyle = wx.StaticText(self, -1, "Style") self.choStyle = wx.Choice(self, -1, choices=['Normal', 'Italic', 'Slant']) self.choStyle.SetSelection(0) # weight self.lblWeight = wx.StaticText(self, -1, "Weight") self.choWeight = wx.Choice(self, -1, choices=['Normal', 'Light', 'Bold']) self.choWeight.SetSelection(0) # direction self.lblFontDir = wx.StaticText(self, -1, "Direction") self.choFontDir = wx.Choice(self, -1, choices=['Horizontal', 'Vertical']) self.choFontDir.SetSelection(0) # point size self.lblPntSize = wx.StaticText(self, -1, "Point Size") self.spnPntSize = wx.SpinCtrl(self, -1, min=8, max=24, initial=10) # generate self.btnGenFont = wx.Button(self, -1, "Generate LCD Font") # sample self.txtLorem = wx.TextCtrl(self, -1, LOREM_IPSUM, style=wx.TE_READONLY | wx.TE_MULTILINE) self.__set_properties() self.__do_layout() self.__initialize()
def get_font_names(): global known_fonts if known_fonts is None: # NOTE: The list of face names from wx are in unicode fonts = wx.FontEnumerator() fonts.EnumerateFacenames() known_fonts = fonts.GetFacenames() known_fonts.sort() known_fonts[0:0] = ["default"] return known_fonts
def ReadFonts(): '''Returns list with fixed width fonts''' f = wx.FontEnumerator() f.EnumerateFacenames() if wx.VERSION >= (3, 0, 3, ''): # DEBUG wxPhoenix names = f.GetFacenames(fixedWidthOnly=True) else: names = f.GetFacenames() names = [n for n in names if not n.startswith('@')] names.sort() return names
def prepare_font_choices(): """Get list of all font faces available.""" global FontChoices e = wx.FontEnumerator() e.EnumerateFacenames() elist = e.GetFacenames() elist.sort() FontChoices = [x for x in elist if x[0] != '.']
def enumerate(self, mode = None): """Iterate through all available font-keys (whether instantiated or not) This uses the wxFontEnumerator class to provide a list of font names from the wxPython system, (with all names lowercased). """ if not self.systemNames: ## wxPython with do a memory-access fault if we try this :( enumerator = wx.FontEnumerator() enumerator.EnumerateFacenames() systemNames = enumerator.GetFacenames() self.systemNames = systemNames = [item.lower() for item in systemNames] return self.systemNames
def __init__(self): wx.Frame.__init__(self, None, -1, 'Text Entry Example', size=(300, 250)) panel = wx.Panel(self, -1) multiLabel = wx.StaticText(panel, -1, "Multi-line") multiText = wx.TextCtrl(panel, -1, "Here is a looooooooooooong line " "of text set in the control.\n\n" "See that it wrapped, and that " "this line is after the blank", size=(200, 100), style=wx.TE_MULTILINE) multiText.SetInsertionPoint(0) richLabel = wx.StaticText(panel, -1, "Rich Text") richText = wx.TextCtrl( panel, -1, "If supported by the native control, " "this is reversed, and this is in a different font.", size=(200, 100), style=wx.TE_MULTILINE | wx.TE_RICH2) richText.SetInsertionPoint(0) #Setting text styles, based on locations (characters + spaces) #(start, end, style) richText.SetStyle(44, 52, wx.TextAttr("white", "black")) #Creating a font, points can be used to +/- the size points = richText.GetFont().GetPointSize() f = wx.Font(points + 8, wx.ROMAN, wx.ITALIC, wx.BOLD, True) #Setting a style in the new font #(col of text, col of background, font) richText.SetStyle(68, 82, wx.TextAttr("blue", wx.NullColour, f)) sizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6) sizer.AddMany([multiLabel, multiText, richLabel, richText]) panel.SetSizer(sizer) e = wx.FontEnumerator() e.EnumerateFacenames() fontList = e.GetFacenames() for font in fontList: print font + "\n"
def __init__(self, parent): e = wx.FontEnumerator() e.EnumerateFacenames() fontList = e.GetFacenames() fontList.sort() rdn = random.randint(0, len(fontList)-1) randomFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) randomFont.SetFaceName(fontList[rdn]) self.randomFont = randomFont self.text = "This is my renderer" dc = wx.ClientDC(parent) dc.SetFont(self.randomFont) self.width, self.height, descent, el = dc.GetFullTextExtent(self.text) self.height += descent
def extractFont(self, fontList, base=[]): """Extract specified font from theme spec""" # Convert to list if not already if isinstance(base, str): base = base.split(",") base = base if isinstance(base, list) else [base] if isinstance(fontList, str): fontList = fontList.split(",") fontList = fontList if isinstance(fontList, list) else [fontList] # Extract styles bold, italic = [], [] if "bold" in fontList: bold = [fontList.pop(fontList.index("bold"))] if "italic" in fontList: italic = [fontList.pop(fontList.index("italic"))] # Extract styles from base, if needed if "bold" in base: bold = [base.pop(base.index("bold"))] if "italic" in base: italic = [base.pop(base.index("italic"))] # Append base and default fonts fontList.extend(base + ["JetBrains Mono"]) if "" in fontList: del fontList[fontList.index("")] # Set starting font in case none are found try: finalFont = [ wx.SystemSettings.GetFont( wx.SYS_ANSI_FIXED_FONT).GetFaceName() ] except wx._core.wxAssertionError: finalFont = [ wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL).GetFaceName() ] # Cycle through font names, stop at first valid font if sys.platform == 'win32': for font in fontList: if font in wx.FontEnumerator().GetFacenames(): finalFont = [font] + bold + italic break return ','.join(finalFont)
def __init__(self, parent): super(FontChoiceDialog, self).__init__(parent) self.font_face.Bind(wx.EVT_CHOICE, self.on_font_changed) self.font_size.Bind(wx.EVT_SPINCTRL, self.on_font_changed) self.gui_use_default_font.Bind( wx.EVT_CHECKBOX, lambda evt: self.on_use_default_font(evt.Checked())) self.gui_use_in_ui.Bind(wx.EVT_CHECKBOX, self.on_font_changed) self.tree = FontTree(self.filterable_tree_holder) self.tree.on_module_choice += self.on_module_choice self.tree.on_category_choice += self.on_category_choice self.filterable_tree_holder.Sizer.Add(self.tree, 1, wx.GROW) self.filterable_tree_holder.Layout() names = wx.FontEnumerator().GetFacenames() names.sort() self.font_face.Clear() self.font_face.AppendItems(names) self.preview.handle_links = False self.on_default_choice()
def __init__(self, *args, **kwargs): """ Initialize a font face combobox. In addition to the public attributes describes as public attributes, the constructor understands the following parameters: extendedText This string will be added to the face name to give an indication of how the font appears. Typically a panagram. """ self.fontHeight = kwargs.pop("fontHeight", 18) self.maximumPopupWidth = kwargs.pop("maximumPopupWidth", 400) self.evenRowBackground = kwargs.pop("evenRowBackground", wx.WHITE) self.oddRowBackground = kwargs.pop("oddRowBackground", wx.Colour(191, 239, 255)) extendedText = kwargs.pop("extendedText", " - Big fjords vex quick waltz nymph") # Build the data behind the control fe = wx.FontEnumerator() fe.EnumerateFacenames() self.fontInfo = [ Bucket(name=x, display=x + extendedText) for x in sorted(fe.GetFacenames(), key=unicode.lower) ] kwargs['style'] = kwargs.get("style", 0) | wx.CB_READONLY kwargs["choices"] = [x.name for x in self.fontInfo] wx.combo.OwnerDrawnComboBox.__init__(self, *args, **kwargs) # Fill in some other information that is better to precalculate. # Measuring text has to be done after the control is initialized measuringDC = wx.ClientDC(self) for x in self.fontInfo: x.font = wx.FFont(self.fontHeight, wx.FONTFAMILY_DEFAULT, face=x.name) x.extent = measuringDC.GetFullTextExtent(x.display, font=x.font)
def refreshFontList(): aaa = wx.App(False) My_fonts1 = wx.FontEnumerator().GetFacenames() for i in range(len(My_fonts1)-1,-1,-1): if '@' in My_fonts1[i]: My_fonts1.remove(My_fonts1[i]) My_fonts2 = os.listdir('C:\\Windows\\Fonts') for i in range(len(My_fonts2)): if '.' in My_fonts2[i]: sub_s = My_fonts2[i].find('.') My_fonts2[i] = My_fonts2[i][:sub_s] My_fonts1.extend(My_fonts2) My_fonts = list(set(My_fonts1)) My_fonts.extend(installed_fonts) with open("Fontdict.txt", 'r+', encoding="utf-8") as f: f.seek(0, 0) for i in range(len(My_fonts)): f.write(str(My_fonts[i])+'\n')
def getSystemFonts(encoding='system', fixedWidthOnly=False): """Get a list of installed system fonts. Parameters ---------- encoding : str Get fonts with matching encodings. fixedWidthOnly : bool Return on fixed width fonts. Returns ------- list List of font facenames. """ fontEnum = wx.FontEnumerator() encoding = "FONTENCODING_" + encoding.upper() if hasattr(wx, encoding): encoding = getattr(wx, encoding) return fontEnum.GetFacenames(encoding, fixedWidthOnly=fixedWidthOnly)
def __init__(self, parent, *args, context=None, node=None, **kwds): kwds["style"] = kwds.get("style", 0) | wx.TAB_TRAVERSAL super().__init__(parent, *args, **kwds) self.context = context self.text_id = wx.TextCtrl(self, wx.ID_ANY, "") self.text_label = wx.TextCtrl(self, wx.ID_ANY, "") self.text_text = wx.TextCtrl(self, wx.ID_ANY, "") self.node = node self.label_fonttest = wx.StaticText(self, wx.ID_ANY, "", style=wx.ST_ELLIPSIZE_END | wx.ST_NO_AUTORESIZE) self.label_fonttest.SetMinSize((-1, 90)) self.label_fonttest.SetFont( wx.Font( 16, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, "Segoe UI", )) self.button_choose_font = wx.BitmapButton( self, wx.ID_ANY, icons8_choose_font_50.GetBitmap()) self.button_stroke_none = wx.Button(self, wx.ID_ANY, "None") self.button_stroke_none.name = "stroke none" self.button_stroke_F00 = wx.Button(self, wx.ID_ANY, "") self.button_stroke_F00.name = "stroke #F00" self.button_stroke_0F0 = wx.Button(self, wx.ID_ANY, "") self.button_stroke_0F0.name = "stroke #0F0" self.button_stroke_00F = wx.Button(self, wx.ID_ANY, "") self.button_stroke_00F.name = "stroke #00F" self.button_stroke_F0F = wx.Button(self, wx.ID_ANY, "") self.button_stroke_F0F.name = "stroke #F0F" self.button_stroke_0FF = wx.Button(self, wx.ID_ANY, "") self.button_stroke_0FF.name = "stroke #0FF" self.button_stroke_FF0 = wx.Button(self, wx.ID_ANY, "") self.button_stroke_FF0.name = "stroke #FF0" self.button_stroke_000 = wx.Button(self, wx.ID_ANY, "") self.button_stroke_000.name = "stroke #000" self.button_fill_none = wx.Button(self, wx.ID_ANY, "None") self.button_fill_none.name = "fill none" self.button_fill_F00 = wx.Button(self, wx.ID_ANY, "") self.button_fill_F00.name = "fill #F00" self.button_fill_0F0 = wx.Button(self, wx.ID_ANY, "") self.button_fill_0F0.name = "fill #0F0" self.button_fill_00F = wx.Button(self, wx.ID_ANY, "") self.button_fill_00F.name = "fill #00F" self.button_fill_F0F = wx.Button(self, wx.ID_ANY, "") self.button_fill_F0F.name = "fill #F0F" self.button_fill_0FF = wx.Button(self, wx.ID_ANY, "") self.button_fill_0FF.name = "fill #0FF" self.button_fill_FF0 = wx.Button(self, wx.ID_ANY, "") self.button_fill_FF0.name = "fill #FF0" self.button_fill_000 = wx.Button(self, wx.ID_ANY, "") self.button_fill_000.name = "fill #000" flist = wx.FontEnumerator() flist.EnumerateFacenames() elist = flist.GetFacenames() elist.sort() self.combo_font = PromptingComboBox(self, choices=elist, style=wx.TE_PROCESS_ENTER) self.button_attrib_larger = wx.Button(self, id=wx.ID_ANY, label="A", size=wx.Size(23, 23)) self.button_attrib_smaller = wx.Button(self, id=wx.ID_ANY, label="a", size=wx.Size(23, 23)) self.button_attrib_bold = wx.ToggleButton(self, id=wx.ID_ANY, label="b", size=wx.Size(23, 23)) self.button_attrib_italic = wx.ToggleButton(self, id=wx.ID_ANY, label="i", size=wx.Size(23, 23)) self.button_attrib_underline = wx.ToggleButton(self, id=wx.ID_ANY, label="u", size=wx.Size(23, 23)) self.button_attrib_strikethrough = wx.ToggleButton(self, id=wx.ID_ANY, label="s", size=wx.Size( 23, 23)) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_TEXT, self.on_text_id_change, self.text_id) self.Bind(wx.EVT_TEXT_ENTER, self.on_text_id_change, self.text_id) self.Bind(wx.EVT_TEXT, self.on_text_label_change, self.text_label) self.Bind(wx.EVT_TEXT_ENTER, self.on_text_label_change, self.text_label) self.Bind(wx.EVT_TEXT, self.on_text_name_change, self.text_text) self.Bind(wx.EVT_TEXT_ENTER, self.on_text_name_change, self.text_text) self.Bind(wx.EVT_BUTTON, self.on_button_choose_font, self.button_choose_font) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_stroke_none) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_stroke_F00) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_stroke_0F0) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_stroke_00F) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_stroke_F0F) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_stroke_0FF) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_stroke_FF0) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_stroke_000) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_fill_none) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_fill_F00) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_fill_0F0) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_fill_00F) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_fill_F0F) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_fill_0FF) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_fill_FF0) self.Bind(wx.EVT_BUTTON, self.on_button_color, self.button_fill_000) self.Bind(wx.EVT_COMBOBOX, self.on_font_choice, self.combo_font) self.Bind(wx.EVT_TEXT_ENTER, self.on_font_choice, self.combo_font) self.Bind(wx.EVT_KILL_FOCUS, self.on_font_choice, self.combo_font) self.Bind(wx.EVT_BUTTON, self.on_button_larger, self.button_attrib_larger) self.Bind(wx.EVT_BUTTON, self.on_button_smaller, self.button_attrib_smaller) self.Bind(wx.EVT_TOGGLEBUTTON, self.on_button_bold, self.button_attrib_bold) self.Bind(wx.EVT_TOGGLEBUTTON, self.on_button_italic, self.button_attrib_italic) self.Bind(wx.EVT_TOGGLEBUTTON, self.on_button_underline, self.button_attrib_underline) self.Bind( wx.EVT_TOGGLEBUTTON, self.on_button_strikethrough, self.button_attrib_strikethrough, )
def __DoLayout(self): """Layout the controls in the panel""" hsizer = wx.BoxSizer(wx.HORIZONTAL) # Setup Left hand side with Style Tag List ss_v = wx.BoxSizer(wx.VERTICAL) style_lbl = wx.StaticText(self, label=_("Style Tags") + u": ") ss_v.AddMany([(style_lbl, 0, wx.ALIGN_LEFT), (self._tag_list, 1, wx.EXPAND)]) hsizer.Add(ss_v, 0, wx.EXPAND|wx.ALL, 5) # Add divider line hsizer.Add(wx.StaticLine(self, size=(-1, 2), style=wx.LI_VERTICAL), 0, wx.ALIGN_CENTER_HORIZONTAL|wx.EXPAND|wx.TOP|wx.BOTTOM, 5) # Setup the Right side setting_sizer = wx.BoxSizer(wx.VERTICAL) setting_top = wx.BoxSizer(wx.HORIZONTAL) # Settings top sbox = wx.StaticBox(self, label=_("Color")) cbox_sizer = wx.StaticBoxSizer(sbox, wx.VERTICAL) # Foreground fground_sizer = wx.BoxSizer(wx.HORIZONTAL) fground_lbl = wx.StaticText(self, label=_("Foreground") + u": ") fground_sel = eclib.ColorSetter(self, ID_FORE_COLOR, wx.BLACK) fground_sizer.AddMany([((5, 5)), (fground_lbl, 0, wx.ALIGN_CENTER_VERTICAL), ((2, 2), 0), (fground_sel, 0, wx.ALIGN_CENTER_VERTICAL), ((5, 5))]) cbox_sizer.AddMany([(fground_sizer, 0, wx.ALIGN_LEFT | wx.EXPAND), ((10, 10))]) # Background bground_sizer = wx.BoxSizer(wx.HORIZONTAL) bground_lbl = wx.StaticText(self, label=_("Background") + u": ") bground_sel = eclib.ColorSetter(self, ID_BACK_COLOR, wx.WHITE) bground_sizer.AddMany([((5, 5)), (bground_lbl, 0, wx.ALIGN_CENTER_VERTICAL), ((2, 2), 0), (bground_sel, 0, wx.ALIGN_CENTER_VERTICAL), ((5, 5))]) cbox_sizer.Add(bground_sizer, 0, wx.EXPAND) setting_top.AddMany([(cbox_sizer, 0, wx.ALIGN_TOP), ((10, 10), 0)]) # Attrib Box attrib_box = wx.StaticBox(self, label=_("Attributes")) abox_sizer = wx.StaticBoxSizer(attrib_box, wx.VERTICAL) # Attributes bold_cb = wx.CheckBox(self, ID_BOLD, _("bold")) eol_cb = wx.CheckBox(self, ID_EOL, _("eol")) ital_cb = wx.CheckBox(self, ID_ITALIC, _("italic")) uline_cb = wx.CheckBox(self, ID_ULINE, _("underline")) abox_sizer.AddMany([(bold_cb, 0), (eol_cb, 0), (ital_cb, 0), (uline_cb, 0)]) setting_top.Add(abox_sizer, 0, wx.ALIGN_TOP) # Font fh_sizer = wx.BoxSizer(wx.HORIZONTAL) font_box = wx.StaticBox(self, label=_("Font Settings")) fbox_sizer = wx.StaticBoxSizer(font_box, wx.VERTICAL) # Font Face Name fsizer = wx.BoxSizer(wx.HORIZONTAL) flbl = wx.StaticText(self, label=_("Font") + u": ") fontenum = wx.FontEnumerator() if wx.Platform == '__WXMAC__': # FixedWidthOnly Asserts on wxMac fontenum.EnumerateFacenames(fixedWidthOnly=False) else: fontenum.EnumerateFacenames(fixedWidthOnly=True) font_lst = [u"%(primary)s", u"%(secondary)s"] font_lst.extend(sorted(fontenum.GetFacenames())) fchoice = wx.Choice(self, ID_FONT, choices=font_lst) fsizer.AddMany([((5, 5), 0), (flbl, 0, wx.ALIGN_CENTER_VERTICAL), (fchoice, 0, wx.ALIGN_CENTER_VERTICAL), ((5, 5),0)]) fbox_sizer.Add(fsizer, 0) # Font Size fsize_sizer = wx.BoxSizer(wx.HORIZONTAL) fsize_lbl = wx.StaticText(self, label=_("Size") + u": ") fsizes = [u"%(size)d", u"%(size2)d"] fsizes.extend([ unicode(x) for x in range(4, 21) ]) fs_choice = wx.Choice(self, ID_FONT_SIZE, choices=fsizes) fsize_sizer.AddMany([((5, 5), 0), (fsize_lbl, 0, wx.ALIGN_CENTER_VERTICAL), (fs_choice, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL), ((5, 5), 0)]) fbox_sizer.AddMany([((5, 5), 0), (fsize_sizer, 0, wx.EXPAND)]) fh_sizer.AddMany([(fbox_sizer, 0, wx.ALIGN_CENTER_HORIZONTAL), ((10, 10), 0)]) # Build Section setting_sizer.AddMany([(setting_top, 0, wx.ALIGN_CENTER_HORIZONTAL), ((10, 10), 0), (fh_sizer, 0, wx.ALIGN_CENTER_HORIZONTAL)]) # Setup Right hand side with the settings controls hsizer.AddStretchSpacer() hsizer.Add(setting_sizer, 0, wx.EXPAND|wx.ALL, 5) hsizer.AddStretchSpacer() self.SetSizer(hsizer)