Esempio n. 1
0
    def _createEditorWidgets(self):
        self._createAcceleratorTable()

        self.notebook = fnb.FlatNotebook(self, wx.ID_ANY, style = fnb.FNB_BOTTOM | fnb.FNB_NO_NAV_BUTTONS | fnb.FNB_NO_X_BUTTON | fnb.FNB_NODRAG)
        self.notebook.AddPage(self._createWysiwygPage(), _extstr(u"blogeditor.Design"), True, -1) #$NON-NLS-1$
        self.notebook.AddPage(self._createXHTMLPage(), _extstr(u"blogeditor.XHTML"), False, -1) #$NON-NLS-1$
        self.notebook.AddPage(self._createPreviewPage(), _extstr(u"blogeditor.Preview"), False, -1) #$NON-NLS-1$
Esempio n. 2
0
    def __createNoteBook(self):
        """!Creates notebook widgets"""

        #create main notebook widget
        nbStyle = FN.FNB_FANCY_TABS | \
            FN.FNB_BOTTOM | \
            FN.FNB_NO_NAV_BUTTONS | \
            FN.FNB_NO_X_BUTTON
        

        self.disp_idx = -1
  

        # create displays notebook widget and add it to main notebook page
        cbStyle = globalvar.FNPageStyle
        self.notebook = FN.FlatNotebook(parent=self, id=wx.ID_ANY, style=cbStyle)
        
        self.notebook.SetTabAreaColour(globalvar.FNPageColor)

        self.pg_panel = MapFrame(parent=self.notebook, id=wx.ID_ANY, Map=render.Map(), size=globalvar.MAP_WINDOW_SIZE,flag=False,frame=self)
        
        self.disp_idx = self.disp_idx + 1
        self.notebook.AddPage(self.pg_panel, text="Display "+ str(self.disp_idx), select = True)

        self.goutput = goutput.GMConsole(self, pageid=1)
        self.outpage = self.notebook.AddPage(self.goutput, text=_("Command console"))

        self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnCBPageChanged)
        self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnCBPageClosed)


        return self.notebook
Esempio n. 3
0
    def __init__(self, *args, **kw):
        wx.Frame.__init__(self, *args, **kw)

        if TEST == 1:
            wkparent = self
            lbl = "Destroy 2nd WKC"
        elif TEST == 2:
            self.nb = wx.Notebook(self)
            wkparent = self.nb
            lbl = "Delete 2nd Page"
        elif TEST == 3:
            self.nb = fnb.FlatNotebook(self)
            wkparent = self.nb
            lbl = "Delete 2nd Page"

        self.wk1 = WebKitCtrl(wkparent)
        self.wk2 = WebKitCtrl(wkparent)
        self.wk1.LoadURL("http://wxPython.org")
        self.wk2.LoadURL("http://wxWidgets.org")
        #self.wk1 = wx.Panel(self.nb); self.wk1.SetBackgroundColour('red')
        #self.wk2 = wx.Panel(self.nb); self.wk2.SetBackgroundColour('blue')

        if TEST > 1:
            self.nb.AddPage(self.wk1, "zero")
            self.nb.AddPage(self.wk2, "one")
        btn = wx.Button(self, -1, lbl)
        self.Bind(wx.EVT_BUTTON, self.OnButton, btn)

        self.Sizer = wx.BoxSizer(wx.VERTICAL)
        if TEST == 1:
            self.Sizer.Add(self.wk1, 1, wx.EXPAND)
            self.Sizer.Add(self.wk2, 1, wx.EXPAND)
        else:
            self.Sizer.Add(self.nb, 1, wx.EXPAND)
        self.Sizer.Add(btn, 0, wx.ALL, 10)
Esempio n. 4
0
    def create_new_editor(self, xml_path):
        """
        Create the tree and xml editing widgets when the user loads
        an XML file
        """
        if not self.notebook:
            self.notebook = fnb.FlatNotebook(
                self.panel)
            self.main_sizer.Add(self.notebook, 1, wx.ALL|wx.EXPAND, 5)
            style = self.notebook.GetAGWWindowStyleFlag()
            style |= fnb.FNB_X_ON_TAB
            self.notebook.SetAGWWindowStyleFlag(style)
            self.notebook.Bind(
                fnb.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.on_page_closing)

        if xml_path not in self.opened_files:
            self.current_page = NewPage(self.notebook, xml_path, self.size,
                                        self.opened_files)
            self.notebook.AddPage(self.current_page,
                                  os.path.basename(xml_path),
                                  select=True)
            self.last_opened_file = xml_path

            self.opened_files.append(self.last_opened_file)

        self.panel.Layout()
