BeremizIDE.py
changeset 1739 ec153828ded2
parent 1737 a39c2918c015
child 1740 b789b695b5c6
equal deleted inserted replaced
1738:d2e979738700 1739:ec153828ded2
    74 
    74 
    75 MAX_RECENT_PROJECTS = 9
    75 MAX_RECENT_PROJECTS = 9
    76 
    76 
    77 if wx.Platform == '__WXMSW__':
    77 if wx.Platform == '__WXMSW__':
    78     faces = {
    78     faces = {
    79         'mono' : 'Courier New',
    79         'mono': 'Courier New',
    80         'size' : 8,
    80         'size': 8,
    81     }
    81     }
    82 else:
    82 else:
    83     faces = {
    83     faces = {
    84         'mono' : 'Courier',
    84         'mono': 'Courier',
    85         'size' : 10,
    85         'size': 10,
    86     }
    86     }
    87 
    87 
    88 from threading import Lock,Timer,currentThread
    88 from threading import Lock,Timer,currentThread
    89 MainThread = currentThread().ident
    89 MainThread = currentThread().ident
    90 REFRESH_PERIOD = 0.1
    90 REFRESH_PERIOD = 0.1
   144                 if self.YieldLock.acquire(0):
   144                 if self.YieldLock.acquire(0):
   145                     app.Yield()
   145                     app.Yield()
   146                     self.YieldLock.release()
   146                     self.YieldLock.release()
   147 
   147 
   148     def _write(self):
   148     def _write(self):
   149         if self.output :
   149         if self.output:
   150             self.output.Freeze()
   150             self.output.Freeze()
   151             self.lock.acquire()
   151             self.lock.acquire()
   152             for s, style in self.stack:
   152             for s, style in self.stack:
   153                 if style is None : style=self.black_white
   153                 if style is None: style=self.black_white
   154                 if style != self.black_white:
   154                 if style != self.black_white:
   155                     self.output.StartStyling(self.output.GetLength(), 0xff)
   155                     self.output.StartStyling(self.output.GetLength(), 0xff)
   156 
   156 
   157                 # Temporary deactivate read only mode on StyledTextCtrl for
   157                 # Temporary deactivate read only mode on StyledTextCtrl for
   158                 # adding text. It seems that text modifications, even
   158                 # adding text. It seems that text modifications, even
   485             self.local_runtime = ProcessLogger(self.Log,
   485             self.local_runtime = ProcessLogger(self.Log,
   486                 "\"%s\" \"%s\" -p %s -i localhost %s %s" % (
   486                 "\"%s\" \"%s\" -p %s -i localhost %s %s" % (
   487                     sys.executable,
   487                     sys.executable,
   488                     Bpath("Beremiz_service.py"),
   488                     Bpath("Beremiz_service.py"),
   489                     self.runtime_port,
   489                     self.runtime_port,
   490                     {False : "-x 0", True :"-x 1"}[taskbaricon],
   490                     {False: "-x 0", True:"-x 1"}[taskbaricon],
   491                     self.local_runtime_tmpdir),
   491                     self.local_runtime_tmpdir),
   492                 no_gui=False,
   492                 no_gui=False,
   493                 timeout=500, keyword = self.local_runtime_tmpdir,
   493                 timeout=500, keyword = self.local_runtime_tmpdir,
   494                 cwd = self.local_runtime_tmpdir)
   494                 cwd = self.local_runtime_tmpdir)
   495             self.local_runtime.spin()
   495             self.local_runtime.spin()
   611                 self.CTR.KillDebugThread()
   611                 self.CTR.KillDebugThread()
   612             self.KillLocalRuntime()
   612             self.KillLocalRuntime()
   613 
   613 
   614             self.SaveLastState()
   614             self.SaveLastState()
   615 
   615 
   616             for Thing in self.ToDoBeforeQuit :
   616             for Thing in self.ToDoBeforeQuit:
   617                 Thing()
   617                 Thing()
   618             self.ToDoBeforeQuit = []
   618             self.ToDoBeforeQuit = []
   619 
   619 
   620             event.Skip()
   620             event.Skip()
   621         else:
   621         else:
   842         try:
   842         try:
   843             defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder"))
   843             defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder"))
   844         except:
   844         except:
   845             defaultpath = os.path.expanduser("~")
   845             defaultpath = os.path.expanduser("~")
   846 
   846 
   847         dialog = wx.DirDialog(self , _("Choose an empty directory for new project"), defaultpath)
   847         dialog = wx.DirDialog(self, _("Choose an empty directory for new project"), defaultpath)
   848         if dialog.ShowModal() == wx.ID_OK:
   848         if dialog.ShowModal() == wx.ID_OK:
   849             projectpath = dialog.GetPath()
   849             projectpath = dialog.GetPath()
   850             self.Config.Write("lastopenedfolder",
   850             self.Config.Write("lastopenedfolder",
   851                               EncodeFileSystemPath(os.path.dirname(projectpath)))
   851                               EncodeFileSystemPath(os.path.dirname(projectpath)))
   852             self.Config.Flush()
   852             self.Config.Flush()
   878         try:
   878         try:
   879             defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder"))
   879             defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder"))
   880         except:
   880         except:
   881             defaultpath = os.path.expanduser("~")
   881             defaultpath = os.path.expanduser("~")
   882 
   882 
   883         dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, style=wx.DEFAULT_DIALOG_STYLE|
   883         dialog = wx.DirDialog(self, _("Choose a project"), defaultpath, style=wx.DEFAULT_DIALOG_STYLE|
   884                                                                                wx.RESIZE_BORDER)
   884                                                                                wx.RESIZE_BORDER)
   885         if dialog.ShowModal() == wx.ID_OK:
   885         if dialog.ShowModal() == wx.ID_OK:
   886             self.OpenProject(dialog.GetPath())
   886             self.OpenProject(dialog.GetPath())
   887         dialog.Destroy()
   887         dialog.Destroy()
   888 
   888