dialogs/BrowseLocationsDialog.py
branchpython3
changeset 3789 8def429216ca
parent 3750 f62625418bff
equal deleted inserted replaced
3788:d5014da90054 3789:8def429216ca
   202                     item = self.LocationsTree.AppendItem(root, infos["name"])
   202                     item = self.LocationsTree.AppendItem(root, infos["name"])
   203                     if wx.Platform != '__WXMSW__':
   203                     if wx.Platform != '__WXMSW__':
   204                         item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie)
   204                         item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie)
   205                 else:
   205                 else:
   206                     self.LocationsTree.SetItemText(item, infos["name"])
   206                     self.LocationsTree.SetItemText(item, infos["name"])
   207                 self.LocationsTree.SetPyData(item, infos)
   207                 self.LocationsTree.SetItemData(item, infos)
   208                 self.LocationsTree.SetItemImage(item, self.TreeImageDict[infos["type"]])
   208                 self.LocationsTree.SetItemImage(item, self.TreeImageDict[infos["type"]])
   209                 self.GenerateLocationsTreeBranch(item, children)
   209                 self.GenerateLocationsTreeBranch(item, children)
   210                 item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie)
   210                 item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie)
   211         while item.IsOk():
   211         while item.IsOk():
   212             to_delete.append(item)
   212             to_delete.append(item)
   213             item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie)
   213             item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie)
   214         for item in to_delete:
   214         for item in to_delete:
   215             self.LocationsTree.Delete(item)
   215             self.LocationsTree.Delete(item)
   216 
   216 
   217     def OnLocationsTreeItemActivated(self, event):
   217     def OnLocationsTreeItemActivated(self, event):
   218         infos = self.LocationsTree.GetPyData(event.GetItem())
   218         infos = self.LocationsTree.GetItemData(event.GetItem())
   219         if infos["type"] not in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
   219         if infos["type"] not in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
   220             wx.CallAfter(self.EndModal, wx.ID_OK)
   220             wx.CallAfter(self.EndModal, wx.ID_OK)
   221         event.Skip()
   221         event.Skip()
   222 
   222 
   223     def OnFilterChoice(self, event):
   223     def OnFilterChoice(self, event):
   224         self.RefreshFilters()
   224         self.RefreshFilters()
   225         self.RefreshLocationsTree()
   225         self.RefreshLocationsTree()
   226 
   226 
   227     def GetValues(self):
   227     def GetValues(self):
   228         selected = self.LocationsTree.GetSelection()
   228         selected = self.LocationsTree.GetSelection()
   229         infos = self.LocationsTree.GetPyData(selected)
   229         infos = self.LocationsTree.GetItemData(selected)
   230         if not self.do_rename:
   230         if not self.do_rename:
   231             infos["var_name"] = None
   231             infos["var_name"] = None
   232         return infos
   232         return infos
   233 
   233 
   234     def OnOK(self, event):
   234     def OnOK(self, event):
   235         self.do_rename = self.RenameCheckBox.IsChecked()
   235         self.do_rename = self.RenameCheckBox.IsChecked()
   236         self.Config.Write("RenameVariableOnLocationChange", str(self.do_rename))
   236         self.Config.Write("RenameVariableOnLocationChange", str(self.do_rename))
   237         selected = self.LocationsTree.GetSelection()
   237         selected = self.LocationsTree.GetSelection()
   238         var_infos = None
   238         var_infos = None
   239         if selected.IsOk():
   239         if selected.IsOk():
   240             var_infos = self.LocationsTree.GetPyData(selected)
   240             var_infos = self.LocationsTree.GetItemData(selected)
   241         if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
   241         if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
   242             dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK | wx.ICON_ERROR)
   242             dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK | wx.ICON_ERROR)
   243             dialog.ShowModal()
   243             dialog.ShowModal()
   244             dialog.Destroy()
   244             dialog.Destroy()
   245         else:
   245         else: