BeremizIDE.py
changeset 3833 73a44957c381
parent 3789 8def429216ca
child 3906 f831ff63ca6e
equal deleted inserted replaced
3832:b4f8fe5e3b0f 3833:73a44957c381
    29 import sys
    29 import sys
    30 import shutil
    30 import shutil
    31 import time
    31 import time
    32 import signal
    32 import signal
    33 from time import time as gettime
    33 from time import time as gettime
    34 from threading import Lock, Timer, currentThread
    34 from threading import Lock, Timer, current_thread
    35 
    35 
    36 import wx.lib.buttons
    36 import wx.lib.buttons
    37 import wx.lib.statbmp
    37 import wx.lib.statbmp
    38 import wx.stc
    38 import wx.stc
    39 import wx.adv
    39 import wx.adv
   100         'mono': 'FreeMono',
   100         'mono': 'FreeMono',
   101         'size': 10,
   101         'size': 10,
   102     }
   102     }
   103 
   103 
   104 
   104 
   105 MainThread = currentThread().ident
   105 MainThread = current_thread().ident
   106 REFRESH_PERIOD = 0.1
   106 REFRESH_PERIOD = 0.1
   107 
   107 
   108 
   108 
   109 class LogPseudoFile(object):
   109 class LogPseudoFile(object):
   110     """ Base class for file like objects to facilitate StdOut for the Shell."""
   110     """ Base class for file like objects to facilitate StdOut for the Shell."""
   151         self._should_write()
   151         self._should_write()
   152         with self.TimerAccessLock:
   152         with self.TimerAccessLock:
   153             self.LastRefreshTimer = None
   153             self.LastRefreshTimer = None
   154 
   154 
   155     def _should_write(self):
   155     def _should_write(self):
   156         if MainThread == currentThread().ident:
   156         if MainThread == current_thread().ident:
   157             app = wx.GetApp()
   157             app = wx.GetApp()
   158             if app is not None:
   158             if app is not None:
   159                 self._write()
   159                 self._write()
   160                 if self.YieldLock.acquire(0):
   160                 if self.YieldLock.acquire(0):
   161                     app.Yield()
   161                     app.Yield()
   245     def _init_coll_FileMenu_Items(self, parent):
   245     def _init_coll_FileMenu_Items(self, parent):
   246         AppendMenu(parent, help='', id=wx.ID_NEW,
   246         AppendMenu(parent, help='', id=wx.ID_NEW,
   247                    kind=wx.ITEM_NORMAL, text=_('New') + '\tCTRL+N')
   247                    kind=wx.ITEM_NORMAL, text=_('New') + '\tCTRL+N')
   248         AppendMenu(parent, help='', id=wx.ID_OPEN,
   248         AppendMenu(parent, help='', id=wx.ID_OPEN,
   249                    kind=wx.ITEM_NORMAL, text=_('Open') + '\tCTRL+O')
   249                    kind=wx.ITEM_NORMAL, text=_('Open') + '\tCTRL+O')
   250         parent.Append(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu)
   250         self.RecentProjectsMenuItem = parent.AppendSubMenu(self.RecentProjectsMenu, _("&Recent Projects"))
   251         parent.AppendSeparator()
   251         parent.AppendSeparator()
   252         parent.Append(wx.ID_ANY, _("&Tutorials and Examples"), self.TutorialsProjectsMenu)
   252         parent.AppendSubMenu(self.TutorialsProjectsMenu, _("&Tutorials and Examples"))
   253 
   253 
   254         exemples_dir = Bpath("exemples")
   254         exemples_dir = Bpath("exemples")
   255         project_list = sorted(os.listdir(exemples_dir))
   255         project_list = sorted(os.listdir(exemples_dir))
   256 
   256 
   257         for idx, dirname  in enumerate(project_list):
   257         for idx, dirname  in enumerate(project_list):
   705 
   705 
   706         while self.RecentProjectsMenu.GetMenuItemCount() > 0:
   706         while self.RecentProjectsMenu.GetMenuItemCount() > 0:
   707             item = self.RecentProjectsMenu.FindItemByPosition(0)
   707             item = self.RecentProjectsMenu.FindItemByPosition(0)
   708             self.RecentProjectsMenu.Remove(item)
   708             self.RecentProjectsMenu.Remove(item)
   709 
   709 
   710         self.FileMenu.Enable(ID_FILEMENURECENTPROJECTS, len(recent_projects) > 0)
   710         self.RecentProjectsMenuItem.Enable(len(recent_projects) > 0)
   711         for idx, projectpath in enumerate(recent_projects):
   711         for idx, projectpath in enumerate(recent_projects):
   712             text = '&%d: %s' % (idx + 1, projectpath)
   712             text = '&%d: %s' % (idx + 1, projectpath)
   713 
   713 
   714             item = self.RecentProjectsMenu.Append(wx.ID_ANY, text, '')
   714             item = self.RecentProjectsMenu.Append(wx.ID_ANY, text, '')
   715             self.Bind(wx.EVT_MENU, self.GenerateOpenRecentProjectFunction(projectpath), item)
   715             self.Bind(wx.EVT_MENU, self.GenerateOpenRecentProjectFunction(projectpath), item)