Python wx.App() Examples

The following are 30 code examples of wx.App(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: FrameAndPanelApp.py    From advancedpython3 with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self):
        super().__init__(parent=None,
                         title='Sample App',
                         size=(300, 300))

        # Set up the first Panel to be at position 1, 1
        # and of size 300 by 100 with a blue background
        self.panel1 = wx.Panel(self)
        self.panel1.SetSize(300, 100)
        self.panel1.SetBackgroundColour(wx.Colour(0, 0, 255))

        # Set up the second Panel to be at position 1, 110
        # and of size 300 by 100 with a red background
        self.panel2 = wx.Panel(self)
        self.panel2.SetSize(1, 110, 300, 100)
        self.panel2.SetBackgroundColour(wx.Colour(255, 0, 0)) 
Example #2
Source File: chapter2.py    From OpenCV-Computer-Vision-Projects-with-Python with MIT License 7 votes vote down vote up
def main():
    device = cv2.CAP_OPENNI
    capture = cv2.VideoCapture(device)
    if not(capture.isOpened()):
        capture.open(device)

    capture.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
    capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)

    app = wx.App()
    frame = MyFrame(None, -1, 'chapter2.py', capture)
    frame.Show(True)
#   self.SetTopWindow(frame)
    app.MainLoop()

    # When everything done, release the capture
    capture.release()
    cv2.destroyAllWindows() 
Example #3
Source File: yamled.py    From report-ng with GNU General Public License v2.0 6 votes vote down vote up
def GUI():
    wx_app = wx.App(redirect=True) # redirect in wxpython 3.0 defaults to False
    #wx_app = wx.App(redirect=False)
    #YamledWindow(content='../workbench/x.yaml')
    #YamledWindow(content='../workbench/y.yaml')
    #YamledWindow(content='../workbench/_yamled_dies.yaml')
    #YamledWindow(content='../workbench/yamled/sample-1.yaml')
    #YamledWindow(content='../workbench/yamled/pt.yaml')
    #YamledWindow(content=yaml_load(open('../workbench/yamled/burp-state-1-report.yaml').read(), yaml.SafeLoader, UnsortableOrderedDict))
    #YamledWindow(content='../workbench/yamled/asdf.yaml')
    #YamledWindow(content='../workbench/yamled/asdfgh.yaml')
    #YamledWindow(content='../workbench/yamled/burp-state-1-report.yaml')
    #YamledWindow(content='../workbench/yamled/_export_webinspect.yaml')
    #YamledWindow(content='../workbench/yamled/midsized.yaml')
    YamledWindow()
    #YamledWindow(content='../workbench/xss-2-intruder-items.yaml')
    wx_app.MainLoop() 
Example #4
Source File: Control_Frameworks.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 6 votes vote down vote up
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()) 
Example #5
Source File: tray.py    From superpaper with MIT License 6 votes vote down vote up
def tray_loop():
    """Runs the tray applet."""
    if not os.path.isdir(sp_paths.PROFILES_PATH):
        os.mkdir(sp_paths.PROFILES_PATH)
    if "wx" in sys.modules:
        app = App(False)
        app.MainLoop()
    else:
        print("ERROR: Module 'wx' import has failed. Is it installed? \
GUI unavailable, exiting.")
        sp_logging.G_LOGGER.error("ERROR: Module 'wx' import has failed. Is it installed? \
GUI unavailable, exiting.")
        exit()



# Tray applet definitions 
Example #6
Source File: Control_Frameworks.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 6 votes vote down vote up
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()) 
Example #7
Source File: loginScreen.py    From HH---POS-Accounting-and-ERP-Software with MIT License 6 votes vote down vote up
def attemptLogin (self, event):
		usr = self.userName.GetValue()
		passwd = self.passwd.GetValue()
		c = conn.cursor()
		c.execute("select id, access FROM users WHERE username = '%s' AND password = '%s'" % (usr, passwd))
		r = c.fetchone()
		if r is None:
			#print("Invalid Username and Password")
			self.userName.SetValue("")
			self.passwd.SetValue("")
		else:
			self.Close()
			
			# app = wx.App()
			mainInterface(None, r['access'], r['id']).Show()
			# app.MainLoop()
			print('else closed') 
