author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Tue, 22 Dec 2020 18:05:05 +0100 | |
changeset 2711 | ecfb59e4ecb0 |
parent 1881 | 091005ec69c4 |
child 3303 | 0ffb41625592 |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
814 | 6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1620
diff
changeset
|
8 |
# Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com> |
814 | 9 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
814 | 11 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
12 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
13 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
14 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
15 |
# of the License, or (at your option) any later version. |
814 | 16 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
17 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
20 |
# GNU General Public License for more details. |
814 | 21 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
22 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
23 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1558
diff
changeset
|
24 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 25 |
|
1881
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1878
diff
changeset
|
26 |
|
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1878
diff
changeset
|
27 |
from __future__ import absolute_import |
814 | 28 |
import wx |
1556
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
29 |
from plcopen.plcopen import * |
814 | 30 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
31 |
|
1618
474de7fdcfd9
convert FindInPouDialog from wx.Frame to wx.Dialog
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
32 |
class FindInPouDialog(wx.Dialog): |
814 | 33 |
|
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1098
diff
changeset
|
34 |
def _init_icon(self, parent): |
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1098
diff
changeset
|
35 |
if parent and parent.icon: |
1838
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
36 |
self.SetIcon(parent.icon) |
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1098
diff
changeset
|
37 |
|
814 | 38 |
def __init__(self, parent): |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
39 |
wx.Dialog.__init__( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
40 |
self, parent, title=_("Find"), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
41 |
style=wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN | wx.RESIZE_BORDER) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
42 |
|
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1098
diff
changeset
|
43 |
self._init_icon(parent) |
814 | 44 |
panel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
45 |
|
814 | 46 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=2, vgap=5) |
47 |
main_sizer.AddGrowableCol(0) |
|
48 |
main_sizer.AddGrowableRow(0) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
49 |
|
814 | 50 |
controls_sizer = wx.BoxSizer(wx.VERTICAL) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
51 |
main_sizer.AddSizer(controls_sizer, border=20, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
52 |
flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
53 |
|
814 | 54 |
patterns_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=5) |
55 |
patterns_sizer.AddGrowableCol(1) |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
56 |
controls_sizer.AddSizer(patterns_sizer, border=5, flag=wx.GROW | wx.BOTTOM) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
57 |
|
814 | 58 |
find_label = wx.StaticText(panel, label=_("Find:")) |
59 |
patterns_sizer.AddWindow(find_label, flag=wx.ALIGN_CENTER_VERTICAL) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
60 |
|
814 | 61 |
self.FindPattern = wx.TextCtrl(panel) |
62 |
self.Bind(wx.EVT_TEXT, self.OnFindPatternChanged, self.FindPattern) |
|
1558
d75cc9ad328e
now dialogs Find and Search in Project can be closed with ESC button
Sergey Surkov <surkovsv93@gmail.com>
parents:
1556
diff
changeset
|
63 |
self.Bind(wx.EVT_CHAR_HOOK, self.OnEscapeKey) |
814 | 64 |
patterns_sizer.AddWindow(self.FindPattern, flag=wx.GROW) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
65 |
|
814 | 66 |
params_sizer = wx.BoxSizer(wx.HORIZONTAL) |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
67 |
controls_sizer.AddSizer(params_sizer, border=5, flag=wx.GROW | wx.BOTTOM) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
68 |
|
814 | 69 |
direction_staticbox = wx.StaticBox(panel, label=_("Direction")) |
70 |
direction_staticboxsizer = wx.StaticBoxSizer( |
|
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1838
diff
changeset
|
71 |
direction_staticbox, wx.VERTICAL) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
72 |
params_sizer.AddSizer(direction_staticboxsizer, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
73 |
flag=wx.GROW | wx.RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
74 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
75 |
self.Forward = wx.RadioButton(panel, label=_("Forward"), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
76 |
style=wx.RB_GROUP) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
77 |
direction_staticboxsizer.AddWindow(self.Forward, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
78 |
flag=wx.ALL | wx.GROW) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
79 |
|
814 | 80 |
self.Backward = wx.RadioButton(panel, label=_("Backward")) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
81 |
direction_staticboxsizer.AddWindow(self.Backward, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
82 |
flag=wx.ALL | wx.GROW) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
83 |
|
814 | 84 |
options_staticbox = wx.StaticBox(panel, label=_("Options")) |
85 |
options_staticboxsizer = wx.StaticBoxSizer( |
|
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1838
diff
changeset
|
86 |
options_staticbox, wx.VERTICAL) |
814 | 87 |
params_sizer.AddSizer(options_staticboxsizer, 1, flag=wx.GROW) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
88 |
|
814 | 89 |
self.CaseSensitive = wx.CheckBox(panel, label=_("Case sensitive")) |
90 |
self.CaseSensitive.SetValue(True) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
91 |
options_staticboxsizer.AddWindow(self.CaseSensitive, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
92 |
flag=wx.ALL | wx.GROW) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
93 |
|
814 | 94 |
self.WrapSearch = wx.CheckBox(panel, label=_("Wrap search")) |
95 |
self.WrapSearch.SetValue(True) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
96 |
options_staticboxsizer.AddWindow(self.WrapSearch, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
97 |
flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.GROW) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
98 |
|
814 | 99 |
self.RegularExpressions = wx.CheckBox(panel, label=_("Regular expressions")) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
100 |
options_staticboxsizer.AddWindow(self.RegularExpressions, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
101 |
flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.GROW) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
102 |
|
814 | 103 |
buttons_sizer = wx.BoxSizer(wx.HORIZONTAL) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
104 |
main_sizer.AddSizer(buttons_sizer, border=20, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
105 |
flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
106 |
|
814 | 107 |
self.FindButton = wx.Button(panel, label=_("Find")) |
1098
0ead830daf26
Fixed bug when pressing Return key in FindInPouDialog
Laurent Bessard
parents:
1056
diff
changeset
|
108 |
self.FindButton.SetDefault() |
814 | 109 |
self.Bind(wx.EVT_BUTTON, self.OnFindButton, self.FindButton) |
110 |
buttons_sizer.AddWindow(self.FindButton, border=5, flag=wx.RIGHT) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
111 |
|
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1098
diff
changeset
|
112 |
self.CloseButton = wx.Button(panel, label=_("Close")) |
814 | 113 |
self.Bind(wx.EVT_BUTTON, self.OnCloseButton, self.CloseButton) |
114 |
buttons_sizer.AddWindow(self.CloseButton) |
|
1618
474de7fdcfd9
convert FindInPouDialog from wx.Frame to wx.Dialog
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
115 |
|
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1620
diff
changeset
|
116 |
# set the longest message here, to use it length to calculate |
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1620
diff
changeset
|
117 |
# optimal size of dialog window |
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1620
diff
changeset
|
118 |
self.RegExpSyntaxErrMsg = _("Syntax error in regular expression of pattern to search!") |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
119 |
self.StatusLabel = wx.StaticText(panel, label=self.RegExpSyntaxErrMsg) |
1618
474de7fdcfd9
convert FindInPouDialog from wx.Frame to wx.Dialog
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
120 |
controls_sizer.AddWindow(self.StatusLabel, flag=wx.ALIGN_CENTER_VERTICAL) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
121 |
|
814 | 122 |
panel.SetSizer(main_sizer) |
1620
3bffe3bd8d78
make FindInPouDialog work on Windows with wxPython 2.8
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1618
diff
changeset
|
123 |
main_sizer.Fit(self) |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1620
diff
changeset
|
124 |
|
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1620
diff
changeset
|
125 |
# clear message after dialog size calculation |
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1620
diff
changeset
|
126 |
self.SetStatusText("") |
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1620
diff
changeset
|
127 |
|
814 | 128 |
self.ParentWindow = parent |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
129 |
|
814 | 130 |
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
1556
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
131 |
self.infosPrev = {} |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
132 |
self.criteria = {} |
1056
f7aaf31d000f
Fixed pattern textctrl in FindInPouDialog to get focus when dialog appear
Laurent Bessard
parents:
814
diff
changeset
|
133 |
self.FindPattern.SetFocus() |
814 | 134 |
self.RefreshButtonsState() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
135 |
|
814 | 136 |
def RefreshButtonsState(self): |
137 |
find_pattern = self.FindPattern.GetValue() |
|
138 |
self.FindButton.Enable(find_pattern != "") |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
139 |
|
814 | 140 |
def OnCloseFrame(self, event): |
141 |
self.Hide() |
|
142 |
event.Veto() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
143 |
|
814 | 144 |
def OnCloseButton(self, event): |
145 |
self.Hide() |
|
146 |
event.Skip() |
|
147 |
||
1558
d75cc9ad328e
now dialogs Find and Search in Project can be closed with ESC button
Sergey Surkov <surkovsv93@gmail.com>
parents:
1556
diff
changeset
|
148 |
def OnEscapeKey(self, event): |
d75cc9ad328e
now dialogs Find and Search in Project can be closed with ESC button
Sergey Surkov <surkovsv93@gmail.com>
parents:
1556
diff
changeset
|
149 |
keycode = event.GetKeyCode() |
d75cc9ad328e
now dialogs Find and Search in Project can be closed with ESC button
Sergey Surkov <surkovsv93@gmail.com>
parents:
1556
diff
changeset
|
150 |
if keycode == wx.WXK_ESCAPE: |
d75cc9ad328e
now dialogs Find and Search in Project can be closed with ESC button
Sergey Surkov <surkovsv93@gmail.com>
parents:
1556
diff
changeset
|
151 |
self.OnCloseButton(event) |
d75cc9ad328e
now dialogs Find and Search in Project can be closed with ESC button
Sergey Surkov <surkovsv93@gmail.com>
parents:
1556
diff
changeset
|
152 |
else: |
d75cc9ad328e
now dialogs Find and Search in Project can be closed with ESC button
Sergey Surkov <surkovsv93@gmail.com>
parents:
1556
diff
changeset
|
153 |
event.Skip() |
d75cc9ad328e
now dialogs Find and Search in Project can be closed with ESC button
Sergey Surkov <surkovsv93@gmail.com>
parents:
1556
diff
changeset
|
154 |
|
814 | 155 |
def OnFindPatternChanged(self, event): |
156 |
self.RefreshButtonsState() |
|
157 |
event.Skip() |
|
158 |
||
1618
474de7fdcfd9
convert FindInPouDialog from wx.Frame to wx.Dialog
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
159 |
def SetStatusText(self, msg): |
474de7fdcfd9
convert FindInPouDialog from wx.Frame to wx.Dialog
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
160 |
self.StatusLabel.SetLabel(msg) |
474de7fdcfd9
convert FindInPouDialog from wx.Frame to wx.Dialog
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
161 |
self.Layout() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
162 |
|
814 | 163 |
def OnFindButton(self, event): |
164 |
infos = { |
|
165 |
"find_pattern": self.FindPattern.GetValue(), |
|
166 |
"wrap": self.WrapSearch.GetValue(), |
|
167 |
"case_sensitive": self.CaseSensitive.GetValue(), |
|
1556
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
168 |
"regular_expression": self.RegularExpressions.GetValue(), |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
169 |
"filter": "all"} |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
170 |
|
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
171 |
if self.infosPrev != infos: |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
172 |
self.infosPrev = infos |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
173 |
message = "" |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
174 |
try: |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
175 |
self.criteria = infos |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
176 |
CompilePattern(self.criteria) |
1780
c52d1460cea8
clean-up: fix PEP8 E722 do not use bare except'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
177 |
except Exception: |
1556
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
178 |
self.criteria.clear() |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1620
diff
changeset
|
179 |
message = self.RegExpSyntaxErrMsg |
1556
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
180 |
self.SetStatusText(message) |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
181 |
if len(self.criteria) > 0: |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1490
diff
changeset
|
182 |
wx.CallAfter(self.ParentWindow.FindInPou, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
183 |
{True: 1, False: -1}[self.Forward.GetValue()], |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
184 |
self.criteria) |
814 | 185 |
event.Skip() |