Ejemplo n.º 1
0
    def GetKeyProfiles():
        """Get the list of available key profiles
        @return: list of strings

        """
        recs = util.GetResourceFiles(u'cache', trim=True, get_all=False,
                                     suffix='.ekeys', title=False)
        if recs == -1:
            recs = list()

        tmp = util.GetResourceFiles(u'ekeys', True, True, '.ekeys', False)
        if tmp != -1:
            recs.extend(tmp)

        return recs
Ejemplo n.º 2
0
    def GetStyleSheet(sheet_name=None):
        """Finds the current style sheet and returns its path. The
        lookup is done by first looking in the users config directory
        and if it is not found there it looks for one on the system
        level and if that fails it returns None.
        @param sheet_name: style sheet to look for
        @return: full path to style sheet

        """
        if sheet_name:
            style = sheet_name
        else:
            style = Profile_Get('SYNTHEME', 'str')
        style = ebmlib.AddFileExtension(style, u'.ess').lower()

        # Get Correct Filename if it exists
        for sheet in util.GetResourceFiles(u'styles',
                                           trim=False,
                                           get_all=True,
                                           title=False):
            if sheet.lower() == style:
                style = sheet
                break

        user = os.path.join(ed_glob.CONFIG['STYLES_DIR'], style)
        sysp = os.path.join(ed_glob.CONFIG['SYS_STYLES_DIR'], style)
        if os.path.exists(user):
            return user
        elif os.path.exists(sysp):
            return sysp
        else:
            return None
Ejemplo n.º 3
0
    def GetStyleSheet(sheet_name=None):
        """Finds the current style sheet and returns its path. The
        Lookup is done by first looking in the users config directory
        and if it is not found there it looks for one on the system
        level and if that fails it returns None.
        @param sheet_name: style sheet to look for
        @return: full path to style sheet

        """
        if sheet_name:
            style = sheet_name
            if sheet_name.split(u'.')[-1] != u"ess":
                style += u".ess"
        elif Profile_Get('SYNTHEME', 'str').split(u'.')[-1] != u"ess":
            style = (Profile_Get('SYNTHEME', 'str') + u".ess").lower()
        else:
            style = Profile_Get('SYNTHEME', 'str').lower()

        # Get Correct Filename if it exists
        for sheet in util.GetResourceFiles(u'styles', False, True, title=False):
            if sheet.lower() == style.lower():
                style = sheet
                break

        user = os.path.join(ed_glob.CONFIG['STYLES_DIR'], style)
        sysp = os.path.join(ed_glob.CONFIG['SYS_STYLES_DIR'], style)
        if os.path.exists(user):
            return user
        elif os.path.exists(sysp):
            return sysp
        else:
            return None
Ejemplo n.º 4
0
    def __init__(self, parent):
        super(StyleEditorBox, self).__init__(parent)

        # Attributes
        self._prevTheme = None
        ctrlbar = self.CreateControlBar(wx.TOP)
        ss_lst = util.GetResourceFiles(u'styles', get_all=True, title=False)
        ss_lst = [sheet for sheet in ss_lst if not sheet.startswith('.')]
        self._style_ch = wx.Choice(ctrlbar,
                                   ed_glob.ID_PREF_SYNTHEME,
                                   choices=sorted(ss_lst))
        bmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_ADD), wx.ART_MENU)
        if not bmp.IsOk():
            bmp = None
        self._addbtn = eclib.PlateButton(ctrlbar,
                                         label=_("New"),
                                         bmp=bmp,
                                         style=eclib.PB_STYLE_NOBG)
        bmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_REMOVE), wx.ART_MENU)
        if not bmp.IsOk():
            bmp = None
        self._delbtn = eclib.PlateButton(ctrlbar,
                                         label=_("Remove"),
                                         bmp=bmp,
                                         style=eclib.PB_STYLE_NOBG)

        # Setup
        ss_lbl = wx.StaticText(ctrlbar, label=_("Style Theme") + u": ")
        ctrlbar.AddControl(ss_lbl, wx.ALIGN_LEFT)
        self.StyleTheme = Profile_Get('SYNTHEME', 'str')
        ctrlbar.AddControl(self._style_ch, wx.ALIGN_LEFT)
        ctrlbar.AddControl(self._addbtn, wx.ALIGN_LEFT)
        self._addbtn.SetToolTipString(_("Create a new style theme"))
        ctrlbar.AddControl(self._delbtn, wx.ALIGN_LEFT)
        self._delbtn.SetToolTipString(_("Remove Style"))
        self.SetWindow(StyleEditorPanel(self))

        # Events
        self.Bind(wx.EVT_CHOICE, self.OnThemeChoice, self._style_ch)
        self.Bind(wx.EVT_BUTTON, self.OnButton)
        self.Bind(wx.EVT_UPDATE_UI,
                  lambda evt: evt.Enable(not self.IsSystemStyleSheet()),
                  self._delbtn)
Ejemplo n.º 5
0
    def __init__(self, parent):
        ctrlbox.ControlBox.__init__(self, parent)

        # Attributes
        self._shell = EdPyShell(self)
        self._styles = util.GetResourceFiles('styles', True, True, title=False)
        self._choice = None
        self._clear = None

        # Setup
        self.__DoLayout()
        style = self._shell.GetShellTheme()
        for sty in self._styles:
            if sty.lower() == style.lower():
                self._choice.SetStringSelection(sty)
                break

        # Event handlers
        self.Bind(wx.EVT_BUTTON, self.OnButton, self._clear)
        self.Bind(wx.EVT_CHOICE, self.OnChoice, self._choice)
Ejemplo n.º 6
0
    def __StyleSheets(self):
        """Returns a sizer item that contains a choice control with
        all the available style sheets listed in it.
        @return: sizer item holding all installed style sheets

        """
        ss_sizer = wx.BoxSizer(wx.HORIZONTAL)
        ss_lbl = wx.StaticText(self.ctrl_pane, wx.ID_ANY,
                               _("Style Theme") + u": ")
        ss_lst = util.GetResourceFiles(u'styles', get_all=True)
        ss_choice = wx.Choice(self.ctrl_pane,
                              ed_glob.ID_PREF_SYNTHEME,
                              choices=sorted(ss_lst))
        ss_choice.SetToolTip(wx.ToolTip(_("Base new theme on existing one")))
        ss_choice.SetStringSelection(Profile_Get('SYNTHEME', 'str'))
        ss_new = wx.CheckBox(self.ctrl_pane, wx.ID_NEW, _("New"))
        ss_new.SetToolTip(wx.ToolTip(_("Start a blank new style")))
        ss_sizer.AddMany([((10, 10)), (ss_lbl, 0, wx.ALIGN_CENTER_VERTICAL),
                          ((5, 0)), (ss_choice, 0, wx.ALIGN_CENTER_VERTICAL),
                          ((10, 0)), (ss_new, 0, wx.ALIGN_CENTER_VERTICAL),
                          ((10, 10))])
        return ss_sizer
Ejemplo n.º 7
0
 def RefreshStyleSheets(self):
     """Update the list of style sheets"""
     ss_lst = util.GetResourceFiles(u'styles', get_all=True)
     ss_lst = [sname for sname in ss_lst if not sname.startswith('.')]
     self.SyntaxSheets = ss_lst