Пример #1
0
    def __init__(self, parent, id, title, position, db):
        wx.Dialog.__init__(self, parent, id, title, position)
        if position == (-1, -1):
            self.CentreOnParent(wx.BOTH)
        self.db = db
        self.tb = bp.ButtonPanel(self, -1, "")
        self.sizes = [(396, 412), (350, 450), (400, 600)]
        self.OPanel = self.makeOptionsPanel(self)
        opts_img = icons.getoptionsBitmap()
        lang_img = icons.getlanguagesBitmap()
        btn_opts = bp.ButtonInfo(self.tb, 1051, opts_img, text='Options')
        btn_lang = bp.ButtonInfo(self.tb, 1052, lang_img, text='Languages')
        self.tb.AddButton(btn_opts)
        self.tb.AddButton(btn_lang)
        self.vs = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(self.vs)
        self.vs.Add(self.tb, 0, wx.EXPAND)
        self.vs.Add(self.OPanel, 1, wx.EXPAND)
        #self.tb.GetBPArt().SetColour(bp.BP_GRADIENT_COLOR_FROM, wx.Colour(255,255,255,255))
        #self.tb.GetBPArt().SetColour(bp.BP_GRADIENT_COLOR_TO, wx.Colour(255,255,255,255))
        #self.tb.GetBPArt().SetGradientType(bp.BP_GRADIENT_VERTICAL)
        self.tb.SetStyle(bp.BP_USE_GRADIENT)
        self.tb.DoLayout()

        self.SetSize((396, 412))
Пример #2
0
 def test_lib_agw_buttonpanelCtor(self):
     bar = BP.ButtonPanel(self.frame, -1, 'sample text')
     btn = BP.ButtonInfo(bar,
                         wx.NewId(),
                         wx.ArtProvider.GetBitmap(wx.ART_INFORMATION,
                                                  wx.ART_OTHER, (32, 32)),
                         text='Button 1')
     bar.AddButton(btn)
Пример #3
0
    def CreateButtons(self):
        " Add buttons and controls"
        self.pagelabel = wx.StaticText(self, -1, 'Page')
        self.page = wx.TextCtrl(self, -1, size=(30, -1), style=wx.TE_CENTRE|wx.TE_PROCESS_ENTER)
        self.page.Bind(wx.EVT_KILL_FOCUS, self.OnPage)
        self.Bind(wx.EVT_TEXT_ENTER, self.OnPage, self.page)    
        self.maxlabel = wx.StaticText(self, -1, '          ')
        self.zoom = wx.ComboBox(self, -1, style=wx.CB_DROPDOWN|wx.TE_PROCESS_ENTER)
        self.comboval = (('Actual size', 1.0), ('Fit width', -1), ('Fit page', -2),
                          ('25%', 0.25), ('50%', 0.5), ('75%', 0.75), ('100%', 1.0),
                            ('125%', 1.25), ('150%', 1.5), ('200%', 2.0), ('400%', 4.0),
                            ('800%', 8.0), ('1000%', 10.0))
        for item in self.comboval:
            self.zoom.Append(item[0], item[1])      # string value and client data
        self.Bind(wx.EVT_COMBOBOX, self.OnZoomSet, self.zoom)    
        self.Bind(wx.EVT_TEXT_ENTER, self.OnZoomSet, self.zoom)    
        self.zoom.Bind(wx.EVT_KILL_FOCUS, self.OnZoomSet)
        panelitems = [
          ('btn', images.PrintIt.GetBitmap(), wx.ITEM_NORMAL, "Print", self.OnPrint),
          ('sep',),
          ('btn', images.SaveIt.GetBitmap(), wx.ITEM_NORMAL, "Save", self.OnSave),
          ('sep',),
          ('btn', images.First.GetBitmap(), wx.ITEM_NORMAL, "First page", self.OnFirst),
          ('btn', images.Prev.GetBitmap(), wx.ITEM_NORMAL, "Previous page", self.OnPrev),
          ('btn', images.Next.GetBitmap(), wx.ITEM_NORMAL, "Next page", self.OnNext),
          ('btn', images.Last.GetBitmap(), wx.ITEM_NORMAL, "Last page", self.OnLast),
          ('Ctrl', self.pagelabel),
          ('ctrl', self.page),
          ('ctrl', self.maxlabel),
          ('sep',),
          ('btn', images.ZoomOut.GetBitmap(), wx.ITEM_NORMAL, "Zoom out", self.OnZoomOut),
          ('btn', images.ZoomIn.GetBitmap(), wx.ITEM_NORMAL, "Zoom in", self.OnZoomIn),
          ('ctrl', self.zoom),
          ('btn', images.Width.GetBitmap(), wx.ITEM_NORMAL, "Fit page width", self.OnWidth),
          ('btn', images.Height.GetBitmap(), wx.ITEM_NORMAL, "Fit page height", self.OnHeight),
          ]

        self.Freeze()
        for item in panelitems:
            if item[0].lower() == 'btn':
                type, image, kind, popup, handler = item
                btn = bp.ButtonInfo(self, wx.NewId(),image, kind=kind,
                                    shortHelp=popup, longHelp='')
                self.AddButton(btn)
                self.Bind(wx.EVT_BUTTON, handler, id=btn.GetId())
            elif item[0].lower() == 'sep':
                self.AddSeparator()
            elif item[0].lower() == 'space':
                self.AddSpacer(item[1])
            elif item[0].lower() == 'ctrl':
                self.AddControl(item[1])
        self.Thaw()
        self.DoLayout()
