716 if plugin == self.PluginRoot: |
685 if plugin == self.PluginRoot: |
717 bkgdclr = CHANGED_TITLE_COLOUR |
686 bkgdclr = CHANGED_TITLE_COLOUR |
718 items = ["main", "params"] |
687 items = ["main", "params"] |
719 else: |
688 else: |
720 bkgdclr = CHANGED_WINDOW_COLOUR |
689 bkgdclr = CHANGED_WINDOW_COLOUR |
721 items = ["left", "middle", "params"] |
690 items = ["left", "right", "params"] |
722 for i in items: |
691 for i in items: |
723 self.PluginInfos[plugin][i].SetBackgroundColour(bkgdclr) |
692 self.PluginInfos[plugin][i].SetBackgroundColour(bkgdclr) |
724 self.PluginInfos[plugin][i].Refresh() |
693 self.PluginInfos[plugin][i].Refresh() |
725 return res |
694 return res |
726 |
695 |
727 def ExpandPlugin(self, plugin, force = False): |
696 def ExpandPlugin(self, plugin, force = False): |
728 for child in self.PluginInfos[plugin]["children"]: |
697 for child in self.PluginInfos[plugin]["children"]: |
729 self.PluginInfos[child]["left"].Show() |
698 self.PluginInfos[child]["left"].Show() |
730 self.PluginInfos[child]["middle"].Show() |
699 self.PluginInfos[child]["right"].Show() |
731 # self.PluginTreeSizer.Show(self.PluginInfos[child]["right"]) |
|
732 if force or not self.PluginInfos[child]["expanded"]: |
700 if force or not self.PluginInfos[child]["expanded"]: |
733 self.ExpandPlugin(child, force) |
701 self.ExpandPlugin(child, force) |
734 if force: |
702 if force: |
735 self.PluginInfos[child]["expanded"] = True |
703 self.PluginInfos[child]["expanded"] = True |
|
704 locations_infos = self.PluginInfos[plugin].get("locations_infos", None) |
|
705 if locations_infos is not None: |
|
706 if force or locations_infos["root"]["expanded"]: |
|
707 self.ExpandLocation(locations_infos, "root", force) |
|
708 if force: |
|
709 locations_infos["root"]["expanded"] = True |
|
710 |
736 |
711 |
737 def CollapsePlugin(self, plugin, force = False): |
712 def CollapsePlugin(self, plugin, force = False): |
738 for child in self.PluginInfos[plugin]["children"]: |
713 for child in self.PluginInfos[plugin]["children"]: |
739 self.PluginInfos[child]["left"].Hide() |
714 self.PluginInfos[child]["left"].Hide() |
740 self.PluginInfos[child]["middle"].Hide() |
715 self.PluginInfos[child]["right"].Hide() |
741 # self.PluginTreeSizer.Hide(self.PluginInfos[child]["right"]) |
|
742 if force or self.PluginInfos[child]["expanded"]: |
716 if force or self.PluginInfos[child]["expanded"]: |
743 self.CollapsePlugin(child, force) |
717 self.CollapsePlugin(child, force) |
744 if force: |
718 if force: |
745 self.PluginInfos[child]["expanded"] = False |
719 self.PluginInfos[child]["expanded"] = False |
|
720 locations_infos = self.PluginInfos[plugin].get("locations_infos", None) |
|
721 if locations_infos is not None: |
|
722 if force or not locations_infos["root"]["expanded"]: |
|
723 self.CollapseLocation(locations_infos, "root", force) |
|
724 if force: |
|
725 locations_infos["root"]["expanded"] = False |
|
726 |
|
727 def ExpandLocation(self, locations_infos, group, force = False): |
|
728 for child in locations_infos[group]["children"]: |
|
729 locations_infos[child]["left"].Show() |
|
730 locations_infos[child]["right"].Show() |
|
731 if force or not locations_infos[child]["expanded"]: |
|
732 self.ExpandLocation(locations_infos, child, force) |
|
733 if force: |
|
734 locations_infos[child]["expanded"] = True |
|
735 |
|
736 def CollapseLocation(self, locations_infos, group, force = False): |
|
737 for child in locations_infos[group]["children"]: |
|
738 locations_infos[child]["left"].Hide() |
|
739 locations_infos[child]["right"].Hide() |
|
740 if force or not locations_infos[child]["expanded"]: |
|
741 self.CollapseLocation(locations_infos, child, force) |
|
742 if force: |
|
743 locations_infos[child]["expanded"] = False |
746 |
744 |
747 def GenerateTreeBranch(self, plugin): |
745 def GenerateTreeBranch(self, plugin): |
748 leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
746 leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
749 if plugin.PlugTestModified(): |
747 if plugin.PlugTestModified(): |
750 bkgdclr=CHANGED_WINDOW_COLOUR |
748 bkgdclr=CHANGED_WINDOW_COLOUR |
751 else: |
749 else: |
752 bkgdclr=WINDOW_COLOUR |
750 bkgdclr=WINDOW_COLOUR |
753 |
751 |
754 leftwindow.SetBackgroundColour(bkgdclr) |
752 leftwindow.SetBackgroundColour(bkgdclr) |
755 |
753 |
756 if plugin not in self.PluginInfos: |
754 if not self.PluginInfos.has_key(plugin): |
757 self.PluginInfos[plugin] = {"expanded" : False, "left_visible" : False, "middle_visible" : False} |
755 self.PluginInfos[plugin] = {"expanded" : False, "right_visible" : False} |
758 |
756 |
759 self.PluginInfos[plugin]["children"] = plugin.IECSortedChilds() |
757 self.PluginInfos[plugin]["children"] = plugin.IECSortedChilds() |
|
758 plugin_locations = [] |
|
759 if len(self.PluginInfos[plugin]["children"]) == 0: |
|
760 plugin_locations = plugin.GetVariableLocationTree() |
|
761 if not self.PluginInfos[plugin].has_key("locations_infos"): |
|
762 self.PluginInfos[plugin]["locations_infos"] = {"root": {"expanded" : False}} |
|
763 |
|
764 self.PluginInfos[plugin]["locations_infos"]["root"]["children"] = [] |
760 |
765 |
761 self.PluginTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) |
766 self.PluginTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) |
762 |
767 |
763 leftwindowsizer = wx.FlexGridSizer(cols=1, rows=3) |
768 leftwindowsizer = wx.FlexGridSizer(cols=1, rows=2) |
764 leftwindowsizer.AddGrowableCol(0) |
769 leftwindowsizer.AddGrowableCol(0) |
765 leftwindowsizer.AddGrowableRow(2) |
|
766 leftwindow.SetSizer(leftwindowsizer) |
770 leftwindow.SetSizer(leftwindowsizer) |
767 |
771 |
768 leftbuttonmainsizer = wx.FlexGridSizer(cols=3, rows=1) |
772 leftbuttonmainsizer = wx.FlexGridSizer(cols=3, rows=1) |
769 leftbuttonmainsizer.AddGrowableCol(0) |
773 leftbuttonmainsizer.AddGrowableCol(0) |
770 leftwindowsizer.AddSizer(leftbuttonmainsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT) #|wx.TOP |
774 leftwindowsizer.AddSizer(leftbuttonmainsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT) #|wx.TOP |
874 tc.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
890 tc.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
875 tc.ChangeValue(plugin.MandatoryParams[1].getName()) |
891 tc.ChangeValue(plugin.MandatoryParams[1].getName()) |
876 tc.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(tc, plugin, "BaseParams.Name"), id=tc_id) |
892 tc.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(tc, plugin, "BaseParams.Name"), id=tc_id) |
877 iecsizer.AddWindow(tc, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
893 iecsizer.AddWindow(tc, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
878 |
894 |
879 |
895 rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
880 leftminimizebutton_id = wx.NewId() |
896 rightwindow.SetBackgroundColour(bkgdclr) |
881 leftminimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=leftminimizebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'ShowVars.png')), |
897 |
882 name='MinimizeButton', parent=leftwindow, pos=wx.Point(0, 0), |
898 self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
|
899 |
|
900 rightwindowmainsizer = wx.BoxSizer(wx.VERTICAL) |
|
901 rightwindow.SetSizer(rightwindowmainsizer) |
|
902 |
|
903 rightwindowsizer = wx.FlexGridSizer(cols=2, rows=1) |
|
904 rightwindowsizer.AddGrowableCol(1) |
|
905 rightwindowsizer.AddGrowableRow(0) |
|
906 rightwindowmainsizer.AddSizer(rightwindowsizer, 0, border=8, flag=wx.TOP|wx.GROW) |
|
907 |
|
908 msizer = self.GenerateMethodButtonSizer(plugin, rightwindow, not self.PluginInfos[plugin]["right_visible"]) |
|
909 rightwindowsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW) |
|
910 |
|
911 rightparamssizer = wx.BoxSizer(wx.HORIZONTAL) |
|
912 rightwindowsizer.AddSizer(rightparamssizer, 0, border=0, flag=wx.ALIGN_RIGHT) |
|
913 |
|
914 paramswindow = wx.Panel(rightwindow, -1, size=wx.Size(-1, -1)) |
|
915 paramswindow.SetBackgroundColour(bkgdclr) |
|
916 |
|
917 psizer = wx.BoxSizer(wx.HORIZONTAL) |
|
918 paramswindow.SetSizer(psizer) |
|
919 self.PluginInfos[plugin]["params"] = paramswindow |
|
920 |
|
921 rightparamssizer.AddWindow(paramswindow, 0, border=5, flag=wx.ALL) |
|
922 |
|
923 plugin_infos = plugin.GetParamsAttributes() |
|
924 self.RefreshSizerElement(paramswindow, psizer, plugin, plugin_infos, None, False) |
|
925 |
|
926 if not self.PluginInfos[plugin]["right_visible"]: |
|
927 paramswindow.Hide() |
|
928 |
|
929 rightminimizebutton_id = wx.NewId() |
|
930 rightminimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=rightminimizebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Maximize.png')), |
|
931 name='MinimizeButton', parent=rightwindow, pos=wx.Point(0, 0), |
883 size=wx.Size(24, 24), style=wx.NO_BORDER) |
932 size=wx.Size(24, 24), style=wx.NO_BORDER) |
884 make_genbitmaptogglebutton_flat(leftminimizebutton) |
933 make_genbitmaptogglebutton_flat(rightminimizebutton) |
885 leftminimizebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'HideVars.png'))) |
934 rightminimizebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Minimize.png'))) |
886 leftminimizebutton.SetToggle(self.PluginInfos[plugin]["left_visible"]) |
935 rightminimizebutton.SetToggle(self.PluginInfos[plugin]["right_visible"]) |
887 def toggleleftwindow(event): |
936 rightparamssizer.AddWindow(rightminimizebutton, 0, border=5, flag=wx.ALL) |
888 if leftminimizebutton.GetToggle(): |
937 |
889 leftwindowsizer.Show(1) |
938 def togglerightwindow(event): |
|
939 if rightminimizebutton.GetToggle(): |
|
940 rightparamssizer.Show(0) |
|
941 msizer.SetCols(1) |
890 else: |
942 else: |
891 leftwindowsizer.Hide(1) |
943 rightparamssizer.Hide(0) |
892 self.PluginInfos[plugin]["left_visible"] = leftminimizebutton.GetToggle() |
944 msizer.SetCols(len(plugin.PluginMethods)) |
|
945 self.PluginInfos[plugin]["right_visible"] = rightminimizebutton.GetToggle() |
893 self.PLCConfigMainSizer.Layout() |
946 self.PLCConfigMainSizer.Layout() |
894 self.RefreshScrollBars() |
947 self.RefreshScrollBars() |
895 event.Skip() |
948 event.Skip() |
896 leftminimizebutton.Bind(wx.EVT_BUTTON, toggleleftwindow, id=leftminimizebutton_id) |
949 rightminimizebutton.Bind(wx.EVT_BUTTON, togglerightwindow, id=rightminimizebutton_id) |
897 leftbuttonmainsizer.AddWindow(leftminimizebutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
|
898 |
|
899 locations = plugin.GetLocations() |
|
900 lb = wx.ListBox(leftwindow, -1, size=wx.Size(-1, max(1, min(len(locations), 4)) * 25), style=wx.NO_BORDER) |
|
901 for location in locations: |
|
902 lb.Append(location["NAME"].replace("__", "%").replace("_", ".")) |
|
903 if not self.PluginInfos[plugin]["left_visible"]: |
|
904 lb.Hide() |
|
905 self.PluginInfos[plugin]["variable_list"] = lb |
|
906 leftwindowsizer.AddWindow(lb, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM) |
|
907 |
|
908 middlewindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
|
909 middlewindow.SetBackgroundColour(bkgdclr) |
|
910 |
|
911 self.PluginTreeSizer.AddWindow(middlewindow, 0, border=0, flag=wx.GROW) |
|
912 |
|
913 middlewindowmainsizer = wx.BoxSizer(wx.VERTICAL) |
|
914 middlewindow.SetSizer(middlewindowmainsizer) |
|
915 |
|
916 middlewindowsizer = wx.FlexGridSizer(cols=2, rows=1) |
|
917 middlewindowsizer.AddGrowableCol(1) |
|
918 middlewindowsizer.AddGrowableRow(0) |
|
919 middlewindowmainsizer.AddSizer(middlewindowsizer, 0, border=8, flag=wx.TOP|wx.GROW) |
|
920 |
|
921 msizer = self.GenerateMethodButtonSizer(plugin, middlewindow, not self.PluginInfos[plugin]["middle_visible"]) |
|
922 middlewindowsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW) |
|
923 |
|
924 middleparamssizer = wx.BoxSizer(wx.HORIZONTAL) |
|
925 middlewindowsizer.AddSizer(middleparamssizer, 0, border=0, flag=wx.ALIGN_RIGHT) |
|
926 |
|
927 paramswindow = wx.Panel(middlewindow, -1, size=wx.Size(-1, -1)) |
|
928 paramswindow.SetBackgroundColour(bkgdclr) |
|
929 |
|
930 psizer = wx.BoxSizer(wx.HORIZONTAL) |
|
931 paramswindow.SetSizer(psizer) |
|
932 self.PluginInfos[plugin]["params"] = paramswindow |
|
933 |
|
934 middleparamssizer.AddWindow(paramswindow, 0, border=5, flag=wx.ALL) |
|
935 |
|
936 plugin_infos = plugin.GetParamsAttributes() |
|
937 self.RefreshSizerElement(paramswindow, psizer, plugin, plugin_infos, None, False) |
|
938 |
|
939 if not self.PluginInfos[plugin]["middle_visible"]: |
|
940 paramswindow.Hide() |
|
941 |
|
942 middleminimizebutton_id = wx.NewId() |
|
943 middleminimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=middleminimizebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Maximize.png')), |
|
944 name='MinimizeButton', parent=middlewindow, pos=wx.Point(0, 0), |
|
945 size=wx.Size(24, 24), style=wx.NO_BORDER) |
|
946 make_genbitmaptogglebutton_flat(middleminimizebutton) |
|
947 middleminimizebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Minimize.png'))) |
|
948 middleminimizebutton.SetToggle(self.PluginInfos[plugin]["middle_visible"]) |
|
949 middleparamssizer.AddWindow(middleminimizebutton, 0, border=5, flag=wx.ALL) |
|
950 |
|
951 # rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
|
952 # rightwindow.SetBackgroundColour(wx.Colour(240,240,240)) |
|
953 # |
|
954 # self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
|
955 # |
|
956 # rightsizer = wx.BoxSizer(wx.VERTICAL) |
|
957 # rightwindow.SetSizer(rightsizer) |
|
958 # |
|
959 # rightmainsizer = wx.BoxSizer(wx.VERTICAL) |
|
960 # rightsizer.AddSizer(rightmainsizer, 0, border=5, flag=wx.ALL) |
|
961 # |
|
962 # if len(plugin.PlugChildsTypes) > 0: |
|
963 # addsizer = self.GenerateAddButtonSizer(plugin, rightwindow) |
|
964 # rightmainsizer.AddSizer(addsizer, 0, border=4, flag=wx.TOP) |
|
965 # else: |
|
966 # addsizer = None |
|
967 |
|
968 def togglemiddlerightwindow(event): |
|
969 if middleminimizebutton.GetToggle(): |
|
970 middleparamssizer.Show(0) |
|
971 msizer.SetCols(1) |
|
972 # if addsizer is not None: |
|
973 # addsizer.SetCols(1) |
|
974 else: |
|
975 middleparamssizer.Hide(0) |
|
976 msizer.SetCols(len(plugin.PluginMethods)) |
|
977 # if addsizer is not None: |
|
978 # addsizer.SetCols(len(plugin.PlugChildsTypes)) |
|
979 self.PluginInfos[plugin]["middle_visible"] = middleminimizebutton.GetToggle() |
|
980 self.PLCConfigMainSizer.Layout() |
|
981 self.RefreshScrollBars() |
|
982 event.Skip() |
|
983 middleminimizebutton.Bind(wx.EVT_BUTTON, togglemiddlerightwindow, id=middleminimizebutton_id) |
|
984 |
950 |
985 self.PluginInfos[plugin]["left"] = leftwindow |
951 self.PluginInfos[plugin]["left"] = leftwindow |
986 self.PluginInfos[plugin]["middle"] = middlewindow |
952 self.PluginInfos[plugin]["right"] = rightwindow |
987 # self.PluginInfos[plugin]["right"] = rightwindow |
|
988 for child in self.PluginInfos[plugin]["children"]: |
953 for child in self.PluginInfos[plugin]["children"]: |
989 self.GenerateTreeBranch(child) |
954 self.GenerateTreeBranch(child) |
990 if not self.PluginInfos[child]["expanded"]: |
955 if not self.PluginInfos[child]["expanded"]: |
991 self.CollapsePlugin(child) |
956 self.CollapsePlugin(child) |
992 |
957 if len(plugin_locations) > 0: |
993 def RefreshVariableLists(self): |
958 locations_infos = self.PluginInfos[plugin]["locations_infos"] |
994 for plugin, infos in self.PluginInfos.items(): |
959 for location in plugin_locations: |
995 locations = plugin.GetLocations() |
960 locations_infos["root"]["children"].append("root.%s" % location["name"]) |
996 infos["variable_list"].SetSize(wx.Size(-1, max(1, min(len(locations), 4)) * 25)) |
961 self.GenerateLocationTreeBranch(locations_infos, "root", location) |
997 infos["variable_list"].Clear() |
962 if not locations_infos["root"]["expanded"]: |
998 for location in locations: |
963 self.CollapseLocation(locations_infos, "root") |
999 infos["variable_list"].Append(location["NAME"].replace("__", "%").replace("_", ".")) |
964 |
1000 self.PLCConfigMainSizer.Layout() |
965 LOCATION_BITMAP = {LOCATION_VAR_INPUT: "VAR_INPUT", |
1001 self.RefreshScrollBars() |
966 LOCATION_VAR_OUTPUT: "VAR_OUTPUT", |
1002 |
967 LOCATION_VAR_MEMORY: "VAR_LOCAL"} |
|
968 |
|
969 def GenerateLocationTreeBranch(self, locations_infos, parent, location): |
|
970 leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
|
971 self.PluginTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) |
|
972 |
|
973 leftwindowsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
974 leftwindow.SetSizer(leftwindowsizer) |
|
975 |
|
976 rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
|
977 self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
|
978 |
|
979 location_name = "%s.%s" % (parent, location["name"]) |
|
980 if not locations_infos.has_key(location_name): |
|
981 locations_infos[location_name] = {"expanded" : False} |
|
982 |
|
983 locations_infos[location_name]["children"] = ["%s.%s" % (location_name, child["name"]) for child in location["children"]] |
|
984 |
|
985 if location["type"] in [LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP]: |
|
986 leftwindow.SetBackgroundColour(WINDOW_COLOUR) |
|
987 rightwindow.SetBackgroundColour(WINDOW_COLOUR) |
|
988 |
|
989 st = wx.StaticText(leftwindow, -1) |
|
990 st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
|
991 st.SetLabel(location["location"]) |
|
992 leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT) |
|
993 |
|
994 expandbutton_id = wx.NewId() |
|
995 expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')), |
|
996 name='ExpandButton', parent=leftwindow, pos=wx.Point(0, 0), |
|
997 size=wx.Size(13, 13), style=wx.NO_BORDER) |
|
998 expandbutton.labelDelta = 0 |
|
999 expandbutton.SetBezelWidth(0) |
|
1000 expandbutton.SetUseFocusIndicator(False) |
|
1001 expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png'))) |
|
1002 expandbutton.SetToggle(self.PluginInfos[plugin]["expanded"]) |
|
1003 |
|
1004 if len(location["children"]) > 0: |
|
1005 def togglebutton(event): |
|
1006 if expandbutton.GetToggle(): |
|
1007 self.ExpandLocation(locations_infos, location_name) |
|
1008 else: |
|
1009 self.CollapseLocation(locations_infos, location_name) |
|
1010 locations_infos[location_name]["expanded"] = expandbutton.GetToggle() |
|
1011 self.PLCConfigMainSizer.Layout() |
|
1012 self.RefreshScrollBars() |
|
1013 event.Skip() |
|
1014 expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
|
1015 else: |
|
1016 expandbutton.Enable(False) |
|
1017 leftwindowsizer.AddWindow(expandbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
|
1018 |
|
1019 else: |
|
1020 leftwindow.SetBackgroundColour(wx.WHITE) |
|
1021 rightwindow.SetBackgroundColour(wx.WHITE) |
|
1022 |
|
1023 leftwindowsizer.Add(wx.Size(50, 16), 0) |
|
1024 |
|
1025 st = wx.StaticBitmap(leftwindow, -1) |
|
1026 st.SetBitmap(wx.Bitmap(os.path.join(base_folder, "plcopeneditor", 'Images', '%s.png' % self.LOCATION_BITMAP[location["type"]]))) |
|
1027 leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT) |
|
1028 |
|
1029 st_id = wx.NewId() |
|
1030 st = wx.StaticText(leftwindow, st_id, size=wx.DefaultSize, style=wx.NO_BORDER) |
|
1031 st.SetFont(wx.Font(faces["size"] * 0.5, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"])) |
|
1032 st.SetLabel(location["name"]) |
|
1033 if location["type"] in [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]: |
|
1034 infos = location.copy() |
|
1035 infos.pop("children") |
|
1036 st.Bind(wx.EVT_LEFT_DOWN, self.GenerateLocationLeftDownFunction(infos)) |
|
1037 leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
|
1038 |
|
1039 locations_infos[location_name]["left"] = leftwindow |
|
1040 locations_infos[location_name]["right"] = rightwindow |
|
1041 for child in locations_infos[location_name]["children"]: |
|
1042 self.GenerateLocationTreeBranch(child) |
|
1043 if not locations_infos[child]["expanded"]: |
|
1044 self.CollapseLocation(locations_infos, child) |
|
1045 |
|
1046 def GenerateLocationLeftDownFunction(self, infos): |
|
1047 def OnLocationLeftDownFunction(event): |
|
1048 data = wx.TextDataObject(str((infos["location"], "location", infos["IEC_type"], infos["name"], infos["description"]))) |
|
1049 dragSource = wx.DropSource(self) |
|
1050 dragSource.SetData(data) |
|
1051 dragSource.DoDragDrop() |
|
1052 event.Skip() |
|
1053 return OnLocationLeftDownFunction |
|
1054 |
1003 def RefreshAll(self): |
1055 def RefreshAll(self): |
1004 self.RefreshPLCParams() |
1056 self.RefreshPLCParams() |
1005 self.RefreshPluginTree() |
1057 self.RefreshPluginTree() |
1006 |
1058 |
1007 def GetItemChannelChangedFunction(self, plugin, value): |
1059 def GetItemChannelChangedFunction(self, plugin, value): |