Exemple #1
0
def main():
    conn, cur = check_and_setup()
    if len(sys.argv) == 1:
        # no args, use curdir
        target_files = None
    else:
        target_files = sys.argv[1:]

    if (target_files is None):
        # use cwd as target_files
        files_with_data, files_wo_data = process_dir(u'.', conn, cur)
    else:
        files_with_data = []
        files_wo_data = []

        #target_files should be in cwd
        #make all target_files non_absolute
        for i in range(len(target_files)):
            target_files[i] = unicode(os.path.basename(target_files[i]), 'utf-8')

        for fil in target_files:
            if os.path.isdir(fil):
                f_with, f_wo = process_dir(fil, conn, cur)
                files_with_data.extend(f_with)
                files_wo_data.extend(f_wo)
            else:
                if is_movie_file(fil):
                    if is_in_db(conn, cur, fil):
                        files_with_data.append(fil)
                    else:
                        files_wo_data.append(fil)

    print 'files_with_data', files_with_data
    print 'files_wo_data', files_wo_data

    #spawn threads
    if (config.platform == 'windows' and config.config['debug']):
        app = wx.App(redirect=True)
    else:
        app = wx.App(redirect=False)

    if (not config.config['debug']):
        wx.Log_SetActiveTarget(wx.LogStderr())

    frame = MyFrame(None, conn, cur)

    check_for_updates(frame)

    app.SetTopWindow(frame)
    frame.Maximize()

    for f in files_with_data:
        frame.add_row(f)

    if len(files_wo_data) > 0:
        start_dbbuilder(frame, files_wo_data)

    frame.Show()
    frame.Layout()
    app.MainLoop()
 def test_run_example(self):
     app = wx.App()
     wx.Log.SetActiveTarget(wx.LogStderr())
     file = Path(__file__).resolve().parent / "example.xlsx"
     generator = Generator(file)
     generator.process()
     del app
Exemple #3
0
 def OnInit(self):
     wx.Log_SetActiveTarget(wx.LogStderr())
     wx.InitAllImageHandlers()
     frame = MainFrame(None)
     frame.Show(True)
     self.SetTopWindow(frame)
     return True
Exemple #4
0
    def setUp(self):

        config.default()

        main_dlg.glob_choices.clear()
        self.app = wx.App()
        wx.Log.SetActiveTarget(wx.LogStderr())
        self.outdir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), "./outdir"))
 def launch(self):
     self.main_frame.Show()
     self.refresh_installed_mod_list()
     self.refresh_downloaded_mod_list()
     wx.Log.SetActiveTarget(wx.LogStderr())
     StartCoroutine(self.job_manager.worker, self.main_frame)
     StartCoroutine(self.manager.validate_cache, self.main_frame)
     loop = get_event_loop()
     loop.run_until_complete(self.app.MainLoop())
Exemple #6
0
    def OnInit(self):
        wx.Log.SetActiveTarget(wx.LogStderr())

        self.SetAssertMode(wx.APP_ASSERT_DIALOG)

        frame = MainFrame(None, **self.kwargs)
        frame.Show(True)
        self.SetTopWindow(frame)
        self.frame = frame
        return True
Exemple #7
0
 def InitLocale(self):
     self.ResetLocale()
     if 'wxMSW' in wx.PlatformInfo:
         import locale
         try:
             lang, enc = locale.getdefaultlocale()
             self._initial_locale = wx.Locale(lang, lang[:2], lang)
             locale.setlocale(locale.LC_ALL, lang)
         except (ValueError, locale.Error) as ex:
             target = wx.LogStderr()
             orig = wx.Log.SetActiveTarget(target)
             wx.LogError("Unable to set default locale: '{}'".format(ex))
             wx.Log.SetActiveTarget(orig)
Exemple #8
0
    def OnInit(self):
        wx.Log.SetActiveTarget(wx.LogStderr())

        if debug:
            print("Starting App OnInit")
        frame = MainInvisibleWindow()
        self.SetTopWindow(frame)
        taskbar = TaskBarIcon(frame)

        if not os.path.isfile(os.path.join(DATA_PATH, "id_rsa")):
            taskbar.on_open_main(None)
        # frame2 = MainFrame(frame, "Main")

        return True
Exemple #9
0
    def OnInit(self):
        wx.Log_SetActiveTarget(wx.LogStderr())
        # wx.Log_SetActiveTarget(wx.LogBuffer())

        self.SetAppName(appconstants.AppName)
        self.SetVendorName(appconstants.VendorName)

        frame = mainframe.HPPFrame(parent=None)
        title = appconstants.AppTitle + ' - ' + appconstants.AppVersion
        frame.SetTitle(title)
        self.SetTopWindow(frame)
        frame.Show(True)

        return True