Esempio n. 5
0
    def LayoutItems(self):

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

        bookStyle = fnb.FNB_NODRAG

        self.book = fnb.FlatNotebook(self, wx.ID_ANY, style=bookStyle)

        bookStyle &= ~(fnb.FNB_NODRAG)
        bookStyle |= fnb.FNB_ALLOW_FOREIGN_DND
        self.secondBook = fnb.FlatNotebook(self, wx.ID_ANY, style=bookStyle)

        # Set right click menu to the notebook
        self.book.SetRightClickMenu(self._rmenu)

        # Set the image list
        self.book.SetImageList(self._ImageList)
        mainSizer.Add(self.book, 6, wx.EXPAND)

        # Add spacer between the books
        spacer = wx.Panel(self, -1)
        spacer.SetBackgroundColour(
            wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
        mainSizer.Add(spacer, 0, wx.ALL | wx.EXPAND)

        mainSizer.Add(self.secondBook, 2, wx.EXPAND)

        # Add some pages to the second notebook
        self.Freeze()

        text = wx.TextCtrl(self.secondBook,
                           -1,
                           "Second Book Page 1\n",
                           style=wx.TE_MULTILINE | wx.TE_READONLY)
        self.secondBook.AddPage(text, "Second Book Page 1")

        text = wx.TextCtrl(self.secondBook,
                           -1,
                           "Second Book Page 2\n",
                           style=wx.TE_MULTILINE | wx.TE_READONLY)
        self.secondBook.AddPage(text, "Second Book Page 2")

        self.Thaw()

        mainSizer.Layout()
        self.SendSizeEvent()
Esempio n. 6
0
    def __init__(
            self,
            parent,
            id=wx.ID_ANY,
            style=wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER,
            title=_("GRASS GIS Hydrological Modelling Utility"),
            **kwargs,
    ):
        """!Main window of r.stream's GUI

        @param parent parent window
        @param id window id
        @param title window title

        @param kwargs wx.Frames' arguments
        """
        self.parent = parent

        wx.Frame.__init__(
            self,
            parent=parent,
            id=id,
            title=title,
            name="RStream",
            size=(600, 900),
            **kwargs,
        )
        self.SetIcon(
            wx.Icon(os.path.join(globalvar.ETCICONDIR, "grass.ico"),
                    wx.BITMAP_TYPE_ICO))

        self.nb = FN.FlatNotebook(
            parent=self,
            id=wx.ID_ANY,
            style=FN.FNB_NO_NAV_BUTTONS | FN.FNB_FANCY_TABS
            | FN.FNB_NO_X_BUTTON,
        )

        # add pages to the notebook
        self.pages = [
            (TabPanelOne(self.nb, self.parent, self), "Network extraction"),
            (TabPanel(self.nb), "Network ordering"),
            (TabPanel(self.nb), "Tab 3"),
        ]

        for page, label in self.pages:
            self.nb.AddPage(page, label)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.nb, 1, wx.EXPAND)

        # button for close and other
        self.button = wx.BoxSizer(wx.HORIZONTAL)
        self.btn_close = wx.Button(parent=self, id=wx.ID_CLOSE)
        self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose)
        self.button.Add(item=self.btn_close, flag=wx.ALL, border=5)
        self.sizer.Add(self.button)

        self.SetSizer(self.sizer)
Esempio n. 7
0
    def __init__(self,app,
            pos=wx.DefaultPosition, size=dlgSize,
            style=wx.DEFAULT_DIALOG_STYLE|wx.DIALOG_NO_PARENT|wx.TAB_TRAVERSAL|wx.RESIZE_BORDER):
        wx.Dialog.__init__(self,None,-1,"PsychoPy Preferences",pos,size,style)
        self.app=app
        self.Center()
        self.prefsCfg = self.app.prefs.userPrefsCfg
        self.prefsSpec = self.app.prefs.prefsSpec
        sizer = wx.BoxSizer(wx.VERTICAL)

        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
        
        #notebook, flatnotebook or something else?
        
        self.nb = flatnotebook.FlatNotebook(self)#flatNoteBook has the option to close pages (which we don't want)
