我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.App()。
def wxPythonApp(): import wx app = wx.App() frame = wx.Frame(None, -1, "wxPython GUI", size=(200,150)) frame.SetBackgroundColour('white') frame.CreateStatusBar() menu= wx.Menu() menu.Append(wx.ID_ABOUT, "About", "wxPython GUI") menuBar = wx.MenuBar() menuBar.Append(menu,"File") frame.SetMenuBar(menuBar) frame.Show() runT = Thread(target=app.MainLoop) runT.setDaemon(True) runT.start() print(runT) print('createThread():', runT.isAlive())
def _build_menu_bar(self): self.menuBar = wx.MenuBar() # File menu file_menu = wx.Menu() wx.App.SetMacExitMenuItemId(wx.ID_EXIT) exit_item = file_menu.Append(wx.ID_EXIT, "E&xit\tCtrl-Q", "Exit NodeMCU PyFlasher") exit_item.SetBitmap(images.Exit.GetBitmap()) self.Bind(wx.EVT_MENU, self._on_exit_app, exit_item) self.menuBar.Append(file_menu, "&File") # Help menu help_menu = wx.Menu() help_item = help_menu.Append(wx.ID_ABOUT, '&About NodeMCU PyFlasher', 'About') self.Bind(wx.EVT_MENU, self._on_help_about, help_item) self.menuBar.Append(help_menu, '&Help') self.SetMenuBar(self.menuBar)
def start_gui(self): ''' @summary: Initialises and launches the ransomware GUI screen ''' # Get Crypter start_time start_time = self.get_start_time() app = wx.App() # TODO Update this to new path and place in __init__ #sys._MEIPASS = "..\\build\\images" crypter_gui = Gui.Gui( image_path=sys._MEIPASS, start_time=start_time, decrypter=self, config=self.__config) crypter_gui.Show() app.MainLoop()
def __init__(self): app = wx.App() self.frame = MainWindow(None, "Bonsu - The Interactive Phase Retrieval Suite") self.nb = wx.Notebook(self.frame) self.nb.AddPage(PanelPhase(self.nb), "Phasing Pipeline") self.nb.AddPage(PanelVisual(self.nb), "Visualisation") self.nb.AddPage(PanelGraph(self.nb), "Graph") self.nb.AddPage(PanelScript(self.nb), "Python Prompt") self.nb.AddPage(PanelStdOut(self.nb), "Log") self.frame.nb = self.nb self.frame.sizer.Add(self.nb, 1, wx.ALL|wx.EXPAND, 5) self.frame.SetBackgroundColour(wx.NullColour) self.frame.SetSizer(self.frame.sizer) self.frame.Fit() self.frame.Show() self.frame.OnFileArg() app.MainLoop()
def show_file(self, imageFile, fullPath): """ Load the DICOM file, make sure it contains at least one image, and set it up for display by OnPaint(). ** be careful not to pass a unicode string to read_file or it will give you 'fp object does not have a defer_size attribute, or some such.""" ds = pydicom.read_file(str(fullPath)) ds.decode() # change strings to unicode self.populateTree(ds) if 'PixelData' in ds: self.dImage = self.loadPIL_LUT(ds) if self.dImage is not None: tmpImage = self.ConvertPILToWX(self.dImage, False) self.bitmap = wx.BitmapFromImage(tmpImage) self.Refresh() # ------ This is just the initialization of the App ------------------------- # ======================================================= # The main App Class. # =======================================================
def main(): app = wx.App() top = SampleFrame() top.Show() # close the console window as soon as the main window shows try: import launcher except ImportError: pass # ignore this when testing and running this file directly else: #~ launcher.close_console() launcher.hide_console_until_error() top.SetFocus() app.MainLoop()
def run_visualiser(parent_parser=argparse.ArgumentParser(add_help=False)): #Keyword arguments parser = argparse.ArgumentParser( description=""" Runs visualiser XXXX where XXXX is an increasingly more futuristic and exciting number""", parents=[parent_parser]) parser.add_argument('-d', '--fdir', dest='fdir', help='Directory containing results', default='../flowmol/src/results/') args = vars(parser.parse_args()) app = wx.App() fr = pplv.MainFrame(None, fdir=args['fdir']) fr.Show() app.MainLoop()
def main(): parser = optparse.OptionParser("[!] usage: python wx_mpl_display_detections_gui.py\n"+\ "\t -F <data file>\n") parser.add_option("-F", dest="dataFile", type="string", \ help="specify data file to analyse") (options, args) = parser.parse_args() dataFile = options.dataFile if dataFile is None: print parser.usage exit(0) app = wx.App(False) app.frame = mainFrame(dataFile) app.frame.Show() app.MainLoop()
def __del__(self): pass # def nullfn(*arg): # print "run_updte called" # # if __name__ == '__main__': # app = wx.App() # app.appversion = 201 # app.run_update = nullfn # wizard = UpdateFrame(None) # wizard.Show() # import time # #time.sleep(1) # wizard.check_update() # app.MainLoop()
def CreateApplication(self): if os.path.exists("BEREMIZ_DEBUG"): __builtin__.__dict__["BMZ_DBG"] = True else: __builtin__.__dict__["BMZ_DBG"] = False global wx import wx if wx.VERSION >= (3, 0, 0): self.app = wx.App(redirect=BMZ_DBG) else: self.app = wx.PySimpleApp(redirect=BMZ_DBG) self.app.SetAppName('beremiz') if wx.VERSION < (3, 0, 0): wx.InitAllImageHandlers() self.ShowSplashScreen() self.BackgroundInitialization() self.app.MainLoop()
def __init__(self, items, label=None): # app = wx.PySimpleApp(0) app = wx.App() dlg = ui_choice2Dialog(None, -1, "") nItems = len(items) for i in range(nItems): dlg.numListBox.Insert(str(items[i]),i) dlg.denListBox.Insert(str(items[i]),i) # app.SetTopWindow(dialog_1) app.SetTopWindow(dlg) if dlg.ShowModal() == wx.ID_OK: self.numIndex = dlg.numListBox.GetSelections() # print ' numIndex = ', self.numIndex self.denIndex = dlg.denListBox.GetSelections() self.numText = [] self.denText = [] for one in self.numIndex: # print ' one = ', one # self.numText.append(items[self.numIndex[one]]) self.numText.append(items[one]) for one in self.denIndex: # self.denText.append(items[self.denIndex[one]]) self.denText.append(items[one]) dlg.Destroy()
def __init__(self, xmeshfile, ymeshfile): #Do fast loading bypassing the mesh data structures since geometry #and topology are never changed xmesh = PolyMesh() print "Loading %s..."%xmeshfile (xmesh.VPos, xmesh.VColors, xmesh.ITris) = loadOffFileExternal(xmeshfile) xmesh.performDisplayUpdate(True) ymesh = PolyMesh() print "Loading %s..."%ymeshfile (ymesh.VPos, ymesh.VColors, ymesh.ITris) = loadOffFileExternal(ymeshfile) ymesh.performDisplayUpdate(True) app = wx.App() frame = ICPViewerFrame(None, -1, 'ICPViewer', xmesh, ymesh) frame.Show(True) app.MainLoop() app.Destroy()
def getplayername(self): """Ask the player his name, to go on the high-score list.""" if NO_WX: return USER_NAME try: import wx except: print "Pacman Error: No module wx. Can not ask the user his name!" print " :( Download wx from http://www.wxpython.org/" print " :( To avoid seeing this error again, set NO_WX in file pacman.pyw." return USER_NAME app=wx.App(None) dlog=wx.TextEntryDialog(None,"You made the high-score list! Name:") dlog.ShowModal() name=dlog.GetValue() dlog.Destroy() app.Destroy() return name
def __init__(self, redirect=False, filename=None): wx.App.__init__(self, redirect, filename) BASEURL = "http://127.0.0.1:8000" self.InitUpdates(BASEURL, BASEURL + "/" + 'ChangeLog.txt') self.SetAppDisplayName('Image Viewer') self.CheckForUpdate() self.frame = wx.Frame(None, title='Photo Control') self.panel = wx.Panel(self.frame) self.PhotoMaxSize = 500 self.createWidgets() self.frame.Show()
def __init__(self, fileServerPort, status): self.fileServerPort = fileServerPort self.status = status self.frame = None self.panel = None self.statusBar = None self.sizer = None wx.App.__init__(self, redirect=False)
def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, -1, title, size = (1, 1), style=wx.FRAME_NO_TASKBAR|wx.NO_FULL_REPAINT_ON_RESIZE) self.tbicon = MyTaskBarIcon(self) self.tbicon.SetIconTimer() self.Show(True) ## # The main application wx.App class #
def __init__(self, app, twistedLogFileName=None): """'app' is a wx.App instance""" Thread.__init__(self) self.app = None self.twistedLogFileName = twistedLogFileName self.setApp(app) ThreadCommand.twistedThread = self if app: self.running = True self.start()
def main(): app = wx.App() MainFrame().Show() app.MainLoop()
def main(): glutInit(sys.argv) app = wx.App() SignalKScope().Show() app.MainLoop()
def main(): app = wx.App() AutopilotControl().Show() app.MainLoop()
def main(): glutInit(sys.argv) app = wx.App() CalibrationDialog().ShowModal()
def wxPythonApp(): import wx app = wx.App() frame = wx.Frame(None, -1, "wxPython GUI", size=(200,150)) frame.SetBackgroundColour('white') frame.CreateStatusBar() menu= wx.Menu() menu.Append(wx.ID_ABOUT, "About", "wxPython GUI") menuBar = wx.MenuBar() menuBar.Append(menu,"File") frame.SetMenuBar(menuBar) frame.Show() app.MainLoop()
def wxPythonApp(): app = wx.App() frame = wx.Frame( None, title="Python GUI using wxPython", size=(300,180)) GUI(frame) frame.Show() runT = Thread(target=app.MainLoop) runT.setDaemon(True) runT.start() print(runT) print('createThread():', runT.isAlive()) #==================================================================
def wxPythonApp(): import wx app = wx.App() frame = wx.Frame(None, -1, "wxPython GUI", size=(200,150)) frame.SetBackgroundColour('white') frame.CreateStatusBar() menu= wx.Menu() menu.Append(wx.ID_ABOUT, "About", "wxPython GUI") menuBar = wx.MenuBar() menuBar.Append(menu, "File") frame.SetMenuBar(menuBar) frame.Show() app.MainLoop()
def __init__(self): wx.App.__init__(self, redirect=False)
def main(): app = App(False) app.MainLoop() # ---------------------------------------------------------------------------
def main(argv): """ The default host will be None if the environment variable PYRO_NS_HOSTNAME is not set. The default port will be 9090 (Pyro.config.PYRO_NS_PORT) if PYRO_NS_BC_PORT environment variable is not set. """ nsHost = os.getenv('PYRO_NS_HOSTNAME') nsPort = os.getenv('PYRO_NS_BC_PORT') or Pyro.config.PYRO_NS_PORT bcAddr = Pyro.config.PYRO_NS_BC_ADDR if bcAddr: bcAddr=bcAddr.strip() bcAddr=bcAddr or None class wx_NSCApp(wx.App): def OnInit(self): Pyro.core.initClient() frame = wx_NSC(nsHost, nsPort, bcAddr) frame.SetSize(wx.Size(630,500)) frame.Show(True) return True app = wx_NSCApp(0) app.MainLoop() # allow easy usage with python -m
def show(df): """ The main function to start the data frame GUI. """ app = wx.App(False) frame = MainFrame(df) frame.Show() app.MainLoop()
def main(opts): app = wx.App(False) window = GUI(None, id=1, title="stopgo", style=wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE, clargs=opts) window.Show() app.MainLoop() return True
def __init__(self, renderer, title="wx test"): "Creates an OpenGL context and a window, and acquires OpenGL resources" self.renderer = renderer self.title = title self._is_initialized = False # keep track of whether self.init_gl() has been called self.window = None wx.App.__init__(self, redirect = False)
def __init__(self, show_new_ui=False, redirect=False, filename=None): wx.App.__init__(self, redirect, filename) self.get_app_info() self.check_for_update() user_config_file = path.join(user_config_dir("iridaUploader"), "config.conf") if not path.exists(user_config_file): dialog = SettingsDialog(first_run=True) dialog.ShowModal() self._show_main_app()
def main(): import config app = wx.App() for screen in config.GRID: x1, y1, x2, y2 = screen w = x2 - x1 h = y2 - y1 # print screen, w, h frm = AppFrame(size=(w, h), pos=(x1, y1)) frm.ShowWithoutActivating() app.MainLoop()
def main(): wx.Log.SetLogLevel(0) app = wx.App() app.frame = WindowClass(None) app.MainLoop()
def __init__(self, *args, **kwargs): wx.App.__init__(self, *args, **kwargs)
def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,"Test App") self.renderer = Renderer(self) self.log = MyTextCtrl(self) self.Canvas = MyCanvas(self) sizer = wx.BoxSizer() sizer.Add(self.Canvas,3,wx.EXPAND) sizer.Add(self.log,1,wx.EXPAND) self.SetSizer(sizer) self.Bind(wx.EVT_CLOSE,self.OnExit) self.Show(True)
def __init__(self): ''' @summary: Constructor ''' # Initialise the Builder GUI app = wx.App() builder_gui = Gui() builder_gui.Show() app.MainLoop()
def main(): def onKeyDown(event): if event.GetKeyCode() == wx.WXK_ESCAPE: frame.Close() app = wx.App(0) frame = wx.Frame(None, title="Hello World from wxPython") panel = wx.Panel(frame) label = wx.StaticText(panel, -1, u"Press <ESC> to exit. Some non-ascii chars: ??š?íá?") panel.Bind(wx.EVT_KEY_DOWN, onKeyDown) panel.SetFocus() frame.Show() app.MainLoop()
def __init__(self, title=None, masterPID=-1, launch_listen_thread=False, control_panels_to_load=None, default_data_dir=None, default_autoload_pattern=None): self.__version__ = version=about["__version__"] WatchMasterPIDThread(masterPID) app = wx.App(False) self.frame = ZTVFrame(title=title, launch_listen_thread=launch_listen_thread, control_panels_to_load=control_panels_to_load, default_data_dir=default_data_dir, default_autoload_pattern=default_autoload_pattern) app.MainLoop() # TODO: need to figure out why ztvframe_pid is being left alive
def main(): app = wx.App() Make_TL(None) app.MainLoop()
def main(): app = wx.App() config_cam(None) app.MainLoop()
def main(): app = wx.App() window = MainApp(None) window.Show(True) app.MainLoop()
def __test(): class MyApp(wx.App): def OnInit(self): wx.InitAllImageHandlers() frame = TestFrame(None, -1, "PlotCanvas") # frame.Show(True) self.SetTopWindow(frame) return True app = MyApp(0) app.MainLoop()
def explore_cellstar(cellstar=None, seeds=[], snakes=[], images=None, image=None, params=None): if explorer_expected(): value = 0 try: app = None try: import wx app = wx.App(0) except: pass import utils.explorer as exp if image is None: image = cellstar.images.image if images is None: images = cellstar.images explorer_ui = exp.ExplorerFrame(images) explorer = exp.Explorer(image, images, explorer_ui, cellstar, params) explorer.stick_seeds = seeds explorer.stick_snakes = snakes value = explorer_ui.ShowModal() #if app is not None: # app.MainLoop() except Exception as ex: print ex pass if value == exp.ExplorerFrame.ABORTED: raise Exception("Execution aborted")
def enable_wx(self, app=None): """Enable event loop integration with wxPython. Parameters ---------- app : WX Application, optional. Running application to use. If not given, we probe WX for an existing application object, and create a new one if none is found. Notes ----- This methods sets the ``PyOS_InputHook`` for wxPython, which allows the wxPython to integrate with terminal based applications like IPython. If ``app`` is not given we probe for an existing one, and return it if found. If no existing app is found, we create an :class:`wx.App` as follows:: import wx app = wx.App(redirect=False, clearSigInt=False) """ import wx from distutils.version import LooseVersion as V wx_version = V(wx.__version__).version # @UndefinedVariable if wx_version < [2, 8]: raise ValueError("requires wxPython >= 2.8, but you have %s" % wx.__version__) # @UndefinedVariable from pydev_ipython.inputhookwx import inputhook_wx self.set_inputhook(inputhook_wx) self._current_gui = GUI_WX if app is None: app = wx.GetApp() # @UndefinedVariable if app is None: app = wx.App(redirect=False, clearSigInt=False) # @UndefinedVariable app._in_event_loop = True self._apps[GUI_WX] = app return app
def OnInit(self): frame = MyFrame(None, "Simple wxPython App") self.SetTopWindow(frame) print("Print statements go to this stdout window by default.") frame.Show(True) return True
def __init__(self, redirect=False): ''' Takes a location as a tuple of the form (LAT, LON) ''' # App fields wx.App.__init__(self, redirect) self.frame = wx.Frame(None, title='Pinder') self.panel = wx.Panel(self.frame) self.PhotoMaxSize = 240 self.createWidgets() self.frame.Show() # Authenticate Facebook token self.login() # Start pynder session self.start_session() # Geopy fields self.location = 'Somewhere' self.latlon = None # Ask for initial location self.onChangeLoc(None) self.users = [] self.users_index = 0 self.hopeful = None self.update_user()
def __init__(self): screenSize = wx.DisplaySize() x = screenSize[0] y = screenSize[1]-80 wx.Frame.__init__(self, None, title="App Auto Viewer", size=(x-80,y)) self.panel = MainPanel(self) self.statusB = self.CreateStatusBar(number=2) global recordStatus recordStatus = "?" self.updateRecordStatus(recordStatus) self.statusB.SetStatusText("??? ???", 1)