예제 #1
0
    def constructTopResultToolBar(self):
        #         path = os.path.abspath(__file__)
        #         tail = None
        # #         head, tail = os.path.split(path)
        # #         print('createAuiManager',head, tail )
        #         try:
        #             while tail != 'src':
        #                 path = os.path.abspath(os.path.join(path, '..',))
        #                 head, tail = os.path.split(path)
        #         except Exception as e:
        #             logger.error(e, exc_info=True)
        #         print('------------------------------------------------------------------------->',path)
        #         path = os.path.abspath(os.path.join(path, "images"))
        # create some toolbars
        tb1 = aui.AuiToolBar(self,
                             -1,
                             wx.DefaultPosition,
                             wx.DefaultSize,
                             agwStyle=aui.AUI_TB_DEFAULT_STYLE
                             | aui.AUI_TB_OVERFLOW)
        tb1.SetToolBitmapSize(wx.Size(42, 42))
        #         tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
        #                          wx.TB_FLAT | wx.TB_NODIVIDER)
        #         tb1.SetToolBitmapSize(wx.Size(16, 16))
        #         playImage = None
        #         if "worksheet" == os.path.split(os.getcwd())[-1:][0]:
        #             imageLocation = os.path.join("..", "..", "images")
        #
        #         elif "view" == os.path.split(os.getcwd())[-1:][0]:
        #             imageLocation = os.path.join("..", "images")
        tb1.AddSimpleTool(
            ID_PIN,
            "Pin",
            self.fileOperations.getImageBitmap(imageName="pin2_green.png"),
            short_help_string="Pin",
            kind=ITEM_CHECK)
        tb1.AddSimpleTool(ID_RUN,
                          "Result refresh",
                          self.fileOperations.getImageBitmap(
                              imageName="resultset_refresh.png"),
                          short_help_string="Refresh")
        tb1.AddSimpleTool(
            ID_SQL_TEXT,
            "SQL \t(Ctrl+Q)",
            self.fileOperations.getImageBitmap(imageName="sql_text.png"),
            short_help_string="SQL \t(Ctrl+Q)")

        self.Bind(wx.EVT_MENU, self.onPinClick, id=ID_PIN)
        self.Bind(wx.EVT_MENU, self.onSqlText, id=ID_SQL_TEXT)
        tb1.AddSeparator()

        tb1.Realize()

        return tb1
    def constructTopToolBar(self):

        # create some toolbars
        tb1 = aui.AuiToolBar(self, -1, wx.DefaultPosition, (10, 10), agwStyle=aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_OVERFLOW)

#         tb1.SetToolBitmapSize(wx.Size(16, 16))
        # id, name, image, name, method, kind
        pageSizeText = TransparentText(tb1, -1, "Page Size")
#         tb1.AddControl(pageSizeText)
        pageNumber = [f'{pageNum}' for pageNum in range(5, 101, 20)]       
        self.pageSizeCtrl = wx.Choice(tb1, 10, (-1, -1), (50, 25), pageNumber, style=0)
        index = pageNumber.index(f'{self.page.pageSize}')
        self.pageSizeCtrl.SetSelection(index)
        
        pageNumbers = [f'{1+pageNum}' for pageNum in range(self.page.pages)]            
        self.pageNumberCtrl = wx.Choice(tb1, 11, (-1, -1), (50, 25), pageNumbers, style=0)
        self.pageNumberCtrl.SetSelection(0)
        self.pageNumbersCountText = TransparentText(tb1, -1, f"/{len(pageNumbers)}")