Exemple #10
0
    def OnInit(self):
        locale.setlocale(locale.LC_ALL, 'C')
        wx.Log.SetActiveTarget(wx.LogStderr())

        if debug:
            print("Starting App OnInit")
        frame = MainFrame("BackupFriend")
        self.SetTopWindow(frame)
        taskbar = TaskBarIcon(frame, self)

        # if not os.path.isfile(os.path.join(DATA_PATH, "id_rsa")):
        #     taskbar.on_open_main(None)
        # frame2 = MainFrame(frame, "Main")

        return True
Exemple #11
0
def main():
    init_path()
    init_logging()
    import wx
    import ipc
    import controller
    container, message = ipc.init()
    if not container:
        return
    app = wx.App()  # redirect=True, filename='log.txt')
    wx.Log.SetActiveTarget(wx.LogStderr())
    ctrl = controller.Controller()
    container.callback = ctrl.parse_args
    container(message)
    app.MainLoop()
def InitLocale(self):
    """
    Substituição do método padrão devido a problemas relacionados a detecção de locale no Windows 7.
    Não foi testado no windows 10.
    """

    self.ResetLocale()
    try:
        lang, _ = locale.getdefaultlocale()
        self._initial_locale = wx.Locale(lang, lang[:2], lang)
        locale.setlocale(locale.LC_ALL, 'portuguese_brazil')  #pulo do gato
    except (ValueError, locale.Error) as ex:
        target = wx.LogStderr()
        orig = wx.Log.SetActiveTarget(target)
        wx.LogError("Unable to set default locale: '{}'".format(ex))
        wx.Log.SetActiveTarget(orig)
Exemple #13
0
    def setUp(self):

        config.default()
        args.theArgs = args.theArgsParser.parse_args(
            [])  # rewrite command line with no args

        main_dlg.glob_choices.clear()
        self.app = wx.App()
        wx.Log.SetActiveTarget(wx.LogStderr())
        self.frame = main_dlg.MainFrame()
        self.frame.Show()
        self.frame.PostSizeEvent()
        self.button_panel = self.frame.panel.GetChildren()[0].GetChildren(
        )[0].GetChildren()[0]
        self.outdir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), "./outdir"))
Exemple #14
0
    def OnInit(self):
        wx.Log_SetActiveTarget(wx.LogStderr())

        self.SetAssertMode(assertMode)

        # Resolve resource locations
        ed_glob.CONFIG['CONFIG_DIR'] = self.curr_dir
        ed_glob.CONFIG['INSTALL_DIR'] = self.curr_dir
        ed_glob.CONFIG['KEYPROF_DIR'] = os.path.join(self.curr_dir, u"ekeys")
        ed_glob.CONFIG['SYSPIX_DIR'] = os.path.join(self.curr_dir, u"pixmaps")
        ed_glob.CONFIG['PLUGIN_DIR'] = os.path.join(self.curr_dir, u"plugins")
        ed_glob.CONFIG['THEME_DIR'] = os.path.join(self.curr_dir, u"pixmaps",
                                                   u"theme")
        ed_glob.CONFIG['LANG_DIR'] = os.path.join(self.curr_dir, u"locale")
        ed_glob.CONFIG['STYLES_DIR'] = os.path.join(self.curr_dir, u"styles")
        ed_glob.CONFIG['SYS_PLUGIN_DIR'] = os.path.join(
            self.curr_dir, u"plugins")
        ed_glob.CONFIG['SYS_STYLES_DIR'] = os.path.join(
            self.curr_dir, u"styles")
        ed_glob.CONFIG['TEST_DIR'] = os.path.join(self.curr_dir, u"tests",
                                                  u"syntax")
        ed_glob.CONFIG['ISLOCAL'] = True
        ed_glob.CONFIG['PROFILE_DIR'] = os.path.join(self.curr_dir,
                                                     u"profiles")
        ed_glob.CONFIG['GLOBAL_PROFILE_DIR'] = os.path.join(
            self.curr_dir, u"profiles")

        Deca.CreateWorld()

        profiler.TheProfile.Load(
            os.path.join(ed_glob.CONFIG['PROFILE_DIR'], "default.ppb"))
        profiler.TheProfile.Update()

        self._pluginmgr = plugin.PluginManager()

        self.ReloadTranslation()

        ogl.OGLInitialize()
        frame = PyAUIFrame(None, _("Sampo Framework"), size=(750, 570))
        frame.Show(True)

        self.SetTopWindow(frame)
        self.frame = frame

        return True
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title="",
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_FRAME_STYLE,
                 name="MyFrame"):

        super(MyFrame,
              self).__init__(parent,
                             id,
                             title='Solenoid Test',
                             size=(640, 450),
                             style=wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)

        ##        self.panel = wx.Panel(self)
        self.sb = CustomStatusBar(self)
        self.SetStatusBar(self.sb)

        self.loop_all = 0
        self.SerialSearch()
        self.SerialConfig()
        self.thread = None
        self.alive = threading.Event()
        self.InitFrame()
        self.Centre()
        self.Show()
        self.InitButtons()
        self.InitRunMode()
        self.InitSolGUI()
        #self.InitStatusBar()
        #self.InitStatusSummary()
        wx.Log.SetActiveTarget(wx.LogStderr())

        # create log file in the log sub-directory
        if not os.path.exists('Log'):
            os.makedirs('Log')

        os.chdir('Log')
        t_now = time.localtime()
        self.file_name = 'Log ' + str(t_now[0]) + str(t_now[1]) + str(t_now[2])
        fp = open(self.file_name, 'a')
        fp.close()
