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 |
31 """ |
32 """ |
32 |
33 |
33 def __init__(self, parent, name, library, default=None): |
34 def __init__(self, parent, name, library, default=None): |
34 wx.Dialog.__init__(self, |
35 wx.Dialog.__init__(self, |
35 name='BrowseValueDialog', parent=parent, |
36 name='BrowseValueDialog', parent=parent, |
36 size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
37 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
37 title=_('Browse %s values library') % name) |
38 title=_('Browse %s values library') % name) |
38 |
|
39 self.SetClientSize(wx.Size(600, 400)) |
|
40 |
39 |
41 self.staticText1 = wx.StaticText( |
40 self.staticText1 = wx.StaticText( |
42 label=_('Choose a value for %s:') % name, name='staticText1', parent=self, |
41 label=_('Choose a value for %s:') % name, name='staticText1', parent=self, |
43 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
42 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
44 |
43 |
45 self.ValuesLibrary = wx.TreeCtrl( |
44 self.ValuesLibrary = wx.TreeCtrl( |
46 name='ValuesLibrary', parent=self, pos=wx.Point(0, 0), |
45 name='ValuesLibrary', parent=self, pos=wx.Point(0, 0), |
47 size=wx.Size(0, 0), style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT) |
46 size=wx.Size(400, 200), style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT) |
48 |
47 |
49 self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
48 self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
50 |
49 |
51 self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
50 self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
52 |
51 |
58 |
57 |
59 self.flexGridSizer1.AddGrowableCol(0) |
58 self.flexGridSizer1.AddGrowableCol(0) |
60 self.flexGridSizer1.AddGrowableRow(1) |
59 self.flexGridSizer1.AddGrowableRow(1) |
61 |
60 |
62 self.SetSizer(self.flexGridSizer1) |
61 self.SetSizer(self.flexGridSizer1) |
|
62 self.Fit() |
63 |
63 |
64 root = self.ValuesLibrary.AddRoot("") |
64 root = self.ValuesLibrary.AddRoot("") |
65 self.GenerateValuesLibraryBranch(root, library, default) |
65 self.GenerateValuesLibraryBranch(root, library, default) |
66 |
66 |
67 def GenerateValuesLibraryBranch(self, root, children, default): |
67 def GenerateValuesLibraryBranch(self, root, children, default): |