230 |
230 |
231 def _init_coll_LeftGridSizer_Growables(self, parent): |
231 def _init_coll_LeftGridSizer_Growables(self, parent): |
232 parent.AddGrowableCol(0) |
232 parent.AddGrowableCol(0) |
233 parent.AddGrowableRow(0) |
233 parent.AddGrowableRow(0) |
234 |
234 |
|
235 def _init_coll_RightGridSizer_Items(self, parent): |
|
236 parent.AddSizer(self.MenuSizer, 0, border=0, flag=wx.GROW) |
|
237 parent.AddWindow(self.SecondSplitter, 0, border=0, flag=wx.GROW) |
|
238 |
|
239 def _init_coll_RightGridSizer_Growables(self, parent): |
|
240 parent.AddGrowableCol(0) |
|
241 parent.AddGrowableRow(1) |
|
242 |
235 def _init_coll_ButtonGridSizer_Items(self, parent): |
243 def _init_coll_ButtonGridSizer_Items(self, parent): |
236 parent.AddWindow(self.PluginChilds, 0, border=0, flag=wx.GROW) |
244 parent.AddWindow(self.PluginChilds, 0, border=0, flag=wx.GROW) |
237 parent.AddWindow(self.AddButton, 0, border=0, flag=0) |
245 parent.AddWindow(self.AddButton, 0, border=0, flag=0) |
238 parent.AddWindow(self.DeleteButton, 0, border=0, flag=0) |
246 parent.AddWindow(self.DeleteButton, 0, border=0, flag=0) |
239 |
247 |
241 parent.AddGrowableCol(0) |
249 parent.AddGrowableCol(0) |
242 parent.AddGrowableRow(0) |
250 parent.AddGrowableRow(0) |
243 |
251 |
244 def _init_sizers(self): |
252 def _init_sizers(self): |
245 self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2) |
253 self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2) |
|
254 self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2) |
246 self.ButtonGridSizer = wx.FlexGridSizer(cols=3, hgap=2, rows=1, vgap=2) |
255 self.ButtonGridSizer = wx.FlexGridSizer(cols=3, hgap=2, rows=1, vgap=2) |
|
256 self.MenuSizer = wx.BoxSizer(wx.HORIZONTAL) |
247 self.ParamsPanelMainSizer = wx.BoxSizer(wx.VERTICAL) |
257 self.ParamsPanelMainSizer = wx.BoxSizer(wx.VERTICAL) |
248 |
258 |
249 self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
259 self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
250 self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
260 self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
|
261 self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
|
262 self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
251 self._init_coll_ButtonGridSizer_Growables(self.ButtonGridSizer) |
263 self._init_coll_ButtonGridSizer_Growables(self.ButtonGridSizer) |
252 self._init_coll_ButtonGridSizer_Items(self.ButtonGridSizer) |
264 self._init_coll_ButtonGridSizer_Items(self.ButtonGridSizer) |
253 |
265 |
254 self.LeftPanel.SetSizer(self.LeftGridSizer) |
266 self.LeftPanel.SetSizer(self.LeftGridSizer) |
|
267 self.RightPanel.SetSizer(self.RightGridSizer) |
255 self.ParamsPanel.SetSizer(self.ParamsPanelMainSizer) |
268 self.ParamsPanel.SetSizer(self.ParamsPanelMainSizer) |
256 |
269 |
257 def _init_ctrls(self, prnt): |
270 def _init_ctrls(self, prnt): |
258 wx.Frame.__init__(self, id=ID_BEREMIZ, name=u'Beremiz', |
271 wx.Frame.__init__(self, id=ID_BEREMIZ, name=u'Beremiz', |
259 parent=prnt, pos=wx.Point(0, 0), size=wx.Size(1000, 600), |
272 parent=prnt, pos=wx.Point(0, 0), size=wx.Size(1000, 600), |
296 size=wx.Size(32, 32), style=wx.NO_BORDER) |
309 size=wx.Size(32, 32), style=wx.NO_BORDER) |
297 self.DeleteButton.SetToolTipString("Delete the current selected plugin") |
310 self.DeleteButton.SetToolTipString("Delete the current selected plugin") |
298 self.DeleteButton.Bind(wx.EVT_BUTTON, self.OnDeleteButton, |
311 self.DeleteButton.Bind(wx.EVT_BUTTON, self.OnDeleteButton, |
299 id=ID_BEREMIZDELETEBUTTON) |
312 id=ID_BEREMIZDELETEBUTTON) |
300 |
313 |
|
314 self.RightPanel = wx.Panel(id=ID_BEREMIZLEFTPANEL, |
|
315 name='RightPanel', parent=self.MainSplitter, pos=wx.Point(0, 0), |
|
316 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
317 |
301 self.SecondSplitter = wx.SplitterWindow(id=ID_BEREMIZSECONDSPLITTER, |
318 self.SecondSplitter = wx.SplitterWindow(id=ID_BEREMIZSECONDSPLITTER, |
302 name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0), |
319 name='SecondSplitter', parent=self.RightPanel, point=wx.Point(0, 0), |
303 size=wx.Size(0, 0), style=wx.SP_3D) |
320 size=wx.Size(0, 0), style=wx.SP_3D) |
304 self.SecondSplitter.SetNeedUpdating(True) |
321 self.SecondSplitter.SetNeedUpdating(True) |
305 self.SecondSplitter.SetMinimumPaneSize(1) |
322 self.SecondSplitter.SetMinimumPaneSize(1) |
306 |
323 |
307 self.MainSplitter.SplitVertically(self.LeftPanel, self.SecondSplitter, |
324 self.MainSplitter.SplitVertically(self.LeftPanel, self.RightPanel, |
308 300) |
325 300) |
309 |
326 |
310 self.ParamsPanel = wx.ScrolledWindow(id=ID_BEREMIZPARAMSPANEL, |
327 self.ParamsPanel = wx.ScrolledWindow(id=ID_BEREMIZPARAMSPANEL, |
311 name='ParamsPanel', parent=self.SecondSplitter, pos=wx.Point(0, 0), |
328 name='ParamsPanel', parent=self.SecondSplitter, pos=wx.Point(0, 0), |
312 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
329 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
474 else: |
491 else: |
475 # Refresh ParamsPanel |
492 # Refresh ParamsPanel |
476 self.ParamsPanel.Show() |
493 self.ParamsPanel.Show() |
477 infos = plugin.GetParamsAttributes() |
494 infos = plugin.GetParamsAttributes() |
478 if wx.VERSION >= (2, 7, 0): |
495 if wx.VERSION >= (2, 7, 0): |
|
496 self.MenuSizer.Clear(True) |
479 self.ParamsPanelMainSizer.Clear(True) |
497 self.ParamsPanelMainSizer.Clear(True) |
480 else: |
498 else: |
|
499 self.ClearSizer(self.MenuSizer) |
481 self.ClearSizer(self.ParamsPanelMainSizer) |
500 self.ClearSizer(self.ParamsPanelMainSizer) |
482 if len(self.PluginRoot.PluginMethods) > 0: |
501 if len(self.PluginRoot.PluginMethods) > 0: |
483 boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
502 boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
484 self.ParamsPanelMainSizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
503 self.MenuSizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
485 for plugin_infos in self.PluginRoot.PluginMethods: |
504 for plugin_infos in self.PluginRoot.PluginMethods: |
486 if "method" in plugin_infos: |
505 if "method" in plugin_infos: |
487 id = wx.NewId() |
506 id = wx.NewId() |
488 if "bitmap" in plugin_infos: |
507 if "bitmap" in plugin_infos: |
489 button = wx.lib.buttons.GenBitmapTextButton(ID=id, parent=self.ParamsPanel, |
508 button = wx.lib.buttons.GenBitmapTextButton(ID=id, parent=self.RightPanel, |
490 bitmap=wx.Bitmap(plugin_infos["bitmap"]), label=plugin_infos["name"], |
509 bitmap=wx.Bitmap(plugin_infos["bitmap"]), label=plugin_infos["name"], |
491 name=plugin_infos["name"], pos=wx.Point(0, 0), style=wx.BU_EXACTFIT|wx.NO_BORDER) |
510 name=plugin_infos["name"], pos=wx.Point(0, 0), style=wx.BU_EXACTFIT|wx.NO_BORDER) |
492 else: |
511 else: |
493 button = wx.Button(id=id, label=plugin_infos["name"], |
512 button = wx.Button(id=id, label=plugin_infos["name"], |
494 name=plugin_infos["name"], parent=self.ParamsPanel, |
513 name=plugin_infos["name"], parent=self.RightPanel, |
495 pos=wx.Point(0, 0), style=wx.BU_EXACTFIT) |
514 pos=wx.Point(0, 0), style=wx.BU_EXACTFIT) |
496 button.SetToolTipString(plugin_infos["tooltip"]) |
515 button.SetToolTipString(plugin_infos["tooltip"]) |
497 button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(self.PluginRoot, plugin_infos["method"]), id=id) |
516 button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(self.PluginRoot, plugin_infos["method"]), id=id) |
498 boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT) |
517 boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT) |
|
518 self.RightGridSizer.Layout() |
499 self.RefreshSizerElement(self.ParamsPanelMainSizer, infos, None, False) |
519 self.RefreshSizerElement(self.ParamsPanelMainSizer, infos, None, False) |
500 if plugin != self.PluginRoot and len(plugin.PluginMethods) > 0: |
520 if plugin != self.PluginRoot and len(plugin.PluginMethods) > 0: |
501 boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
521 boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
502 self.ParamsPanelMainSizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
522 self.MenuSizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
503 for plugin_infos in plugin.PluginMethods: |
523 for plugin_infos in plugin.PluginMethods: |
504 if "method" in plugin_infos: |
524 if "method" in plugin_infos: |
505 id = wx.NewId() |
525 id = wx.NewId() |
506 if "bitmap" in plugin_infos: |
526 if "bitmap" in plugin_infos: |
507 button = wx.lib.buttons.GenBitmapTextButton(ID=id, parent=self.ParamsPanel, |
527 button = wx.lib.buttons.GenBitmapTextButton(ID=id, parent=self.RightPanel, |
508 bitmap=wx.Bitmap(plugin_infos["bitmap"]), label=plugin_infos["name"], |
528 bitmap=wx.Bitmap(plugin_infos["bitmap"]), label=plugin_infos["name"], |
509 name=plugin_infos["name"], pos=wx.Point(0, 0), style=wx.BU_EXACTFIT|wx.NO_BORDER) |
529 name=plugin_infos["name"], pos=wx.Point(0, 0), style=wx.BU_EXACTFIT|wx.NO_BORDER) |
510 else: |
530 else: |
511 button = wx.Button(id=id, label=plugin_infos["name"], |
531 button = wx.Button(id=id, label=plugin_infos["name"], |
512 name=plugin_infos["name"], parent=self.ParamsPanel, |
532 name=plugin_infos["name"], parent=self.RightPanel, |
513 pos=wx.Point(0, 0), style=wx.BU_EXACTFIT) |
533 pos=wx.Point(0, 0), style=wx.BU_EXACTFIT) |
514 button.SetToolTipString(plugin_infos["tooltip"]) |
534 button.SetToolTipString(plugin_infos["tooltip"]) |
515 button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_infos["method"]), id=id) |
535 button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_infos["method"]), id=id) |
516 boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT) |
536 boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT) |
|
537 self.RightGridSizer.Layout() |
517 self.ParamsPanelMainSizer.Layout() |
538 self.ParamsPanelMainSizer.Layout() |
518 self.ParamsPanel.SetClientSize(self.ParamsPanel.GetClientSize()) |
539 self.ParamsPanel.SetClientSize(self.ParamsPanel.GetClientSize()) |
519 |
540 |
520 # Refresh PluginChilds |
541 # Refresh PluginChilds |
521 self.PluginChilds.Clear() |
542 self.PluginChilds.Clear() |
618 pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
639 pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
619 boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT) |
640 boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT) |
620 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
641 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
621 name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
642 name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
622 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
643 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
623 boxsizer.AddWindow(statictext, 0, border=0, flag=0) |
644 boxsizer.AddWindow(statictext, 0, border=4, flag=wx.TOP) |
624 id = wx.NewId() |
645 id = wx.NewId() |
625 choicectrl = wx.Choice(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
646 choicectrl = wx.Choice(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
626 pos=wx.Point(0, 0), size=wx.Size(150, 25), style=0) |
647 pos=wx.Point(0, 0), size=wx.Size(150, 25), style=0) |
627 boxsizer.AddWindow(choicectrl, 0, border=0, flag=0) |
648 boxsizer.AddWindow(choicectrl, 0, border=0, flag=0) |
628 choicectrl.Append("") |
649 choicectrl.Append("") |
656 pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
677 pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
657 boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT) |
678 boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT) |
658 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
679 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
659 name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
680 name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
660 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
681 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
661 boxsizer.AddWindow(statictext, 0, border=0, flag=wx.TOP|wx.LEFT|wx.BOTTOM) |
682 boxsizer.AddWindow(statictext, 0, border=4, flag=wx.TOP) |
662 id = wx.NewId() |
683 id = wx.NewId() |
663 scmin = -(2**31) |
684 scmin = -(2**31) |
664 scmax = 2**31-1 |
685 scmax = 2**31-1 |
665 if "min" in element_infos["type"]: |
686 if "min" in element_infos["type"]: |
666 scmin = element_infos["type"]["min"] |
687 scmin = element_infos["type"]["min"] |
695 pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
716 pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
696 boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT) |
717 boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT) |
697 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
718 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
698 name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
719 name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
699 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
720 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
700 boxsizer.AddWindow(statictext, 0, border=0, flag=0) |
721 boxsizer.AddWindow(statictext, 0, border=4, flag=wx.TOP) |
701 id = wx.NewId() |
722 id = wx.NewId() |
702 if element_infos["type"] == "boolean": |
723 if element_infos["type"] == "boolean": |
703 checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
724 checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
704 pos=wx.Point(0, 0), size=wx.Size(17, 25), style=0) |
725 pos=wx.Point(0, 0), size=wx.Size(17, 25), style=0) |
705 boxsizer.AddWindow(checkbox, 0, border=0, flag=0) |
726 boxsizer.AddWindow(checkbox, 0, border=0, flag=0) |