#         tb1.AddControl(choice)
        tools = [
            ('control', pageSizeText),
            ('control', self.pageSizeCtrl),
            (ID_FIRST_RESULT, "First", "resultset_first.png", 'First', lambda e:self.onToolButtonClick(e), wx.ITEM_NORMAL),
            (ID_PREVIOUS_RESULT, "Previous", "resultset_previous.png", 'Previous', lambda e:self.onToolButtonClick(e), wx.ITEM_NORMAL),
            ('control', self.pageNumberCtrl),
            ('control', self.pageNumbersCountText),
            (ID_NEXT_RESULT, "Next", "resultset_next.png", 'Next', lambda e:self.onToolButtonClick(e), wx.ITEM_NORMAL),
            (ID_LAST_RESULT, "Last", "resultset_last.png", 'Last', lambda e:self.onToolButtonClick(e), wx.ITEM_CHECK),
            
#             (ID_REFRESH_ROW, "Result refresh", "resultset_refresh.png", 'Result refresh \tF5', self.onRefresh),
#             (ID_ADD_ROW, "Add a new row", "row_add.png", 'Add a new row', self.onAddRow),
#             (ID_DUPLICATE_ROW, "Duplicate selected row", "row_copy.png", 'Duplicate selected row', self.onDuplicateRow),
#             (ID_DELETE_ROW, "Delete selected row", "row_delete.png", 'Delete selected row', self.onDeleteRow),
            ]
        for tool in tools:
            if len(tool) == 0:
                tb1.AddSeparator()
            elif len(tool) == 2:
                tb1.AddControl(tool[1])
            else:
                logger.debug(tool)
                toolItem = tb1.AddSimpleTool(tool[0], tool[1], self.fileOperations.getImageBitmap(imageName=tool[2]), kind=tool[5], short_help_string=tool[3])
                
                if tool[4]:
                    self.Bind(wx.EVT_MENU, tool[4], id=tool[0])

#         tb1.AddControl(choice)
        self.Bind(wx.EVT_CHOICE, self.onPageNumberCtrl, self.pageNumberCtrl)
        self.Bind(wx.EVT_CHOICE, self.onPageSizeCtrl, self.pageSizeCtrl)
        tb1.Realize()

        return tb1
예제 #3
0
    def initToolBar_(self):
        """Initilize some default toolbar entries."""
        self.toolBar_ = aui.AuiToolBar(
            self, -1, wx.DefaultPosition, wx.DefaultSize,
            aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_PLAIN_BACKGROUND)
        #| aui.AUI_TB_OVERFLOW)

        self.toolBar_.SetToolBitmapSize(wx.Size(22, 22))
        tbquit = self.toolBar_.AddSimpleTool(
            wx.NewId(), "Quit", loadIcon("application-exit-16.png"),
            "Quit application")
        wx.EVT_TOOL(self, tbquit.GetId(), self.onMainQuit)

        # self.toolBar_.Realize()
        self.auiMgr.AddPane(
            self.toolBar_,
            aui.AuiPaneInfo().Name("Main Toolbar").Caption(
                "Main Toolbar").ToolbarPane().Top().Row(0).Position(
                    0).LeftDockable(True).RightDockable(True))
예제 #4
0
    def constructTopToolBar(self):

        # create some toolbars
        tb1 = aui.AuiToolBar(self,
                             -1,
                             wx.DefaultPosition, (10, 10),
                             agwStyle=aui.AUI_TB_DEFAULT_STYLE
                             | aui.AUI_TB_OVERFLOW)

        #         tb1.SetToolBitmapSize(wx.Size(16, 16))
        # id, name, image, name, method, kind
        tools = [
            (ID_COLLAPSE_ALL, "Collapse All", "collapseall-small.png",
             'Collapse All', self.onCollapseAll, wx.ITEM_NORMAL),
            (ID_LINK_WITH_EDITOR, "Link with Editor",
             "icon_link_with_editor.png", 'Link with Editor',
             self.onLinkWithEditor, wx.ITEM_CHECK),
            (),
            (ID_VIEW_MENU, "View Menu", "icon_menu.png", 'View Menu',
             self.onViewMenu, wx.ITEM_NORMAL),
            #             (ID_REFRESH_ROW, "Result refresh", "resultset_refresh.png", 'Result refresh \tF5', self.onRefresh),
            #             (ID_ADD_ROW, "Add a new row", "row_add.png", 'Add a new row', self.onAddRow),
            #             (ID_DUPLICATE_ROW, "Duplicate selected row", "row_copy.png", 'Duplicate selected row', self.onDuplicateRow),
            #             (ID_DELETE_ROW, "Delete selected row", "row_delete.png", 'Delete selected row', self.onDeleteRow),
        ]
        for tool in tools:
            if len(tool) == 0:
                tb1.AddSeparator()
            else:
                logger.debug(tool)
                toolItem = tb1.AddSimpleTool(
                    tool[0],
                    tool[1],
                    self.fileOperations.getImageBitmap(imageName=tool[2]),
                    kind=tool[5],
                    short_help_string=tool[3])

                if tool[4]:
                    self.Bind(wx.EVT_MENU, tool[4], id=tool[0])

        tb1.Realize()

        return tb1
