author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Tue, 10 Oct 2017 12:21:46 +0300 | |
changeset 1855 | f33942053466 |
parent 1782 | 5b6ad7a7fd9d |
child 1881 | 091005ec69c4 |
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:
1537
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:
1537
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
diff
changeset
|
6 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
diff
changeset
|
7 |
# Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1678
diff
changeset
|
8 |
# Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com> |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
diff
changeset
|
9 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
diff
changeset
|
11 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
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:
1537
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:
1537
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:
1537
diff
changeset
|
15 |
# of the License, or (at your option) any later version. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
diff
changeset
|
16 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
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:
1537
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:
1537
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:
1537
diff
changeset
|
20 |
# GNU General Public License for more details. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
diff
changeset
|
21 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1537
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:
1537
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:
1537
diff
changeset
|
24 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 25 |
|
26 |
import wx |
|
27 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
28 |
# ------------------------------------------------------------------------------- |
814 | 29 |
# Helpers |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
30 |
# ------------------------------------------------------------------------------- |
814 | 31 |
|
32 |
REQUIRED_PARAMS = ["projectName", "productName", "productVersion", "companyName"] |
|
33 |
||
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
34 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
35 |
TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
36 |
POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
814 | 37 |
] = range(10) |
38 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
39 |
|
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
40 |
# ------------------------------------------------------------------------------- |
814 | 41 |
# Project Properties Panel |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
42 |
# ------------------------------------------------------------------------------- |
814 | 43 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
44 |
|
814 | 45 |
class ProjectPropertiesPanel(wx.Notebook): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
46 |
|
814 | 47 |
def AddSizerParams(self, parent, sizer, params): |
48 |
for idx, (name, label) in enumerate(params): |
|
49 |
border = 0 |
|
50 |
if idx == 0: |
|
51 |
border |= wx.TOP |
|
52 |
elif idx == len(params) - 1: |
|
53 |
border |= wx.BOTTOM |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
54 |
|
814 | 55 |
st = wx.StaticText(parent, label=label) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
56 |
sizer.AddWindow(st, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
57 |
flag=wx.ALIGN_CENTER_VERTICAL | border | wx.LEFT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
58 |
|
814 | 59 |
tc = wx.TextCtrl(parent, style=wx.TE_PROCESS_ENTER) |
60 |
setattr(self, name, tc) |
|
61 |
callback = self.GetTextCtrlChangedFunction(tc, name) |
|
62 |
self.Bind(wx.EVT_TEXT_ENTER, callback, tc) |
|
63 |
tc.Bind(wx.EVT_KILL_FOCUS, callback) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
64 |
sizer.AddWindow(tc, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
65 |
flag=wx.GROW | border | wx.RIGHT) |
814 | 66 |
|
67 |
def __init__(self, parent, controller=None, window=None, enable_required=True): |
|
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1678
diff
changeset
|
68 |
wx.Notebook.__init__(self, parent) |
814 | 69 |
|
70 |
self.Controller = controller |
|
71 |
self.ParentWindow = window |
|
72 |
self.Values = None |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
73 |
|
814 | 74 |
# Project Panel elements |
75 |
||
76 |
self.ProjectPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
|
77 |
projectpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=5, vgap=15) |
|
78 |
projectpanel_sizer.AddGrowableCol(1) |
|
79 |
self.ProjectPanel.SetSizer(projectpanel_sizer) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
80 |
|
814 | 81 |
self.AddSizerParams(self.ProjectPanel, projectpanel_sizer, |
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 |
[("projectName", _('Project Name (required):')), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
83 |
("projectVersion", _('Project Version (optional):')), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
84 |
("productName", _('Product Name (required):')), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
85 |
("productVersion", _('Product Version (required):')), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
86 |
("productRelease", _('Product Release (optional):'))]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
87 |
|
814 | 88 |
self.AddPage(self.ProjectPanel, _("Project")) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
89 |
|
814 | 90 |
# Author Panel elements |
91 |
||
92 |
self.AuthorPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
|
93 |
authorpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=15) |
|
94 |
authorpanel_sizer.AddGrowableCol(1) |
|
95 |
self.AuthorPanel.SetSizer(authorpanel_sizer) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
96 |
|
814 | 97 |
self.AddSizerParams(self.AuthorPanel, authorpanel_sizer, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
98 |
[("companyName", _('Company Name (required):')), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
99 |
("companyURL", _('Company URL (optional):')), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
100 |
("authorName", _('Author Name (optional):')), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
101 |
("organization", _('Organization (optional):'))]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
102 |
|
814 | 103 |
self.AddPage(self.AuthorPanel, _("Author")) |
104 |
||
105 |
# Graphics Panel elements |
|
106 |
||
107 |
self.GraphicsPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
|
108 |
graphicpanel_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=4, vgap=5) |
|
109 |
graphicpanel_sizer.AddGrowableCol(0) |
|
110 |
graphicpanel_sizer.AddGrowableRow(3) |
|
111 |
self.GraphicsPanel.SetSizer(graphicpanel_sizer) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
112 |
|
814 | 113 |
pageSize_st = wx.StaticText(self.GraphicsPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
114 |
label=_('Page Size (optional):')) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
115 |
graphicpanel_sizer.AddWindow( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
116 |
pageSize_st, border=10, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
117 |
flag=wx.ALIGN_CENTER_VERTICAL | 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
|
118 |
|
814 | 119 |
pageSize_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) |
120 |
pageSize_sizer.AddGrowableCol(1) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
121 |
graphicpanel_sizer.AddSizer(pageSize_sizer, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
122 |
flag=wx.GROW | wx.LEFT | wx.RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
123 |
|
814 | 124 |
for name, label in [('PageWidth', _('Width:')), |
125 |
('PageHeight', _('Height:'))]: |
|
126 |
st = wx.StaticText(self.GraphicsPanel, label=label) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
127 |
pageSize_sizer.AddWindow(st, border=12, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
128 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
129 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
130 |
sp = wx.SpinCtrl(self.GraphicsPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
131 |
min=0, max=2**16, style=wx.TE_PROCESS_ENTER) |
814 | 132 |
setattr(self, name, sp) |
133 |
callback = self.GetPageSizeChangedFunction(sp, name) |
|
134 |
self.Bind(wx.EVT_TEXT_ENTER, callback, sp) |
|
135 |
sp.Bind(wx.EVT_KILL_FOCUS, callback) |
|
136 |
pageSize_sizer.AddWindow(sp, flag=wx.GROW) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
137 |
|
814 | 138 |
scaling_st = wx.StaticText(self.GraphicsPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
139 |
label=_('Grid Resolution:')) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
140 |
graphicpanel_sizer.AddWindow(scaling_st, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
141 |
flag=wx.GROW | wx.LEFT | wx.RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
142 |
|
814 | 143 |
scaling_nb = wx.Notebook(self.GraphicsPanel) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
144 |
graphicpanel_sizer.AddWindow(scaling_nb, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
145 |
flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
146 |
|
814 | 147 |
self.Scalings = {} |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
148 |
for language, translation in [("FBD", _("FBD")), ("LD", _("LD")), ("SFC", _("SFC"))]: |
814 | 149 |
scaling_panel = wx.Panel(scaling_nb, style=wx.TAB_TRAVERSAL) |
150 |
scalingpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) |
|
151 |
scalingpanel_sizer.AddGrowableCol(1) |
|
152 |
scaling_panel.SetSizer(scalingpanel_sizer) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
153 |
|
814 | 154 |
scaling_controls = [] |
155 |
for idx, (name, label) in enumerate([('XScale', _('Horizontal:')), |
|
156 |
('YScale', _('Vertical:'))]): |
|
157 |
if idx == 0: |
|
158 |
border = wx.TOP |
|
159 |
else: |
|
160 |
border = wx.BOTTOM |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
161 |
|
814 | 162 |
st = wx.StaticText(scaling_panel, label=label) |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
163 |
scalingpanel_sizer.AddWindow( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
164 |
st, border=10, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
165 |
flag=wx.ALIGN_CENTER_VERTICAL | border | wx.LEFT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
166 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
167 |
sp = wx.SpinCtrl(scaling_panel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
168 |
min=0, max=2**16, style=wx.TE_PROCESS_ENTER) |
814 | 169 |
scaling_controls.append(sp) |
170 |
callback = self.GetScalingChangedFunction(sp, language, name) |
|
171 |
self.Bind(wx.EVT_TEXT_ENTER, callback, sp) |
|
172 |
sp.Bind(wx.EVT_KILL_FOCUS, callback) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
173 |
scalingpanel_sizer.AddWindow(sp, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
174 |
flag=wx.GROW | border | wx.RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
175 |
|
814 | 176 |
self.Scalings[language] = scaling_controls |
177 |
scaling_nb.AddPage(scaling_panel, translation) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
178 |
|
814 | 179 |
self.AddPage(self.GraphicsPanel, _("Graphics")) |
180 |
||
181 |
# Miscellaneous Panel elements |
|
182 |
||
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 |
self.MiscellaneousPanel = wx.Panel( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
184 |
id=-1, parent=self, name='MiscellaneousPanel', pos=wx.Point(0, 0), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
185 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
814 | 186 |
miscellaneouspanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=15) |
187 |
miscellaneouspanel_sizer.AddGrowableCol(1) |
|
188 |
miscellaneouspanel_sizer.AddGrowableRow(1) |
|
189 |
self.MiscellaneousPanel.SetSizer(miscellaneouspanel_sizer) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
190 |
|
814 | 191 |
language_label = wx.StaticText(self.MiscellaneousPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
192 |
label=_('Language (optional):')) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
193 |
miscellaneouspanel_sizer.AddWindow(language_label, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
194 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.LEFT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
195 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
196 |
self.Language = wx.ComboBox(self.MiscellaneousPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
197 |
style=wx.CB_READONLY) |
814 | 198 |
self.Bind(wx.EVT_COMBOBOX, self.OnLanguageChanged, self.Language) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
199 |
miscellaneouspanel_sizer.AddWindow(self.Language, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
200 |
flag=wx.GROW | wx.TOP | wx.RIGHT) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
201 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
202 |
description_label = wx.StaticText( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
203 |
self.MiscellaneousPanel, label=_('Content Description (optional):')) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
204 |
miscellaneouspanel_sizer.AddWindow(description_label, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
205 |
flag=wx.BOTTOM | wx.LEFT) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
206 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
207 |
self.ContentDescription = wx.TextCtrl( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
208 |
self.MiscellaneousPanel, size=wx.Size(240, 150), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
209 |
style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
210 |
self.Bind(wx.EVT_TEXT_ENTER, self.OnContentDescriptionChanged, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
211 |
self.ContentDescription) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
212 |
self.ContentDescription.Bind(wx.EVT_KILL_FOCUS, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
213 |
self.OnContentDescriptionChanged) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
214 |
miscellaneouspanel_sizer.AddWindow(self.ContentDescription, border=10, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
215 |
flag=wx.GROW | wx.BOTTOM | wx.RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
216 |
|
814 | 217 |
self.AddPage(self.MiscellaneousPanel, _("Miscellaneous")) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
218 |
|
814 | 219 |
for param in REQUIRED_PARAMS: |
220 |
getattr(self, param).Enable(enable_required) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
221 |
|
1537
e8629f0cc93b
Add russian language in Project properties -> Other menu.
Sergey Surkov <surkovsv93@gmail.com>
parents:
814
diff
changeset
|
222 |
languages = ["", "en-US", "fr-FR", "zh-CN", "ru-RU"] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
223 |
|
814 | 224 |
for language in languages: |
225 |
self.Language.Append(language) |
|
226 |
||
227 |
def RefreshView(self): |
|
228 |
if self.Controller is not None: |
|
229 |
self.SetValues(self.Controller.GetProjectProperties()) |
|
230 |
||
231 |
def SetValues(self, values): |
|
232 |
self.Values = values |
|
233 |
for item, value in values.items(): |
|
234 |
if item == "language": |
|
235 |
self.Language.SetStringSelection(value) |
|
236 |
elif item == "contentDescription": |
|
237 |
self.ContentDescription.SetValue(value) |
|
238 |
elif item == "pageSize": |
|
239 |
self.PageWidth.SetValue(value[0]) |
|
240 |
self.PageHeight.SetValue(value[1]) |
|
241 |
elif item == "scaling": |
|
242 |
for language, (x, y) in value.items(): |
|
243 |
if language in self.Scalings: |
|
244 |
self.Scalings[language][0].SetValue(x) |
|
245 |
self.Scalings[language][1].SetValue(y) |
|
246 |
else: |
|
247 |
tc = getattr(self, item, None) |
|
248 |
if tc is not None: |
|
249 |
tc.SetValue(value) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
250 |
|
814 | 251 |
def GetValues(self): |
252 |
values = {} |
|
253 |
for param in ["projectName", "projectVersion", |
|
254 |
"productName", "productVersion", |
|
255 |
"productRelease", "companyName", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
256 |
"companyURL", "authorName", |
814 | 257 |
"organization"]: |
258 |
value = getattr(self, param).GetValue() |
|
259 |
if param in REQUIRED_PARAMS or value != "": |
|
260 |
values[param] = value |
|
261 |
else: |
|
262 |
values[param] = None |
|
263 |
language = self.Language.GetStringSelection() |
|
264 |
if language != "": |
|
265 |
values["language"] = language |
|
266 |
else: |
|
267 |
values["language"] = None |
|
268 |
content_description = self.ContentDescription.GetValue() |
|
269 |
if content_description != "": |
|
270 |
values["contentDescription"] = content_description |
|
271 |
else: |
|
272 |
values["contentDescription"] = None |
|
273 |
values["pageSize"] = (self.PageWidth.GetValue(), self.PageHeight.GetValue()) |
|
274 |
values["scaling"] = {} |
|
275 |
for language in ["FBD", "LD", "SFC"]: |
|
276 |
values["scaling"][language] = (self.Scalings[language][0].GetValue(), |
|
277 |
self.Scalings[language][1].GetValue()) |
|
278 |
return values |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
279 |
|
814 | 280 |
def GetTextCtrlChangedFunction(self, textctrl, name): |
281 |
def TextCtrlChangedFunction(event): |
|
1678
55b6db51eb63
fix clearing project name on opening project properties page.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
282 |
if self.Controller is not None and self.Values is not None: |
55b6db51eb63
fix clearing project name on opening project properties page.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
283 |
old_value = self.Values.get(name) |
814 | 284 |
new_value = textctrl.GetValue() |
285 |
if name not in REQUIRED_PARAMS and new_value == "": |
|
286 |
new_value = None |
|
287 |
if old_value != new_value: |
|
288 |
self.Controller.SetProjectProperties(properties={name: new_value}) |
|
289 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
290 |
PROJECTTREE, PAGETITLES) |
814 | 291 |
wx.CallAfter(self.RefreshView) |
292 |
event.Skip() |
|
293 |
return TextCtrlChangedFunction |
|
294 |
||
295 |
def GetPageSizeChangedFunction(self, spinctrl, name): |
|
296 |
def PageSizeChangedFunction(event): |
|
297 |
if self.Controller is not None: |
|
298 |
if self.Values is not None: |
|
299 |
old_value = self.Values.get("pageSize") |
|
300 |
else: |
|
301 |
old_value = (0, 0) |
|
302 |
if name == 'PageWidth': |
|
303 |
new_value = (spinctrl.GetValue(), old_value[1]) |
|
304 |
else: |
|
305 |
new_value = (old_value[0], spinctrl.GetValue()) |
|
306 |
if old_value != new_value: |
|
307 |
self.Controller.SetProjectProperties(properties={"pageSize": new_value}) |
|
308 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
309 |
PAGETITLES, SCALING) |
814 | 310 |
wx.CallAfter(self.RefreshView) |
311 |
event.Skip() |
|
312 |
return PageSizeChangedFunction |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
313 |
|
814 | 314 |
def GetScalingChangedFunction(self, spinctrl, language, name): |
315 |
def ScalingChangedFunction(event): |
|
316 |
if self.Controller is not None: |
|
317 |
old_value = (0, 0) |
|
318 |
if self.Values is not None: |
|
319 |
scaling = self.Values.get("scaling") |
|
320 |
if scaling is not None: |
|
321 |
old_value = scaling.get(language) |
|
322 |
if name == 'XScale': |
|
323 |
new_value = (spinctrl.GetValue(), old_value[1]) |
|
324 |
else: |
|
325 |
new_value = (old_value[0], spinctrl.GetValue()) |
|
326 |
if old_value != new_value: |
|
327 |
self.Controller.SetProjectProperties(properties={"scaling": {language: new_value}}) |
|
328 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
329 |
PAGETITLES, SCALING) |
814 | 330 |
wx.CallAfter(self.RefreshView) |
331 |
event.Skip() |
|
332 |
return ScalingChangedFunction |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
333 |
|
814 | 334 |
def OnLanguageChanged(self, event): |
335 |
if self.Controller is not None: |
|
336 |
if self.Values is not None: |
|
337 |
old_value = self.Values.get("language") |
|
338 |
else: |
|
339 |
old_value = None |
|
340 |
new_value = self.Language.GetStringSelection() |
|
341 |
if new_value == "": |
|
342 |
new_value = None |
|
343 |
if old_value != new_value: |
|
344 |
self.Controller.SetProjectProperties(properties={"language": new_value}) |
|
345 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) |
|
346 |
wx.CallAfter(self.RefreshView) |
|
347 |
event.Skip() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
348 |
|
814 | 349 |
def OnContentDescriptionChanged(self, event): |
350 |
if self.Controller is not None: |
|
351 |
if self.Values is not None: |
|
352 |
old_value = self.Values.get("contentDescription") |
|
353 |
else: |
|
354 |
old_value = None |
|
355 |
new_value = self.ContentDescription.GetValue() |
|
356 |
if new_value == "": |
|
357 |
new_value = None |
|
358 |
if old_value != new_value: |
|
359 |
self.Controller.SetProjectProperties(properties={"contentDescription": new_value}) |
|
360 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) |
|
361 |
wx.CallAfter(self.RefreshView) |
|
362 |
event.Skip() |