Example #8
Source File: Main.py    From nodemcu-pyflasher with MIT License 6 votes vote down vote up
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) 
Example #9
Source File: ui.py    From python-wifi-survey-heatmap with GNU Affero General Public License v3.0 6 votes vote down vote up
def main():
    args = parse_args(sys.argv[1:])

    # set logging level
    if args.verbose > 1:
        set_log_debug()
    elif args.verbose == 1:
        set_log_info()

    app = wx.App()
    frm = MainFrame(
        args.IMAGE, args.INTERFACE, args.SERVER, args.TITLE,
        None, title='wifi-survey: %s' % args.TITLE
    )
    frm.Show()
    frm.Maximize(True)
    frm.SetStatusText('%s' % frm.pnl.GetSize())
    app.MainLoop() 
Example #10
Source File: loginScreen.py    From HH---POS-Accounting-and-ERP-Software with MIT License 6 votes vote down vote up
def attemptLogin (self, event):
		usr = self.userName.GetValue()
		passwd = self.passwd.GetValue()
		c = conn.cursor()
		c.execute("select id, access FROM users WHERE username = '%s' AND password = '%s'" % (usr, passwd))
		r = c.fetchone()
		if r is None:
			#print("Invalid Username and Password")
			self.userName.SetValue("")
			self.passwd.SetValue("")
		else:
			self.Destroy()
			
			app = wx.App()
			mainInterface(None, r['access'], r['id']).Show()
			app.MainLoop() 
Example #11
Source File: Control_Frameworks_NOT_working.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 5 votes vote down vote up
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() 
Example #12
Source File: color_recognizer2.py    From color_recognizer with MIT License 5 votes vote down vote up
def main():
    try:
        app = wx.App()
        frame = viewWindow(None)
        frame.Center()
        frame.Show()
        app.MainLoop()
    except:
        app.Close() 
Example #13
Source File: EngineWx.py    From p2ptv-pi with MIT License 5 votes vote down vote up
def __init__(self, redirectstderrout = False):
        self.bgapp = None
        self.systray = None
        wx.App.__init__(self, redirectstderrout) 
Example #14
Source File: __main__.py    From HH---POS-Accounting-and-ERP-Software with MIT License 5 votes vote down vote up
def main():

	print("hello")
	app = wx.App()
	loginScreen(None).Show()
	
	app.MainLoop()
	print("hello")
	my_sql.stop()
	print('closed') 
Example #15
Source File: createlivestream_wx.py    From p2ptv-pi with MIT License 5 votes vote down vote up
def __init__(self, wxapp, bgapp, iconfilename):
        wx.TaskBarIcon.__init__(self)
        self.bgapp = bgapp
        self.wxapp = wxapp
        self.icons = wx.IconBundle()
        self.icon = wx.Icon(iconfilename, wx.BITMAP_TYPE_ICO)
        self.icons.AddIcon(self.icon)
        if sys.platform != 'darwin':
            self.SetIcon(self.icon, self.bgapp.appname)
        else:
            menuBar = wx.MenuBar()
            filemenu = wx.Menu()
            item = filemenu.Append(-1, 'E&xit', 'Terminate the program')
            self.Bind(wx.EVT_MENU, self.OnExit, item)
            wx.App.SetMacExitMenuItemId(item.GetId()) 
Example #16
Source File: createlivestream_wx.py    From p2ptv-pi with MIT License 5 votes vote down vote up
def __init__(self, redirectstderrout = False):
        self.bgapp = None
        self.systray = None
        wx.App.__init__(self, redirectstderrout) 
Example #17
Source File: Communicate.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 5 votes vote down vote up
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())
        
#================================================================== 
Example #18
Source File: __main__.py    From HH---POS-Accounting-and-ERP-Software with MIT License 5 votes vote down vote up
def main():
	app = wx.App()
	loginScreen(None).Show()
	
	app.MainLoop() 
Example #19
Source File: Embed_wxPython.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 5 votes vote down vote up
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() 
Example #20
Source File: backend_wx.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def mainloop():
        if not wx.App.IsMainLoopRunning():
            wxapp = wx.GetApp()
            if wxapp is not None:
                wxapp.MainLoop() 
Example #21
Source File: backend_wx.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def new_figure_manager(cls, num, *args, **kwargs):
        # Create a wx.App instance if it has not been created sofar.
        wxapp = wx.GetApp()
        if wxapp is None:
            wxapp = wx.App(False)
            wxapp.SetExitOnFrameDelete(True)
            # Retain a reference to the app object so that it does not get
            # garbage collected.
            _BackendWx._theWxApp = wxapp
        return super().new_figure_manager(num, *args, **kwargs) 
