26 |
26 |
27 import os, sys, getopt, wx |
27 import os, sys, getopt, wx |
28 import tempfile |
28 import tempfile |
29 import shutil |
29 import shutil |
30 import random |
30 import random |
|
31 import time |
31 |
32 |
32 CWD = os.path.split(os.path.realpath(__file__))[0] |
33 CWD = os.path.split(os.path.realpath(__file__))[0] |
33 |
34 |
34 def Bpath(*args): |
35 def Bpath(*args): |
35 return os.path.join(CWD,*args) |
36 return os.path.join(CWD,*args) |
250 self.red_white = wx.TextAttr("RED", "WHITE") |
251 self.red_white = wx.TextAttr("RED", "WHITE") |
251 self.red_yellow = wx.TextAttr("RED", "YELLOW") |
252 self.red_yellow = wx.TextAttr("RED", "YELLOW") |
252 self.black_white = wx.TextAttr("BLACK", "WHITE") |
253 self.black_white = wx.TextAttr("BLACK", "WHITE") |
253 self.default_style = None |
254 self.default_style = None |
254 self.output = output |
255 self.output = output |
|
256 # to prevent rapid fire on rising log panel |
|
257 self.rising_timer = 0 |
255 |
258 |
256 def write(self, s, style = None): |
259 def write(self, s, style = None): |
257 if style is None : style=self.black_white |
260 if style is None : style=self.black_white |
258 self.output.Freeze(); |
261 self.output.Freeze(); |
259 if self.default_style != style: |
262 if self.default_style != style: |
261 self.default_style = style |
264 self.default_style = style |
262 self.output.AppendText(s) |
265 self.output.AppendText(s) |
263 self.output.ScrollLines(s.count('\n')+1) |
266 self.output.ScrollLines(s.count('\n')+1) |
264 self.output.ShowPosition(self.output.GetLastPosition()) |
267 self.output.ShowPosition(self.output.GetLastPosition()) |
265 self.output.Thaw() |
268 self.output.Thaw() |
|
269 newtime = time.time() |
|
270 if newtime - self.rising_timer > 1: |
|
271 self.output.Rise() |
|
272 self.rising_timer = newtime |
266 |
273 |
267 def write_warning(self, s): |
274 def write_warning(self, s): |
268 self.write(s,self.red_white) |
275 self.write(s,self.red_white) |
269 |
276 |
270 def write_error(self, s): |
277 def write_error(self, s): |
374 self.BottomNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True) |
381 self.BottomNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True) |
375 |
382 |
376 self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='', |
383 self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='', |
377 name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0), |
384 name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0), |
378 size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2) |
385 size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2) |
|
386 self.LogConsole.Rise = self.RiseLogConsole |
379 self.LogConsole.Bind(wx.EVT_LEFT_DCLICK, self.OnLogConsoleDClick) |
387 self.LogConsole.Bind(wx.EVT_LEFT_DCLICK, self.OnLogConsoleDClick) |
380 self.BottomNoteBook.AddPage(self.LogConsole, _("Log Console")) |
388 self.BottomNoteBook.AddPage(self.LogConsole, _("Log Console")) |
381 |
389 |
382 self._init_beremiz_sizers() |
390 self._init_beremiz_sizers() |
383 |
391 |
420 |
428 |
421 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
429 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
422 |
430 |
423 self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
431 self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
424 |
432 |
|
433 def RiseLogConsole(self): |
|
434 for idx in xrange(self.BottomNoteBook.GetPageCount()): |
|
435 window = self.BottomNoteBook.GetPage(idx) |
|
436 if window == self.LogConsole: |
|
437 self.BottomNoteBook.SetSelection(idx) |
|
438 break |
|
439 |
425 def RefreshTitle(self): |
440 def RefreshTitle(self): |
426 name = _("Beremiz") |
441 name = _("Beremiz") |
427 if self.PluginRoot is not None: |
442 if self.PluginRoot is not None: |
428 projectname = self.PluginRoot.GetProjectName() |
443 projectname = self.PluginRoot.GetProjectName() |
429 if self.PluginRoot.PlugTestModified(): |
444 if self.PluginRoot.PlugTestModified(): |