def __init__(self, parent):
        if wx.Platform == '__WXGTK__':
            wx.PyPanel.__init__(self,
                                parent,
                                -1,
                                style=wx.RAISED_BORDER | wx.WANTS_CHARS)
        else:
            wx.PyPanel.__init__(self, parent, -1, style=wx.WANTS_CHARS)
        self.bg = wx.Colour(115, 180, 215)
        # Top sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        # Use toolbook or foldpanelbar depending of preferences
        if g.conf.toolPanelType == 'TB':
            self.tp = wx.Toolbook(self, -1, style=wx.BK_TOP)
            sizer.Add(self.tp, 1, wx.EXPAND)
            # Image list
            thumbSize = g.conf.toolThumbSize
            il = wx.ImageList(thumbSize, thumbSize, True)
            # Default Id 0
            il.Add(images.ToolPanel_Default.GetImage().Scale(
                thumbSize, thumbSize).ConvertToBitmap())
            self.il = il
            self.tp.AssignImageList(il)
        elif g.conf.toolPanelType == 'FPB':
            self.tp = fpb.FoldPanelBar(self,
                                       -1,
                                       wx.DefaultPosition,
                                       wx.DefaultSize,
                                       agwStyle=fpb.FPB_VERTICAL)
            sizer.Add(self.tp, 1, wx.EXPAND)
        self.panels = []
        for name in Manager.panelNames:
            panelData = Manager.getPanelData(name)
            if not panelData: continue
            try:
                im = Manager.panelImages[name]
                imageId = il.Add(
                    im.Scale(thumbSize, thumbSize).ConvertToBitmap())
            except:
                imageId = 0
            panel = self.AddPanel(name)
            self.panels.append(panel)
            for pos, span, comp, bmp in panelData:
                self.AddButton(panel, pos, span, comp.id, bmp, comp.klass)
            panel.Fit()
            if g.conf.toolPanelType == 'TB':
                self.tp.AddPage(panel, '', imageId=imageId)
            else:
                p = self.tp.AddFoldPanel(name, collapsed=False)
                p.SetBackgroundColour(self.bg)
                panel.Reparent(p)
                p.AddWindow(panel, fpb.FPB_ALIGN_WIDTH)
        self.tp.Fit()

        self.SetSizer(sizer)
        # Allow to be resized in horizontal direction only
        # Events
        #        wx.EVT_KEY_DOWN(self, self.OnKeyDown)
        #        wx.EVT_KEY_UP(self, self.OnKeyUp)
        self.drag = None
Beispiel #2
0
    def __init__(self, parent):
        if wx.Platform == "__WXGTK__":
            wx.Panel.__init__(self, parent, -1, style=wx.RAISED_BORDER | wx.WANTS_CHARS)
        else:
            wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)
        self.bg = wx.Colour(115, 180, 215)
        # Top sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        # Use toolbook or foldpanelbar depending of preferences
        if g.conf.toolPanelType == "TB":
            self.tp = wx.Toolbook(self, -1, style=wx.BK_TOP)
            sizer.Add(self.tp, 1, wx.EXPAND)
            # Image list
            thumbSize = g.conf.toolThumbSize
            il = wx.ImageList(thumbSize, thumbSize, True)
            # Default Id 0
            il.Add(images.getToolPanel_DefaultImage().Scale(thumbSize, thumbSize).ConvertToBitmap())
            self.il = il
            self.tp.AssignImageList(il)
        elif g.conf.toolPanelType == "FPB":
            self.tp = fpb.FoldPanelBar(
                self, -1, wx.DefaultPosition, wx.DefaultSize, fpb.FPB_DEFAULT_STYLE | fpb.FPB_VERTICAL
            )
            sizer.Add(self.tp, 1, wx.EXPAND)
        self.panels = []
        for name in Manager.panelNames:
            panelData = Manager.getPanelData(name)
            if not panelData:
                continue
            try:
                im = Manager.panelImages[name]
                imageId = il.Add(im.Scale(thumbSize, thumbSize).ConvertToBitmap())
            except:
                imageId = 0
            panel = self.AddPanel(name)
            self.panels.append(panel)
            for pos, span, comp, bmp in panelData:
                self.AddButton(panel, pos, span, comp.id, bmp, comp.klass)
            panel.Fit()
            if g.conf.toolPanelType == "TB":
                self.tp.AddPage(panel, "", imageId=imageId)
            else:
                p = self.tp.AddFoldPanel(name, collapsed=False)
                p.SetBackgroundColour(self.bg)
                panel.Reparent(p)
                p.AddWindow(panel, fpb.FPB_ALIGN_WIDTH)
        self.tp.Fit()

        self.SetSizerAndFit(sizer)
        # Allow to be resized in horizontal direction only
        # Events
        #        wx.EVT_KEY_DOWN(self, self.OnKeyDown)
        #        wx.EVT_KEY_UP(self, self.OnKeyUp)
        self.drag = None