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 |
32 self.SetIcon(parent.icon) |
33 self.SetIcon(parent.icon) |
33 |
34 |
34 |
35 |
35 def __init__(self, parent): |
36 def __init__(self, parent): |
36 wx.Dialog.__init__(self, parent, title=_("Find"), |
37 wx.Dialog.__init__(self, parent, title=_("Find"), |
37 size=wx.Size(500, 280), style=wx.CAPTION| |
38 style=wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN|wx.RESIZE_BORDER) |
38 wx.CLOSE_BOX| |
|
39 wx.CLIP_CHILDREN| |
|
40 wx.RESIZE_BORDER) |
|
41 |
39 |
42 self._init_icon(parent) |
40 self._init_icon(parent) |
43 panel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
41 panel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
44 |
42 |
45 main_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=2, vgap=5) |
43 main_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=2, vgap=5) |
110 |
108 |
111 self.CloseButton = wx.Button(panel, label=_("Close")) |
109 self.CloseButton = wx.Button(panel, label=_("Close")) |
112 self.Bind(wx.EVT_BUTTON, self.OnCloseButton, self.CloseButton) |
110 self.Bind(wx.EVT_BUTTON, self.OnCloseButton, self.CloseButton) |
113 buttons_sizer.AddWindow(self.CloseButton) |
111 buttons_sizer.AddWindow(self.CloseButton) |
114 |
112 |
115 self.StatusLabel = wx.StaticText(panel, label= "") |
113 # set the longest message here, to use it length to calculate |
|
114 # optimal size of dialog window |
|
115 self.RegExpSyntaxErrMsg = _("Syntax error in regular expression of pattern to search!") |
|
116 self.StatusLabel = wx.StaticText(panel, label= self.RegExpSyntaxErrMsg) |
116 controls_sizer.AddWindow(self.StatusLabel, flag=wx.ALIGN_CENTER_VERTICAL) |
117 controls_sizer.AddWindow(self.StatusLabel, flag=wx.ALIGN_CENTER_VERTICAL) |
117 |
118 |
118 panel.SetSizer(main_sizer) |
119 panel.SetSizer(main_sizer) |
119 main_sizer.Fit(self) |
120 main_sizer.Fit(self) |
|
121 |
|
122 # clear message after dialog size calculation |
|
123 self.SetStatusText("") |
|
124 |
120 |
125 |
121 self.ParentWindow = parent |
126 self.ParentWindow = parent |
122 |
127 |
123 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
128 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
124 self.infosPrev = {} |
129 self.infosPrev = {} |
167 try: |
172 try: |
168 self.criteria = infos |
173 self.criteria = infos |
169 CompilePattern(self.criteria) |
174 CompilePattern(self.criteria) |
170 except: |
175 except: |
171 self.criteria.clear() |
176 self.criteria.clear() |
172 message = _("Syntax error in regular expression of pattern to search!") |
177 message = self.RegExpSyntaxErrMsg |
173 self.SetStatusText(message) |
178 self.SetStatusText(message) |
174 if len(self.criteria) > 0: |
179 if len(self.criteria) > 0: |
175 wx.CallAfter(self.ParentWindow.FindInPou, |
180 wx.CallAfter(self.ParentWindow.FindInPou, |
176 {True: 1, False:-1}[self.Forward.GetValue()], |
181 {True: 1, False:-1}[self.Forward.GetValue()], |
177 self.criteria) |
182 self.criteria) |