Beispiel #1
0
    def __init__(self, parent, filepaths=(), **kwargs):
        """
        Args:
            parent:
                parent window.
            filepaths:
                String or list of strings with the path of the nc files to open
                Empty tuple if no file should be opened during the initialization of the frame.
        """
        if "size" not in kwargs:
            kwargs["size"] = (1200, 800)

        super(NcViewerFrame, self).__init__(parent, id=-1, **kwargs)

        # This combination of options for config seems to work on my Mac.
        self.config = wx.FileConfig(appName=self.codename,
                                    localFilename=self.codename + ".ini",
                                    style=wx.CONFIG_USE_LOCAL_FILE)

        # Build menu, toolbar and status bar.
        self.makeMenu()
        self.makeToolBar()
        self.statusbar = self.CreateStatusBar()

        # Open netcdf files.
        filepaths, datasets = list_strings(filepaths), []
        filepaths = map(os.path.abspath, filepaths)

        for path in filepaths:
            datasets.append(netCDF4.Dataset(path, mode="r"))
            self.AddFileToHistory(path)

        # Create the notebook (each file will have its own tab).
        panel = wx.Panel(self, -1)
        try:
            self.notebook = fnb.FlatNotebook(
                panel, -1, style=fnb.FNB_NAV_BUTTONS_WHEN_NEEDED)
        except AttributeError:
            self.notebook = fnb.FlatNotebook(panel, -1)

        for path, dataset in zip(filepaths, datasets):
            tab = NcFileTab(self.notebook, dataset)
            self.notebook.AddPage(tab, os.path.basename(path))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.notebook, 1, wx.EXPAND, 5)
        panel.SetSizerAndFit(sizer)

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

        # Intercept the command event associated to variable/dimension comparison.
        self.Bind(EVT_COMPARE, self.OnCompare)
Beispiel #2
0
    def _InitComponents(self):
        self.tabs = fnb.FlatNotebook(self, wx.ID_ANY,
                                     agwStyle=fnb.FNB_NODRAG|fnb.FNB_X_ON_TAB)
        # You also have to set the wx.WANTS_CHARS style for
        # all parent panels/controls, if it's deeply embedded.
        self.tabs.SetWindowStyleFlag(wx.WANTS_CHARS)

        ctrl1 = chrome.ChromeCtrl(self.tabs, useTimer=True,
                                  url="wikipedia.org")
        ctrl1.GetNavigationBar().GetUrlCtrl().SetEditable(False)
        ctrl1.GetNavigationBar().GetBackButton().SetBitmapLabel(
            wx.Bitmap(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "back.png"), wx.BITMAP_TYPE_PNG))
        ctrl1.GetNavigationBar().GetForwardButton().SetBitmapLabel(
            wx.Bitmap(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    "forward.png"), wx.BITMAP_TYPE_PNG))
        ctrl1.GetNavigationBar().GetReloadButton().SetBitmapLabel(
            wx.Bitmap(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    "reload_page.png"), wx.BITMAP_TYPE_PNG))

        self.tabs.AddPage(ctrl1, "Wikipedia")

        ctrl2 = chrome.ChromeCtrl(self.tabs, useTimer=True, url="google.com",
                                  hasNavBar=False)
        self.tabs.AddPage(ctrl2, "Google")

        ctrl3 = chrome.ChromeCtrl(self.tabs, useTimer=True, url="greenpeace.org")
        ctrl3.SetNavigationBar(CustomNavigationBar(ctrl3))
        self.tabs.AddPage(ctrl3, "Greenpeace")