예제 #5
0
    def constructTopResultToolBar(self, tabName=None):
        
        # create some toolbars
        tb1 = aui.AuiToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, agwStyle=aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_OVERFLOW)
        
        tb1.SetToolBitmapSize(wx.Size(42, 42))

        if tabName == 'Data':
            tools = [
                (ID_SAVE_ROW, "Save", "save_to_database.png", 'Save (Ctrl+S)', self.onSave),
                (),
                (ID_REFRESH_ROW, "Result refresh", "resultset_refresh.png", 'Result refresh \tF5', self.onRefresh),
                (ID_ADD_ROW, "Add a new row", "row_add.png", 'Add a new row', self.onAddRow),
                (ID_DUPLICATE_ROW, "Duplicate selected row", "row_copy.png", 'Duplicate selected row', self.onDuplicateRow),
                (ID_DELETE_ROW, "Delete selected row", "row_delete.png", 'Delete selected row', self.onDeleteRow),
                ]
            for tool in tools:
                if len(tool) == 0:
                    tb1.AddSeparator()
                else:
                    logger.debug(tool)
                    toolItem = tb1.AddSimpleTool(tool[0], tool[1], self.fileOperations.getImageBitmap(imageName=tool[2]), short_help_string=tool[3])
                    if tool[4]:
                        self.Bind(wx.EVT_MENU, tool[4], id=tool[0])
#             tb1.AddSimpleTool(ID_SAVE_ROW, "Save", fileOperations.getImageBitmap(imageName="save_to_database.png"), short_help_string='Save to database')
#             tb1.AddSeparator()
#             
#             tb1.AddSimpleTool(ID_REFRESH_ROW, "Result refresh", fileOperations.getImageBitmap(imageName="resultset_refresh.png"), short_help_string='Refresh data')
#             tb1.AddSimpleTool(ID_ADD_ROW, "Add a new row", fileOperations.getImageBitmap(imageName="row_add.png"), short_help_string='Add new row')
#             tb1.AddSimpleTool(ID_DUPLICATE_ROW, "Duplicate current row", fileOperations.getImageBitmap(imageName="row_copy.png"), short_help_string='Duplicate current row')
#             tb1.AddSimpleTool(ID_DELETE_ROW, "Delete current row", fileOperations.getImageBitmap(imageName="row_delete.png"), short_help_string='Delete current row')
#             tb1.AddSeparator()
            
#         tb1.AddTool(ID_RUN, "Pin", fileOperations.getImageBitmap(imageName="pin2_green.png"))

        tb1.Realize()
        
        return tb1     