Пример #4
0
    def test_lib_agw_buttonpanelMethods(self):
        bar = BP.ButtonPanel(self.frame, -1, 'sample text')
        btn = BP.ButtonInfo(bar, wx.NewId(),
                            wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_OTHER, (32, 32)),
                            text='Button 1')
        bar.AddButton(btn)

        bar.SetBarText('')
        self.assertTrue(not bar.HasBarText())
        bar.RemoveText()
        self.assertTrue(not bar.HasBarText())

        self.assertTrue(bar.IsStandard())
        self.assertTrue(not bar.IsVertical())
Пример #5
0
    def CreateToolbar(self):
        self.titleBar = bp.ButtonPanel(self, -1, "Template Designer",agwStyle=bp.BP_USE_GRADIENT, alignment=bp.BP_ALIGN_LEFT)
        #
        self.titleBar.SetInitialSize(wx.Size(2000,66))
        self.titleBar.Size=wx.Size(66,-1)
        #Game ID Field
        bmps=[self.il.new_bmp,self.il.open_bmp,self.il.save_bmp,self.il.saveas_bmp,self.il.debugelt,self.il.mseelt]
        shs=["New","Open","Save","Save as","Debug",'MSE']
        lhs=["Reset Current Template","Open template file","Save Current Template","Save current template As",'Start debug shell','Start MSE']
        cbs=[self.OnNew,self.OnOpen,self.OnSave,self.OnSaveAs,self.OnPyShell,self.OnStartMSE]
        
        for bmp,shortHelp,longHelp,cb in zip(bmps,shs,lhs,cbs):        
            btn = bp.ButtonInfo(self.titleBar, wx.NewId(),self.il.GetBitmap(bmp),shortHelp=shortHelp, longHelp=longHelp)
            self.titleBar.AddButton(btn)
            self.Bind(wx.EVT_BUTTON, cb,id=btn.GetId())

        self.titleBar.DoLayout()
Пример #6
0
    def CreateButtons(self):
        """
        Add the buttons and other controls to the panel.
        """
        self.disabled_controls = []
        self.pagelabel = wx.StaticText(self, -1, 'Page')
        self.page = wx.TextCtrl(self, -1, size=(30, -1), style=wx.TE_CENTRE|wx.TE_PROCESS_ENTER)
        self.page.Enable(False)
        self.disabled_controls.append(self.page)
        self.page.Bind(wx.EVT_KILL_FOCUS, self.OnPage)
        self.Bind(wx.EVT_TEXT_ENTER, self.OnPage, self.page)
        self.maxlabel = wx.StaticText(self, -1, '          ')
        self.zoom = wx.ComboBox(self, -1, style=wx.CB_DROPDOWN|wx.TE_PROCESS_ENTER)
        self.zoom.Enable(False)
        self.disabled_controls.append(self.zoom)
        self.comboval = (('Actual size', 1.0), ('Fit width', -1), ('Fit page', -2),
                          ('25%', 0.25), ('50%', 0.5), ('75%', 0.75), ('100%', 1.0),
                            ('125%', 1.25), ('150%', 1.5), ('200%', 2.0), ('400%', 4.0),
                            ('800%', 8.0), ('1000%', 10.0))
        for item in self.comboval:
            self.zoom.Append(item[0], item[1])      # string value and client data
        self.Bind(wx.EVT_COMBOBOX, self.OnZoomSet, self.zoom)
        self.Bind(wx.EVT_TEXT_ENTER, self.OnZoomSet, self.zoom)
        panelitems = self.GetPanelItems()

        self.Freeze()
        for item in panelitems:
            if item[0].lower() == 'btn':
                x_type, image, kind, popup, handler = item
                btn = bp.ButtonInfo(self, wx.ID_ANY,image, kind=kind,
                                    shortHelp=popup, longHelp='')
                self.AddButton(btn)
                btn.Enable(False)
                self.disabled_controls.append(btn)
                self.Bind(wx.EVT_BUTTON, handler, id=btn.GetId())
            elif item[0].lower() == 'sep':
                self.AddSeparator()
            elif item[0].lower() == 'space':
                self.AddSpacer(item[1])
            elif item[0].lower() == 'ctrl':
                self.AddControl(item[1])
        self.Thaw()
        self.DoLayout()
Пример #7
0
    def buildButtonPanel(self, mainPanel):
        """

        :param mainPanel:
        :return:
        """
        self.titleBar = BP.ButtonPanel(mainPanel,
                                       -1, "Add points to ODMTools\n"
                                       "Pressing 'c' when editing time "
                                       "will set the value to the localtime",
                                       alignment=BP.BP_ALIGN_LEFT)

        self.addRowBtn = BP.ButtonInfo(self.titleBar,
                                       wx.NewId(),
                                       plus_6_64.GetBitmap(),
                                       text="Add Row")
        self.deleteRowBtn = BP.ButtonInfo(self.titleBar,
                                          wx.NewId(),
                                          minus_6_64.GetBitmap(),
                                          text="Delete Row")
        self.clearRowsBtn = BP.ButtonInfo(self.titleBar,
                                          wx.NewId(),
                                          delete_64.GetBitmap(),
                                          text="Clear All")
        self.csvUploadBtn = BP.ButtonInfo(self.titleBar,
                                          wx.NewId(),
                                          csv_64.GetBitmap(),
                                          text="Upload CSV")
        self.infoBtn = BP.ButtonInfo(self.titleBar,
                                     wx.NewId(),
                                     info_5_32.GetBitmap(),
                                     text="Format Guide")
        self.finishedBtn = BP.ButtonInfo(self.titleBar,
                                         wx.NewId(),
                                         exit_64.GetBitmap(),
                                         text="Finished")

        self.titleBar.AddButton(self.addRowBtn)
        self.titleBar.AddButton(self.deleteRowBtn)
        self.titleBar.AddButton(self.clearRowsBtn)
        self.titleBar.AddButton(self.csvUploadBtn)
        self.titleBar.AddButton(self.infoBtn)
        self.titleBar.AddButton(self.finishedBtn)

        self.Bind(wx.EVT_BUTTON, self.onAddBtn, self.addRowBtn)
        self.Bind(wx.EVT_BUTTON, self.onDeleteBtn, self.deleteRowBtn)
        self.Bind(wx.EVT_BUTTON, self.onClearAllBtn, self.clearRowsBtn)
        self.Bind(wx.EVT_BUTTON, self.onUploadBtn, self.csvUploadBtn)
        self.Bind(wx.EVT_BUTTON, self.onInfoBtn, self.infoBtn)
        self.Bind(wx.EVT_BUTTON, self.onFinishedBtn, self.finishedBtn)