Beispiel #3
0
    def __init__(self):

        title = "%s %s" % (cerapp.name, cerapp.version)
        size = (cerapp.ini.app_width, cerapp.ini.app_height)

        wx.Frame.__init__(self, None, -1, title, size=size)

        self.SetMenuBar(mbd.Make())
        self.SetToolBar(tbd.Make(self))
        self.CreateStatusBar(2)
        self.SetIcon(cerapp.resman.Icon("taoEd_ico"))

        self.nb = fnb.FlatNotebook(self, wx.ID_ANY, style=NB_STYLE)

        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged,
                  self.nb)
        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnPageClosing,
                  self.nb)
        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CLOSED, self.OnPageClosed, self.nb)

        #self.UpdateMenu()

        cmd.Bind(self)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        self.Center(wx.BOTH)
    def __init__(self, parent, menuItems, bodyPanel):
        wx.Panel.__init__(self, parent )
        
        self.SetBackgroundColour("#FFB90F")
        self.bodyPanel = bodyPanel
        
        #self.anb = AuiNotebook(bodyPanel)
        self.anb = fnb.FlatNotebook(bodyPanel,-1)

        nhbox = wx.BoxSizer(wx.HORIZONTAL)
        nhbox.Add(self.anb,-1,flag=wx.EXPAND, border=0)
        nvbox = wx.BoxSizer(wx.VERTICAL)
        nvbox.Add(nhbox,-1, flag=wx.EXPAND)
        self.bodyPanel.SetSizer(nvbox)
        self.bodyPanel.Layout()

        vbox = wx.BoxSizer(wx.VERTICAL)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        for menuitem in menuItems:
            if  menuitem.get("visibility").strip().lower() == "true":
                btn = wx.Button(self,id = int(menuitem.get("key")), label =menuitem.get("des"), size=(100,80))
                btn.Bind(wx.EVT_BUTTON, self.menuHandler)
                hbox.Add(btn, flag=wx.LEFT|wx.BOTTOM|wx.ALIGN_CENTER_VERTICAL, border=0)
                hbox.Add((-1,10))
        vbox.Add(hbox,1, flag=wx.ALIGN_LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=1)
        self.SetAutoLayout(1)
        self.SetSizer(vbox)
        self.Layout()
        pass
Beispiel #5
0
def flatnotebook(parent,
                 paneldict,
                 panelkws={},
                 on_change=None,
                 drag_tabs=True,
                 selection=0):
    style = FNB_STYLE
    if not drag_tabs:
        style |= flat_nb.FNB_NODRAG

    nb = flat_nb.FlatNotebook(parent, agwStyle=style)
    nb.SetTabAreaColour(wx.Colour(250, 250, 250))
    nb.SetActiveTabColour(wx.Colour(254, 254, 195))
    nb.SetNonActiveTabTextColour(wx.Colour(10, 10, 128))
    nb.SetActiveTabTextColour(wx.Colour(128, 0, 0))
    nb.SetPadding(wx.Size(4, -1))
    nb.DeleteAllPages()
    nb.pagelist = []
    for name, creator in paneldict.items():
        _page = creator(parent=parent.GetParent(), **panelkws)
        nb.AddPage(_page, " %s " % name, True)
        nb.pagelist.append(_page)

    if callable(on_change):
        nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, on_change)

    nb.SetSelection(selection)
    return nb
    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()
Beispiel #7
0
 def makeTabs(self):
     self.pnl = wx.Panel(self, wx.ID_ANY)
     self.nb = fnb.FlatNotebook(self.pnl)
     self.nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnTabChange)
     # How many instances do we open right now?
     self.nins = 0
     self.ports = []
     for port in range(7490,7500):
         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         try:
             s.bind(("127.0.0.1", port))
         except Exception as e:
             self.ports.append(port)
         finally:
             s.close()
     self.tabs = []
     print(self.ports)
     self.master = None
     self.slavery = None
     for port in self.ports:
         name = "port %d" % port
         tab = Tab(self.nb, self, port=port, clientId = port-7497)
         self.tabs.append(tab)
         self.nb.AddPage(tab, name)
     self.sizer = wx.BoxSizer(wx.HORIZONTAL)
     st = wx.StaticText(self.pnl, label="Hi, {}".format(self.dlg.user.GetValue()), pos=(10,10))
     font = st.GetFont()
     font = font.Bold()
     st.SetFont(font)
     self.sizer_greet = wx.BoxSizer(wx.HORIZONTAL)
     self.sizer_greet.Add(st)
     self.sizer.Add(self.sizer_greet,0,wx.ALL|wx.EXPAND,3)
     self.sizer.Add(self.nb, 1, wx.EXPAND)
     self.pnl.SetSizer(self.sizer)
Beispiel #8
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 = fnb.FlatNotebook(self, style=fnb.FNB_NO_X_BUTTON|fnb.FNB_NO_NAV_BUTTONS)
        #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)
        self.nb.SetSelection(self.app.prefs.pageCurrent)
        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)
