387 |
387 |
388 self.PLCConfig = wx.ScrolledWindow(id=ID_BEREMIZPLCCONFIG, |
388 self.PLCConfig = wx.ScrolledWindow(id=ID_BEREMIZPLCCONFIG, |
389 name='PLCConfig', parent=parent, pos=wx.Point(0, 0), |
389 name='PLCConfig', parent=parent, pos=wx.Point(0, 0), |
390 size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL) |
390 size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL) |
391 self.PLCConfig.SetBackgroundColour(wx.WHITE) |
391 self.PLCConfig.SetBackgroundColour(wx.WHITE) |
|
392 self.PLCConfig.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
392 self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow) |
393 self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow) |
393 |
394 |
394 self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='', |
395 self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='', |
395 name='LogConsole', parent=parent, pos=wx.Point(0, 0), |
396 name='LogConsole', parent=parent, pos=wx.Point(0, 0), |
396 size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2) |
397 size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2) |
519 |
520 |
520 def OnFrameActivated(self, event): |
521 def OnFrameActivated(self, event): |
521 if not event.GetActive() and self.PluginRoot is not None: |
522 if not event.GetActive() and self.PluginRoot is not None: |
522 self.PluginRoot.RefreshPluginsBlockLists() |
523 self.PluginRoot.RefreshPluginsBlockLists() |
523 |
524 |
|
525 def OnPanelLeftDown(self, event): |
|
526 focused = self.FindFocus() |
|
527 if isinstance(focused, TextCtrlAutoComplete.TextCtrlAutoComplete): |
|
528 focused._showDropDown(False) |
|
529 event.Skip() |
|
530 |
524 def RefreshMainMenu(self): |
531 def RefreshMainMenu(self): |
525 if self.PluginRoot is not None: |
532 if self.PluginRoot is not None: |
526 ## self.MenuBar.EnableTop(1, True) |
533 ## self.MenuBar.EnableTop(1, True) |
527 ## self.MenuBar.EnableTop(2, True) |
534 ## self.MenuBar.EnableTop(2, True) |
528 self.FileMenu.Enable(wx.ID_SAVE, True) |
535 self.FileMenu.Enable(wx.ID_SAVE, True) |
586 plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER) |
594 plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER) |
587 |
595 |
588 msizer = self.GenerateMethodButtonSizer(self.PluginRoot, plcwindow, not self.PluginInfos[self.PluginRoot]["middle_visible"]) |
596 msizer = self.GenerateMethodButtonSizer(self.PluginRoot, plcwindow, not self.PluginInfos[self.PluginRoot]["middle_visible"]) |
589 plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW) |
597 plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW) |
590 |
598 |
591 paramswindow = wx.Panel(plcwindow, -1, size=wx.Size(-1, -1)) |
599 paramswindow = wx.Panel(plcwindow, -1, size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
592 paramswindow.SetBackgroundColour(TITLE_COLOUR) |
600 paramswindow.SetBackgroundColour(TITLE_COLOUR) |
|
601 paramswindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
593 plcwindowbuttonsizer.AddWindow(paramswindow, 0, border=0, flag=0) |
602 plcwindowbuttonsizer.AddWindow(paramswindow, 0, border=0, flag=0) |
594 |
603 |
595 psizer = wx.BoxSizer(wx.HORIZONTAL) |
604 psizer = wx.BoxSizer(wx.HORIZONTAL) |
596 paramswindow.SetSizer(psizer) |
605 paramswindow.SetSizer(psizer) |
597 |
606 |
1126 name="%s_label"%element_infos["name"], parent=parent, |
1135 name="%s_label"%element_infos["name"], parent=parent, |
1127 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
1136 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
1128 boxsizer.AddWindow(statictext, 0, border=4, flag=wx.TOP) |
1137 boxsizer.AddWindow(statictext, 0, border=4, flag=wx.TOP) |
1129 id = wx.NewId() |
1138 id = wx.NewId() |
1130 if isinstance(element_infos["type"], types.ListType): |
1139 if isinstance(element_infos["type"], types.ListType): |
1131 choicectrl = wx.Choice(id=id, name=element_infos["name"], parent=parent, |
1140 combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent, |
1132 pos=wx.Point(0, 0), size=wx.Size(150, 25), style=0) |
1141 pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.CB_READONLY) |
1133 boxsizer.AddWindow(choicectrl, 0, border=0, flag=0) |
1142 boxsizer.AddWindow(combobox, 0, border=0, flag=0) |
1134 if element_infos["use"] == "optional": |
1143 if element_infos["use"] == "optional": |
1135 choicectrl.Append("") |
1144 combobox.Append("") |
1136 if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
1145 if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
1137 for choice, xsdclass in element_infos["type"]: |
1146 for choice, xsdclass in element_infos["type"]: |
1138 choicectrl.Append(choice) |
1147 combobox.Append(choice) |
1139 staticbox = wx.StaticBox(id=-1, label="%(name)s - %(value)s"%element_infos, |
1148 staticbox = wx.StaticBox(id=-1, label="%(name)s - %(value)s"%element_infos, |
1140 name='%s_staticbox'%element_infos["name"], parent=parent, |
1149 name='%s_staticbox'%element_infos["name"], parent=parent, |
1141 pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0) |
1150 pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0) |
1142 staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
1151 staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
1143 sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
1152 sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
1144 self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) |
1153 self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) |
1145 callback = self.GetChoiceContentCallBackFunction(choicectrl, staticboxsizer, plugin, element_path) |
1154 callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, plugin, element_path) |
1146 else: |
1155 else: |
1147 for choice in element_infos["type"]: |
1156 for choice in element_infos["type"]: |
1148 choicectrl.Append(choice) |
1157 combobox.Append(choice) |
1149 callback = self.GetChoiceCallBackFunction(choicectrl, plugin, element_path) |
1158 callback = self.GetChoiceCallBackFunction(combobox, plugin, element_path) |
1150 if element_infos["value"] is None: |
1159 if element_infos["value"] is None: |
1151 choicectrl.SetStringSelection("") |
1160 combobox.SetStringSelection("") |
1152 else: |
1161 else: |
1153 choicectrl.SetStringSelection(element_infos["value"]) |
1162 combobox.SetStringSelection(element_infos["value"]) |
1154 choicectrl.Bind(wx.EVT_CHOICE, callback, id=id) |
1163 combobox.Bind(wx.EVT_COMBOBOX, callback, id=id) |
1155 elif isinstance(element_infos["type"], types.DictType): |
1164 elif isinstance(element_infos["type"], types.DictType): |
1156 scmin = -(2**31) |
1165 scmin = -(2**31) |
1157 scmax = 2**31-1 |
1166 scmax = 2**31-1 |
1158 if "min" in element_infos["type"]: |
1167 if "min" in element_infos["type"]: |
1159 scmin = element_infos["type"]["min"] |
1168 scmin = element_infos["type"]["min"] |