#        self.nb = wx.Notebook(self)#notebook isn't nice with lots of pages
        
        self.ctrls={}
        for sectionName in self.prefsCfg.keys():
            prefsPage = self.makePrefsPage(parent=self.nb, 
                    sectionName=sectionName,
                    prefsSection=self.prefsCfg[sectionName],
                    specSection = self.prefsSpec[sectionName])
            self.nb.AddPage(prefsPage, sectionName)
        sizer.Add(self.nb,1, wx.EXPAND)
        
        #create buttons
        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
        btnsizer = wx.StdDialogButtonSizer()     
        #ok
        btn = wx.Button(self, wx.ID_OK)
        btn.SetHelpText("Save prefs (in all sections) and close window")
        btn.Bind(wx.EVT_BUTTON, self.onOK)
        btn.SetDefault()
        btnsizer.AddButton(btn)
        #cancel
        btn = wx.Button(self, wx.ID_CANCEL)
        btn.SetHelpText("Cancel any changes (to any panel)")
        btn.Bind(wx.EVT_BUTTON, self.onCancel)
        btnsizer.AddButton(btn)
        #apply
        btn = wx.Button(self, wx.ID_APPLY)
        btn.SetHelpText("Apply these prefs (in all sections) and continue")
        btn.Bind(wx.EVT_BUTTON, self.onApply)
        btnsizer.AddButton(btn)    
        #help
        btn = wx.Button(self, wx.ID_HELP)
        btn.SetHelpText("Get help on prefs")
        btn.Bind(wx.EVT_BUTTON, self.onHelp)
        btnsizer.AddButton(btn)
        btnsizer.Realize()
        #add buttons to dlg
        sizer.Add(btnsizer, 0, wx.BOTTOM|wx.ALL, 5)

        self.SetSizerAndFit(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
Esempio n. 8
0
 def _createWidgets(self):
     self.panel = wx.Panel(self.parent, wx.ID_ANY, style = wx.SIMPLE_BORDER)
     self.panel.SetBackgroundColour(self.pdColor)
     self.notebook = fnb.FlatNotebook(self.panel, wx.ID_ANY, style = fnb.FNB_BOTTOM | fnb.FNB_NO_NAV_BUTTONS | fnb.FNB_NO_X_BUTTON | fnb.FNB_NODRAG)
     self.notebook.SetBackgroundColour(self.pdColor)
     self.notebook.SetActiveTabColour(self.pdColor)
     self.notebook.AddPage(self._createCategoriesPage(), _extstr(u"blogconfig.Categories"), False, -1) #$NON-NLS-1$
     self.notebook.AddPage(self._createCommonPage(), _extstr(u"blogconfig.General"), True, -1) #$NON-NLS-1$
     self.notebook.AddPage(self._createPingPage(), _extstr(u"blogconfig.WeblogPing"), False, -1) #$NON-NLS-1$
     self.notebook.AddPage(self._createTagsPage(), _extstr(u"blogconfig.TagSites"), False, -1) #$NON-NLS-1$
     self.notebook.AddPage(self._createTrackbackPage(), _extstr(u"blogconfig.Trackbacks"), False, -1) #$NON-NLS-1$
Esempio n. 9
0
    def _createContentWidgets(self):
        self.notebook = fnb.FlatNotebook(
            self,
            wx.ID_ANY,
            style=fnb.FNB_BOTTOM | fnb.FNB_NO_NAV_BUTTONS | fnb.FNB_NO_X_BUTTON
            | fnb.FNB_NODRAG)
        self.notebook.AddPage(self._createRavenInfoPage(),
                              _extstr(u"aboutdialog.Info"), True,
                              -1)  #$NON-NLS-1$
        self.notebook.AddPage(self._createCreditsPage(),
                              _extstr(u"aboutdialog.Credits"), False,
                              -1)  #$NON-NLS-1$

        self.staticLine = wx.StaticLine(self, wx.HORIZONTAL)
Esempio n. 10
0
    def __init__(self, parent):
        self.parent = parent
        self.pages = []

        wx.Dialog.__init__(self,
                           id=wxID_WXOPTIONSDIALOG,
                           name='',
                           parent=parent,
                           pos=wx.DefaultPosition,
                           size=wx.Size(500, 400),
                           style=wx.DEFAULT_DIALOG_STYLE,
                           title=_("Options"))

        self.SetExtraStyle(wx.DIALOG_EX_METAL)
        sizer2 = wx.StdDialogButtonSizer()

        self.okbutton = wx.Button(id=wx.ID_OK,
                                  label=_("Ok"),
                                  parent=self,
                                  style=0)

        wx.EVT_BUTTON(self.okbutton, wx.ID_OK, self.OnOk)

        self.cancelbutton = wx.Button(id=wx.ID_CANCEL,
                                      label=_("Cancel"),
                                      parent=self,
                                      style=0)

        self.notebook = fnb.FlatNotebook(id=wxID_WXOPTIONSNOTEBOOK,
                                         name='notebook1',
                                         parent=self,
                                         style=fnb.FNB_NO_X_BUTTON)

        self.create_plugins_pages()

        sizer = self.sizer

        sizer2.Add(self.okbutton, 0, wx.ALIGN_CENTRE | wx.ALL)
        sizer2.Add(self.cancelbutton, 0, wx.ALIGN_CENTRE | wx.ALL)
        sizer.Add(sizer2, 0,
                  wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER | wx.ALL, 5)

        self.notebook.SetSelection(0)
        self.SetSizer(sizer)
        sizer.Fit(self)
        self.SetAutoLayout(True)
        self.CenterOnScreen()
Esempio n. 11
0
    def create_tool_ctrl(self):

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(mainSizer)
        self.Freeze()

        # Main FlatNoteBook
        bookStyle = fnb.FNB_ALLOW_FOREIGN_DND
        bookStyle |= fnb.FNB_NO_X_BUTTON
        bookStyle |= fnb.FNB_NODRAG
        ctrl = fnb.FlatNotebook(self, wx.ID_ANY, style=bookStyle)

        # Global result view
        res_glo = frm_results.ResultFrame("Global", ctrl)
        res_glo.set_log(self)
        res_glo.path = self.path["global_file"]
        self.ctrl["res_glo"] = res_glo
        ctrl.AddPage(res_glo, "Global Result")

        # Stack result view
        res_sta = frm_results.ResultFrame("Stack", ctrl)
        res_sta.set_log(self)
        res_sta.add_result_dest(res_glo)
        res_sta.path = self.path["stack_file"]
        self.ctrl["res_sta"] = res_sta
        ctrl.AddPage(res_sta, "Stack Result")

        # Document AuiNoteBook
        _style = wx.DEFAULT_FRAME_STYLE
        mdi = wx.aui.AuiNotebook(self,
                                 -1,
                                 size=(640, 480),
                                 style=_style,
                                 pos=wx.DefaultPosition)
        self.ctrl["mdi"] = mdi
        ctrl.AddPage(mdi, "Document")

        self.Thaw()
        #mainSizer.Layout()
        self.SendSizeEvent()

        self.ctrl["fnb"] = ctrl
        return ctrl
Esempio n. 12
0
    def __init__(self, parent=None):
        # Initialize wxFrame
        wx.Frame.__init__(self, 
                          None, 
                          wx.ID_ANY, 
                          "Text Editor", 
                          size=(800, 600))

        self.panel = wx.Panel(self)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.panel.SetSizer(self.sizer)
        # Create the notebook
        self.notebook = fnb.FlatNotebook(self.panel)
        self.notebook.SetFont(wx.Font(15, 
                                      wx.FONTFAMILY_DEFAULT,
                                      wx.FONTWEIGHT_NORMAL, 
                                      wx.FONTSTYLE_NORMAL))
        # Call the high-level setup function
        self.SetupEditor()
Esempio n. 13
0
    def __init__(self, parent, pos=wx.DefaultPosition, size=wx.DefaultSize):
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          u'交谈',
                          pos,
                          size,
                          style=wx.SYSTEM_MENU | wx.MINIMIZE_BOX
                          | wx.RESIZE_BORDER | wx.CAPTION | wx.CLOSE_BOX
                          | wx.CLIP_CHILDREN)

        self._mgr = wx.aui.AuiManager()
        self._mgr.SetManagedWindow(self)

        self.SetIcon(parent._icon)

        #self._tilePanel = TitlePanel(self, wx.ID_ANY, size = (size[0], self.TITLE_HEIGHT))

        #self._mgr.AddPane(self._tilePanel, wx.aui.AuiPaneInfo().Top().Fixed().
        #			MinSize((size[0],self.TITLE_HEIGHT)).
        #			CloseButton(False).CaptionVisible(False).Name('titlepanel'))

        bookStyle = fnb.FNB_NODRAG | fnb.FNB_TABS_BORDER_SIMPLE
        self._chatBook = fnb.FlatNotebook(self, wx.ID_ANY, style=bookStyle)
        self._mgr.AddPane(self._chatBook,
                          wx.aui.AuiPaneInfo().Name('chatbook').CenterPane())
        self._mgr.Update()

        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnPageClosing)

        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        #self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
        #self.Bind(wx.EVT_SET_FOCUS, self.OnFocus)

        #self.SetTransparent(TRANSPARENCY_MAX)
        '''
Esempio n. 14
0
    def createTabs(self):
        """Creates and lays out the tab menu appropriately"""
        ##initialize a notebook widget
        self.book = fnb.FlatNotebook(self,
                                     wx.ID_ANY,
                                     style=fnb.FNB_NODRAG
                                     | fnb.FNB_NO_NAV_BUTTONS
                                     | fnb.FNB_NO_X_BUTTON)

        # Add some pages to the second notebook
        self.Freeze()
        try:
            #########################
            ##  Launchers tab      ##
            #########################
            self.appSizer = wx.BoxSizer(wx.VERTICAL)
            #main panel
            mainPanel = wx.Panel(self.book, -1, style=wx.MAXIMIZE_BOX)
            mainSizer = wx.BoxSizer(wx.VERTICAL)
            mainPanel.SetSizer(mainSizer)

            launcherPanel = wx.Panel(mainPanel, -1, style=wx.MAXIMIZE_BOX)
            launcherSizer = wx.BoxSizer(wx.HORIZONTAL)
            launcherPanel.SetSizer(launcherSizer)

            #add this stretch to keep buttons centered
            launcherSizer.AddStretchSpacer(1)

            browsers = ['Firefox', 'Safari', 'IE']
            self.browserButtons = {}

            for browser in browsers:

                try:
                    #create an img object for use in the button
                    img = wx.Bitmap(
                        os.path.join(
                            os.path.dirname(os.path.abspath(__file__)),
                            'Images/' + browser.lower() + '.png'),
                        wx.BITMAP_TYPE_PNG)

                    #determine if the img was created successfully
                    if img:
                        #got a valid img time to create the button
                        self.browserButtons[browser] = wx.BitmapButton(
                            launcherPanel, -1, img, size=(60, 60))
                    else:
                        #bad img create a plain text button.
                        self.browserButtons[browser] = wx.Button(launcherPanel,
                                                                 id=-1,
                                                                 label=browser)

                except Exception, e:
                    #for some reason an exception has occured so just creating a default text button
                    self.browserButtons[browser] = wx.Button(launcherPanel,
                                                             id=-1,
                                                             label=browser)

                #Add the button to the button sizer
                launcherSizer.Add(self.browserButtons[browser], 1, wx.CENTER)
                launcherSizer.AddStretchSpacer(1)

                #bind the button to the event
                #this functions uses a lambda to brings all the calls together
                self.Bind(wx.EVT_BUTTON,
                          lambda event, bwser=browser: self.
                          OnBrowserButtonClick(event, bwser),
                          self.browserButtons[browser])

            #disable the buttons that won't work on specific platforms
            if sys.platform == "win32":
                self.browserButtons['Safari'].Disable()
            if sys.platform == "linux2":
                self.browserButtons['Safari'].Disable()
                self.browserButtons['IE'].Disable()
            if sys.platform == "darwin":
                self.browserButtons['IE'].Disable()

            morePanel = wx.Panel(mainPanel, -1, style=wx.MAXIMIZE_BOX)
            moreSizer = wx.BoxSizer(wx.HORIZONTAL)
            morePanel.SetSizer(moreSizer)

            #setup input and textbox
            self.url_label = wx.StaticBox(morePanel,
                                          -1,
                                          'Test URL', (5, 5),
                                          size=(70, 15))
            self.url_input = wx.TextCtrl(morePanel,
                                         -1,
                                         size=wx.Size(250, -1),
                                         value="http://www.getwindmill.com")
            moreSizer.Add(self.url_label)
            moreSizer.Add(self.url_input)

            #setup close button
            closeBPanel = wx.Panel(mainPanel, -1, style=wx.MAXIMIZE_BOX)
            closeBSizer = wx.BoxSizer(wx.HORIZONTAL)
            closeBPanel.SetSizer(closeBSizer)
            closeBrowser = wx.Button(closeBPanel,
                                     label="Close Open Windmill Browsers")
            closeBrowser.Bind(wx.EVT_BUTTON, self.OnCloseBrowser)
            closeBSizer.Add(closeBrowser, 0, wx.ALL | wx.CENTER | wx.EXPAND,
                            20)

            mainSizer.Add(morePanel, 1, wx.ALIGN_CENTER)
            mainSizer.Add(launcherPanel, 1, wx.ALIGN_CENTER)
            mainSizer.Add(closeBPanel, 1, wx.ALIGN_CENTER)

            #we want the launcher tab to be selected when the app comes up
            self.book.AddPage(mainPanel, 'Browser Launcher', select=True)
            #self.book.AddPage(morePanel, 'More', select=True)

            #########################
            ##  Windmill shell tab ##
            #########################

            #self.appSizer = wx.BoxSizer(wx.VERTICAL)
            #self.SetSizer(self.appSizer)

            #self.appSizer.Add(self.book, 2, wx.EXPAND)

            ##setup the tab contain the shell
            shellTab = wx.Panel(self.book, 2)

            #define that the tabSizer for this panel be used.
            shellTabSizer = wx.BoxSizer(wx.VERTICAL)

            shellTab.SetSizer(shellTabSizer)

            #create the shell frame
            shellFrame = wx.py.shell.Shell(shellTab, locals=self.shell_objects)

            import windmill
            windmill.stdout = shellFrame.stdout
            windmill.stdin = shellFrame.stdin

            #add the shell frame to the shellTab sizer
            shellTabSizer.Add(shellFrame, 2, wx.EXPAND)

            #add the tab setup to the book
            self.book.AddPage(shellTab, "Windmill Shell", select=False)

            #########################
            ##  Python shell tab   ##
            #########################

            self.SetSizer(self.appSizer)

            self.appSizer.Add(self.book, 1, wx.EXPAND)

            ##setup the tab contain the shell
            pyShellTab = wx.Panel(self.book, 1)

            #define that the tabSizer for this panel be used.
            pyShellTabSizer = wx.BoxSizer(wx.VERTICAL)

            pyShellTab.SetSizer(pyShellTabSizer)

            #create the shell frame
            pyShellFrame = wx.py.shell.Shell(pyShellTab)

            #add the shell frame to the shellTab sizer
            pyShellTabSizer.Add(pyShellFrame, 1, wx.EXPAND)

            #add the tab setup to the book
            self.book.AddPage(pyShellTab, "Python Shell", select=False)
Esempio n. 15
0
    def __init__(self, parent, Rinstance, controller, *args, **kwargs):
        wx.Panel.__init__(self, parent, *args, **kwargs)

        self.parent = parent
        self.border = 4

        #    1. Input data
        InputBoxSizer = wx.StaticBoxSizer(wx.StaticBox(self,
                                                       id=wx.ID_ANY,
                                                       label=_("Input Data")),
                                          orient=wx.HORIZONTAL)

        flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(1)

        flexSizer.Add(item=wx.StaticText(self,
                                         id=wx.ID_ANY,
                                         label=_("Point dataset:")),
                      flag=wx.ALIGN_CENTER_VERTICAL)
        self.InputDataMap = gselect.VectorSelect(parent=self, ftype='points')
        self.InputDataMap.SetFocus()
        flexSizer.Add(item=self.InputDataMap, flag=wx.ALIGN_CENTER_VERTICAL)

        RefreshButton = wx.Button(self, id=wx.ID_REFRESH)
        RefreshButton.Bind(wx.EVT_BUTTON, self.OnButtonRefresh)
        flexSizer.Add(item=RefreshButton, flag=wx.ALIGN_CENTER_VERTICAL)

        flexSizer.Add(item=wx.StaticText(self,
                                         id=wx.ID_ANY,
                                         label=_("Numeric column:")),
                      flag=wx.ALIGN_CENTER_VERTICAL)
        self.InputDataColumn = gselect.ColumnSelect(self, id=wx.ID_ANY)
        self.InputDataColumn.SetSelection(0)
        flexSizer.Add(item=self.InputDataColumn)

        self.InputDataMap.GetChildren()[0].Bind(wx.EVT_TEXT,
                                                self.OnInputDataChanged)

        InputBoxSizer.Add(item=flexSizer)

        #    2. Kriging. In book pages one for each R package. Includes variogram fit.
        KrigingSizer = wx.StaticBoxSizer(
            wx.StaticBox(self, id=wx.ID_ANY, label=_("Kriging")),
            wx.HORIZONTAL)

        self.RPackagesBook = FN.FlatNotebook(
            parent=self,
            id=wx.ID_ANY,
            style=FN.FNB_BOTTOM | FN.FNB_NO_NAV_BUTTONS | FN.FNB_FANCY_TABS
            | FN.FNB_NO_X_BUTTON)

        for Rpackage in [
                "gstat"
        ]:  # , "geoR"]: #@TODO: enable it if/when it'll be implemented.
            self.CreatePage(package=Rpackage,
                            Rinstance=Rinstance,
                            controller=controller)

        ## Command output. From menuform module, cmdPanel class
        self.goutput = goutput.GMConsole(
            parent=self,
            margin=False,
            pageid=self.RPackagesBook.GetPageCount(),
            notebook=self.RPackagesBook)
        self.goutputId = self.RPackagesBook.GetPageCount()
        self.outpage = self.RPackagesBook.AddPage(self.goutput,
                                                  text=_("Command output"))

        self.RPackagesBook.SetSelection(0)
        KrigingSizer.Add(self.RPackagesBook, proportion=1, flag=wx.EXPAND)

        #    3. Output Parameters.
        OutputSizer = wx.StaticBoxSizer(
            wx.StaticBox(self, id=wx.ID_ANY, label=_("Output")), wx.HORIZONTAL)

        OutputParameters = wx.GridBagSizer(hgap=5, vgap=5)
        OutputParameters.AddGrowableCol(1)
        OutputParameters.Add(item=wx.StaticText(
            self, id=wx.ID_ANY, label=_("Name for the output raster map:")),
                             flag=wx.ALIGN_CENTER_VERTICAL,
                             pos=(0, 0))
        self.OutputMapName = gselect.Select(parent=self,
                                            id=wx.ID_ANY,
                                            type='raster',
                                            mapsets=[grass.gisenv()['MAPSET']])
        OutputParameters.Add(item=self.OutputMapName,
                             flag=wx.EXPAND | wx.ALL,
                             pos=(0, 1))
        self.VarianceRasterCheckbox = wx.CheckBox(
            self, id=wx.ID_ANY, label=_("Export variance map as well: "))
        self.VarianceRasterCheckbox.SetValue(state=True)
        OutputParameters.Add(item=self.VarianceRasterCheckbox,
                             flag=wx.ALIGN_CENTER_VERTICAL,
                             pos=(1, 0))
        self.OutputVarianceMapName = gselect.Select(
            parent=self,
            id=wx.ID_ANY,
            type='raster',
            mapsets=[grass.gisenv()['MAPSET']])
        self.VarianceRasterCheckbox.Bind(wx.EVT_CHECKBOX,
                                         self.OnVarianceCBChecked)
        OutputParameters.Add(item=self.OutputVarianceMapName,
                             flag=wx.EXPAND | wx.ALL,
                             pos=(1, 1))

        self.OverwriteCheckBox = wx.CheckBox(
            self,
            id=wx.ID_ANY,
            label=_("Allow output files to overwrite existing files"))
        self.OverwriteCheckBox.SetValue(
            UserSettings.Get(group='cmd', key='overwrite', subkey='enabled'))
        OutputParameters.Add(item=self.OverwriteCheckBox,
                             pos=(2, 0),
                             span=(1, 2))

        OutputSizer.Add(OutputParameters,
                        proportion=0,
                        flag=wx.EXPAND | wx.ALL,
                        border=self.border)

        #    4. Run Button and Quit Button
        ButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
        HelpButton = wx.Button(self, id=wx.ID_HELP)
        HelpButton.Bind(wx.EVT_BUTTON, self.OnHelpButton)
        QuitButton = wx.Button(self, id=wx.ID_EXIT)
        QuitButton.Bind(wx.EVT_BUTTON, self.OnCloseWindow)
        self.RunButton = wx.Button(
            self, id=wx.ID_ANY,
            label=_("&Run"))  # no stock ID for Run button..
        self.RunButton.Bind(wx.EVT_BUTTON, self.OnRunButton)
        self.RunButton.Enable(
            False
        )  # disable it on loading the interface, as input map is not set
        ButtonSizer.Add(HelpButton,
                        proportion=0,
                        flag=wx.ALIGN_LEFT | wx.ALL,
                        border=self.border)
        ButtonSizer.Add(QuitButton,
                        proportion=0,
                        flag=wx.ALIGN_RIGHT | wx.ALL,
                        border=self.border)
        ButtonSizer.Add(self.RunButton,
                        proportion=0,
                        flag=wx.ALIGN_RIGHT | wx.ALL,
                        border=self.border)

        #    Main Sizer. Add each child sizer as soon as it is ready.
        Sizer = wx.BoxSizer(wx.VERTICAL)
        Sizer.Add(InputBoxSizer,
                  proportion=0,
                  flag=wx.EXPAND | wx.ALL,
                  border=self.border)
        Sizer.Add(KrigingSizer,
                  proportion=1,
                  flag=wx.EXPAND | wx.ALL,
                  border=self.border)
        Sizer.Add(OutputSizer,
                  proportion=0,
                  flag=wx.EXPAND | wx.ALL,
                  border=self.border)
        Sizer.Add(ButtonSizer,
                  proportion=0,
                  flag=wx.ALIGN_RIGHT | wx.ALL,
                  border=self.border)
        self.SetSizerAndFit(Sizer)
Esempio n. 16
0
    def __init__(self,
                 frame,
                 title,
                 params,
                 order,
                 helpUrl=None,
                 suppressTitles=True,
                 size=wx.DefaultSize,
                 style=_style,
                 editing=False):

        # translate title
        localizedTitle = title.replace(' Properties',
                                       _translate(' Properties'))
        wx.Dialog.__init__(self,
                           frame,
                           -1,
                           localizedTitle,
                           size=size,
                           style=style)
        self.frame = frame
        self.app = frame.app
        self.helpUrl = helpUrl
        self.params = params  # dict
        self.order = order
        self.title = title
        # keep localized title to update dialog's properties later.
        self.localizedTitle = localizedTitle
        self.codeGuiElements = {}
        if not editing and 'name' in self.params.keys():
            # then we're adding a new component so ensure a valid name:
            makeValid = self.frame.exp.namespace.makeValid
            self.params['name'].val = makeValid(params['name'].val)

        agwStyle = flatnotebook.FNB_NO_X_BUTTON
        if hasattr(flatnotebook, "FNB_NAV_BUTTONS_WHEN_NEEDED"):
            # not available in wxPython 2.8
            agwStyle |= flatnotebook.FNB_NAV_BUTTONS_WHEN_NEEDED
        if hasattr(flatnotebook, "FNB_NO_TAB_FOCUS"):
            # not available in wxPython 2.8.10
            agwStyle |= flatnotebook.FNB_NO_TAB_FOCUS
        self.codeSections = flatnotebook.FlatNotebook(self,
                                                      wx.ID_ANY,
                                                      style=agwStyle)

        openToPage = 0
        for idx, pkey in enumerate(self.order):
            param = self.params.get(pkey)
            if pkey == 'name':
                self.nameLabel = wx.StaticText(self, wx.ID_ANY, param.label)
                _style = wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB
                self.componentName = wx.TextCtrl(self,
                                                 wx.ID_ANY,
                                                 unicode(param.val),
                                                 style=_style)
                self.componentName.SetToolTipString(param.hint)
                self.componentName.SetValidator(validators.NameValidator())
                self.nameOKlabel = wx.StaticText(self,
                                                 -1,
                                                 '',
                                                 style=wx.ALIGN_RIGHT)
                self.nameOKlabel.SetForegroundColour(wx.RED)
            else:
                guikey = pkey.replace(' ', '_')
                _param = self.codeGuiElements.setdefault(guikey, dict())

                _section = wx.Panel(self.codeSections, wx.ID_ANY)
                _panel = _param.setdefault(guikey + '_panel', _section)
                _codeBox = _param.setdefault(
                    guikey + '_codebox',
                    CodeBox(_panel,
                            wx.ID_ANY,
                            pos=wx.DefaultPosition,
                            style=0,
                            prefs=self.app.prefs))
                if len(param.val):
                    _codeBox.AddText(unicode(param.val))
                if len(param.val.strip()) and not openToPage:
                    # index of first non-blank page
                    openToPage = idx

        if self.helpUrl is not None:
            self.helpButton = wx.Button(self, wx.ID_HELP, _translate(" Help "))
            tip = _translate("Go to online help about this component")
            self.helpButton.SetToolTip(wx.ToolTip(tip))
        self.okButton = wx.Button(self, wx.ID_OK, _translate(" OK "))
        self.okButton.SetDefault()
        self.cancelButton = wx.Button(self, wx.ID_CANCEL,
                                      _translate(" Cancel "))
        self.__set_properties()
        self.__do_layout()
        self.codeSections.SetSelection(max(0, openToPage - 1))

        self.Bind(wx.EVT_BUTTON, self.helpButtonHandler, self.helpButton)

        # do show and process return
        ret = self.ShowModal()

        if ret == wx.ID_OK:
            self.checkName()
            self.OK = True
            self.params = self.getParams()  # get new vals from dlg
            self.Validate()
            # TODO: check syntax of code from each code section tab??
        else:
            self.OK = False