Beispiel #9
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

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

        bookstyle = fnb.FNB_NODRAG | fnb.FNB_SMART_TABS
        self.book = fnb.FlatNotebook(self, wx.ID_ANY, agwStyle=bookstyle)

        sizer.Add(self.book, 1, wx.ALL | wx.EXPAND)

        # Add some pages to the second notebook

        self.text = wx.TextCtrl(self.book,
                                -1,
                                SAMPLE_WIKI_TEXT,
                                style=wx.TE_MULTILINE)
        self.book.AddPage(self.text, "Edition")

        self.html = wx.html.HtmlWindow(self, -1, wx.DefaultPosition,
                                       wx.Size(400, 300))
        if "gtk2" in wx.PlatformInfo:
            self.html.SetStandardFonts()
        self.book.AddPage(self.html, "Preview")

        sizer.Layout()
        self.SendSizeEvent()

        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
        self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
    def __init__(self, parent, IDactivite=None, IDtarif=None):
        wx.Panel.__init__(self, parent, id=-1, style=wx.TAB_TRAVERSAL)
        self.parent = parent
        self.IDactivite = IDactivite
        self.IDtarif = IDtarif
        self.listePages = []

        # Validité
        self.notebook = FNB.FlatNotebook(self,
                                         -1,
                                         agwStyle=FNB.FNB_NO_TAB_FOCUS
                                         | FNB.FNB_NO_X_BUTTON)

        if self.GetGrandParent().GetName() == "notebook":
            couleur = self.GetGrandParent().GetThemeBackgroundColour()
            self.SetBackgroundColour(couleur)
            self.notebook.SetBackgroundColour(couleur)
            self.notebook.SetTabAreaColour(couleur)

        # Binds
        sizer_base = wx.BoxSizer(wx.VERTICAL)
        sizer_base.Add(self.notebook, 1, wx.EXPAND | wx.ALL, 10)
        self.SetSizer(sizer_base)
        sizer_base.Fit(self)

        # Init contrôles
        self.CreationPages()
Beispiel #11
0
    def __init__ (self, parent):
        super (TabsCtrl, self).__init__ (parent)

        self._tabs = fnb.FlatNotebook (self, agwStyle = (fnb.FNB_MOUSE_MIDDLE_CLOSES_TABS | 
            fnb.FNB_X_ON_TAB |
            fnb.FNB_DROPDOWN_TABS_LIST))

        self.__layout()
Beispiel #12
0
    def initComponents(self):
        self.tree = wx.TreeCtrl(self, id=-1, size=(200, -1))
        self.root = self.tree.AddRoot(ROOT_NAME)
        for url in URLS:
            self.tree.AppendItem(self.root, url)
        self.tree.Expand(self.root)

        self.tabs = fnb.FlatNotebook(self, wx.ID_ANY, agwStyle=fnb.FNB_NODRAG | fnb.FNB_X_ON_TAB)
    def test_lib_agw_flatnotebookMethods(self):
        nb = FNB.FlatNotebook(self.frame)
        p1 = wx.Panel(nb)
        nb.AddPage(p1, "Page1")
        p2 = wx.Panel(nb)
        nb.AddPage(p2, "Page2")

        nb.EnableTab(0, False)
        self.assertTrue(nb.GetEnabled(0) == False)
    def test_lib_agw_flatnotebookPages(self):
        nb = FNB.FlatNotebook(self.frame)
        p1 = wx.Panel(nb)
        nb.AddPage(p1, "Page1")
        p2 = wx.Panel(nb)
        nb.AddPage(p2, "Page2")
        nb.SetSelection(0)

        self.assertEqual(nb.GetSelection(), 0)
Beispiel #15
0
    def createMainPanel(self):
        self.SetTitle("Epics Scans")
        self.SetSize((750, 750))
        self.SetFont(Font(10))

        sizer = wx.BoxSizer(wx.VERTICAL)

        self.nb = flat_nb.FlatNotebook(self, wx.ID_ANY, agwStyle=FNB_STYLE)
        self.nb.SetSize((750, 600))
        self.nb.SetBackgroundColour('#FCFCFA')
        self.SetBackgroundColour('#F0F0E8')

        self.scanpanels = []
        self.scanpanel_types = []
        self.scanpanels_nid = {}
        inb = 0
        # Notebooks   scantype   title   panel
        creators = {
            'slew': SlewScanPanel,
            'xafs': XAFSScanPanel,
            'linear': LinearScanPanel
        }
        self.notebooks = (('slew', 'Map Scans'), ('xafs', 'XAFS Scans'),
                          ('linear', 'Linear Scans'))

        for stype, title in self.notebooks:
            span = creators[stype](self,
                                   scandb=self.scandb,
                                   pvlist=self.pvlist)
            self.nb.AddPage(span, title, True)
            self.scanpanels.append(span)
            self.scanpanel_types.append(stype)

        self.nb.SetSelection(0)
        sizer.Add(self.nb, 1, wx.ALL | wx.EXPAND)
        sizer.Add(wx.StaticLine(self, size=(675, 3), style=wx.LI_HORIZONTAL),
                  0, wx.EXPAND)

        btnsizer = wx.BoxSizer(wx.HORIZONTAL)
        btnpanel = wx.Panel(self)
        # bnames = ("Start", "Abort", "Pause", "Resume", "Debug")
        bnames = ("Start", "Abort", "Pause", "Resume")
        for ibtn, label in enumerate(bnames):
            btn = add_button(btnpanel,
                             "%s Scan" % label,
                             size=(120, -1),
                             action=Closure(self.onCtrlScan, cmd=label))
            btnsizer.Add(btn, 0, CEN, 8)
        pack(btnpanel, btnsizer)

        sizer.Add(btnpanel, 0, wx.ALIGN_LEFT | wx.ALL, 3)
        self.SetSizer(sizer)
        sizer.Fit(self)
        self.nb.SetSize((750, 675))
        self.SetSize((775, 700))
        self._icon = None
Beispiel #16
0
 def __init__(self, *args, **kwargs):
     super(StdoutTabPanel, self).__init__(*args, **kwargs)
     self.sizer = wx.BoxSizer(wx.VERTICAL)
     self.SetSizer(self.sizer)
     self.notebook = fnb.FlatNotebook(self,
                                      agwStyle=fnb.FNB_X_ON_TAB
                                      | fnb.FNB_NO_X_BUTTON
                                      | fnb.FNB_NO_TAB_FOCUS | fnb.FNB_VC8,
                                      pos=(-100, -100))
     self.sizer.Add(self.notebook, 1, wx.EXPAND | wx.ALL, 0)
Beispiel #17
0
 def __init__(self, *args, **kwargs):
     super(EditorTabPanel, self).__init__(*args, **kwargs)
     self.sizer = wx.BoxSizer(wx.VERTICAL)
     self.logger = wx.GetApp().logger
     self.SetSizer(self.sizer)
     self.notebook = fnb.FlatNotebook(self, agwStyle=fnb.FNB_X_ON_TAB |
                                     fnb.FNB_NO_X_BUTTON | fnb.FNB_NO_TAB_FOCUS | fnb.FNB_VC8,
                                     pos=(-100, -100))
     self.sizer.Add(self.notebook, 1, wx.EXPAND | wx.ALL, 0)
     self.new_tab(None) #TODO: Should open last tab
Beispiel #18
0
 def __init__(self, *args, **kwds):
     kwds['style'] = wx.DEFAULT_FRAME_STYLE
     wx.Frame.__init__(self, *args, **kwds)
     self.sizer = wx.BoxSizer(wx.HORIZONTAL)
     self.SetSizer(self.sizer)
     tb = wx.ToolBar(self, style=wx.TB_3DBUTTONS | wx.TB_TEXT)
     tb.SetToolBitmapSize((32, 32))
     self.SetToolBar(tb)
     btn1 = tb.AddLabelTool(-1,
                            label="Update and exit",
                            bitmap=wxtbx.bitmaps.fetch_icon_bitmap(
                                "actions", "button_ok"),
                            kind=wx.ITEM_NORMAL)
     btn2 = tb.AddLabelTool(-1,
                            label="Update settings",
                            bitmap=wxtbx.bitmaps.fetch_icon_bitmap(
                                "actions", "redo"),
                            kind=wx.ITEM_NORMAL)
     btn3 = tb.AddLabelTool(-1,
                            label="Cancel",
                            bitmap=wxtbx.bitmaps.fetch_icon_bitmap(
                                "actions", "cancel"),
                            kind=wx.ITEM_NORMAL)
     btn4 = tb.AddLabelTool(-1,
                            label="Delete all",
                            bitmap=wxtbx.bitmaps.fetch_icon_bitmap(
                                "actions", "editdelete"),
                            kind=wx.ITEM_NORMAL)
     self.Bind(wx.EVT_MENU, self.OnExit, btn1)
     self.Bind(wx.EVT_MENU, self.OnUpdate, btn2)
     self.Bind(wx.EVT_MENU, self.OnCancel, btn3)
     self.Bind(wx.EVT_MENU, self.OnClearAll, btn4)
     tb.Realize()
     self.statusbar = self.CreateStatusBar()
     self.statusbar.SetStatusText("No restraints loaded.")
     self.nb = flatnotebook.FlatNotebook(
         parent=self,
         agwStyle=flatnotebook.FNB_TABS_BORDER_SIMPLE
         | flatnotebook.FNB_NODRAG | flatnotebook.FNB_NO_X_BUTTON
         | flatnotebook.FNB_NO_NAV_BUTTONS)
     self.bonds_panel = CustomBondPanel(self.nb,
                                        style=ATOM_SELECTION_BUTTONS)
     self.angles_panel = CustomAnglePanel(self.nb,
                                          style=ATOM_SELECTION_BUTTONS)
     self.planes_panel = CustomPlanarityPanel(self.nb,
                                              style=ATOM_SELECTION_BUTTONS)
     self.nb.AddPage(self.bonds_panel, "Bonds")
     self.nb.AddPage(self.angles_panel, "Angles")
     self.nb.AddPage(self.planes_panel, "Planes")
     self.sizer.Add(self.nb, 1, wx.EXPAND | wx.ALL)
     self.sizer.Fit(self.nb)
     self.Fit()
     self.Bind(wx.EVT_CLOSE, lambda evt: self.Destroy(), self)
     self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy, self)
     self._index = self._params = self._prefix = None
    def test_lib_agw_flatnotebookDeletePages(self):
        nb = FNB.FlatNotebook(self.frame)
        p1 = wx.Panel(nb)
        nb.AddPage(p1, "Page1")
        p2 = wx.Panel(nb)
        nb.AddPage(p2, "Page2")
        nb.DeleteAllPages()

        self.assertEqual(nb.GetPageCount(), 0)

        nb = FNB.FlatNotebook(self.frame)
        p1 = wx.Panel(nb)
        nb.AddPage(p1, "Page1")
        p2 = wx.Panel(nb)
        nb.AddPage(p2, "Page2")

        for index in range(nb.GetPageCount() - 1, -1, -1):
            nb.DeletePage(index)

        self.assertEqual(nb.GetPageCount(), 0)
