Beremiz.py
changeset 426 3f285782ac9b
parent 422 76aebe92fd5f
child 427 7ac746c07ff2
equal deleted inserted replaced
425:f390e9fdd2cf 426:3f285782ac9b
   365               name='PLCConfig', parent=self.LeftNoteBook, pos=wx.Point(0, 0),
   365               name='PLCConfig', parent=self.LeftNoteBook, pos=wx.Point(0, 0),
   366               size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL)
   366               size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL)
   367         self.PLCConfig.SetBackgroundColour(wx.WHITE)
   367         self.PLCConfig.SetBackgroundColour(wx.WHITE)
   368         self.PLCConfig.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown)
   368         self.PLCConfig.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown)
   369         self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow)
   369         self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow)
       
   370         self.PLCConfig.Bind(wx.EVT_MOUSEWHEEL, self.OnPLCConfigScroll)
   370         self.BottomNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True)
   371         self.BottomNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True)
   371         
   372         
   372         self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='',
   373         self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='',
   373                   name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0),
   374                   name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0),
   374                   size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2)
   375                   size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2)
   386         self.local_runtime = None
   387         self.local_runtime = None
   387         self.runtime_port = None
   388         self.runtime_port = None
   388         self.local_runtime_tmpdir = None
   389         self.local_runtime_tmpdir = None
   389         
   390         
   390         self.DisableEvents = False
   391         self.DisableEvents = False
       
   392         # Variable allowing disabling of PLCConfig scroll when Popup shown 
       
   393         self.ScrollingEnabled = True
   391         
   394         
   392         self.PluginInfos = {}
   395         self.PluginInfos = {}
   393         
   396         
   394         if projectOpen is not None and os.path.isdir(projectOpen):
   397         if projectOpen is not None and os.path.isdir(projectOpen):
   395             self.PluginRoot = PluginsRoot(self, self.Log)
   398             self.PluginRoot = PluginsRoot(self, self.Log)
   504     def OnMoveWindow(self, event):
   507     def OnMoveWindow(self, event):
   505         self.GetBestSize()
   508         self.GetBestSize()
   506         self.RefreshScrollBars()
   509         self.RefreshScrollBars()
   507         event.Skip()
   510         event.Skip()
   508     
   511     
       
   512     def EnableScrolling(self, enable):
       
   513         self.ScrollingEnabled = enable
       
   514     
       
   515     def OnPLCConfigScroll(self, event):
       
   516         if self.ScrollingEnabled:
       
   517             event.Skip()
       
   518 
   509     def OnPanelLeftDown(self, event):
   519     def OnPanelLeftDown(self, event):
   510         focused = self.FindFocus()
   520         focused = self.FindFocus()
   511         if isinstance(focused, TextCtrlAutoComplete.TextCtrlAutoComplete):
   521         if isinstance(focused, TextCtrlAutoComplete.TextCtrlAutoComplete):
   512             focused._showDropDown(False)
   522             focused.DismissListBox()
   513         event.Skip()
   523         event.Skip()
   514     
   524     
   515     def RefreshFileMenu(self):
   525     def RefreshFileMenu(self):
   516         if self.PluginRoot is not None:
   526         if self.PluginRoot is not None:
   517             selected = self.TabsOpened.GetSelection()
   527             selected = self.TabsOpened.GetSelection()
  1199                     pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
  1209                     pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
  1200                 boxsizer.AddWindow(statictext, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT)
  1210                 boxsizer.AddWindow(statictext, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT)
  1201                 id = wx.NewId()
  1211                 id = wx.NewId()
  1202                 if isinstance(element_infos["type"], types.ListType):
  1212                 if isinstance(element_infos["type"], types.ListType):
  1203                     combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent, 
  1213                     combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent, 
  1204                         pos=wx.Point(0, 0), size=wx.Size(150, 28), style=wx.CB_READONLY)
  1214                         pos=wx.Point(0, 0), size=wx.Size(300, 28), style=wx.CB_READONLY)
  1205                     boxsizer.AddWindow(combobox, 0, border=0, flag=0)
  1215                     boxsizer.AddWindow(combobox, 0, border=0, flag=0)
  1206                     if element_infos["use"] == "optional":
  1216                     if element_infos["use"] == "optional":
  1207                         combobox.Append("")
  1217                         combobox.Append("")
  1208                     if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType):
  1218                     if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType):
  1209                         for choice, xsdclass in element_infos["type"]:
  1219                         for choice, xsdclass in element_infos["type"]:
  1232                     if "min" in element_infos["type"]:
  1242                     if "min" in element_infos["type"]:
  1233                         scmin = element_infos["type"]["min"]
  1243                         scmin = element_infos["type"]["min"]
  1234                     if "max" in element_infos["type"]:
  1244                     if "max" in element_infos["type"]:
  1235                         scmax = element_infos["type"]["max"]
  1245                         scmax = element_infos["type"]["max"]
  1236                     spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, 
  1246                     spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, 
  1237                         pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
  1247                         pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
  1238                     spinctrl.SetRange(scmin,scmax)
  1248                     spinctrl.SetRange(scmin,scmax)
  1239                     boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
  1249                     boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
  1240                     spinctrl.SetValue(element_infos["value"])
  1250                     spinctrl.SetValue(element_infos["value"])
  1241                     spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id)
  1251                     spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id)
  1242                 else:
  1252                 else:
  1251                             scmin = 0
  1261                             scmin = 0
  1252                         else:
  1262                         else:
  1253                             scmin = -(2**31)
  1263                             scmin = -(2**31)
  1254                         scmax = 2**31-1
  1264                         scmax = 2**31-1
  1255                         spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, 
  1265                         spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, 
  1256                             pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
  1266                             pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
  1257                         spinctrl.SetRange(scmin, scmax)
  1267                         spinctrl.SetRange(scmin, scmax)
  1258                         boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
  1268                         boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
  1259                         spinctrl.SetValue(element_infos["value"])
  1269                         spinctrl.SetValue(element_infos["value"])
  1260                         spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id)
  1270                         spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id)
  1261                     else:
  1271                     else:
  1262                         choices = cPickle.loads(str(self.Config.Read(element_path, cPickle.dumps([""]))))                           
  1272                         choices = cPickle.loads(str(self.Config.Read(element_path, cPickle.dumps([""]))))                           
  1263                         textctrl = TextCtrlAutoComplete.TextCtrlAutoComplete(id=id, 
  1273                         textctrl = TextCtrlAutoComplete.TextCtrlAutoComplete(id=id, 
  1264                                                                      name=element_infos["name"], 
  1274                                                                      name=element_infos["name"], 
  1265                                                                      parent=parent, 
  1275                                                                      parent=parent, 
       
  1276                                                                      appframe=self, 
  1266                                                                      choices=choices, 
  1277                                                                      choices=choices, 
  1267                                                                      element_path=element_path,
  1278                                                                      element_path=element_path,
  1268                                                                      pos=wx.Point(0, 0), 
  1279                                                                      pos=wx.Point(0, 0), 
  1269                                                                      size=wx.Size(150, 25), 
  1280                                                                      size=wx.Size(300, 25), 
  1270                                                                      style=0)
  1281                                                                      style=0)
  1271                         
  1282                         
  1272                         boxsizer.AddWindow(textctrl, 0, border=0, flag=0)
  1283                         boxsizer.AddWindow(textctrl, 0, border=0, flag=0)
  1273                         textctrl.ChangeValue(str(element_infos["value"]))
  1284                         textctrl.ChangeValue(str(element_infos["value"]))
  1274                         textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path))
  1285                         textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path))