Beispiel #1
0
    def ButtonOnly(self):
        
        # Here we (re)create the buttons for the button-only demo
        self.Freeze()
        
        if self.created:
            sizer = self.mainPanel.GetSizer()
            sizer.Detach(0)
            self.titleBar.Hide()
            wx.CallAfter(self.titleBar.Destroy)
            self.titleBar = bp.ButtonPanel(self.mainPanel, -1, "A Simple Test & Demo",
                                           style=self.style, alignment=self.alignment)
            self.SetProperties()

        # Buttons are created completely random, with random images, toggle behavior
        # and text
        
        self.indices = []
        
        for count in xrange(8):

            itemImage = random.randint(0, 3)
            hasText = random.randint(0, 1)
            itemKind = random.randint(0, 1)
                            
            btn = bp.ButtonInfo(self.titleBar, wx.NewId(), self.pngs[itemImage][0],
                                kind=itemKind)

            if hasText:
                btn.SetText(self.pngs[itemImage][1])
                rightText = random.randint(0, 1)
                if rightText:
                    btn.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)

            self.titleBar.AddButton(btn)
            self.Bind(wx.EVT_BUTTON, self.OnButton, id=btn.GetId())
            
            self.indices.append(btn.GetId())

            if count in [0, 3, 5]:
                self.titleBar.AddSeparator()
                    
        self.strings = ["First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth"]

        self.ChangeLayout()              
        self.Thaw()
        self.titleBar.DoLayout()
Beispiel #2
0
    def __init__(self,
                 parent,
                 id=-1,
                 title="ButtonPanel",
                 pos=wx.DefaultPosition,
                 size=(800, 600),
                 style=wx.DEFAULT_FRAME_STYLE):

        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        mainPanel = wx.Panel(self, -1)
        self.logtext = wx.TextCtrl(mainPanel, -1, "", style=wx.TE_MULTILINE)

        vSizer = wx.BoxSizer(wx.VERTICAL)
        mainPanel.SetSizer(vSizer)

        #alignment = BP_ALIGN_RIGHT

        titleBar = bp.ButtonPanel(mainPanel, -1, "A Simple Test & Demo")

        btn1 = bp.ButtonInfo(titleBar, wx.NewId(),
                             wx.Bitmap("png4.png", wx.BITMAP_TYPE_PNG))
        titleBar.AddButton(btn1)
        #self.Bind(wx.EVT_BUTTON, self.OnButton, btn1)

        btn2 = bp.ButtonInfo(titleBar, wx.NewId(),
                             wx.Bitmap("png3.png", wx.BITMAP_TYPE_PNG))
        titleBar.AddButton(btn2)
        #self.Bind(wx.EVT_BUTTON, self.OnButton, btn2)

        btn3 = bp.ButtonInfo(titleBar, wx.NewId(),
                             wx.Bitmap("png2.png", wx.BITMAP_TYPE_PNG))
        titleBar.AddButton(btn3)
        #self.Bind(wx.EVT_BUTTON, self.OnButton, btn3)

        btn4 = bp.ButtonInfo(titleBar, wx.NewId(),
                             wx.Bitmap("png1.png", wx.BITMAP_TYPE_PNG))
        titleBar.AddButton(btn4)
        #self.Bind(wx.EVT_BUTTON, self.OnButton, btn4)

        vSizer.Add(titleBar, 0, wx.EXPAND)
        vSizer.Add((20, 20))
        vSizer.Add(self.logtext, 1, wx.EXPAND | wx.ALL, 5)

        titleBar.DoLayout()
        vSizer.Layout()