Beispiel #20
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "FlatNotebook Demo")
        panel = wx.Panel(self)
        notebook = fnb.FlatNotebook(panel, -1)
        for i in range(3):
            caption = "Page %d" % (i + 1)
            notebook.AddPage(self.CreatePage(notebook, caption), caption)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(notebook, 1, wx.ALL | wx.EXPAND, 5)
        panel.SetSizer(sizer)
Beispiel #21
0
    def _LayoutItems(self):
        """ Layout """
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(mainSizer)
        bookStyle = fnb.FNB_FANCY_TABS
        self.book = fnb.FlatNotebook(self, wx.ID_ANY, style=bookStyle)
        bookStyle &= ~(fnb.FNB_NODRAG)
        bookStyle |= fnb.FNB_ALLOW_FOREIGN_DND

        mainSizer.Add(self.book, 6, wx.EXPAND)
        mainSizer.Layout()
        self.SendSizeEvent()
Beispiel #22
0
    def __init__(self, parent):
        wx.Frame.__init__(
            self,
            parent,
            id=wx.ID_ANY,
            title=f"Amulet V{__version__}",
            pos=wx.DefaultPosition,
            size=wx.Size(560, 400),
            style=wx.CAPTION
            | wx.CLOSE_BOX
            | wx.MINIMIZE_BOX
            | wx.MAXIMIZE_BOX
            | wx.MAXIMIZE
            | wx.SYSTEM_MENU
            | wx.TAB_TRAVERSAL
            | wx.CLIP_CHILDREN
            | wx.RESIZE_BORDER,
        )
        self.locale = wx.Locale(
            wx.LANGUAGE_ENGLISH
        )  # TODO: work out proper localisation
        icon = wx.Icon()
        icon.CopyFromBitmap(image.logo.icon128.bitmap())
        self.SetIcon(icon)

        self._open_worlds: Dict[str, CLOSEABLE_PAGE_TYPE] = {}

        self.world_tab_holder = flatnotebook.FlatNotebook(
            self, agwStyle=NOTEBOOK_MENU_STYLE
        )

        self.world_tab_holder.Bind(
            flatnotebook.EVT_FLATNOTEBOOK_PAGE_CLOSING, self._on_page_close
        )

        self._main_menu = AmuletMainMenu(self.world_tab_holder, self._open_world)

        self._last_page: BasePageUI = self._main_menu

        self._add_world_tab(self._main_menu, lang.get("main_menu.tab_name"))

        self.Bind(wx.EVT_CLOSE, self._on_close_app)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self._page_change)

        if update_check:
            self.Bind(
                update_check.EVT_UPDATE_CHECK,
                lambda evt: update_check.show_update_window(self, __version__, evt),
            )
            update_check.check_for_update(__version__, self)

        self.Show()
