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