Exemple #16
0
    def OnInit(self):
        wx.Log_SetActiveTarget(wx.LogStderr())

        self.frame = wx.Frame(None,
                              -1,
                              "test1",
                              pos=(50, 50),
                              size=(200, 100),
                              style=wx.DEFAULT_FRAME_STYLE,
                              name="test2")
        self.frame.Show()
        self.SetTopWindow(self.frame)
        self.panel1 = TestPanel(self.frame, Log())
        self.frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
        self.frame.Show(True)

        self.frame.SetSize((640, 480))

        return True
Exemple #17
0
def main():
    """Start point of app.
    """

    init_path()
    init_logging()

    # import sys  # FIXME: delete this import
    # import wx
    # import ipc
    # import controller

    logging.debug('-> ipc.init() - In')  # FIXME: delete this
    try:
        container, message = ipc.init()
    except TypeError:
        logging.error('IPC no initialize!\nExit.')
        sys.exit('Problems! IPC no initialize')
    logging.debug(f'container: {container}')
    logging.debug(f'message: {message}')
    logging.debug('<- ipc.init() - Out')

    if not container:
        logging.error('main:: The container could not be created.')
        return

    logging.debug(f'Initializing wx.app class')

    # app = wx.App()  # redirect=True, filename='log.txt')
    app = wx.App(redirect=True, filename="log.txt", useBestVisual=True)
    logging.debug(f'Initialized wx.app class')
    wx.Log.SetActiveTarget(wx.LogStderr())
    logging.debug(f'Initializing wx.Log.SetActiveTarget(wx.LogStderr())')
    ctrl = controller.Controller()
    logging.debug(f'Initializing ctrl with controller.Controller()')
    container.callback = ctrl.parse_args
    logging.debug(f'Initializing container.callback with ctrl.parse_args')
    container(message)
    logging.debug(f'Initializing container(message)')
    app.MainLoop()
Exemple #18
0
 def OnInit(self):
     wx.Log_SetActiveTarget(wx.LogStderr())
     self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
     frame = wx.Frame(None,
                      -1,
                      self.name,
                      pos=(50, 50),
                      size=(640, 480),
                      style=wx.DEFAULT_FRAME_STYLE)
     frame.CreateStatusBar()
     menuBar = wx.MenuBar()
     menu = wx.Menu()
     item = menu.Append(-1, "E&xit\tAlt-X", "Exit demo")
     self.Bind(wx.EVT_MENU, self.OnExitApp, item)
     menuBar.Append(menu, "&File")
     frame.SetMenuBar(menuBar)
     frame.Show(True)
     frame.SetSize((640, 480))
     win = CubeCanvas(frame)
     win.SetFocus()
     self.SetTopWindow(frame)
     self.frame = frame
     return True
Exemple #19
0
    def __init__(self, parent, menuData, size=None, pos=None):
        wx.Frame.__init__(self, parent, -1, "GeniControl", size=size, pos=pos)
        self.initStatusBar()
        createMenuBar(self, menuData)
        self.locale = None
        #self.updateLanguage(wx.LANGUAGE_ITALIAN)

        ##
        ##        self.log = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
        ##        if wx.Platform == "__WXMAC__":
        ##            self.log.MacCheckSpelling(False)
        ##

        # Set the wxWindows log target to be this textctrl
        #wx.Log_SetActiveTarget(wx.LogTextCtrl(self.log))

        # for serious debugging
        wx.Log_SetActiveTarget(wx.LogStderr())
        #wx.Log_SetTraceMask(wx.TraceMessages

        self.notebook = TestNB(self, wx.NewId())
        if not pos:
            self.Center()