Beispiel #23
0
    def create_ui(self):
        """
        Create UI in main panel
        """
        self.main_sizer = wx.BoxSizer(wx.VERTICAL)

        # Add leaderboard button
        btn_sizer = wx.BoxSizer()
        bmp = wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK, wx.ART_TOOLBAR,
                                       (16, 16))
        self.leaderboard_btn = wx.ToggleButton(self, size=(40, 40))
        self.leaderboard_btn.SetBitmap(bmp)
        self.leaderboard_btn.Bind(wx.EVT_TOGGLEBUTTON, self.on_leaderboard)
        btn_sizer.AddStretchSpacer(prop=2)
        btn_sizer.Add(self.leaderboard_btn, 0, wx.ALL, 5)
        self.main_sizer.Add(btn_sizer, 0, wx.EXPAND)

        # Add notebook
        hsizer = wx.BoxSizer(wx.HORIZONTAL)
        self.notebook = fnb.FlatNotebook(self)
        style = self.notebook.GetAGWWindowStyleFlag()
        style |= fnb.FNB_NO_X_BUTTON
        self.notebook.SetAGWWindowStyleFlag(style)
        self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_tab_change)

        for tab in range(8):
            tab_panel = FilePanel(self.notebook)
            self.notebook.AddPage(tab_panel, f'File {tab+1}')
        hsizer.Add(self.notebook, 2, wx.ALL | wx.EXPAND, 5)

        # Add leaderboard widget (HtmlWindow)
        self.leaderboard = Leaderboard(self)
        self.leaderboard.SetPage('''
            <h2>Leaderboard</h2>
            ''')
        hsizer.Add(self.leaderboard, 1, wx.ALL | wx.EXPAND, 5)
        self.leaderboard.Hide()
        self.main_sizer.Add(hsizer, 1, wx.ALL | wx.EXPAND)

        # Add counters
        self.current_count = wx.StaticText(
            self, label='Current: Characters: 0 / Words: 0')
        self.main_sizer.Add(self.current_count, 0, wx.TOP | wx.LEFT, 5)
        self.remaining = wx.StaticText(
            self, label='Remaining: Characters: 5000 / Words 2500')
        self.main_sizer.Add(self.remaining, 0, wx.LEFT, 5)
        target = wx.StaticText(self,
                               label='(Target: 5000 Characters / 2500 Words)')
        self.main_sizer.Add(target, 0, wx.LEFT | wx.BOTTOM, 5)

        self.SetSizer(self.main_sizer)
        self.main_sizer.Layout()
Beispiel #24
0
    def __init__(self, parent, text_list, page_names, num_dirs=2, **kwargs):
        """
        Args:
            parent:
                Parent Widget.
            text_list:
                List of strings. Each string is displayed in its own page in the notebook.
            page_names:
                List of strings giving the name of the tab for each string in text_list.
            num_dirs:
                Maximum number of directories that will be shown in the tab.
        """
        super(TextNotebookFrame, self).__init__(parent, **add_size(kwargs))

        # Add the pages to the notebook with the name to show on the tab
        if not isinstance(text_list, (list, tuple)):
            text_list = [text_list]

        if not isinstance(page_names, (list, tuple)):
            page_names = [page_names]

        assert len(page_names) == len(text_list)

        # Here we create a panel and a notebook on the panel
        nb_panel = awx.Panel(self)

        try:
            style = fnb.FNB_X_ON_TAB | fnb.FNB_NAV_BUTTONS_WHEN_NEEDED
        except AttributeError:
            style = fnb.FNB_X_ON_TAB

        nb = fnb.FlatNotebook(nb_panel, style=style)

        for page_name, text in zip(page_names, text_list):
            page = wx.TextCtrl(nb,
                               -1,
                               text,
                               style=wx.TE_MULTILINE | wx.TE_LEFT
                               | wx.TE_READONLY)

            if num_dirs > 0:
                tokens = page_name.split(os.path.sep)
                page_name = os.path.join(*tokens[-num_dirs:])

            nb.AddPage(page, text=page_name)

        # Finally, put the notebook in a sizer for the nb_panel to manage the layout
        sizer = wx.BoxSizer()
        sizer.Add(nb, 1, wx.EXPAND)

        nb_panel.SetSizerAndFit(sizer)