예제 #6
0
    def __init__(self, parent, style=wx.TR_DEFAULT_STYLE | wx.BORDER_NONE):
        super(WelcomePanel, self).__init__()
        wx.Panel.__init__(self, parent, style=style)
        if wx.PlatformInformation.Get().GetOperatingSystemIdName() in [
                'Linux', 'Unix', 'OS/2'
        ]:
            pass
        elif wx.PlatformInformation.Get().GetOperatingSystemIdName() in [
                'DOS', 'Windows'
        ]:
            self.startWebHelp()

        fileOperations = FileOperations()
        self.current = "http://localhost:5000"
        self.frame = self.GetTopLevelParent()
        self.titleBase = self.frame.GetTitle()

        sizer = wx.BoxSizer(wx.VERTICAL)
        #         btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.wv = webview.WebView.New(self)
        self.Bind(webview.EVT_WEBVIEW_NAVIGATING, self.OnWebViewNavigating,
                  self.wv)
        self.Bind(webview.EVT_WEBVIEW_NAVIGATED, self.OnWebViewNavigated,
                  self.wv)
        self.Bind(webview.EVT_WEBVIEW_LOADED, self.OnWebViewLoaded, self.wv)
        self.Bind(webview.EVT_WEBVIEW_TITLE_CHANGED,
                  self.OnWebViewTitleChanged, self.wv)

        # create some toolbars
        tb1 = aui.AuiToolBar(self,
                             -1,
                             wx.DefaultPosition,
                             wx.DefaultSize,
                             agwStyle=aui.AUI_TB_DEFAULT_STYLE
                             | aui.AUI_TB_OVERFLOW)
        tb1.SetToolBitmapSize(wx.Size(16, 16))
        backButtonId = wx.NewIdRef()
        homeButtonId = wx.NewIdRef()
        forwardButtonId = wx.NewIdRef()
        stopButtonId = wx.NewIdRef()
        refreshButtonId = wx.NewIdRef()
        openButtonId = wx.NewIdRef()

        tb1_back = wx.ArtProvider.GetBitmap(wx.ART_GO_BACK, wx.ART_OTHER,
                                            wx.Size(16, 16))
        backButton = tb1.AddSimpleTool(backButtonId,
                                       "Back",
                                       tb1_back,
                                       short_help_string="Back")
        self.Bind(wx.EVT_MENU, self.OnPrevPageButton, id=backButtonId)
        self.Bind(wx.EVT_UPDATE_UI, self.OnCheckCanGoBack, backButton)

        tb1_home = wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_OTHER,
                                            wx.Size(16, 16))
        tb1.AddSimpleTool(homeButtonId,
                          "Start Page",
                          tb1_home,
                          short_help_string="Start page")
        self.Bind(wx.EVT_MENU, self.OnHomeButton, id=homeButtonId)

        tb1_forward = wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_OTHER,
                                               wx.Size(16, 16))
        forwardButton = tb1.AddSimpleTool(forwardButtonId,
                                          "Forword",
                                          tb1_forward,
                                          short_help_string="Forword")
        self.Bind(wx.EVT_MENU, self.OnNextPageButton, id=forwardButtonId)
        self.Bind(wx.EVT_UPDATE_UI, self.OnCheckCanGoForward, forwardButton)

        tb1_stop = wx.ArtProvider.GetBitmap(wx.ART_ERROR, wx.ART_OTHER,
                                            wx.Size(16, 16))
        tb1.AddSimpleTool(stopButtonId,
                          "Stop",
                          tb1_stop,
                          short_help_string="Stop")
        self.Bind(wx.EVT_MENU, self.OnStopButton, id=stopButtonId)

        tb1_refresh = wx.ArtProvider.GetBitmap(wx.ART_REDO, wx.ART_OTHER,
                                               wx.Size(16, 16))
        tb1.AddSimpleTool(refreshButtonId,
                          "Refresh",
                          tb1_refresh,
                          short_help_string="Refresh")
        self.Bind(wx.EVT_MENU, self.OnRefreshPageButton, id=refreshButtonId)

        self.location = wx.ComboBox(tb1,
                                    -1,
                                    "",
                                    size=(400, -1),
                                    style=wx.CB_DROPDOWN | wx.TE_PROCESS_ENTER)
        self.location.AppendItems([
            "http://localhost:5000", 'http://wxPython.org',
            'http://wxwidgets.org', 'http://google.com'
        ])

        for url in [
                "http://localhost:5000", 'http://wxPython.org',
                'http://wxwidgets.org', 'http://google.com'
        ]:
            item = webview.WebViewHistoryItem(url, url)
