dialogs/BrowseLocationsDialog.py
changeset 1745 f9d32913bad4
parent 1742 92932cd370a4
child 1749 d73b64672238
equal deleted inserted replaced
1744:69dfdb26f600 1745:f9d32913bad4
    64 
    64 
    65 class BrowseLocationsDialog(wx.Dialog):
    65 class BrowseLocationsDialog(wx.Dialog):
    66 
    66 
    67     def __init__(self, parent, var_type, controller):
    67     def __init__(self, parent, var_type, controller):
    68         wx.Dialog.__init__(self, parent, title=_('Browse Locations'),
    68         wx.Dialog.__init__(self, parent, title=_('Browse Locations'),
    69               style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
    69               style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
    70 
    70 
    71         main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
    71         main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
    72         main_sizer.AddGrowableCol(0)
    72         main_sizer.AddGrowableCol(0)
    73         main_sizer.AddGrowableRow(1)
    73         main_sizer.AddGrowableRow(1)
    74 
    74 
    75         locations_label = wx.StaticText(self, label=_('Locations available:'))
    75         locations_label = wx.StaticText(self, label=_('Locations available:'))
    76         main_sizer.AddWindow(locations_label, border=20,
    76         main_sizer.AddWindow(locations_label, border=20,
    77               flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
    77               flag=wx.TOP | wx.LEFT | wx.RIGHT | wx.GROW)
    78 
    78 
    79         self.LocationsTree = wx.TreeCtrl(self,
    79         self.LocationsTree = wx.TreeCtrl(self,
    80               style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT)
    80               style=wx.TR_HAS_BUTTONS | wx.TR_SINGLE | wx.SUNKEN_BORDER | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT)
    81         self.LocationsTree.SetInitialSize(wx.Size(-1, 300))
    81         self.LocationsTree.SetInitialSize(wx.Size(-1, 300))
    82         self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated,
    82         self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated,
    83                   self.LocationsTree)
    83                   self.LocationsTree)
    84         main_sizer.AddWindow(self.LocationsTree, border=20,
    84         main_sizer.AddWindow(self.LocationsTree, border=20,
    85               flag=wx.LEFT|wx.RIGHT|wx.GROW)
    85               flag=wx.LEFT | wx.RIGHT | wx.GROW)
    86 
    86 
    87         button_gridsizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
    87         button_gridsizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
    88         button_gridsizer.AddGrowableCol(1)
    88         button_gridsizer.AddGrowableCol(1)
    89         button_gridsizer.AddGrowableCol(3)
    89         button_gridsizer.AddGrowableCol(3)
    90         button_gridsizer.AddGrowableRow(0)
    90         button_gridsizer.AddGrowableRow(0)
    91         main_sizer.AddSizer(button_gridsizer, border=20,
    91         main_sizer.AddSizer(button_gridsizer, border=20,
    92               flag=wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.GROW)
    92               flag=wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.GROW)
    93 
    93 
    94         direction_label = wx.StaticText(self, label=_('Direction:'))
    94         direction_label = wx.StaticText(self, label=_('Direction:'))
    95         button_gridsizer.AddWindow(direction_label,
    95         button_gridsizer.AddWindow(direction_label,
    96               flag=wx.ALIGN_CENTER_VERTICAL)
    96               flag=wx.ALIGN_CENTER_VERTICAL)
    97 
    97 
    98         self.DirFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY)
    98         self.DirFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY)
    99         self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.DirFilterChoice)
    99         self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.DirFilterChoice)
   100         button_gridsizer.AddWindow(self.DirFilterChoice,
   100         button_gridsizer.AddWindow(self.DirFilterChoice,
   101               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL)
   101               flag=wx.GROW | wx.ALIGN_CENTER_VERTICAL)
   102 
   102 
   103         filter_label = wx.StaticText(self, label=_('Type:'))
   103         filter_label = wx.StaticText(self, label=_('Type:'))
   104         button_gridsizer.AddWindow(filter_label,
   104         button_gridsizer.AddWindow(filter_label,
   105               flag=wx.ALIGN_CENTER_VERTICAL)
   105               flag=wx.ALIGN_CENTER_VERTICAL)
   106 
   106 
   107         self.TypeFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY)
   107         self.TypeFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY)
   108         self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.TypeFilterChoice)
   108         self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.TypeFilterChoice)
   109         button_gridsizer.AddWindow(self.TypeFilterChoice,
   109         button_gridsizer.AddWindow(self.TypeFilterChoice,
   110               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL)
   110               flag=wx.GROW | wx.ALIGN_CENTER_VERTICAL)
   111 
   111 
   112         button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
   112         button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
   113         self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
   113         self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
   114         button_gridsizer.AddSizer(button_sizer, flag=wx.ALIGN_RIGHT)
   114         button_gridsizer.AddSizer(button_sizer, flag=wx.ALIGN_RIGHT)
   115 
   115 
   116         self.SetSizer(main_sizer)
   116         self.SetSizer(main_sizer)
   117 
   117 
   216         selected = self.LocationsTree.GetSelection()
   216         selected = self.LocationsTree.GetSelection()
   217         var_infos = None
   217         var_infos = None
   218         if selected.IsOk():
   218         if selected.IsOk():
   219             var_infos = self.LocationsTree.GetPyData(selected)
   219             var_infos = self.LocationsTree.GetPyData(selected)
   220         if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
   220         if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
   221             dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR)
   221             dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK | wx.ICON_ERROR)
   222             dialog.ShowModal()
   222             dialog.ShowModal()
   223             dialog.Destroy()
   223             dialog.Destroy()
   224         else:
   224         else:
   225             self.EndModal(wx.ID_OK)
   225             self.EndModal(wx.ID_OK)