Beispiel #25
0
    def initComponents(self):
        self.tree = wx.TreeCtrl(self, id=-1, size=(200, -1))
        self.root = self.tree.AddRoot(ROOT_NAME)
        for url in URLS:
            self.tree.AppendItem(self.root, url)
        self.tree.Expand(self.root)

        self.tabs = fnb.FlatNotebook(self,
                                     wx.ID_ANY,
                                     agwStyle=fnb.FNB_NODRAG
                                     | fnb.FNB_X_ON_TAB)
        # You also have to set the wx.WANTS_CHARS style for
        # all parent panels/controls, if it's deeply embedded.
        self.tabs.SetWindowStyleFlag(wx.WANTS_CHARS)
Beispiel #26
0
    def __init__(self, parent, size=(675, 525)):
        self.parent = parent
        self.larch = parent.larch
        self.mca = parent.mca
        conf = parent.conf
        self.paramgroup = Group()

        if not hasattr(self.mca, 'init_calib'):
            xrf_calib_fitrois(self.mca, _larch=self.larch)

        wx.Frame.__init__(self,
                          parent,
                          -1,
                          'Fit XRF Spectra',
                          size=size,
                          style=wx.DEFAULT_FRAME_STYLE)
        if not hasattr(self.parent, 'filters_data'):
            self.parent.filters_data = read_filterdata(self.Filter_Materials,
                                                       _larch=self.larch)

        self.wids = Empty()
        self.SetFont(Font(9))
        self.panels = {}
        self.nb = flat_nb.FlatNotebook(self, wx.ID_ANY, agwStyle=FNB_STYLE)
        self.nb.SetBackgroundColour('#FBFBF8')
        self.SetBackgroundColour('#F6F6F0')

        self.nb.AddPage(self.settings_page(), 'Fit & Background Settings')
        self.nb.AddPage(self.filters_page(), 'Filters and Attenuation')
        self.nb.AddPage(self.fitpeaks_page(), 'XRF Peaks')

        self.nb.SetSelection(0)

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

        sizer.Add((5, 5))
        sizer.Add(HLine(self, size=(675, 3)), 0, CEN | LEFT | wx.TOP | wx.GROW)
        sizer.Add((5, 5))

        bpanel = RowPanel(self)
        bpanel.Add(Button(bpanel, 'Fit Peaks', action=self.onFitPeaks), 0,
                   LEFT)
        bpanel.Add(Button(bpanel, 'Done', action=self.onClose), 0, LEFT)
        bpanel.pack()
        sizer.Add(bpanel, 0, CEN)
        pack(self, sizer)
        self.Show()
        self.Raise()
Beispiel #27
0
    def __init__(self, parent, filenames, num_dirs=2, **kwargs):
        """
        Args:
            parent:
                Parent Widget.
            filenames:
                List of filenames.
            num_dirs:
                Maximum number of directories that will be shown in the tab.
        """
        if "title" not in kwargs:
            kwargs["title"] = "Abinit Events"

        super(AbinitEventsNotebookFrame, self).__init__(parent, **kwargs)

        filenames = list_strings(filenames)

        # Remove inexistent files.
        filenames = filter(os.path.exists, filenames)

        if not filenames:
            return

        # Here we create a panel and a notebook on the panel
        panel = awx.Panel(self)

        nb = fnb.FlatNotebook(panel)

        for fname in filenames:
            page = AbinitEventsPanel(nb, fname)
            page_name = fname

            if num_dirs > 0:
                tokens = page_name.split(os.path.sep)
                page_name = os.path.join(*tokens[-num_dirs:])

            # Add only files for which we have events.
            #if page.has_events:

            # Add the pages to the notebook with the name to show on the tab
            nb.AddPage(page, text=page_name)

        # Finally, put the notebook in a sizer for the panel to manage the layout
        sizer = wx.BoxSizer()
        sizer.Add(nb, 1, wx.EXPAND)

        panel.SetSizerAndFit(sizer)