Exemple #20
0
    def set_language(self):
        """
        Determine language to be loaded depending on : setting file, CLI option,
        or neither.
        Apply language to interface.
        """
        app.debug_print("== Interface Localization ==")

        # reference:
        locales = {
            #u'ar' : (wx.LANGUAGE_ARABIC, u'ar_SA.UTF-8'),
            #u'de' : (wx.LANGUAGE_GERMAN, u'de_DE.UTF-8'),
            #u'el' : (wx.LANGUAGE_GREEK, u'el_GR.UTF-8'),
            #u'en_GB' : (wx.LANGUAGE_ENGLISH_UK, u'en_GB.UTF-8'),
            u'en_US': (wx.LANGUAGE_ENGLISH_US, u'en_US.UTF-8'),
            u'es': (wx.LANGUAGE_SPANISH, u'es_ES.UTF-8'),
            u'fr': (wx.LANGUAGE_FRENCH, u'fr_FR.UTF-8'),
            #u'he' : (wx.LANGUAGE_HEBREW, u'he_IL.UTF-8'),
            #u'hu' : (wx.LANGUAGE_HUNGARIAN, u'hu_HU.UTF-8'),
            #u'it' : (wx.LANGUAGE_ITALIAN, u'it_IT.UTF-8'),
            #u'ja' : (wx.LANGUAGE_JAPANESE, u'ja_JP.UTF-8'),
            #u'pl' : (wx.LANGUAGE_POLISH, u'pl_PL.UTF-8'),
            #u'pt_BR' : (wx.LANGUAGE_PORTUGUESE_BRAZILIAN, u'pt_BR.UTF-8'),
            #u'ru' : (wx.LANGUAGE_RUSSIAN, u'ru_RU.UTF-8'),
            #u'sv' : (wx.LANGUAGE_SWEDISH, u'sv_SE.UTF-8'),
            #u'tr' : (wx.LANGUAGE_TURKISH, u'tr_TR.UTF-8'),
            #u'zh_CN' : (wx.LANGUAGE_CHINESE_SIMPLIFIED, u'zh_CN.UTF-8'),
        }

        # right-to-left languages:
        rightToLeftLanguages = ('ar', 'dv', 'fa', 'ha', 'he', 'ps', 'ur', 'yi')
        '''
        syslang = locale.getdefaultlocale()[0]
        if syslang in locales:
            language = syslang
        '''
        # get language from file if not specified from command line
        if not app.language:
            try:  # see if language file exist
                langIni = codecs.open(utils.get_user_path(u'language.ini'), 'r', 'utf-8')
            except IOError:  # have user choose language
                language = self.language_select(0)
            else:  # get language from file
                language = langIni.read().strip()
        else:
            language = app.language

        try:
            locales[language]
        except KeyError:
            msg = u"Could not initialize language: '%s'.\nContinuing in " % language
            msg += u"American English (en_US)\n"
            print(msg)
            language = 'en_US'

        # needed for calendar and other things, send all logs to stderr
        wx.Log.SetActiveTarget(wx.LogStderr())

        # set locale and language
        wx.Locale(locales[language][0], wx.LOCALE_LOAD_DEFAULT)

        try:
            Lang = gettext.translation(u'metamorphose2', app.locale_path(language),
                                       languages=[locales[language][1]])
        except IOError:
            print("Could not find the translation file for '%s'." % language)
            print("Try running messages/update_langs.sh\n")
            sys.exit(1)

        Lang.install(unicode=True)

        # set some globals
        if language not in rightToLeftLanguages:
            self.langLTR = True
            self.alignment = wx.ALIGN_LEFT
        else:
            self.langLTR = False
            self.alignment = wx.ALIGN_RIGHT
        app.language = language
        app.debug_print("Set language: " + app.language)

        locale.setlocale(locale.LC_ALL,'')
        self.encoding = unicode(locale.getlocale()[1])
        app.debug_print("Set encoding: " + self.encoding)

        # to get some language settings to display properly:
        if platform.system() in ('Linux', 'FreeBSD'):
            try:
                os.environ['LANG'] = locales[language][1]
            except (ValueError, KeyError):
                pass
        app.debug_print("============================")
        app.debug_print("")
Exemple #21
0
    def OnInit(self):
        wx.Log.SetActiveTarget(wx.LogStderr())

        #self.SetAssertMode(assertMode)
        #self.InitInspection()  # for the InspectionMixin base class

        style = wx.DEFAULT_FRAME_STYLE
        frame = wx.Frame(None, -1, XH, pos=(-1,-1), size=(-1,-1), style=style)
        menuBar = wx.MenuBar()
        menu = wx.Menu()
        item = menu.Append(-1, u("保存日记到文件"), u("将日记保存到文件中"))
        self.Bind(wx.EVT_MENU, self.OnLogToFile, item)
        #item = menu.Append(-1, "&Widget Inspector\tF6", "Show the wxPython Widget Inspection Tool")
        #self.Bind(wx.EVT_MENU, self.OnWidgetInspector, item)
        item = menu.Append(wx.ID_EXIT, u("退出"), u("关闭并退出"))
        self.Bind(wx.EVT_MENU, self.OnExitApp, item)
        menuBar.Append(menu, u("文件"))

        menu = wx.Menu()
        item = menu.Append(-1, u("关于"), u("软件信息"))
        self.Bind(wx.EVT_MENU, self.OnAbout, item)
        menuBar.Append(menu, u("帮助"))

        ns = {}
        ns['wx'] = wx
        ns['app'] = self
        ns['module'] = self.demoModule
        ns['frame'] = frame

        frame.Center()
        frame.CenterOnScreen()
        frame.CreateStatusBar()
        frame.SetMenuBar(menuBar)
        frame.SetIcon(xinghan_ico.xinghan.GetIcon())
        frame.Show(True)
        frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame)

        win = self.demoModule.runTest(frame, frame, Log())

        # a window will be returned if the demo does not create
        # its own top-level window
        if win:
            # so set the frame to a good size for showing stuff
            #frame.SetClientSize(win.GetBestSize())
            frame.Maximize()
            win.SetFocus()
            self.window = win
            ns['win'] = win
            frect = frame.GetRect()
        else:
            # It was probably a dialog or something that is already
            # gone, so we're done.
            frame.Destroy()
            return True

        self.SetTopWindow(frame)
        #wx.Log_SetActiveTarget(wx.LogStderr())
        #wx.Log_SetTraceMask(wx.TraceMessages)

        if self.useShell:
            # Make a PyShell window, and position it below our test window
            from wx import py
            shell = py.shell.ShellFrame(None, locals=ns)
            frect.OffsetXY(0, frect.height)
            frect.height = 400
            shell.SetRect(frect)
            shell.Show()

            # Hook the close event of the test window so that we close
            # the shell at the same time
            def CloseShell(evt):
                if shell:
                    shell.Close()
                evt.Skip()
            frame.Bind(wx.EVT_CLOSE, CloseShell)
                    
        # redirect output
        if redirect:
            app = wx.GetApp()
            app.RedirectStdio(redirectpath)

        self.frame = frame
        return True
Exemple #22
0
 def setUp(self):
     self.app = wx.App()
     wx.Log.SetActiveTarget(wx.LogStderr())
     self.frame = wx.Frame(None, title='WTC: ' + self.__class__.__name__)
     self.frame.Show()
Exemple #23
0
def _main_run():
    app = wx.GetApp()
    app.locale = wx.Locale(wx.LANGUAGE_DEFAULT)
    app.locale.AddCatalogLookupPathPrefix(SRC_PATH + "/pytigon_gui/locale")

    app.locale.AddCatalog("wx")
    app.locale.AddCatalog("pytigon")

    if app.embeded_browser:
        frame = browserframe.SchBrowserFrame(
            None,
            app.gui_style,
            wx.ID_ANY,
            app.title,
            wx.DefaultPosition,
            wx.Size(_APP_SIZE[0], _APP_SIZE[1]),
        )
    else:
        frame = appframe.SchAppFrame(
            app.gui_style,
            app.title,
            wx.DefaultPosition,
            wx.Size(_APP_SIZE[0], _APP_SIZE[1]),
            video=_VIDEO,
        )

    frame.CenterOnScreen()

    if not "tray" in app.gui_style:
        frame.Show()

    wx.Log.SetActiveTarget(wx.LogStderr())

    destroy_fun_tab = frame.destroy_fun_tab
    httpclient.set_http_error_func(http_error)

    def idle_fun():
        wx.GetApp().web_ctrl.OnIdle(None)

    httpclient.set_http_idle_func(idle_fun)

    # if app.task_manager:
    #    frame.idle_objects.append(app.task_manager)

    if _RPC:
        reactor.listenTCP(app.rpc, server.Site(app))

    if _WEBSOCKET:
        if ";" in _WEBSOCKET:
            websockets = _WEBSOCKET.split(";")
        else:
            websockets = [_WEBSOCKET]

        local = True if app.base_address.startswith("http://127.0.0.2") else False

        for websocket_id in websockets:
            create_websocket_client(app, websocket_id, local)

    if _INSPECTION == True:
        app.MainLoop()
    else:
        if "channels" in _PARAM or "rpc" in _PARAM or "websocket" in _PARAM:
            # loop = get_event_loop()
            LOOP.run_until_complete(app.MainLoop())
        else:
            app.MainLoop()

    # if app.task_manager:
    #    app.task_manager.wait_for_result()
    if app.server:
        app.server.stop()
    del app
    for pos in destroy_fun_tab:
        pos()
Exemple #24
0
    def OnInit(self):
        wx.Log.SetActiveTarget(wx.LogStderr())

        self.SetAssertMode(assertMode)
        self.InitInspection()  # for the InspectionMixin base class

        frame = wx.Frame(None,
                         -1,
                         "RunDemo: " + self.name,
                         size=(200, 100),
                         style=wx.DEFAULT_FRAME_STYLE,
                         name="run a sample")
        frame.CreateStatusBar()

        menuBar = wx.MenuBar()
        menu = wx.Menu()
        item = menu.Append(-1, "&Widget Inspector\tF6",
                           "Show the wxPython Widget Inspection Tool")
        self.Bind(wx.EVT_MENU, self.OnWidgetInspector, item)
        item = menu.Append(wx.ID_EXIT, "E&xit\tCtrl-Q", "Exit demo")
        self.Bind(wx.EVT_MENU, self.OnExitApp, item)
        menuBar.Append(menu, "&File")

        ns = {}
        ns['wx'] = wx
        ns['app'] = self
        ns['module'] = self.demoModule
        ns['frame'] = frame

        frame.SetMenuBar(menuBar)
        frame.Show(True)
        frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame)

        win = self.demoModule.runTest(frame, frame, Log())

        # a window will be returned if the demo does not create
        # its own top-level window
        if win:
            # so set the frame to a good size for showing stuff
            frame.SetSize((800, 600))
            win.SetFocus()
            self.window = win
            ns['win'] = win
            frect = frame.GetRect()

        else:
            # It was probably a dialog or something that is already
            # gone, so we're done.
            frame.Destroy()
            return True

        self.SetTopWindow(frame)
        self.frame = frame
        #wx.Log.SetActiveTarget(wx.LogStderr())
        #wx.Log.SetTraceMask(wx.TraceMessages)

        if self.useShell:
            # Make a PyShell window, and position it below our test window
            from wx import py
            shell = py.shell.ShellFrame(None, locals=ns)
            frect.OffsetXY(0, frect.height)
            frect.height = 400
            shell.SetRect(frect)
            shell.Show()

            # Hook the close event of the test window so that we close
            # the shell at the same time
            def CloseShell(evt):
                if shell:
                    shell.Close()
                evt.Skip()

            frame.Bind(wx.EVT_CLOSE, CloseShell)

        return True
Exemple #25
0
        def __init__(self, parent, id, title, size=(500,500)):
            wx.Frame.__init__(self, parent,id,size=(750,500),title=title,style=wx.DEFAULT_FRAME_STYLE)
            self.Bind(wx.EVT_CLOSE, self.OnClose)
            #self.id=wx.NewId()                              # deprecated in wxPython  phonix
            self.id=wx.Window.NewControlId()                 
            self.gpx=None
            self.replaytimer=None
            self.selstart=0
            self.selstop=0
            self.plugins={}

            # mappanel raises errors on invalid images, which are displayed in dialogs.
            # this redirects error logging to stderr
            wx.Log.SetActiveTarget(wx.LogStderr())

            # standard initialisation of default values
            self.config=configparser.ConfigParser()
            self.config.read(thispath()+os.sep+"wxgpgpsport.ini")
            if not self.config.get("map","map_cache") or self.config.get("map","map_cache")=="default":
                map_cache=None
            elif  os.path.isabs(self.config.get("map","map_cache")):
                map_cache=os.path.normpath(self.config.get("map","map_cache"))
            else:
                map_cache=os.path.normpath(thispath()+os.sep+self.config.get("map","map_cache"))

            #building interface
            self.InitMenus()
            panel = wx.Panel(self, -1)
            fdtarget=MainFrameDropTarget(self)
            #panel.SetDropTarget(fdtarget)
            hsplitter=wx.SplitterWindow(self,style=wx.SP_3D|wx.SP_3DSASH|wx.SP_BORDER|wx.SP_LIVE_UPDATE)
            vsplitter=wx.SplitterWindow(hsplitter,style=wx.SP_3D|wx.SP_3DSASH|wx.SP_BORDER|wx.SP_LIVE_UPDATE)
            hsplitter.SetSashGravity(0.666)
            vsplitter.SetSashGravity(0.500)
            # time panel
            self.timewidget=wxlinescatterwidget.WxTimeWidget(hsplitter)
            self.timewidget.SetDropTarget(fdtarget)
            # map widget
            self.mapwidget=wxmapwidget.WxMapWidget(vsplitter,usegl=self.config.getboolean("map","map_usegl"),\
                                                            localcache=map_cache,\
                                                            numthreads=self.config.getint("map","map_numthreads"),\
                                                            style=wx.BORDER_SUNKEN)
            #self.mapwidget=wxmapwidget.WxMapWidget(vsplitter,usegl=False,localcache=map_cache,style=wx.BORDER_SUNKEN)
            self.mapwidget.mapproviders=[]
            providers=self.config.get("map","tile_providers")
            for l in providers.split('\n'):
                self.mapwidget.AppendTileProvider(*tuple(l.split(',')))
            self.mapwidget.SetMapSrc(self.config.get("map","map_source"))
            self.mapwidget.SetUserAgent(self.config.get("map","http_user_agent"))
            self.mapwidget.SetDropTarget(fdtarget)
            # notebook
            # on OSX, the native notebook control does not allow for a large number of tabs
            # so we use a specific aui notebook with specific style to dismiss close button
            # or a wx.Choicebook
            # notebook=wx.Notebook(vsplitter)
            # notebook=wx.Choicebook(vsplitter,wx.ID_ANY)
            self.notebook=wx.aui.AuiNotebook(vsplitter,style=wx.aui.AUI_NB_DEFAULT_STYLE&~(wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB))
            # pack everything...
            hsplitter.SplitHorizontally(vsplitter, self.timewidget)
            vsplitter.SplitVertically(self.mapwidget, self.notebook)
            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(hsplitter, 1, wx.EXPAND)
            self.SetSizer(sizer)
            # status bar
            self.sb = wxstatusbarwidget.wxStatusBarWidget(self)
            self.SetStatusBar(self.sb)

            msgwrap.register(self.OnSigCurChanged, "CurChanged")
            msgwrap.register(self.OnSigSelChanged, "SelChanged")
            msgwrap.register(self.OnSigValChanged, "ValChanged")

            self.Show()
            self.mapwidget.Draw(True)
