def __init__(self, parent, wfk, **kwargs): """ Args: parent: parent window. wfk: """ super(WfkFileTab, self).__init__(parent, -1, **kwargs) self.wfk = wfk splitter = wx.SplitterWindow(self, id=-1, style=wx.SP_3D) splitter.SetSashGravity(0.95) self.skb_panel = skb_panel = SpinKpointBandPanel( splitter, wfk.structure, wfk.nsppol, wfk.kpoints, wfk.mband) # Set the callback for double click on k-point row.. self.Bind(skb_panel.MYEVT_SKB_ACTIVATED, self.onVisualizeSKB) # Add Python shell msg = "WFK_File object is accessible via the wfk variable. Use wfk.<TAB> to access the list of methods." msg = marquee(msg, width=len(msg) + 8, mark="#") msg = "#" * len(msg) + "\n" + msg + "\n" + "#" * len(msg) + "\n" # FIXME <Error>: CGContextRestoreGState: invalid context 0x0 pyshell = Shell(splitter, introText=msg, locals={"wfk": self.wfk}) splitter.SplitHorizontally(self.skb_panel, pyshell) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(splitter, 1, wx.EXPAND, 5) self.SetSizerAndFit(sizer)
def __init__(self, parent, sigres, **kwargs): """ Args: parent: parent window. sigres: `SigresFile` object """ super(SigresFileTab, self).__init__(parent, -1, **kwargs) self.sigres = sigres splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE) splitter.SetSashGravity(0.95) self.skb_panel = SpinKpointBandPanel(splitter, sigres.structure, sigres.nsppol, sigres.gwkpoints, sigres.max_gwbstop, bstart=sigres.min_gwbstart) # Set the callback for double click on k-point row.. self.Bind(self.skb_panel.MYEVT_SKB_ACTIVATED, self.onShowQPTable) # Add Python shell msg = "SIGRES_File object is accessible via the sigres variable. Use sigres.<TAB> to access the list of methods." msg = marquee(msg, width=len(msg) + 8, mark="#") msg = "#"*len(msg) + "\n" + msg + "\n" + "#"*len(msg) + "\n" pyshell = Shell(splitter, introText=msg, locals={"sigres": sigres}) splitter.SplitHorizontally(self.skb_panel, pyshell) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(splitter, 1, wx.EXPAND, 5) self.SetSizerAndFit(sizer)
def __init__(self, parent, mdf_file, **kwargs): """ Args: parent: parent window. mdf_file: """ super(MdfFileTab, self).__init__(parent, -1, **kwargs) self.mdf_file = mdf_file splitter = wx.SplitterWindow(self, id=-1, style=wx.SP_3D) splitter.SetSashGravity(0.95) self.qpoints_panel = MdfQpointsPanel(splitter, mdf_file) # Add Python shell msg = "MDF_object is accessible via the mdf_file variable. Use mdf_file.<TAB> to access the list of methods." msg = marquee(msg, width=len(msg) + 8, mark="#") msg = "#" * len(msg) + "\n" + msg + "\n" + "#" * len(msg) + "\n" # FIXME <Error>: CGContextRestoreGState: invalid context 0x0 pyshell = Shell(splitter, introText=msg, locals={"mdf_file": mdf_file}) splitter.SplitHorizontally(self.qpoints_panel, pyshell) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(splitter, 1, wx.EXPAND, 5) self.SetSizerAndFit(sizer)
def __init__(self, parent): self.__layout_frame = parent self.__context = parent.GetContext() # create GUI wx.Frame.__init__(self, parent, -1, 'Python Console', size=(500, 300), style=wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | wx.CAPTION | wx.CLOSE_BOX | wx.SYSTEM_MENU) menu_bar = wx.MenuBar() menu = wx.Menu() menu_run_script = menu.Append(wx.NewId(), '&Run Script\tAlt-R', 'Run a script in the console.') menu_bar.Append(menu, '&Shell') self.SetMenuBar(menu_bar) self.__shell = Shell(self) # set up what user is given to work with self.__shell.interp.locals = {'context': self.__context} self.Bind(wx.EVT_CLOSE, lambda evt: self.Hide()) # Hide instead of closing self.Bind(wx.EVT_MENU, self.OnRunScript)
def __init__(self, parent, gsr, **kwargs): """ Args: parent: parent window. gsr: `GsrFile` instance. """ super(GsrFileTab, self).__init__(parent, -1, **kwargs) self.gsr = gsr splitter = wx.SplitterWindow(self, id=-1, style=wx.SP_3D) splitter.SetSashGravity(0.95) self.kpoints_panel = KpointsPanel(splitter, gsr.structure, gsr.kpoints) # Add Python shell msg = "GSR_File object is accessible via the gsr variable. Use gsr.<TAB> to access the list of methods." msg = marquee(msg, width=len(msg) + 8, mark="#") msg = "#" * len(msg) + "\n" + msg + "\n" + "#" * len(msg) + "\n" pyshell = Shell(splitter, introText=msg, locals={"gsr": self.gsr}) splitter.SplitHorizontally(self.kpoints_panel, pyshell) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(splitter, 1, wx.EXPAND, 5) self.SetSizerAndFit(sizer)
def __init__(self, parent, phbst, **kwargs): """ Args: parent: parent window. phbst: `PhbstFile` instance. """ super(PhbstFileTab, self).__init__(parent, -1, **kwargs) self.phbst = phbst self.phdos_file = None splitter = wx.SplitterWindow(self, id=-1, style=wx.SP_3D) splitter.SetSashGravity(0.95) self.qpoints_panel = KpointsPanel(splitter, phbst.structure, phbst.qpoints) # Add Python shell msg = "PHBST_File object is accessible via the phbst variable. Use phbst.<TAB> to access the list of methods." msg = marquee(msg, width=len(msg) + 8, mark="#") msg = "#"*len(msg) + "\n" + msg + "\n" + "#"*len(msg) + "\n" pyshell = Shell(splitter, introText=msg, locals={"phbst": self.phbst}) splitter.SplitHorizontally(self.qpoints_panel, pyshell) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(splitter, 1, wx.EXPAND, 5) self.SetSizerAndFit(sizer)
def __init__(self, parent=None, id=-1, locals=None): wx.Panel.__init__(self, parent, id) self.shell = Shell(parent=self, locals=locals) #self.crust= Crust(parent=self,locals=locals) #self.shell = self.crust.shell #self.shell.SetSize(wxSize(800,100)) EVT_SIZE(self, self.OnSize)
def CreateShell(self): ctrl=Shell(parent=self) ctrl.redirectStdout(redirect=True) ctrl.redirectStdin(redirect=True) ctrl.redirectStderr(redirect=True) init_printing(use_unicode=False) return ctrl
def __init__(self, parent): wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) shell = Shell(self, locals=cmds) bSizer = wx.BoxSizer( wx.VERTICAL ) bSizer.Add( shell, 1, wx.EXPAND|wx.ALL, 5 ) self.SetSizer(bSizer) cmds['plgs'] = Macros() shell.run('# numpy(np) and scipy.ndimage(ndimg) has been imported!\n') shell.run('# plgs.run_name() to call a ImagePy plugin.\n') shell.run('# IPy is avalible here, and curips() to get the current ImagePlus, update() to redraw.\n')
def __init__(self, parent): wx.Panel.__init__(self, parent) self.intro = "Interactive Phase Retrieval Suite" self.shell = Shell(parent=self, id=wx.ID_ANY, introText=self.intro) self.shell.zoom(2) self.shell.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown, self.shell) self.ih = 0 sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.shell, 1, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border=2) sizer.Fit(self) self.SetSizer(sizer) self.SetAutoLayout(True) self.Layout()
def __init__(self, parent=None): """ConsoleWindow(parent=None) -> wx.MDIChildFrame""" super(ConsoleWindow, self).__init__(parent, title=self.title, style=wx.DEFAULT_FRAME_STYLE) self.parent = parent self.namespace = { '__name__': '__main__', 'print': lambda *args, **kwargs: print(*args, **kwargs, file=self.console), 'input': self.parent.InputFunc } self.console = Shell(self) self.Bind(wx.EVT_CLOSE, self.OnClose) self.Show(False)
def __init__(self, scrapefile, win, parent=None, *a, **kw): """ @param scrapefile the config file to use @param win the window object (may be none) """ super(ConfigBuilder, self).__init__(parent, *a, **kw) self.SetTitle("profile builder: %s" % scrapefile) self.win = win self.scrapefile = scrapefile self.use_simple = True self.bmp = wx.StaticBitmap(self, size=(win.size if win else (792, 546))) # @TODO: parametrize vars = {'self': self} vars.update(self.__dict__) self.shell = Shell(self, locals = vars, introText="SnakeEyes v0.0a\n") self.shell.AppendText("REF: ''.join(sorted(self.scraper['chat_box'].tool.font.data.values()))") self.refresh = wx.Button(self, wx.NewId(), "refresh") self.refresh.Bind(wx.EVT_BUTTON, self.on_refresh_button) self.make_scraper() self.live_data = ScrapeDataCtrl(self.scraper, self) self.live_data.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_item) if self.win is None: self.ticking = False else: self.timer = wx.Timer() self.timer.Bind(wx.EVT_TIMER, self.on_tick) self.ticking = True self.timer.Start(500, wx.TIMER_CONTINUOUS) # this is just so the mono image stands out self.SetBackgroundColour(wx.Colour(0x33, 0x33, 0x99)) self.SetForegroundColour(wx.Colour(0xFF, 0xFF, 0xFF)) self.values = {} self.layout() self.Show()
def __init__(self, parent): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) cmds['app'] = parent cmds['get_img'] = lambda name=None, app=self: self.app.get_img() cmds['update'] = lambda app=self: self.app.get_img().update() shell = Shell(self, locals=cmds) bSizer = wx.BoxSizer(wx.VERTICAL) bSizer.Add(shell, 1, wx.EXPAND | wx.ALL, 5) self.SetSizer(bSizer) cmds['plgs'] = Macros() shell.run('# plgs.run_name() to call a ImagePy plugin.\n') shell.run( '# app is avalible here, and get_img() to get the current ImagePlus, update() to redraw.\n' )
def __init__(self, parent): wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) sh = wx.BoxSizer(wx.VERTICAL) sh.Add(Shell(self, -1), -1, wx.ALL|wx.EXPAND, border = 0) self.SetSizer(sh)
def __init__(self, config): wx.Frame.__init__(self, None, id=wx.ID_ANY, title=tourbillon.__nom__, size=(640, 400), style=wx.DEFAULT_FRAME_STYLE) self.SetBackgroundColour(images.couleur('grille')) self.config = config # Création d'un gestionnaire de fenetres pour la gestion des fenêtres flottantes self._mgr = aui.AuiManager( self, aui.AUI_MGR_ALLOW_FLOATING | aui.AUI_MGR_TRANSPARENT_HINT | aui.AUI_MGR_TRANSPARENT_DRAG | aui.AUI_MGR_ALLOW_ACTIVE_PANE) # Fenêtre informations montrée self.fenetre_affichage = dlginfo.DialogueInformations( self, self.config) self.affichage_visible = False self.fenetre_affichage.Bind(wx.EVT_CLOSE, self.masquer_info) # Icon self.SetIcon(images.TourBillon_icon()) # Créer la barre de menu self.barre_menu = barres.BarreMenu(self) self.SetMenuBar(self.barre_menu) # Créer la barre de statut self.barre_etat = barres.BarreEtat(self) self.SetStatusBar(self.barre_etat) # Créer la barre des boutons (pas la guerre) self.barre_bouton = barres.BarreBouton(self) self._mgr.AddPane( self.barre_bouton, aui.AuiPaneInfo().Name("controles").Top().CaptionVisible( False).MinSize(wx.Size(-1, 60)).DockFixed().Floatable(False)) # Créer la grille if self.config.get_typed('INTERFACE', 'image'): chemin_image = glob(configdir('fond_perso*'))[0] else: chemin_image = "" self.grille = grl.GrillePanel(self, images.bitmap(chemin_image)) self.barre_menu.FindItemById(barres.ID_STATISTIQUES).Check( self.config.get_typed('INTERFACE', 'afficher_statistiques')) self.afficher_statistiques(None) self._mgr.AddPane(self.grille, aui.AuiPaneInfo().Name("grille").CenterPane()) # Creation d'un shell Python (utile pour le debug) self.shell = Shell(self, introText='', locals={ 'intf': self, 'trb': tournoi.tournoi(), 'cfg': self.config, 'cst': cst }, InterpClass=None, startupScript=None, execStartupScript=True) self.shell.SetSize((600, 200)) self._mgr.AddPane( self.shell, aui.AuiPaneInfo().Name('shell').Caption("Python Shell").Bottom(). CloseButton(True).MaximizeButton(True).Hide()) self.barre_menu.FindItemById(barres.ID_SHELL).Check( self.config.get_typed('INTERFACE', 'afficher_shell')) self.afficher_shell(None) # Effectuer les connections sur les evenements # ... de la barre de menu self.Bind(wx.EVT_MENU, self.nouveau, id=wx.ID_NEW) self.Bind(wx.EVT_MENU, self.ouvrir_demande, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.enregistrer, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.enregistrer_sous, id=wx.ID_SAVEAS) self.Bind(wx.EVT_MENU, self.apercu_avant_impression, id=wx.ID_PREVIEW_PRINT) self.Bind(wx.EVT_MENU, self.imprimer, id=wx.ID_PRINT) self.Bind(wx.EVT_MENU, self.quitter, id=wx.ID_EXIT) self.Bind(wx.EVT_MENU, self.afficher_statistiques, id=barres.ID_STATISTIQUES) self.Bind(wx.EVT_MENU, self.afficher_info, id=barres.ID_INFO) self.Bind(wx.EVT_MENU, self.afficher_tirage, id=barres.ID_TIRAGE) self.Bind(wx.EVT_MENU, self.afficher_shell, id=barres.ID_SHELL) self.Bind(wx.EVT_MENU, self.nouvelle_equipe, id=barres.ID_NOUVELLE_E) self.Bind(wx.EVT_MENU, self.modifier_equipe, id=barres.ID_MODIFIER_E) self.Bind(wx.EVT_MENU, self.supprimer_equipe, id=barres.ID_SUPPRIMER_E) self.Bind(wx.EVT_MENU, self.nouvelle_partie, id=barres.ID_NOUVELLE_P) self.Bind(wx.EVT_MENU, self.supprimer_partie, id=barres.ID_SUPPRIMER_P) self.Bind(wx.EVT_MENU, self.entrer_resultats, id=barres.ID_RESULTATS) self.Bind(wx.EVT_MENU, self.classement, id=barres.ID_CLASSEMENT) self.Bind(wx.EVT_MENU, self.preferences, id=wx.ID_PREFERENCES) self.Bind(wx.EVT_MENU, self.info_systeme, id=wx.ID_PROPERTIES) self.Bind(wx.EVT_MENU, self.a_propos_de, id=wx.ID_ABOUT) # ... de la barre de contrôle self.Bind(wx.EVT_BUTTON, self.afficher_partie_prec, self.barre_bouton.btn_precedente) self.Bind(wx.EVT_BUTTON, self.afficher_partie_suiv, self.barre_bouton.btn_suivante) self.Bind(wx.EVT_BUTTON, self.enregistrer, id=wx.ID_SAVE) self.Bind(wx.EVT_BUTTON, self.afficher_info, id=barres.ID_INFO) self.Bind(wx.EVT_BUTTON, self.afficher_tirage, id=barres.ID_TIRAGE) self.Bind(wx.EVT_BUTTON, self.nouvelle_equipe, id=barres.ID_NOUVELLE_E) self.Bind(wx.EVT_BUTTON, self.nouvelle_partie, id=barres.ID_NOUVELLE_P) self.Bind(wx.EVT_BUTTON, self.entrer_resultats, id=barres.ID_RESULTATS) self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.grille.rechercher_suivant, id=wx.ID_FIND) self.Bind(wx.EVT_TEXT_ENTER, self.grille.rechercher_suivant, id=wx.ID_FIND) self.Bind(wx.EVT_TEXT, self.grille.rechercher, id=wx.ID_FIND) self.Bind(evt.EVT_MENU_RECHERCHE, self.grille.chg_recherche_colonne, self.barre_bouton) # ... des autres événements self.Bind(wx.EVT_CLOSE, self.quitter) self.Bind(aui.EVT_AUI_PANE_CLOSE, self.masquer_shell) self.Bind(evt.EVT_RAFRAICHIR, self.rafraichir) self.grille.Bind(grl.grid.EVT_GRID_CELL_LEFT_DCLICK, self.grille_double_click) self.grille.Bind(grl.grid.EVT_GRID_CELL_RIGHT_CLICK, self.grille_contexte) self.grille.Bind(wx.EVT_KEY_DOWN, self.grille_enter) # Rafraichir self._mgr.Update() self.Layout() wx.PostEvent(self, evt.RafraichirEvent(self.GetId()))