Beispiel #3
0
    def __init__(self, parent, id=wx.ID_ANY, title="ButtonPanel wxPython Demo ;-)",
                 pos=wx.DefaultPosition, size=(640, 400), style=wx.DEFAULT_FRAME_STYLE):
        
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        self.useredited = False
        self.hassettingpanel = False

        self.SetIcon(GetMondrianIcon())
        self.CreateMenuBar()

        self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
        self.statusbar.SetStatusWidths([-2, -1])
        # statusbar fields
        statusbar_fields = [("ButtonPanel wxPython Demo, Andrea Gavana @ 02 Oct 2006"),
                            ("Welcome To wxPython!")]

        for i in range(len(statusbar_fields)):
            self.statusbar.SetStatusText(statusbar_fields[i], i)
        
        self.mainPanel = wx.Panel(self, -1)
        self.logtext = wx.TextCtrl(self.mainPanel, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY)
        
        vSizer = wx.BoxSizer(wx.VERTICAL) 
        self.mainPanel.SetSizer(vSizer) 

        self.alignments = [bp.BP_ALIGN_LEFT, bp.BP_ALIGN_RIGHT, bp.BP_ALIGN_TOP, bp.BP_ALIGN_BOTTOM]
        
        self.alignment = bp.BP_ALIGN_LEFT
        self.style = bp.BP_USE_GRADIENT
        
        self.titleBar = bp.ButtonPanel(self.mainPanel, -1, "A Simple Test & Demo",
                                       style=self.style, alignment=self.alignment)

        self.created = False
        self.pngs = [ (images.get_bp_btn1Bitmap(), 'label1'),
                      (images.get_bp_btn2Bitmap(), 'label2'),
                      (images.get_bp_btn3Bitmap(), 'label3'),
                      (images.get_bp_btn4Bitmap(), 'label4'),
                      ]
        self.CreateButtons()
        self.SetProperties()
    def __init__(self, parent, pos=(0, 0), style=wx.BORDER_SUNKEN, mgr=None):
        wx.Panel.__init__(self, parent, -1, pos=pos, style=style)
        self.SetBackgroundColour('white')

        #mgr.srchpanel = self
        #self.mgr = mgr

        vSizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(vSizer)

        # Add stuff
        self.bar = bp.ButtonPanel(self,
                                  -1,
                                  alignment=bp.BP_ALIGN_LEFT,
                                  style=bp.BP_USE_GRADIENT
                                  | bp.BP_GRADIENT_VERTICAL)

        self.setupbar(self.bar)

        vSizer.Add(self.bar, 0, wx.EXPAND)

        self.bar.DoLayout()
        vSizer.Layout()
Beispiel #5
0
    def CreateButtons(self):

        # Here we (re)create the buttons for the default startup demo
        self.Freeze()

        if self.created:
            sizer = self.mainPanel.GetSizer()
            sizer.Detach(0)
            self.titleBar.Hide()
            wx.CallAfter(self.titleBar.Destroy)
            self.titleBar = bp.ButtonPanel(self.mainPanel, -1, "A Simple Test & Demo",
                                           style=self.style, alignment=self.alignment)
            self.SetProperties()
                    
        self.indices = []
        
        for count, png in enumerate(self.pngs):

            shortHelp = "Button %d"%(count+1)
            
            if count < 2:
                # First 2 buttons are togglebuttons
                kind = wx.ITEM_CHECK
                longHelp = "ButtonPanel Toggle Button No %d"%(count+1)
            else:
                kind = wx.ITEM_NORMAL
                longHelp = "Simple Button without label No %d"%(count+1)                

            btn = bp.ButtonInfo(self.titleBar, wx.NewId(),
                                png[0], kind=kind,
                                shortHelp=shortHelp, longHelp=longHelp)
            
            self.titleBar.AddButton(btn)
            self.Bind(wx.EVT_BUTTON, self.OnButton, id=btn.GetId())
            
            self.indices.append(btn.GetId())
            
            if count < 2:
                # First 2 buttons have also a text
                btn.SetText(png[1])

            if count == 2:
                # Append a separator after the second button
                self.titleBar.AddSeparator()
            
            if count == 1:
                # Add a wx.TextCtrl to ButtonPanel
                self.titleBar.AddControl(wx.TextCtrl(self.titleBar, -1, "Hello wxPython!"))
                btn.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)

        # Add a wx.Choice to ButtonPanel                        
        self.titleBar.AddControl(wx.Choice(self.titleBar, -1,
                                           choices=["Hello", "From", "wxPython!"]))
        
        self.strings = ["First", "Second", "Third", "Fourth"]

        self.ChangeLayout()              
        self.Thaw()
        self.titleBar.DoLayout()

        self.created = True