Exemple #26
0
    def SetStream(self, value):
        if value:
            self._outstream_stack.append( self._outstream )
            self._outstream = value
        elif value is None and len(self._outstream_stack) > 0:
            self._outstream = self._outstream_stack.pop(-1)


#------------------------------------------------------------

if __name__ == "__main__":
    import  sys
    import  wx
    
    wx.Log.SetActiveTarget(wx.LogStderr())
    logger = Logger('module')
    dbg = logger.dbg
    dbg(enable=1)
    logger('test __call__ interface')
    dbg('testing wxLog output to stderr:', wxlog=1, indent=1)
    dbg('1,2,3...')
    dbg('testing wx.LogNull:')
    devnull = wx.LogNull()
    dbg('4,5,6...') # shouldn't print, according to doc...
    del devnull
    dbg('(resuming to wx.LogStdErr)', '7,8,9...', indent=0)
    dbg('disabling wx.Log output, switching to stderr:')
    dbg(wxlog=0, stream=sys.stderr)
    dbg(logger._outstream, 'switching back to stdout:')
    dbg(stream=None)
Exemple #27
0
    def __init__(self,
                 appTitle="Simbicon Application",
                 fps=30.0,
                 dt=1 / 2000.0,
                 glCanvasSize=wx.DefaultSize,
                 size=wx.DefaultSize,
                 redirect=False,
                 filename=None,
                 useBestVisual=False,
                 clearSigInt=True,
                 showConsole=True):
        """
        appTitle is the window title
        fps is the desired number of frames per seconds
        dt is the desired simulation timestep
        :see: wx.BasicApp.__init__`
        """

        wx.App.__init__(self, redirect, filename, useBestVisual, clearSigInt)

        # No annoying error logging window
        wx.Log.SetActiveTarget(wx.LogStderr())

        import UI

        # Setup the main window style
        style = wx.DEFAULT_FRAME_STYLE
        if size == wx.DefaultSize:
            size = wx.GetDisplaySize()
            size.height *= 0.75
            size.width *= 0.75
            if glCanvasSize == wx.DefaultSize:
                style |= wx.MAXIMIZE

        # Setup the environment for the python interactive console
        consoleEnvironment = {"wx": wx, "Physics": Physics, "Utils": Utils}
        exec "from MathLib import *\n" + \
             "app = wx.GetApp()\n" + \
             "from PyUtils import load" in consoleEnvironment, consoleEnvironment

        # Create the main window
        self._frame = UI.MainWindow(None,
                                    -1,
                                    appTitle,
                                    size=size,
                                    style=style,
                                    fps=fps,
                                    glCanvasSize=glCanvasSize,
                                    showConsole=showConsole,
                                    consoleEnvironment=consoleEnvironment)

        # Define GL callbacks
        self._glCanvas = self._frame.getGLCanvas()
        self._glCanvas.addDrawCallback(self.draw)
        self._glCanvas.addPostDrawCallback(self.postDraw)
        self._glCanvas.addOncePerFrameCallback(self.advanceAnimation)
        self._glCanvas.setDrawAxes(False)
        self._glCanvas.setPrintLoad(True)
        self._glCanvas.setCameraTargetFunction(self.cameraTargetFunction)

        self._glCanvas.setDrawGround(False)

        # Get the tool panel
        self._toolPanel = self._frame.getToolPanel()

        # Show the application
        self._frame.Show()

        # Set-up starting state
        self._dt = dt
        self._drawShadows = True
        self._simulationSecondsPerSecond = 1  # 1 = real time, 2 = twice real time, 1/2 = half real time
        self._animationRunning = False
        self._cameraFollowCharacter = False
        self._drawCollisionVolumes = False
        self._followedCharacter = None  # Pointer to focused character
        self._captureScreenShots = False
        self._printStepReport = True
        self._screenShotNumber = 0
        self._worldOracle = Core.WorldOracle()
        self._worldOracle.initializeWorld(Physics.world())
        self._kinematicMotion = False

        # Set-up starting list of characters and controllers
        self._characters = []

        # Define the observables
        self._controllerList = ObservableList()
        self._characterObservable = PyUtils.Observable()
        self._animationObservable = PyUtils.Observable()
        self._cameraObservable = PyUtils.Observable()
        self._optionsObservable = PyUtils.Observable()

        self._COMObservable = PyUtils.Observable()

        self._curveList = ObservableList()
        self._snapshotTree = SnapshotBranch()

        self._showAbstractView = False
        self._showAbstractViewSkeleton = False
        self._showBodyFrame = False
        self._showCDPrimitives = False
        self._showColors = False
        self._showFrictionParticles = False
        self._showJoints = False
        self._showMesh = True
        self._showMinBDGSphere = False
        self._showCenterOfMass = True

        self._COMErrorScale = 0.01

        params = [
            3.75162180e-04, 1.70361201e+00, -7.30441228e-01, -6.22795336e-01,
            3.05330848e-01
        ]
        fps = 100

        # params = [0, 0, 0, 0, 0]

        # fps = 100.0
        # model_order = (50, 50)
        # params = [0.00019815056771797725, 1.9687785869242351, -0.9709165752219967, -0.565841931234043, 0.3226849680645409]

        self._armaX = ArmaProcess(params[0], params[1:3], params[3:5], fps)
        self._armaY = ArmaProcess(params[0], params[1:3], params[3:5], fps)
        self._armaZ = ArmaProcess(params[0], params[1:3], params[3:5], fps)