Example #22
Source File: embedding_in_wx5_sgskip.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def demo():
    # alternatively you could use
    #app = wx.App()
    # InspectableApp is a great debug tool, see:
    # http://wiki.wxpython.org/Widget%20Inspection%20Tool
    app = wit.InspectableApp()
    frame = wx.Frame(None, -1, 'Plotter')
    plotter = PlotNotebook(frame)
    axes1 = plotter.add('figure 1').gca()
    axes1.plot([1, 2, 3], [2, 1, 4])
    axes2 = plotter.add('figure 2').gca()
    axes2.plot([1, 2, 3, 4, 5], [2, 1, 4, 2, 3])
    frame.Show()
    app.MainLoop() 
Example #23
Source File: embedding_in_wx2_sgskip.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def add_toolbar(self):
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()
        # By adding toolbar in sizer, we are able to put it at the bottom
        # of the frame - so appearance is closer to GTK version.
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar
        self.toolbar.update()


# alternatively you could use
#class App(wx.App): 
Example #24
Source File: graphics.py    From spectral with MIT License 5 votes vote down vote up
def check_wx_app():
    '''Generates a warning if there is not a running wx.App.
    If spectral.START_WX_APP is True and there is no current app, then on will
    be started.
    '''
    import spectral
    import wx
    if wx.GetApp() is None and spectral.settings.START_WX_APP == True:
        warnings.warn('\nThere is no current wx.App object - creating one now.',
                      UserWarning)
        spectral.app = wx.App() 
Example #25
Source File: graphics.py    From spectral with MIT License 5 votes vote down vote up
def warn_no_ipython():
    '''Warns that user is calling a GUI function outside of ipython.'''
    msg = '''
#############################################################################
SPy graphics functions are inteded to be run from IPython with the
`pylab` mode set for wxWindows.  For example,

    # ipython --pylab=WX

GUI functions will likely not function properly if you aren't running IPython
or haven't started it configured for pylab and wx.
#############################################################################
'''

    if sys.platform == 'darwin':
        msg += '''
NOTE: If you are running on Mac OS X and receive an error message
stating the following:

    "PyNoAppError: The wx.App object must be created first!",

You can avoid this error by running the following commandes immediately after
starting your ipython session:

    In [1]: import wx

    In [2]: app = wx.App()
#############################################################################
'''
    warnings.warn(msg, UserWarning) 
Example #26
Source File: GoSync.py    From gosync with GNU General Public License v2.0 5 votes vote down vote up
def main():
    os.chdir(APP_PATH)
#    app = wx.PySimpleApp() : Deprecated
    app = wx.App(False)
    controller = GoSyncController()
    controller.Center()
    controller.Show()
    app.MainLoop() 
Example #27
Source File: backend_wx.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def mainloop():
        if not wx.App.IsMainLoopRunning():
            wxapp = wx.GetApp()
            if wxapp is not None:
                wxapp.MainLoop() 
Example #28
Source File: backend_wx.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def new_figure_manager(cls, num, *args, **kwargs):
        # Create a wx.App instance if it has not been created sofar.
        wxapp = wx.GetApp()
        if wxapp is None:
            wxapp = wx.App(False)
            wxapp.SetExitOnFrameDelete(True)
            # Retain a reference to the app object so that it does not get
            # garbage collected.
            _BackendWx._theWxApp = wxapp
        return super().new_figure_manager(num, *args, **kwargs) 
Example #29
Source File: ugrid_wx.py    From gridded with The Unlicense 5 votes vote down vote up
def main():
    import sys
    app = wx.App(False)
    F = DrawFrame(None, title="UGRID Test App", size=(700, 700))

    if len(sys.argv) > 1:
        filename = sys.argv[1]
        F.load_ugrid_file(filename)
    else:
        from pyugrid import test_examples
        F.Draw_UGRID(test_examples.twenty_one_triangles())

    app.MainLoop() 
Example #30
Source File: application.py    From pyFileFixity with MIT License 5 votes vote down vote up
def run(build_spec):
  app = wx.App(False)

  i18n.load(build_spec['language'])

  frame = BaseWindow(build_spec)
  frame.Show(True)
  app.MainLoop()