Beispiel #6
0
 def CreateTopButtonPanel(self):
     import wx.lib.buttonpanel as bp
     self.Freeze()
     self.alignment = bp.BP_ALIGN_LEFT
     self.style = bp.BP_USE_GRADIENT
     self.buttonBar = bp.ButtonPanel(self.panButtonBar, -1, "MAKE2::Digital Forensic Toolbox",
                                    style=self.style, alignment=self.alignment)
     self.buttonBar.SetBestSize(wx.Size(1042, 56))
     self.buttonBar.SetConstraints(LayoutAnchors(self.buttonBar, True,
           False, True, False))
               
               
     """
     -a -u -i -n folderExplorer Images/Bitmaps/folderExplorer1.png images.py",
             "-a -u -i -n search Images/Bitmaps/Search.png images.py",
             "-a -u -i -n registryViewer Images/Bitmaps/RegistryViewer.png images.py",
             "-a -u -i -n textCat Images/Bitmaps/TextCat.png images.py",
             "-a -u -i -n timelines Images/Bitmaps/Timelines.png images.py",
             "-a -u -i -n logViewer Images/Bitmaps/LogViewer.png images.py",
             "-a -u -i -n imageViewer Images/Bitmaps/ImageViewer.png images.py",
             "-a -u -i -n emailViewer Images/Bitmaps/EmailViewer.png images.py"
     """
     
     self.pngs =[(images.gettimelinesBitmap(), ''),
                 (images.getsearchBitmap(), ""),
                 (images.gettextCatBitmap(), ""),
                 (images.getemailViewerBitmap(), ""),
                 (images.getfolderExplorerBitmap(), ""),
                 (images.getimageViewerBitmap(), ""),
                 (images.getlogViewerBitmap(), ""),
                 (images.getregistryViewerBitmap(), "")
                 ]
     """         
     self.pngs =[(images.gettimelinesBitmap(), ' Timelines  '),
                 (images.getsearchBitmap(), "  Search  "),
                 (images.gettextCatBitmap(), " Text Mining  "),
                 (images.getemailViewerBitmap(), " Emails  "),
                 (images.getfolderExplorerBitmap(), " Explorer  "),
                 (images.getimageViewerBitmap(), " Images  "),
                 (images.getlogViewerBitmap(), " Logs  "),
                 (images.getregistryViewerBitmap(), " Registry  ")
                 ]
     """
     
     
     #explorer button
     self.buttonBar.AddSeparator()
     self.btnExplorer = bp.ButtonInfo(self.buttonBar, wx.NewId(),
                         self.pngs[4][0], kind=wx.ITEM_NORMAL,
                         shortHelp='Folder Explorer', longHelp='Click to view Folder Explorer')
         
     self.btnExplorer.SetText(self.pngs[4][1])
     #self.btnTimeline.SetRect(wx.Rect(0, 0, 100, 100))
     #print self.btnTimeline.Rect
     self.btnExplorer.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)
     self.buttonBar.AddButton(self.btnExplorer)
     self.Bind(wx.EVT_BUTTON, self.OnExplorerButton, id=self.btnExplorer.GetId())
    
     
     #timeline button
     self.buttonBar.AddSeparator()
     self.btnTimeline = bp.ButtonInfo(self.buttonBar, wx.NewId(),
                         self.pngs[0][0], kind=wx.ITEM_NORMAL,
                         shortHelp='Timelines Viewer', longHelp='Click to view Timelines')
         
     self.btnTimeline.SetText(self.pngs[0][1])
     #self.btnTimeline.SetRect(wx.Rect(0, 0, 100, 100))
     #print self.btnTimeline.Rect
     self.btnTimeline.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)
     self.buttonBar.AddButton(self.btnTimeline)
     self.Bind(wx.EVT_BUTTON, self.OnTimelineButton, id=self.btnTimeline.GetId())
     self.buttonBar.AddSeparator()
     
     #ImageViewer button
     self.btnImageViewer = bp.ButtonInfo(self.buttonBar, wx.NewId(),
                 self.pngs[5][0], kind=wx.ITEM_NORMAL,
                 shortHelp='Image Analysis', longHelp='Click to perform Image Analysis...')
     
     self.btnImageViewer.SetText(self.pngs[5][1])
     self.btnImageViewer.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)
     self.buttonBar.AddButton(self.btnImageViewer)
     self.Bind(wx.EVT_BUTTON, self.OnImageViewerButton, id=self.btnImageViewer.GetId())
     self.buttonBar.AddSeparator()
     
             
     #Text Mining button
     self.btnTextCat = bp.ButtonInfo(self.buttonBar, wx.NewId(),
                 self.pngs[2][0], kind=wx.ITEM_NORMAL,
                 shortHelp='Text Mining', longHelp='Click to perform Text Mining...')
     
     self.btnTextCat.SetText(self.pngs[2][1])
     self.btnTextCat.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)
     self.buttonBar.AddButton(self.btnTextCat)
     self.Bind(wx.EVT_BUTTON, self.OnTextCategorizationButton, id=self.btnTextCat.GetId())
     self.buttonBar.AddSeparator()
     
     #Search Keywords button
     self.btnKeywordsSearch = bp.ButtonInfo(self.buttonBar, wx.NewId(),
                 self.pngs[1][0], kind=wx.ITEM_NORMAL,
                 shortHelp='Keywords Search', longHelp='Click to Search for keywords...')
         
     self.btnKeywordsSearch.SetText(self.pngs[1][1])
     self.btnKeywordsSearch.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)
     self.buttonBar.AddButton(self.btnKeywordsSearch)
     self.Bind(wx.EVT_BUTTON, self.OnKeywordsSearchButton, id=self.btnKeywordsSearch.GetId())
     self.buttonBar.AddSeparator()
     
     
     #Emails button
     self.btnEmails = bp.ButtonInfo(self.buttonBar, wx.NewId(),
                 self.pngs[3][0], kind=wx.ITEM_NORMAL,
                 shortHelp='Email Analysis', longHelp='Click to perform Email Analysis...')
     
     self.btnEmails.SetText(self.pngs[3][1])
     self.btnEmails.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)
     self.buttonBar.AddButton(self.btnEmails)
     self.Bind(wx.EVT_BUTTON, self.OnEmailsButton, id=self.btnEmails.GetId())
     self.buttonBar.AddSeparator()
     
    
     """
     #LogViewer button
     self.btnLogViewer = bp.ButtonInfo(self.buttonBar, wx.NewId(),
                 self.pngs[6][0], kind=wx.ITEM_NORMAL,
                 shortHelp='Log Analysis', longHelp='Click to perform Log Analysis...')
     
     self.btnLogViewer.SetText(self.pngs[6][1])
     self.btnLogViewer.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)
     self.buttonBar.AddButton(self.btnLogViewer)
     self.Bind(wx.EVT_BUTTON, self.OnLogViewerButton, id=self.btnLogViewer.GetId())
     self.buttonBar.AddSeparator()
     
     
     #LogViewer button
     self.btnRegistryViewer = bp.ButtonInfo(self.buttonBar, wx.NewId(),
                 self.pngs[7][0], kind=wx.ITEM_NORMAL,
                 shortHelp='Registry Analysis', longHelp='Click to perform Registry Analysis...')
     
     self.btnRegistryViewer.SetText(self.pngs[7][1])
     self.btnRegistryViewer.SetTextAlignment(bp.BP_BUTTONTEXT_ALIGN_RIGHT)
     self.buttonBar.AddButton(self.btnRegistryViewer)
     self.Bind(wx.EVT_BUTTON, self.OnRegistryViewerButton, id=self.btnRegistryViewer.GetId())
     self.buttonBar.AddSeparator()
     """
     
     bpArt = self.buttonBar.GetBPArt()
     # set the color the text is drawn with
     bpArt.SetColor(bp.BP_TEXT_COLOR, wx.Color(244, 0, 0))
     bpArt.SetFont(bp.BP_TEXT_FONT, wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD,
           False, u'MS Shell Dlg 2'))
           
     bpArt.SetColor(bp.BP_BORDER_COLOR, wx.Colour(174,174,255))
     bpArt.SetColor(bp.BP_GRADIENT_COLOR_FROM, wx.Colour(125,152,221))
     bpArt.SetColor(bp.BP_GRADIENT_COLOR_TO, wx.Colour(217, 217, 255))
     bpArt.SetColor(bp.BP_BUTTONTEXT_COLOR, wx.Colour(28,28,255))
     bpArt.SetColor(bp.BP_SEPARATOR_COLOR,
                    bp.BrightenColour(wx.Colour(0, 0, 0), 0.85))
     bpArt.SetColor(bp.BP_SELECTION_BRUSH_COLOR, wx.Color(225, 225, 255))
     bpArt.SetColor(bp.BP_SELECTION_PEN_COLOR, wx.SystemSettings_GetColour(wx.SYS_COLOUR_ACTIVECAPTION))
     bpArt.SetFont(bp.BP_BUTTONTEXT_FONT, wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD,
           False, u'MS Shell Dlg 2'))
     
     #self.ChangeLayout()              
     self.Thaw()
     self.buttonBar.DoLayout()