Beispiel #28
0
    def AjouterRubrique(self, code=""):
        # Recherche du dictRubrique
        indexRubrique = 0
        for dictRubrique in self.listeObjets:
            if dictRubrique["visible"] == True:
                if dictRubrique["code"] == code:
                    dictRubrique["visible"] = True
                    break
                indexRubrique += 1

        # Création du notebook
        flatNoteBook = FNB.FlatNotebook(self.ctrl_labelbook,
                                        -1,
                                        agwStyle=FNB.FNB_BOTTOM
                                        | FNB.FNB_NO_TAB_FOCUS
                                        | FNB.FNB_NO_X_BUTTON)
        flatNoteBook.SetTabAreaColour(self.couleurFond)

        # Mémorise le ctrl flatNoteBook
        self.listeObjets[indexRubrique]["ctrl_notebook"] = flatNoteBook

        # Création des pages
        listePages = []
        indexPage = 0
        for dictPage in dictRubrique["pages"]:
            if dictPage["visible"] == True:

                ctrl_html = MyHtml(flatNoteBook)
                flatNoteBook.AddPage(ctrl_html, dictPage["nom"])
                self.listeObjets[indexRubrique]["pages"][indexPage][
                    "ctrl_html"] = ctrl_html
                listePages.append(dictPage["code"])
                indexPage += 1

        # Ajoute le notebook au labelbook
        self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnChangeNotebook,
                  flatNoteBook)
        if self.dictImages.has_key(dictRubrique["code"]):
            indexImage = self.dictImages[dictRubrique["code"]]["index"]
        else:
            indexImage = -1
        self.ctrl_labelbook.AddPage(flatNoteBook,
                                    dictRubrique["nom"],
                                    imageId=indexImage)
        ##        self.ctrl_labelbook.InsertPage(indexRubrique, flatNoteBook, dictRubrique["nom"], imageId=-1)

        self.listeContenu.append((dictRubrique["code"], listePages))
Beispiel #29
0
    def load_widgets(self):

        self.notebook = Notebook_Widget.FlatNotebook(self, wx.ID_ANY)

        self.notebook.SetAGWWindowStyleFlag(Notebook_Widget.FNB_NO_X_BUTTON)
        self.notebook.SetAGWWindowStyleFlag(Notebook_Widget.FNB_NO_NAV_BUTTONS)
        self.notebook.SetAGWWindowStyleFlag(Notebook_Widget.FNB_NODRAG)

        self.dirTree = wx.TreeCtrl(self.notebook, wx.ID_ANY,
                                   wx.DefaultPosition, wx.DefaultSize,
                                   wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT)
        self.dirTree.Bind(wx.EVT_TREE_SEL_CHANGED, self.updateEditorContent)
        self.updateDirTree()

        self.notebook.AddPage(self.dirTree, "Project")

        self.editor = stc.StyledTextCtrl(
            self.notebook, style=wx.TE_MULTILINE | wx.TE_WORDWRAP)
        self.editor.CmdKeyAssign(
            ord("+"), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN)
        self.editor.CmdKeyAssign(
            ord("-"), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
        self.editor.SetViewWhiteSpace(False)
        self.editor.SetMargins(50, 50)
        self.editor.SetMarginType(2, stc.STC_MARGIN_NUMBER)
        self.editor.SetMarginWidth(2, 35)
        self.editor.SetMarginLeft(10)
        # self.editor.SetMarginType(
        #     2, stc.STC_MARGIN_SYMBOL | stc.STC_MARGIN_NUMBER)
        # self.editor.SetMarginMask(2, stc.STC_MASK_FOLDERS)
        # self.editor.SetMarginSensitive(2, True)
        # self.editor.SetMarginWidth(2, 35)
        self.editor.SetProperty("fold", "1")
        self.editor.SetProperty("tab.timmy.whinge.level", "1")
        self.editor.SetEdgeMode(stc.STC_EDGE_BACKGROUND)
        self.editor.SetEdgeColumn(78)
        self.editor.Bind(wx.EVT_KEY_UP, self.editor_keyup)
        self.editor.SetValue("import __hello__")
        self.editor.SetIndent(4)
        self.editor.SetUseHorizontalScrollBar(False)

        Highlighter.python(editor=self.editor)
        self.file_ext = ".py"

        self.notebook.AddPage(self.editor, "Editor")
        self.notebook.SetSelection(1)
Beispiel #30
0
 def __init__(self, *args, **kwds):
     wx.MiniFrame.__init__(self, *args, **kwds)
     #self.panel = wx.Panel(self)
     self.nb = fnb.FlatNotebook(
         parent=self,
         agwStyle=fnb.FNB_FF2 | fnb.FNB_NO_NAV_BUTTONS | fnb.FNB_NO_X_BUTTON
         | fnb.FNB_NODRAG)
     self.sizer = wx.BoxSizer(wx.VERTICAL)
     self.sizer.Add(self.nb, 1)
     self.SetSizer(self.sizer)
     #self.panel_sizer = wx.BoxSizer(wx.VERTICAL)
     #self.panel.SetSizer(self.panel_sizer)
     self._panels = {}
     self._errors = {}
     self.timer = None
     self.Bind(wx.EVT_CLOSE, self.OnClose)
     self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)