#             self.wv.LoadHistoryItem(item)

        self.Bind(wx.EVT_COMBOBOX, self.OnLocationSelect, self.location)
        self.location.Bind(wx.EVT_TEXT_ENTER, self.OnLocationEnter)
        tb1.AddControl(self.location, label="Location: ")

        #         tb1_open = wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK, wx.ART_OTHER, wx.Size(16, 16))
        tb1.AddSimpleTool(
            openButtonId,
            "Open",
            bitmap=fileOperations.getImageBitmap(imageName="webinar.png"),
            short_help_string="Open")
        self.Bind(wx.EVT_MENU, self.OnOpenButton, id=openButtonId)

        tb1.Realize()
        #         sizer.Add(btnSizer, 0, wx.EXPAND)
        sizer.Add(tb1, 0, wx.EXPAND)
        sizer.Add(self.wv, 1, wx.EXPAND | wx.ALL, 0)

        self.wv.LoadURL(self.current)
        #         logger.debug("---------------------------------"+ os.getcwd())
        #         htmlData=FileOperations().readFile(filePath='./html/welcome.html')
        #         logger.debug(htmlData)
        #
        #         self.wv.SetPage(htmlData,"http://localhost:5000")
        self.SetSizer(sizer)
예제 #7
0
    def constructBottomResultToolBar(self):

        # create some toolbars
        tb1 = aui.AuiToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
                             wx.TB_FLAT | wx.TB_NODIVIDER)
        tb1.SetToolBitmapSize(wx.Size(16, 16))
        path = os.path.abspath(__file__)
        tail = None
        try:
            while tail != 'src':
                path = os.path.abspath(os.path.join(
                    path,
                    '..',
                ))
                head, tail = os.path.split(path)
        except Exception as e:
            logger.error(e, exc_info=True)
        logger.info('path {}'.format(path))
        imageLocation = os.path.abspath(os.path.join(path, "images"))
        tb1.AddSimpleTool(ID_ROW_ADD,
                          "Row add",
                          wx.Bitmap(os.path.join(imageLocation,
                                                 "row_add.png")),
                          short_help_string="Row add ")
        tb1.AddSimpleTool(ID_ROW_DELETE,
                          "Row delete",
                          wx.Bitmap(
                              os.path.join(imageLocation, "row_delete.png")),
                          short_help_string="Row delete ")
        tb1.AddSimpleTool(ID_APPLY_CHANGE,
                          "Apply data change",
                          wx.Bitmap(os.path.join(imageLocation, "accept.png")),
                          short_help_string="Apply data change ")
        tb1.AddSeparator()
        tb1.AddSimpleTool(ID_RESULT_REFRESH,
                          "Result refresh",
                          wx.Bitmap(
                              os.path.join(imageLocation,
                                           "resultset_refresh.png")),
                          short_help_string="Result refresh ")
        tb1.AddSimpleTool(ID_RESULT_FIRST,
                          "Result first",
                          wx.Bitmap(
                              os.path.join(imageLocation,
                                           "resultset_first.png")),
                          short_help_string="Result first ")
        tb1.AddSimpleTool(ID_RESULT_NEXT,
                          "Result next",
                          wx.Bitmap(
                              os.path.join(imageLocation,
                                           "resultset_next.png")),
                          short_help_string="Result next ")
        tb1.AddSimpleTool(ID_RESULT_PREVIOUS,
                          "Result previous",
                          wx.Bitmap(
                              os.path.join(imageLocation,
                                           "resultset_previous.png")),
                          short_help_string="Result previous ")
        tb1.AddSimpleTool(ID_RESULT_LAST,
                          "Result last",
                          wx.Bitmap(
                              os.path.join(imageLocation,
                                           "resultset_last.png")),
                          short_help_string="Result last ")
        tb1.AddSeparator()

        tb1.Realize()

        return tb1