Пример #8
0
    def __init__(self, parent, id, title, pos=wx.DefaultPosition):
        wx.Frame.__init__(self, parent, id, title, pos)

        self.info = Info(self)
        self.SetTitle(self.info.GetName())
        self.SetIcon(wx.Icon(LOGO_ICON, wx.BITMAP_TYPE_PNG))

        self.apiUrl = 'http://' + CONF['server']['host'] + ':' + str(
            CONF['server']['port'])

        self.interface = SqlmapInterface(self.apiUrl,
                                         CONF['server']['headers'])
        self.addOptions = None

        self.taskID = None

        self.saved = True
        self.scanThread = None
        self.options = dict()

        self.auiMgr = aui.AuiManager()
        self.auiMgr.SetManagedWindow(self)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        #====================#
        # menus and menu bar #
        #====================#

        self.menuFile = wx.Menu()
        self.menuFile.Append(ID_MENU_SAVE, '&Save\tCtrl-S',
                             'Save scan results')
        self.menuFile.AppendSeparator()
        self.menuFile.Append(ID_MENU_EXIT, 'E&xit', 'Exit the Application')
        self.menuFile.Enable(ID_MENU_SAVE, False)

        self.menuScan = wx.Menu()
        self.menuScan.Append(ID_MENU_NEW_SCAN, '&New Scan\tCtrl-N',
                             'Start a new scan.')
        self.menuScan.AppendSeparator()
        self.menuScan.Append(ID_MENU_OPTIONS, '&Options\tCtrl-O',
                             'Set scan options')
        self.menuScan.Enable(ID_MENU_OPTIONS, False)

        menuHelp = wx.Menu()
        menuHelp.Append(ID_MENU_ABOUT, '&About...')

        self.Bind(wx.EVT_MENU, self.OnSave, id=ID_MENU_SAVE)
        self.Bind(wx.EVT_MENU, self.OnExit, id=ID_MENU_EXIT)
        self.Bind(wx.EVT_MENU, self.OnNewScan, id=ID_MENU_NEW_SCAN)
        self.Bind(wx.EVT_MENU, self.OnOptions, id=ID_MENU_OPTIONS)
        self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_MENU_ABOUT)

        menuBar = wx.MenuBar()
        menuBar.Append(self.menuFile, "&File")
        menuBar.Append(self.menuScan, "&Scan")
        menuBar.Append(menuHelp, "&Help")
        self.SetMenuBar(menuBar)

        #============================#
        # panel top : target, inputs #
        #============================#

        sizerPnlTop = wx.BoxSizer(wx.VERTICAL)
        pnlTop = wx.Panel(self, -1)

        self.sizerPnlTarget = wx.BoxSizer(wx.HORIZONTAL)
        pnlTarget = wx.Panel(pnlTop, -1)

        self.lTarget = wx.StaticText(pnlTarget, -1, label='target-url: ')
        self.tcTarget = wx.TextCtrl(pnlTarget, -1)
        self.tcTarget.Enable(False)
        self.tcTarget.Bind(wx.EVT_TEXT, self.set_tree_target)

        self.sizerPnlTarget.Add(self.lTarget, flag=wx.ALIGN_CENTRE_VERTICAL)
        self.sizerPnlTarget.Add(self.tcTarget, 1, wx.EXPAND)
        pnlTarget.SetSizerAndFit(self.sizerPnlTarget)

        # self.tcTarget.SetValue('http://www.beispiel.com/?id=1')

        #========================================================#
        # panel top: button panel: create buttons bind functions #
        #========================================================#

        sizerPnlButtons = wx.BoxSizer(wx.HORIZONTAL)
        pnlButtons = wx.Panel(pnlTop, -1)

        self.btnPanel = bp.ButtonPanel(pnlButtons,
                                       -1,
                                       agwStyle=bp.BP_DEFAULT_STYLE)
        self.btnPanel.GetBPArt().SetMetric(bp.BP_PADDING_SIZE, wx.Size(4, 4))
        self.btnPanel.GetBPArt().SetMetric(bp.BP_MARGINS_SIZE, wx.Size(4, 4))
        self.btnPanel.GetBPArt().GetFont(bp.BP_BUTTONTEXT_FONT)\
                                .SetPointSize(8)

        self.btnStop = bp.ButtonInfo(self.btnPanel,
                                     -1,
                                     self.get_icon('stop'),
                                     text='Stop',
                                     shortHelp='Stop the current scan')
        self.btnStop.Enable(False)

        self.btnStart = bp.ButtonInfo(self.btnPanel,
                                      -1,
                                      self.get_icon('target'),
                                      text='Start',
                                      shortHelp='Start the customized scan')

        self.btnSetOptions = bp.ButtonInfo(self.btnPanel,
                                           -1,
                                           self.get_icon('options'),
                                           text='Options',
                                           shortHelp='Set scan options')

        self.btnGetDBs = bp.ButtonInfo(self.btnPanel,
                                       -1,
                                       self.get_icon('db'),
                                       text='Get DBs',
                                       shortHelp='Enumerate DBMS databases')

        self.btnGetTbls = bp.ButtonInfo(
            self.btnPanel,
            -1,
            self.get_icon('tbl'),
            text='Get Tables',
            shortHelp='Enumerate DBMS database tables')

        self.btnGetCols = bp.ButtonInfo(
            self.btnPanel,
            -1,
            self.get_icon('col'),
            text='Get Columns',
            shortHelp='Enumerate DBMS database table columns')

        self.btnGetData = bp.ButtonInfo(
            self.btnPanel,
            -1,
            self.get_icon('tblDump'),
            text='Get Data',
            shortHelp='Dump DBMS database table entries')

        self.btnOutput = bp.ButtonInfo(self.btnPanel,
                                       -1,
                                       self.get_icon('view'),
                                       text='View Output',
                                       shortHelp='View data output')

        self.btnSave = bp.ButtonInfo(self.btnPanel,
                                     -1,
                                     self.get_icon('save'),
                                     text=' Save ',
                                     shortHelp='save scan results')
        self.btnCloseAll = bp.ButtonInfo(self.btnPanel,
                                         -1,
                                         self.get_icon('closeTab'),
                                         text='Close Tabs',
                                         shortHelp='Close all tabs')
        self.btnCloseAll.Enable(False)

        self.Bind(wx.EVT_BUTTON, self.stop_scan, self.btnStop)
        self.Bind(wx.EVT_BUTTON, self.run_custom, self.btnStart)
        self.Bind(wx.EVT_BUTTON, self.OnOptions, self.btnSetOptions)
        self.Bind(wx.EVT_BUTTON, self.run_get_dbs, self.btnGetDBs)
        self.Bind(wx.EVT_BUTTON, self.run_get_tables, self.btnGetTbls)
        self.Bind(wx.EVT_BUTTON, self.run_get_columns, self.btnGetCols)
        self.Bind(wx.EVT_BUTTON, self.run_get_data, self.btnGetData)
        self.Bind(wx.EVT_BUTTON, self.OnShowOutput, self.btnOutput)
        self.Bind(wx.EVT_BUTTON, self.OnSave, self.btnSave)
        self.Bind(wx.EVT_BUTTON, self.OnDeletePages, self.btnCloseAll)

        self.btnPanel.AddButton(self.btnStop)
        self.btnPanel.AddSeparator()
        self.btnPanel.AddButton(self.btnStart)
        self.btnPanel.AddSeparator()
        self.btnPanel.AddButton(self.btnSetOptions)
        self.btnPanel.AddSeparator()
        self.btnPanel.AddButton(self.btnGetDBs)
        self.btnPanel.AddButton(self.btnGetTbls)
        self.btnPanel.AddButton(self.btnGetCols)
        self.btnPanel.AddButton(self.btnGetData)
        self.btnPanel.AddSeparator()
        self.btnPanel.AddButton(self.btnOutput)
        self.btnPanel.AddSeparator()
        self.btnPanel.AddButton(self.btnSave)
        self.btnPanel.AddSeparator()
        self.btnPanel.AddButton(self.btnCloseAll)
        self.btnPanel.DoLayout()

        self.scanBtns = [
            self.btnStart, self.btnGetDBs, self.btnGetTbls, self.btnGetCols,
            self.btnGetData, self.btnOutput, self.btnSave, self.btnSetOptions
        ]

        sizerPnlButtons.Add(self.btnPanel, 1, wx.EXPAND)
        pnlButtons.SetSizerAndFit(sizerPnlButtons)

        self.enable_scan_inputs(False)

        sizerPnlTop.Add(pnlTarget, 0, wx.EXPAND | wx.LEFT | wx.TOP, 2)
        sizerPnlTop.Add(pnlButtons, 0, wx.EXPAND)
        pnlTop.SetSizerAndFit(sizerPnlTop)

        #==============================================#
        # panel center: aui notebook, grid data output #
        #==============================================#

        sizerPnlCenter = wx.BoxSizer(wx.VERTICAL)
        self.pnlCenter = wx.Panel(self, -1)

        self.nb = aui.AuiNotebook(
            self.pnlCenter,
            -1,
            style=aui.AUI_NB_CLOSE_ON_ALL_TABS | aui.AUI_NB_WINDOWLIST_BUTTON
            | aui.AUI_NB_TAB_SPLIT | aui.AUI_NB_TAB_MOVE
            | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_SCROLL_BUTTONS)

        self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSED, self.OnPageClosed, self.nb)

        sizerPnlCenter.Add(self.nb, 1, wx.EXPAND)
        self.pnlCenter.SetSizerAndFit(sizerPnlCenter)

        #==========================#
        # panel left: tree control #
        #==========================#

        self.sizerPnlTree = wx.BoxSizer(wx.HORIZONTAL)
        pnlTree = wx.Panel(self, -1)

        self.tree = ct.CustomTreeCtrl(
            pnlTree,
            -1,
            agwStyle=ct.TR_HAS_BUTTONS | ct.TR_AUTO_CHECK_PARENT
            | ct.TR_AUTO_CHECK_CHILD | ct.TR_HAS_VARIABLE_ROW_HEIGHT)
        self.Bind(ct.EVT_TREE_ITEM_CHECKED, self.OnCheckTree, self.tree)
        self.sizerPnlTree.Add(self.tree, 1, wx.EXPAND)

        # creating image list and assigning list to tree
        # (target, db, table and column icon)
        il = wx.ImageList(16, 16)

        for k in TREE_ICONS.keys():
            TREE_ICONS[k] = il.Add(TREE_ICONS[k].Scale(16,
                                                       16).ConvertToBitmap())

        self.tree.AssignImageList(il)

        self.treeRoot = self.tree.AddRoot('', image=TREE_ICONS['target'])
        self.treeDBs = None
        self.treeTbls = None
        self.treeData = dict()
        self.set_tree_target(None)
        self.tree.Layout()
        pnlTree.SetSizerAndFit(self.sizerPnlTree)

        #========================#
        # pane bottom: scan logs #
        #========================#

        self.tcLog = wx.TextCtrl(self,
                                 -1,
                                 style=wx.TE_MULTILINE | wx.TE_READONLY)

        #=================================================#
        # adding panels and components to the aui manager #
        #=================================================#

        self.auiMgr.AddPane(
            pnlTop,
            aui.AuiPaneInfo().Name('inputs').Top().DockFixed().CaptionVisible(
                False).PaneBorder(False).CloseButton(False))

        self.auiMgr.AddPane(
            pnlTree,
            aui.AuiPaneInfo().Name('tree').Caption(
                'Target Schema').Left().BestSize(wx.Size(160, 500)).PaneBorder(
                    False).MaximizeButton(True).CloseButton(False))

        self.auiMgr.AddPane(
            self.pnlCenter,
            aui.AuiPaneInfo().Name('center').Caption('Table Dumps').Center().
            PaneBorder(False).MaximizeButton(True).CloseButton(False))

        self.auiMgr.AddPane(
            self.tcLog,
            aui.AuiPaneInfo().Name('log').Caption(
                'Scan Log').Bottom().BestSize(wx.Size(600, 140)).PaneBorder(
                    False).MaximizeButton(True).CloseButton(False))

        self.CreateStatusBar()
        self.SetStatusText(self.info.GetName())
