author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Fri, 16 Feb 2018 02:29:10 +0100 | |
changeset 1937 | 986dbad48ab7 |
parent 1886 | e4a656e73aec |
child 1973 | cc7a46953471 |
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 |
|
1881
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
26 |
from __future__ import absolute_import |
814 | 27 |
import wx |
1885
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
28 |
from wx.lib.scrolledpanel import ScrolledPanel |
814 | 29 |
|
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 |
# Helpers |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
32 |
# ------------------------------------------------------------------------------- |
814 | 33 |
|
34 |
REQUIRED_PARAMS = ["projectName", "productName", "productVersion", "companyName"] |
|
35 |
||
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
36 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
37 |
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
|
38 |
POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
814 | 39 |
] = range(10) |
40 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
41 |
|
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
42 |
# ------------------------------------------------------------------------------- |
814 | 43 |
# 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
|
44 |
# ------------------------------------------------------------------------------- |
814 | 45 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
46 |
|
814 | 47 |
class ProjectPropertiesPanel(wx.Notebook): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
48 |
|
814 | 49 |
def AddSizerParams(self, parent, sizer, params): |
50 |
for idx, (name, label) in enumerate(params): |
|
51 |
border = 0 |
|
52 |
if idx == 0: |
|
53 |
border |= wx.TOP |
|
54 |
elif idx == len(params) - 1: |
|
55 |
border |= wx.BOTTOM |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
56 |
|
814 | 57 |
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
|
58 |
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
|
59 |
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
|
60 |
|
814 | 61 |
tc = wx.TextCtrl(parent, style=wx.TE_PROCESS_ENTER) |
62 |
setattr(self, name, tc) |
|
63 |
callback = self.GetTextCtrlChangedFunction(tc, name) |
|
64 |
self.Bind(wx.EVT_TEXT_ENTER, callback, tc) |
|
65 |
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
|
66 |
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
|
67 |
flag=wx.GROW | border | wx.RIGHT) |
814 | 68 |
|
69 |
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
|
70 |
wx.Notebook.__init__(self, parent) |
814 | 71 |
|
72 |
self.Controller = controller |
|
73 |
self.ParentWindow = window |
|
74 |
self.Values = None |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
75 |
|
814 | 76 |
# Project Panel elements |
77 |
||
1886 | 78 |
self.ProjectPanel = ScrolledPanel(self, -1, style=wx.TAB_TRAVERSAL) |
1885
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
79 |
self.ProjectPanel.SetAutoLayout(1) |
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
80 |
self.ProjectPanel.SetupScrolling() |
814 | 81 |
projectpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=5, vgap=15) |
82 |
projectpanel_sizer.AddGrowableCol(1) |
|
83 |
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
|
84 |
|
814 | 85 |
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
|
86 |
[("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
|
87 |
("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
|
88 |
("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
|
89 |
("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
|
90 |
("productRelease", _('Product Release (optional):'))]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
91 |
|
814 | 92 |
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
|
93 |
|
814 | 94 |
# Author Panel elements |
95 |
||
1886 | 96 |
self.AuthorPanel = ScrolledPanel(self, -1, style=wx.TAB_TRAVERSAL) |
1885
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
97 |
self.AuthorPanel.SetAutoLayout(1) |
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
98 |
self.AuthorPanel.SetupScrolling() |
814 | 99 |
authorpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=15) |
100 |
authorpanel_sizer.AddGrowableCol(1) |
|
101 |
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
|
102 |
|
814 | 103 |
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
|
104 |
[("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
|
105 |
("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
|
106 |
("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
|
107 |
("organization", _('Organization (optional):'))]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
108 |
|
814 | 109 |
self.AddPage(self.AuthorPanel, _("Author")) |
110 |
||
111 |
# Graphics Panel elements |
|
112 |
||
1886 | 113 |
self.GraphicsPanel = ScrolledPanel(self, -1, style=wx.TAB_TRAVERSAL) |
1885
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
114 |
self.GraphicsPanel.SetAutoLayout(1) |
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
115 |
self.GraphicsPanel.SetupScrolling() |
814 | 116 |
graphicpanel_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=4, vgap=5) |
117 |
graphicpanel_sizer.AddGrowableCol(0) |
|
118 |
graphicpanel_sizer.AddGrowableRow(3) |
|
119 |
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
|
120 |
|
814 | 121 |
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
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
|
126 |
|
814 | 127 |
pageSize_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) |
128 |
pageSize_sizer.AddGrowableCol(1) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
129 |
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
|
130 |
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
|
131 |
|
814 | 132 |
for name, label in [('PageWidth', _('Width:')), |
133 |
('PageHeight', _('Height:'))]: |
|
134 |
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
|
135 |
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
|
136 |
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
|
137 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
138 |
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
|
139 |
min=0, max=2**16, style=wx.TE_PROCESS_ENTER) |
814 | 140 |
setattr(self, name, sp) |
141 |
callback = self.GetPageSizeChangedFunction(sp, name) |
|
142 |
self.Bind(wx.EVT_TEXT_ENTER, callback, sp) |
|
143 |
sp.Bind(wx.EVT_KILL_FOCUS, callback) |
|
144 |
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
|
145 |
|
814 | 146 |
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
|
147 |
label=_('Grid Resolution:')) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
148 |
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
|
149 |
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
|
150 |
|
814 | 151 |
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
|
152 |
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
|
153 |
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
|
154 |
|
814 | 155 |
self.Scalings = {} |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
156 |
for language, translation in [("FBD", _("FBD")), ("LD", _("LD")), ("SFC", _("SFC"))]: |
814 | 157 |
scaling_panel = wx.Panel(scaling_nb, style=wx.TAB_TRAVERSAL) |
158 |
scalingpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) |
|
159 |
scalingpanel_sizer.AddGrowableCol(1) |
|
160 |
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
|
161 |
|
814 | 162 |
scaling_controls = [] |
163 |
for idx, (name, label) in enumerate([('XScale', _('Horizontal:')), |
|
164 |
('YScale', _('Vertical:'))]): |
|
165 |
if idx == 0: |
|
166 |
border = wx.TOP |
|
167 |
else: |
|
168 |
border = wx.BOTTOM |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
169 |
|
814 | 170 |
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
|
171 |
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
|
172 |
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
|
173 |
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
|
174 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
175 |
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
|
176 |
min=0, max=2**16, style=wx.TE_PROCESS_ENTER) |
814 | 177 |
scaling_controls.append(sp) |
178 |
callback = self.GetScalingChangedFunction(sp, language, name) |
|
179 |
self.Bind(wx.EVT_TEXT_ENTER, callback, sp) |
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
|
814 | 184 |
self.Scalings[language] = scaling_controls |
185 |
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
|
186 |
|
814 | 187 |
self.AddPage(self.GraphicsPanel, _("Graphics")) |
188 |
||
189 |
# Miscellaneous Panel elements |
|
190 |
||
1885
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
191 |
self.MiscellaneousPanel = ScrolledPanel(id=-1, parent=self, |
1886 | 192 |
name='MiscellaneousPanel', |
193 |
pos=wx.Point(0, 0), |
|
194 |
size=wx.Size(0, 0), |
|
195 |
style=wx.TAB_TRAVERSAL) |
|
1885
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
196 |
self.MiscellaneousPanel.SetAutoLayout(1) |
570122574a97
replaced normal panel with scrolled panel under project properties
dporopat <denis.poropat@smarteh.si>
parents:
1881
diff
changeset
|
197 |
self.MiscellaneousPanel.SetupScrolling() |
814 | 198 |
miscellaneouspanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=15) |
199 |
miscellaneouspanel_sizer.AddGrowableCol(1) |
|
200 |
miscellaneouspanel_sizer.AddGrowableRow(1) |
|
201 |
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
|
202 |
|
814 | 203 |
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
|
204 |
label=_('Language (optional):')) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
205 |
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
|
206 |
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
|
207 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
208 |
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
|
209 |
style=wx.CB_READONLY) |
814 | 210 |
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
|
211 |
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
|
212 |
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
|
213 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
214 |
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
|
215 |
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
|
216 |
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
|
217 |
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
|
218 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
219 |
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
|
220 |
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
|
221 |
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
|
222 |
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
|
223 |
self.ContentDescription) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
224 |
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
|
225 |
self.OnContentDescriptionChanged) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
226 |
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
|
227 |
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
|
228 |
|
814 | 229 |
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
|
230 |
|
814 | 231 |
for param in REQUIRED_PARAMS: |
232 |
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
|
233 |
|
1537
e8629f0cc93b
Add russian language in Project properties -> Other menu.
Sergey Surkov <surkovsv93@gmail.com>
parents:
814
diff
changeset
|
234 |
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
|
235 |
|
814 | 236 |
for language in languages: |
237 |
self.Language.Append(language) |
|
238 |
||
239 |
def RefreshView(self): |
|
240 |
if self.Controller is not None: |
|
241 |
self.SetValues(self.Controller.GetProjectProperties()) |
|
242 |
||
243 |
def SetValues(self, values): |
|
244 |
self.Values = values |
|
245 |
for item, value in values.items(): |
|
246 |
if item == "language": |
|
247 |
self.Language.SetStringSelection(value) |
|
248 |
elif item == "contentDescription": |
|
249 |
self.ContentDescription.SetValue(value) |
|
250 |
elif item == "pageSize": |
|
251 |
self.PageWidth.SetValue(value[0]) |
|
252 |
self.PageHeight.SetValue(value[1]) |
|
253 |
elif item == "scaling": |
|
254 |
for language, (x, y) in value.items(): |
|
255 |
if language in self.Scalings: |
|
256 |
self.Scalings[language][0].SetValue(x) |
|
257 |
self.Scalings[language][1].SetValue(y) |
|
258 |
else: |
|
259 |
tc = getattr(self, item, None) |
|
260 |
if tc is not None: |
|
261 |
tc.SetValue(value) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
262 |
|
814 | 263 |
def GetValues(self): |
264 |
values = {} |
|
265 |
for param in ["projectName", "projectVersion", |
|
266 |
"productName", "productVersion", |
|
267 |
"productRelease", "companyName", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
268 |
"companyURL", "authorName", |
814 | 269 |
"organization"]: |
270 |
value = getattr(self, param).GetValue() |
|
271 |
if param in REQUIRED_PARAMS or value != "": |
|
272 |
values[param] = value |
|
273 |
else: |
|
274 |
values[param] = None |
|
275 |
language = self.Language.GetStringSelection() |
|
276 |
if language != "": |
|
277 |
values["language"] = language |
|
278 |
else: |
|
279 |
values["language"] = None |
|
280 |
content_description = self.ContentDescription.GetValue() |
|
281 |
if content_description != "": |
|
282 |
values["contentDescription"] = content_description |
|
283 |
else: |
|
284 |
values["contentDescription"] = None |
|
285 |
values["pageSize"] = (self.PageWidth.GetValue(), self.PageHeight.GetValue()) |
|
286 |
values["scaling"] = {} |
|
287 |
for language in ["FBD", "LD", "SFC"]: |
|
288 |
values["scaling"][language] = (self.Scalings[language][0].GetValue(), |
|
289 |
self.Scalings[language][1].GetValue()) |
|
290 |
return values |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
291 |
|
814 | 292 |
def GetTextCtrlChangedFunction(self, textctrl, name): |
293 |
def TextCtrlChangedFunction(event): |
|
1678
55b6db51eb63
fix clearing project name on opening project properties page.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
294 |
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
|
295 |
old_value = self.Values.get(name) |
814 | 296 |
new_value = textctrl.GetValue() |
297 |
if name not in REQUIRED_PARAMS and new_value == "": |
|
298 |
new_value = None |
|
299 |
if old_value != new_value: |
|
300 |
self.Controller.SetProjectProperties(properties={name: new_value}) |
|
301 |
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
|
302 |
PROJECTTREE, PAGETITLES) |
814 | 303 |
wx.CallAfter(self.RefreshView) |
304 |
event.Skip() |
|
305 |
return TextCtrlChangedFunction |
|
306 |
||
307 |
def GetPageSizeChangedFunction(self, spinctrl, name): |
|
308 |
def PageSizeChangedFunction(event): |
|
309 |
if self.Controller is not None: |
|
310 |
if self.Values is not None: |
|
311 |
old_value = self.Values.get("pageSize") |
|
312 |
else: |
|
313 |
old_value = (0, 0) |
|
314 |
if name == 'PageWidth': |
|
315 |
new_value = (spinctrl.GetValue(), old_value[1]) |
|
316 |
else: |
|
317 |
new_value = (old_value[0], spinctrl.GetValue()) |
|
318 |
if old_value != new_value: |
|
319 |
self.Controller.SetProjectProperties(properties={"pageSize": new_value}) |
|
320 |
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
|
321 |
PAGETITLES, SCALING) |
814 | 322 |
wx.CallAfter(self.RefreshView) |
323 |
event.Skip() |
|
324 |
return PageSizeChangedFunction |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
325 |
|
814 | 326 |
def GetScalingChangedFunction(self, spinctrl, language, name): |
327 |
def ScalingChangedFunction(event): |
|
328 |
if self.Controller is not None: |
|
329 |
old_value = (0, 0) |
|
330 |
if self.Values is not None: |
|
331 |
scaling = self.Values.get("scaling") |
|
332 |
if scaling is not None: |
|
333 |
old_value = scaling.get(language) |
|
334 |
if name == 'XScale': |
|
335 |
new_value = (spinctrl.GetValue(), old_value[1]) |
|
336 |
else: |
|
337 |
new_value = (old_value[0], spinctrl.GetValue()) |
|
338 |
if old_value != new_value: |
|
339 |
self.Controller.SetProjectProperties(properties={"scaling": {language: new_value}}) |
|
340 |
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
|
341 |
PAGETITLES, SCALING) |
814 | 342 |
wx.CallAfter(self.RefreshView) |
343 |
event.Skip() |
|
344 |
return ScalingChangedFunction |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
345 |
|
814 | 346 |
def OnLanguageChanged(self, event): |
347 |
if self.Controller is not None: |
|
348 |
if self.Values is not None: |
|
349 |
old_value = self.Values.get("language") |
|
350 |
else: |
|
351 |
old_value = None |
|
352 |
new_value = self.Language.GetStringSelection() |
|
353 |
if new_value == "": |
|
354 |
new_value = None |
|
355 |
if old_value != new_value: |
|
356 |
self.Controller.SetProjectProperties(properties={"language": new_value}) |
|
357 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) |
|
358 |
wx.CallAfter(self.RefreshView) |
|
359 |
event.Skip() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
360 |
|
814 | 361 |
def OnContentDescriptionChanged(self, event): |
362 |
if self.Controller is not None: |
|
363 |
if self.Values is not None: |
|
364 |
old_value = self.Values.get("contentDescription") |
|
365 |
else: |
|
366 |
old_value = None |
|
367 |
new_value = self.ContentDescription.GetValue() |
|
368 |
if new_value == "": |
|
369 |
new_value = None |
|
370 |
if old_value != new_value: |
|
371 |
self.Controller.SetProjectProperties(properties={"contentDescription": new_value}) |
|
372 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) |
|
373 |
wx.CallAfter(self.RefreshView) |
|
374 |
event.Skip() |