Exemple #28
0
 def _set_frame_icon(self):
     wx.Log.SetActiveTarget(wx.LogStderr())
     wx.Log.EnableLogging(False)
     self.window.SetIcons(icon_bundle())
     wx.Log.EnableLogging(True)
import wx

from traits.trait_notifiers import set_ui_handler, ui_handler

from pyface.base_toolkit import Toolkit
from .gui import GUI

# Check the version number is late enough.
if wx.VERSION < (2, 8):
    raise RuntimeError("Need wx version 2.8 or higher, but got %s" %
                       str(wx.VERSION))

# It's possible that it has already been initialised.
_app = wx.GetApp()
if _app is None:
    _app = wx.App()

# stop logging to a modal window by default
# (apps can override by setting a different active target)
_log = wx.LogStderr()
wx.Log.SetActiveTarget(_log)

# create the toolkit object
toolkit_object = Toolkit('pyface', 'wx', 'pyface.ui.wx')

# ensure that Traits has a UI handler appropriate for the toolkit.
if ui_handler is None:
    # Tell the traits notification handlers to use this UI handler
    set_ui_handler(GUI.invoke_later)
Exemple #30
0
    def OnInit(self):
        wx.InitAllImageHandlers()
        wx.Log_SetActiveTarget(wx.LogStderr())

        self.SetAssertMode(assertMode)

        frame = wx.Frame(None,
                         -1,
                         "RunDemo: " + self.name,
                         pos=(50, 50),
                         size=(200, 100),
                         style=wx.NO_FULL_REPAINT_ON_RESIZE
                         | wx.DEFAULT_FRAME_STYLE)
        frame.CreateStatusBar()

        menuBar = wx.MenuBar()
        menu = wx.Menu()
        item = menu.Append(-1, "E&xit\tAlt-X", "Exit demo")
        self.Bind(wx.EVT_MENU, self.OnButton, item)
        menuBar.Append(menu, "&File")

        ns = {}
        ns['wx'] = wx
        ns['app'] = self
        ns['module'] = self.demoModule
        ns['frame'] = frame

        frame.SetMenuBar(menuBar)
        frame.Show(True)
        frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame)

        win = self.demoModule.runTest(frame, frame, Log())

        # a window will be returned if the demo does not create
        # its own top-level window
        if win:
            # so set the frame to a good size for showing stuff
            frame.SetSize((640, 480))
            win.SetFocus()
            self.window = win
            ns['win'] = win
            frect = frame.GetRect()

        else:
            # otherwise the demo made its own frame, so just put a
            # button in this one
            if hasattr(frame, 'otherWin'):
                ns['win'] = frame.otherWin
                frect = frame.otherWin.GetRect()
                p = wx.Panel(frame, -1)
                b = wx.Button(p, -1, " Exit ", (10, 10))
                wx.CallAfter(frame.SetClientSize, (200, 100))
                frame.Bind(wx.EVT_BUTTON, self.OnButton, b)
            else:
                # It was probably a dialog or something that is already
                # gone, so we're done.
                frame.Destroy()
                return True

        self.SetTopWindow(frame)
        self.frame = frame
        #wx.Log_SetActiveTarget(wx.LogStderr())
        #wx.Log_SetTraceMask(wx.TraceMessages)

        if self.useShell:
            # Make a PyShell window, and position it below our test window
            from wx import py
            shell = py.shell.ShellFrame(None, locals=ns)
            frect.OffsetXY(0, frect.height)
            frect.height = 400
            shell.SetRect(frect)
            shell.Show()

            # Hook the close event of the test window so that we close
            # the shell at the same time
            def CloseShell(evt):
                if shell:
                    shell.Close()
                evt.Skip()

            frame.Bind(wx.EVT_CLOSE, CloseShell)

        return True