Пример #9
0
    def __init__(self, *args, **kwds):
        wx.Frame.__init__(self, *args, **kwds)
        self.cleanShutdown = False
        self.db = settings.database()
        self.SetSizeHints(450, 300)
        self.SetMinSize((450,300))
        x = self.getPreference('width', 'Int')
        y = self.getPreference('height', 'Int')
        self.SetSize((x,y)) # read from db along with next line for position
        x = self.getPreference('xpos', 'Int')
        y = self.getPreference('ypos', 'Int')
        self.SetPosition((x,y))
        self.Update()
        self.names = ["unnamed"]
        self.docs = []
        self.mostRecentPath = self.getPreference('lastPath', 'Str')
        self.tb = bp.ButtonPanel(self, -1, "")
        """
        self.tb = self.CreateToolBar ( (wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT ) )
        self.tb.SetToolBitmapSize(( 32, 32 ))
        """

        blank_img = icons.getblankBitmap()
        new_img = icons.getnew01Bitmap()
        open_img = icons.getopen01Bitmap()
        save_img = icons.getsave01Bitmap()
        #close_img = icons.getclose01Bitmap()

        self.Bind(wx.EVT_CLOSE, self.CloseThis)

        self.vs = wx.BoxSizer(wx.VERTICAL)
        self.hs = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(self.vs)

        self.search = wx.SearchCtrl(self.tb, size=(200,-1), style=wx.TE_PROCESS_ENTER)
        self.search.ShowCancelButton(True)
        self.search.Bind(wx.EVT_TEXT, self.OnIncrSearch)
        self.search.Bind(wx.EVT_TEXT_ENTER, self.OnSearch)
        self.search.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.OnCancel)
        self.search.Bind(wx.EVT_KEY_DOWN, self.OnSearchKey)

        btn_new = bp.ButtonInfo(self.tb, 1001, new_img, text='New')
        btn_open = bp.ButtonInfo(self.tb, 1002, open_img, text='Open')
        btn_save = bp.ButtonInfo(self.tb, 1003, save_img, text='Save')
        #btn_close = bp.ButtonInfo(self.tb, 1004, close_img)
        self.tb.AddButton(btn_new)
        self.tb.AddButton(btn_open)
        self.tb.AddButton(btn_save)
        self.tb.AddControl(self.search)
        #self.tb.AddButton(btn_close)
        self.Bind(wx.EVT_BUTTON, self.Menu101, btn_new)
        self.Bind(wx.EVT_BUTTON, self.Menu102, btn_open)
        self.Bind(wx.EVT_BUTTON, self.Menu105, btn_save)
        #self.Bind(wx.EVT_BUTTON, self.Menu104, btn_close)

        self.vs.Add(self.tb, 0, wx.EXPAND)
        self.tb.DoLayout()
        """
        self.tb.AddLabelTool(1000, '', blank_img)
        self.tb.AddLabelTool(1001, 'New', new_img, longHelp='Begin a new document')
        #self.tb.AddLabelTool(1004, 'Close', close_img, longHelp="Close this tab")
        self.tb.AddLabelTool(1002, 'Open', open_img, longHelp='Open a new document')
        self.tb.AddLabelTool(1003, 'Save', save_img, longHelp='Save this document')
        self.tb.AddLabelTool(1000, '', blank_img)
        #self.tb.AddLabelTool(1004, 'Run', run_img)
        self.tb.AddLabelTool(1000, '', blank_img)
        self.tb.AddControl(self.search)
        self.tb.Realize()
        self.Bind(wx.EVT_TOOL, self.Menu101, id=1001)
        self.Bind(wx.EVT_TOOL, self.Menu102, id=1002)
        self.Bind(wx.EVT_TOOL, self.Menu105, id=1003)
        """

        v = self.getPreference('ViewStatusBar', 'String')
        self.CreateStatusBar() # switched off by default as is horizontal scrollbar
        self.sb = self.GetStatusBar()
        #self.sb.SetStatusWidths([-1, -1])

        self.nb = wx.aui.AuiNotebook(self)
        self.prefsPanel = wx.Panel(self.nb, 888, (0,10), (10,10))
        # may need to create several tabs depending upon last position
        self.docs.append(PySTC(self, 0, self.db))
        self.nb.AddPage(self.docs[0], "Untitled") # use filename here
        self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.CloseTab, self.nb)
        self.m = wx.MenuBar()
        self.vs.Add(self.nb, 1, wx.EXPAND)
        self.vs.Layout()

        self.m1a = wx.Menu()
        self.oldDocs = self.db.GetDocs()
        for i in range(len(self.oldDocs)):
            if i < 10:
                self.m1a.Append(1081+i, self.oldDocs[i])
        self.m1a.Append(1099, "Clear Menu")
        self.Bind(wx.EVT_MENU, self.ClearOldDocsMenu, id=1099)

        self.pd = wx.PrintData()
        self.pd.SetPaperId(wx.PAPER_A4)
        self.pd.SetPrintMode(wx.PRINT_MODE_PRINTER)

        self.m1b = wx.Menu()
        self.sessions = self.db.GetSessions()
        for i in range(len(self.sessions)):
            self.m1b.Append(1111+i, self.sessions[i])

        m1 = wx.Menu() # file
        m1.Append(101, '&New\tCtrl+N', "Begin a new document")
        m1.Append(102, "&Open\tCtrl+O", "Open an existing document")
        m1.AppendMenu(103, "Open recent", self.m1a) # need a list of files from the db
        m1.Append(104, "Close tab\tCtrl+W")
        m1.AppendSeparator()
        m1.AppendMenu(111, "Open session", self.m1b)
        m1.Append(112, "Save session", "Save this as a current session")
        m1.Append(113, "Manage sessions", "Edit or delete sessions")
        m1.AppendSeparator()
        m1.Append(105, "&Save\tCtrl+S", "Save this document now")
        m1.Append(106, "Save &As\tShift+Ctrl+S", "Save this document with a different name")
        m1.Append(107, "Export as")
        m1.Append(108, "Revert to saved")
        m1.AppendSeparator()
        m1.Append(109, "Print\tCtrl+P")
        m1.Append(110, "Page setup\tShift+Ctrl+P")
        self.Bind(wx.EVT_MENU, self.Menu101, id=101)
        self.Bind(wx.EVT_MENU, self.Menu102, id=102)
        self.Bind(wx.EVT_MENU, self.Menu104, id=104)
        self.Bind(wx.EVT_MENU, self.Menu105, id=105)
        self.Bind(wx.EVT_MENU, self.Menu106, id=106)
        self.Bind(wx.EVT_MENU, self.Menu109, id=109)
        self.Bind(wx.EVT_MENU, self.Menu110, id=110)
        self.Bind(wx.EVT_MENU, self.Menu112, id=112)
        self.Bind(wx.EVT_MENU_RANGE, self.SelectOldDocument, id=1081, id2=1091)
        self.Bind(wx.EVT_MENU_RANGE, self.LoadSession, id=1111, id2=1120)

        m2a = wx.Menu() # find submenu for edit menu
        m2a.Append(2081, "Find\tCtrl+F")
        m2a.Append(2082, "Find next\tTAB")
        m2a.Append(2083, "Find previous\tShift+TAB")

        m2b = wx.Menu() # Convert line endings
        m2b.Append(2091, "LF (Mac OS X, Unix, Linux)")
        m2b.Append(2092, "CR (Older Macintosh)")
        m2b.Append(2093, "CR/LF (Windows. DOS)")

        m2 = wx.Menu() # edit
        m2.Append(201, "Undo\tCtrl+Z")
        m2.Append(202, "Redo\tShift+Ctrl+Z")
        m2.AppendSeparator()
        m2.Append(203, "Cut\tCtrl+X")
        m2.Append(204, "Copy\tCtrl+C")
        m2.Append(205, "Paste\Ctrl+V")
        m2.Append(206, "Delete")
        m2.Append(207, "Select all\tCtrl+A")
        m2.AppendSeparator()
        m2.Append(211, "To lower case\tAlt+Ctrl+Shift+C")
        m2.Append(212, "To UPPER case\tCtrl+Shift+C")
        m2.AppendMenu(213, "Convert line endings", m2b)
        m2.AppendSeparator()
        m2.AppendMenu(208, "Find", m2a)
        m2.AppendSeparator()
        m2.Append(209, "Spelling")
        m2.Append(210, "Special characters\tAlt+Ctrl+T")
        self.Bind(wx.EVT_MENU, self.Menu201, id=201)
        self.Bind(wx.EVT_MENU, self.Menu202, id=202)
        self.Bind(wx.EVT_MENU, self.Menu203, id=203)
        self.Bind(wx.EVT_MENU, self.Menu204, id=204)
        self.Bind(wx.EVT_MENU, self.Menu205, id=205)
        self.Bind(wx.EVT_MENU, self.Menu206, id=206)
        self.Bind(wx.EVT_MENU, self.Menu207, id=207)
        self.Bind(wx.EVT_MENU, self.Menu211, id=211)
        self.Bind(wx.EVT_MENU, self.Menu212, id=212)
        self.Bind(wx.EVT_MENU, self.Menu2091, id=2091)
        self.Bind(wx.EVT_MENU, self.Menu2092, id=2092)
        self.Bind(wx.EVT_MENU, self.Menu2093, id=2093)
        self.Bind(wx.EVT_MENU, self.Menu2081, id=2081)

        m3 = wx.Menu() # format
        m3.Append(301, "Text font")
        m3.Append(302, "Background colour")
        m3.Append(303, "blah")

        m6a = wx.Menu() # languages submenu for programming menu
        la = len(languages)
        for i in range(la):
            m6a.Append(1601 + i, languages[i], "", wx.ITEM_RADIO)
        m6 = wx.Menu() # programming
        m6.Append(601, "Run/Compile\tF5")
        m6.Append(602, "Run/compile options\tShift+F5")
        m6.AppendMenu(603, "Change language", m6a)
        self.Bind(wx.EVT_MENU_RANGE, self.ChangeLanguage, id=1601, id2=1700)

        m4 = wx.Menu() # View
        m4.Append(401, "Tool bar", "", wx.ITEM_CHECK)
        m4.Append(402, "Tabs", "", wx.ITEM_CHECK)
        m4.Append(403, "Status bar", "", wx.ITEM_CHECK)
        m4.Append(404, "Horizontal scrollbar", "", wx.ITEM_CHECK)
        m4.Append(405, "Vertical scrollbar", "", wx.ITEM_CHECK)
        m4.Append(406, "Line numbers", "", wx.ITEM_CHECK)
        m4.Append(407, "Folding", "", wx.ITEM_CHECK)
        doc = self.docs[0]
        m4.Check(401, True)
        m4.Check(402, True)
        sb = self.GetStatusBar().IsShown()
        if sb:
            m4.Check(403, True)
        else:
            m4.Check(403, False)
        if doc.GetUseHorizontalScrollBar():
            m4.Check(404, True)
        else:
            m4.Check(404, False)
        if doc.GetUseVerticalScrollBar():
            m4.Check(405, True)
        else:
            m4.Check(405, False)
        if doc.GetMarginWidth(0) == 0:
            m4.Check(406, False)
        else:
            m4.Check(406, True)
        if doc.GetMarginWidth(1) == 0:
            m4.Check(407, False)
        else:
            m4.Check(407, True)

        self.Bind(wx.EVT_MENU, self.Menu401, id=401)
        self.Bind(wx.EVT_MENU, self.Menu403, id=403)
        self.Bind(wx.EVT_MENU, self.Menu404, id=404)
        self.Bind(wx.EVT_MENU, self.Menu405, id=405)
        self.Bind(wx.EVT_MENU, self.Menu406, id=406)
        self.Bind(wx.EVT_MENU, self.Menu407, id=407)

        m5 = wx.Menu() # bookmarks
        m5.Append(501, "Add bookmark for here")
        m5.Append(502, "Manage all bookmarks")
        m5.Append(503, "bookmark #1")

        m7 = wx.Menu()
        #item = m7.Append(wx.ID_EXIT, text="&Quit")
        #self.Bind(wx.ID_EXIT, self.CloseApp, -1)
        item = m7.Append(wx.ID_HELP, "Test & Help", "Help information")
        self.Bind(wx.EVT_MENU, self.OnHelp, item)
        item = m7.Append(wx.ID_ABOUT, "&About TiDEd", "More information about TiDEd")
        self.Bind(wx.EVT_MENU, self.OnAbout, item)
        item = m7.Append(wx.ID_PREFERENCES, text="&Preferences\tCtrl+,")
        self.Bind(wx.EVT_MENU, self.OnPrefs, item)
        #item = m7.Append(wx.ID_QUIT, "&Quit\tCmd+Q")

        self.m.Append(m1, "&File")
        self.m.Append(m2, "Edit")
        self.m.Append(m3, "Format")
        self.m.Append(m6, "Programming")
        self.m.Append(m4, "View")
        self.m.Append(m5, "Bookmarks")
        self.m.Append(m7, "&Help")
        self.SetMenuBar(self.m)
        v = self.getPreference('ViewStatusBar', 'Boolean')
        sb = self.GetStatusBar()
        if (v == True):
            sb.Show(True)
        else:
            sb.Hide()
        v = self.getPreference('ViewToolBar', 'Boolean')
        if (v == True):
            self.tb.Show(True)
        else:
            self.tb.Show(False)
Пример #10
0
    def __init__(self, parent):
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          title="viewer - version 1.1.0",
                          style=wx.DEFAULT_FRAME_STYLE)

        iconBundleName = os.path.join(os.path.dirname(pathExe),
                                      "icons/Glaze/camera.ico")
        if (os.path.exists(iconBundleName)):
            iconBundle = wx.IconBundleFromFile(iconBundleName,
                                               wx.BITMAP_TYPE_ANY)

            icon = iconBundle.GetIcon((32, 32))

            if (icon):
                self.SetIcon(icon)

        self.SetDoubleBuffered(True)

        self.video = None

        self.imgVideo = None

        self.imgWorking = None

        self.bmpVideo = None

        self.playing = False

        menuBar = wx.MenuBar()
        menu = wx.Menu()

        mnuOpenVideo = menu.Append(wx.ID_OPEN, "&Open\tAlt-O", "Open Video")

        self.Bind(wx.EVT_TOOL, self.onOpenVideo, mnuOpenVideo)

        menu.AppendSeparator()

        mnuPlay = menu.Append(self.ID_PLAY, "&Play\tAlt-P", "Play")

        self.Bind(wx.EVT_MENU, self.onPlay, mnuPlay)

        mnuStop = menu.Append(self.ID_STOP, "&Stop\tAlt-S", "Stop")

        self.Bind(wx.EVT_MENU, self.onStop, mnuStop)

        menu.AppendSeparator()

        mnuSaveImage = menu.Append(self.ID_SAVE_IMAGE, "Save &Image\tAlt-I",
                                   "Save Image")

        self.Bind(wx.EVT_MENU, self.onSaveImage, mnuSaveImage)

        menu.AppendSeparator()

        mnuExit = menu.Append(wx.ID_EXIT, "E&xit\tAlt-X",
                              "Close window and exit program")

        self.Bind(wx.EVT_MENU, self.onClose, mnuExit)

        menuBar.Append(menu, "&File")

        menu = wx.Menu()

        mnuAbout = menu.Append(wx.ID_ABOUT, "&About\tAlt-A",
                               "Information about this program")
        self.Bind(wx.EVT_MENU, self.onAbout, mnuAbout)

        menuBar.Append(menu, "&Help")

        self.SetMenuBar(menuBar)

        panel = wx.Panel(self, -1)

        sizer = wx.BoxSizer(wx.VERTICAL)

        panel.SetSizer(sizer)

        toolbar = bp.ButtonPanel(panel, -1)

        openVideo = bp.ButtonInfo(toolbar,
                                  self.ID_OPEN,
                                  wx.Bitmap(
                                      os.path.join(os.path.dirname(pathExe),
                                                   "icons/Vaga/video.png"),
                                      wx.BITMAP_TYPE_PNG),
                                  shortHelp="Open Video")
        toolbar.AddButton(openVideo)

        toolbar.AddSeparator()

        slider = wx.Slider(toolbar, self.ID_SLIDER, 0, 0,
                           self.DEFAULT_TOTAL_FRAMES - 1, None,
                           (self.DEFAULT_FRAME_WIDTH - 220, -1),
                           wx.SL_HORIZONTAL)
        slider.Enable(True)
        slider.SetToolTip(wx.ToolTip("Video Slider"))
        toolbar.AddControl(slider, 1)

        toolbar.AddSeparator()

        lblFrameNumber = wx.TextCtrl(toolbar,
                                     self.ID_LABEL_FRAME_NUMBER,
                                     value="",
                                     size=(50, -1),
                                     style=wx.BORDER_NONE)
        lblFrameNumber.SetToolTip(wx.ToolTip("Video Frame Number"))
        lblFrameNumber.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
        lblFrameNumber.SetLabel("")
        lblFrameNumber.Enable(False)
        toolbar.AddControl(lblFrameNumber)

        toolbar.AddSeparator()

        play = bp.ButtonInfo(toolbar,
                             self.ID_PLAY,
                             wx.Bitmap(
                                 os.path.join(os.path.dirname(pathExe),
                                              "icons/Vaga/play.png"),
                                 wx.BITMAP_TYPE_PNG),
                             shortHelp="Play")
        toolbar.AddButton(play)

        stop = bp.ButtonInfo(toolbar,
                             self.ID_STOP,
                             wx.Bitmap(
                                 os.path.join(os.path.dirname(pathExe),
                                              "icons/Vaga/stop.png"),
                                 wx.BITMAP_TYPE_PNG),
                             shortHelp="Stop")
        toolbar.AddButton(stop)

        toolbar.AddSeparator()

        saveImage = bp.ButtonInfo(toolbar,
                                  self.ID_SAVE_IMAGE,
                                  wx.Bitmap(
                                      os.path.join(os.path.dirname(pathExe),
                                                   "icons/Vaga/save.png"),
                                      wx.BITMAP_TYPE_PNG),
                                  shortHelp="Save Image")
        toolbar.AddButton(saveImage)

        videoPanel = wx.Panel(panel, -1)

        sizer.Add(videoPanel, 1, wx.EXPAND)
        sizer.Add(toolbar, 0, wx.EXPAND)

        self.SetClientSize(
            (self.DEFAULT_FRAME_WIDTH, 36 + self.DEFAULT_FRAME_HEIGHT))

        toolbar.DoLayout()

        panel.Layout()

        self.videoPanel = videoPanel

        self.mnuOpenVideo = mnuOpenVideo
        self.mnuPlay = mnuPlay
        self.mnuStop = mnuStop
        self.mnuSaveImage = mnuSaveImage
        self.openVideo = openVideo
        self.slider = slider
        self.lblFrameNumber = lblFrameNumber
        self.play = play
        self.stop = stop
        self.saveImage = saveImage

        videoPanel.Bind(wx.EVT_SIZE, self.onResizeVideo)

        self.Bind(wx.EVT_CLOSE, self.onClose)

        self.Bind(wx.EVT_BUTTON, self.onOpenVideo, openVideo)
        self.Bind(wx.EVT_SLIDER, self.onSlider, self.slider)
        self.Bind(wx.EVT_BUTTON, self.onPlay, play)
        self.Bind(wx.EVT_BUTTON, self.onStop, stop)
        self.Bind(wx.EVT_BUTTON, self.onSaveImage, saveImage)

        self.playTimer = wx.Timer(self)

        self.Bind(wx.EVT_TIMER, self.onNextFrame, self.playTimer)

        self.Bind(wx.EVT_UPDATE_UI, self.onUpdateUI)
        self.Bind(wx.EVT_PAINT, self.onPaint)

        self.Bind(wx.EVT_SIZE, self.onResize)

        if len(sys.argv) > 1:
            if os.path.exists(sys.argv[1]):
                wx.CallLater(0, self.openFile(os.path.abspath(sys.argv[1])))

        self.Show(True)