예제 #1
0
    def set_kwargs(self, code):
        """Sets widget from kwargs string

        Parameters
        ----------
        code: String
        \tCode representation of kwargs value

        """

        kwargs = {}

        kwarglist = list(parse_dict_strings(code[1:-1]))

        for kwarg, val in zip(kwarglist[::2], kwarglist[1::2]):
            kwargs[unquote_string(kwarg)] = val

        for key in kwargs:
            if key == "color":
                color = code2color(kwargs[key])
                self.colorselect.SetValue(color)
                self.colorselect.SetOwnForegroundColour(color)

            elif key == "fontname":
                self.font_face = unquote_string(kwargs[key])

                if self.chosen_font is None:
                    self.chosen_font = get_default_font()
                self.chosen_font.SetFaceName(self.font_face)

            elif key == "fontsize":
                if kwargs[key]:
                    self.font_size = int(kwargs[key])
                else:
                    self.font_size = get_default_font().GetPointSize()

                if self.chosen_font is None:
                    self.chosen_font = get_default_font()

                self.chosen_font.SetPointSize(self.font_size)

            elif key == "fontstyle":
                self.font_style = \
                    self.style_mpl2wx[unquote_string(kwargs[key])]

                if self.chosen_font is None:
                    self.chosen_font = get_default_font()

                self.chosen_font.SetStyle(self.font_style)

            elif key == "fontweight":
                self.font_weight = \
                    self.weight_mpl2wx[unquote_string(kwargs[key])]

                if self.chosen_font is None:
                    self.chosen_font = get_default_font()

                self.chosen_font.SetWeight(self.font_weight)
예제 #2
0
파일: _toolbars.py 프로젝트: aunix/pyspread
 def OnTextSize(self, event):
     """Text size combo text event handler"""
     
     try:
         size = int(event.GetString())
         
     except Exception:
         size = get_default_font().GetPointSize()
     
     post_command_event(self, FontSizeMsg, size=size)
예제 #3
0
def get_font_from_data(fontdata):
    """Returns wx.Font from fontdata string"""
    
    textfont = get_default_font()
    
    if fontdata != "":
        nativefontinfo = wx.NativeFontInfo()
        nativefontinfo.FromString(fontdata)
        textfont.SetNativeFontInfo(nativefontinfo)
    
    return textfont
예제 #4
0
파일: _toolbars.py 프로젝트: aunix/pyspread
 def _create_font_size_combo(self):
     """Creates font size combo box"""
     
     self.std_font_sizes = config["font_default_sizes"]
     font_size = str(get_default_font().GetPointSize())
     self.font_size_combo = wx.ComboBox(self, -1, value=font_size,
         size=(60, -1), choices=map(unicode, self.std_font_sizes),
         style=wx.CB_DROPDOWN | wx.TE_PROCESS_ENTER)
     self.AddControl(self.font_size_combo)
     self.Bind(wx.EVT_COMBOBOX, self.OnTextSize, self.font_size_combo)
     self.Bind(wx.EVT_TEXT_ENTER, self.OnTextSize, self.font_size_combo)