dialogs/BrowseLocationsDialog.py
changeset 1696 8043f32de7b8
parent 1571 486f94a8032c
child 1730 64d8f52bc8c8
equal deleted inserted replaced
1695:a63bb4025852 1696:8043f32de7b8
     3 
     3 
     4 # This file is part of Beremiz, a Integrated Development Environment for
     4 # This file is part of Beremiz, a Integrated Development Environment for
     5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
     5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
     6 #
     6 #
     7 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
     7 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
       
     8 # Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com>
     8 #
     9 #
     9 # See COPYING file for copyrights details.
    10 # See COPYING file for copyrights details.
    10 #
    11 #
    11 # This program is free software; you can redistribute it and/or
    12 # This program is free software; you can redistribute it and/or
    12 # modify it under the terms of the GNU General Public License
    13 # modify it under the terms of the GNU General Public License
    59 #-------------------------------------------------------------------------------
    60 #-------------------------------------------------------------------------------
    60 
    61 
    61 class BrowseLocationsDialog(wx.Dialog):
    62 class BrowseLocationsDialog(wx.Dialog):
    62     
    63     
    63     def __init__(self, parent, var_type, controller):
    64     def __init__(self, parent, var_type, controller):
    64         wx.Dialog.__init__(self, parent,  
    65         wx.Dialog.__init__(self, parent, title=_('Browse Locations'),
    65               size=wx.Size(600, 400), title=_('Browse Locations'),
       
    66               style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
    66               style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
    67         
    67         
    68         main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
    68         main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
    69         main_sizer.AddGrowableCol(0)
    69         main_sizer.AddGrowableCol(0)
    70         main_sizer.AddGrowableRow(1)
    70         main_sizer.AddGrowableRow(1)
    73         main_sizer.AddWindow(locations_label, border=20, 
    73         main_sizer.AddWindow(locations_label, border=20, 
    74               flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
    74               flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
    75         
    75         
    76         self.LocationsTree = wx.TreeCtrl(self, 
    76         self.LocationsTree = wx.TreeCtrl(self, 
    77               style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT)
    77               style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT)
       
    78         self.LocationsTree.SetInitialSize(wx.Size(-1, 300))
    78         self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated, 
    79         self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated, 
    79                   self.LocationsTree)
    80                   self.LocationsTree)
    80         main_sizer.AddWindow(self.LocationsTree, border=20, 
    81         main_sizer.AddWindow(self.LocationsTree, border=20, 
    81               flag=wx.LEFT|wx.RIGHT|wx.GROW)
    82               flag=wx.LEFT|wx.RIGHT|wx.GROW)
    82         
    83         
    89         
    90         
    90         direction_label = wx.StaticText(self, label=_('Direction:'))
    91         direction_label = wx.StaticText(self, label=_('Direction:'))
    91         button_gridsizer.AddWindow(direction_label,
    92         button_gridsizer.AddWindow(direction_label,
    92               flag=wx.ALIGN_CENTER_VERTICAL)
    93               flag=wx.ALIGN_CENTER_VERTICAL)
    93         
    94         
    94         self.DirFilterChoice = wx.ComboBox(self, size=wx.Size(0, -1), style=wx.CB_READONLY)
    95         self.DirFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY)
    95         self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.DirFilterChoice)
    96         self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.DirFilterChoice)
    96         button_gridsizer.AddWindow(self.DirFilterChoice,
    97         button_gridsizer.AddWindow(self.DirFilterChoice,
    97               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL)
    98               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL)
    98         
    99         
    99         filter_label = wx.StaticText(self, label=_('Type:'))
   100         filter_label = wx.StaticText(self, label=_('Type:'))
   100         button_gridsizer.AddWindow(filter_label,
   101         button_gridsizer.AddWindow(filter_label,
   101               flag=wx.ALIGN_CENTER_VERTICAL)
   102               flag=wx.ALIGN_CENTER_VERTICAL)
   102         
   103         
   103         self.TypeFilterChoice = wx.ComboBox(self, size=wx.Size(0, -1), style=wx.CB_READONLY)
   104         self.TypeFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY)
   104         self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.TypeFilterChoice)
   105         self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.TypeFilterChoice)
   105         button_gridsizer.AddWindow(self.TypeFilterChoice,
   106         button_gridsizer.AddWindow(self.TypeFilterChoice,
   106               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL)
   107               flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL)
   107         
   108         
   108         button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
   109         button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
   142             self.TypeFilterChoice.Append(_(option))
   143             self.TypeFilterChoice.Append(_(option))
   143         self.TypeFilterChoice.SetStringSelection(_("All"))
   144         self.TypeFilterChoice.SetStringSelection(_("All"))
   144         self.RefreshFilters()
   145         self.RefreshFilters()
   145         
   146         
   146         self.RefreshLocationsTree()
   147         self.RefreshLocationsTree()
       
   148         self.Fit()
   147     
   149     
   148     def RefreshFilters(self):
   150     def RefreshFilters(self):
   149         self.DirFilter = DIRFILTERCHOICE_OPTIONS[self.DirFilterChoice.GetStringSelection()]
   151         self.DirFilter = DIRFILTERCHOICE_OPTIONS[self.DirFilterChoice.GetStringSelection()]
   150         self.TypeFilter = self.TypeFilterChoice.GetSelection()
   152         self.TypeFilter = self.TypeFilterChoice.GetSelection()
   151     
   153