Beremiz.py
changeset 201 520d2416ff4d
parent 200 009fc5850157
child 203 cb9901076a21
equal deleted inserted replaced
200:009fc5850157 201:520d2416ff4d
    87               'helv' : 'Helvetica',
    87               'helv' : 'Helvetica',
    88               'other': 'new century schoolbook',
    88               'other': 'new century schoolbook',
    89               'size' : 18,
    89               'size' : 18,
    90              }
    90              }
    91 
    91 
       
    92 MATIEC_ERROR_MODEL = re.compile(".*\.st:([0-9]*)-([0-9]*)..([0-9]*)-([0-9]*): error : (.*)$")
    92 
    93 
    93 # Some helpers to tweak GenBitmapTextButtons
    94 # Some helpers to tweak GenBitmapTextButtons
    94 # TODO: declare customized classes instead.
    95 # TODO: declare customized classes instead.
    95 gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.GetParent().GetBackgroundColour(), wx.SOLID)
    96 gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.GetParent().GetBackgroundColour(), wx.SOLID)
    96 gen_textbutton_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenButton._GetLabelSize(obj)[:-1] + (False,))
    97 gen_textbutton_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenButton._GetLabelSize(obj)[:-1] + (False,))
   328         self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow)
   329         self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow)
   329         
   330         
   330         self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='',
   331         self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='',
   331                   name='LogConsole', parent=parent, pos=wx.Point(0, 0),
   332                   name='LogConsole', parent=parent, pos=wx.Point(0, 0),
   332                   size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2)
   333                   size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2)
       
   334         self.LogConsole.Bind(wx.EVT_LEFT_DCLICK, self.OnLogConsoleDClick)
   333         
   335         
   334         if wx.VERSION < (2, 8, 0):
   336         if wx.VERSION < (2, 8, 0):
   335             self.MainSplitter.SplitHorizontally(self.PLCConfig, self.LogConsole, -250)
   337             self.MainSplitter.SplitHorizontally(self.PLCConfig, self.LogConsole, -250)
   336         else:
   338         else:
   337             self.AUIManager = wx.aui.AuiManager(self)
   339             self.AUIManager = wx.aui.AuiManager(self)
   378         wnd = wx.FindWindowAtPointer()
   380         wnd = wx.FindWindowAtPointer()
   379         if not wnd:
   381         if not wnd:
   380             wnd = self
   382             wnd = self
   381         InspectionTool().Show(wnd, True)
   383         InspectionTool().Show(wnd, True)
   382 
   384 
       
   385     def OnLogConsoleDClick(self, event):
       
   386         wx.CallAfter(self.SearchLineForError)
       
   387         event.Skip()
       
   388 
       
   389     def SearchLineForError(self):
       
   390         text = self.LogConsole.GetRange(0, self.LogConsole.GetInsertionPoint())
       
   391         line = self.LogConsole.GetLineText(len(text.splitlines()) - 1)
       
   392         result = MATIEC_ERROR_MODEL.match(line)
       
   393         if result is not None:
       
   394             first_line, first_column, last_line, last_column, error = result.groups()
       
   395             infos = self.PluginRoot.ShowError(self.Log,
       
   396                                               (int(first_line), int(first_column)), 
       
   397                                               (int(last_line), int(last_column)))
       
   398 		
   383     def OnCloseFrame(self, event):
   399     def OnCloseFrame(self, event):
   384         if self.PluginRoot.HasProjectOpened():
   400         if self.PluginRoot.HasProjectOpened():
   385             if self.PluginRoot.runningPLC is not None:
   401             if self.PluginRoot.runningPLC is not None:
   386                 wx.MessageBox("Please stop any running PLC before closing")
   402                 wx.MessageBox("Please stop any running PLC before closing")
   387                 event.Veto()
   403                 event.Veto()