コード例 #1
0
    def __init__(self, parent):
        """Initialize the window"""
        super(ShelfWindow, self).__init__(parent)

        # Attributes
        # Parent is ed_shelf.EdShelfBook
        self._mw = ed_basewin.FindMainWindow(self)
        self._log = wx.GetApp().GetLog()
        self._listCtrl = CheckResultsList(self,
                                          style=wx.LC_REPORT|wx.BORDER_NONE)
        self._jobtimer = wx.Timer(self)
        self._checker = None
        self._curfile = u""
        self._hasrun = False

        # Setup
        self._listCtrl.set_mainwindow(self._mw)
        ctrlbar = eclib.ControlBar(self, style=eclib.CTRLBAR_STYLE_GRADIENT)
        ctrlbar.SetVMargin(2, 2)
        if wx.Platform == '__WXGTK__':
            ctrlbar.SetWindowStyle(eclib.CTRLBAR_STYLE_DEFAULT)
        rbmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_PREF), wx.ART_MENU)
        if rbmp.IsNull() or not rbmp.IsOk():
            rbmp = None
        self.cfgbtn = eclib.PlateButton(ctrlbar, wx.ID_ANY, bmp=rbmp,
                                        style=eclib.PB_STYLE_NOBG)
        self.cfgbtn.SetToolTipString(_("Configure"))
        ctrlbar.AddControl(self.cfgbtn, wx.ALIGN_LEFT)
        self._lbl = wx.StaticText(ctrlbar)
        ctrlbar.AddControl(self._lbl)
        ctrlbar.AddStretchSpacer()
        rbmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_BIN_FILE), wx.ART_MENU)
        if rbmp.IsNull() or not rbmp.IsOk():
            rbmp = None
        self.runbtn = eclib.PlateButton(ctrlbar, wx.ID_ANY, _("Lint"), rbmp,
                                        style=eclib.PB_STYLE_NOBG)
        ctrlbar.AddControl(self.runbtn, wx.ALIGN_RIGHT)

        # Layout
        self.SetWindow(self._listCtrl)
        self.SetControlBar(ctrlbar, wx.TOP)

        # Event Handlers
        self.Bind(wx.EVT_TIMER, self.OnJobTimer, self._jobtimer)
        self.Bind(wx.EVT_BUTTON, self.OnShowConfig, self.cfgbtn)
        self.Bind(wx.EVT_BUTTON, self.OnRunLint, self.runbtn)
        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy, self)

        # Editra Message Handlers
        ed_msg.Subscribe(self.OnFileLoad, ed_msg.EDMSG_FILE_OPENED)
        ed_msg.Subscribe(self.OnFileSave, ed_msg.EDMSG_FILE_SAVED)
        ed_msg.Subscribe(self.OnPageChanged, ed_msg.EDMSG_UI_NB_CHANGED)
        ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_CHANGED)