author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Thu, 22 Jun 2017 16:43:38 +0300 | |
changeset 1706 | b5c0a10145f1 |
parent 1696 | 8043f32de7b8 |
child 1730 | 64d8f52bc8c8 |
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:
1495
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:
1495
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
814 | 6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1495
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:
1571
diff
changeset
|
8 |
# Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com> |
814 | 9 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1495
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
814 | 11 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1495
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:
1495
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:
1495
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:
1495
diff
changeset
|
15 |
# of the License, or (at your option) any later version. |
814 | 16 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1495
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:
1495
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:
1495
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:
1495
diff
changeset
|
20 |
# GNU General Public License for more details. |
814 | 21 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1495
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:
1495
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:
1495
diff
changeset
|
24 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 25 |
|
26 |
import wx |
|
27 |
||
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
28 |
from controls.ProjectPropertiesPanel import ProjectPropertiesPanel |
814 | 29 |
|
30 |
class ProjectDialog(wx.Dialog): |
|
31 |
||
32 |
def __init__(self, parent, enable_required=True): |
|
33 |
wx.Dialog.__init__(self, parent, title=_('Project properties'), |
|
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
34 |
style=wx.DEFAULT_DIALOG_STYLE) |
814 | 35 |
|
36 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
|
37 |
main_sizer.AddGrowableCol(0) |
|
38 |
main_sizer.AddGrowableRow(0) |
|
39 |
||
40 |
self.ProjectProperties = ProjectPropertiesPanel(self, |
|
41 |
enable_required=enable_required) |
|
42 |
main_sizer.AddWindow(self.ProjectProperties, flag=wx.GROW) |
|
43 |
||
44 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
|
45 |
self.Bind(wx.EVT_BUTTON, self.OnOK, |
|
46 |
self.ButtonSizer.GetAffirmativeButton()) |
|
47 |
main_sizer.AddSizer(self.ButtonSizer, border=20, |
|
48 |
flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
|
49 |
||
50 |
self.SetSizer(main_sizer) |
|
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
51 |
self.ProjectProperties.Fit() |
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
52 |
self.Fit() |
814 | 53 |
|
54 |
def OnOK(self, event): |
|
55 |
values = self.ProjectProperties.GetValues() |
|
56 |
error = [] |
|
1495
078047c3ab85
add i18n for some strings in DiscoveryDialog, DurationEditDialog, ProjectDialog and CodeFileEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
815
diff
changeset
|
57 |
for param, name in [("projectName", _("Project Name")), |
078047c3ab85
add i18n for some strings in DiscoveryDialog, DurationEditDialog, ProjectDialog and CodeFileEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
815
diff
changeset
|
58 |
("productName", _("Product Name")), |
078047c3ab85
add i18n for some strings in DiscoveryDialog, DurationEditDialog, ProjectDialog and CodeFileEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
815
diff
changeset
|
59 |
("productVersion", _("Product Version")), |
078047c3ab85
add i18n for some strings in DiscoveryDialog, DurationEditDialog, ProjectDialog and CodeFileEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
815
diff
changeset
|
60 |
("companyName", _("Company Name"))]: |
814 | 61 |
if values[param] == "": |
62 |
error.append(name) |
|
63 |
if len(error) > 0: |
|
64 |
text = "" |
|
65 |
for i, item in enumerate(error): |
|
66 |
if i == 0: |
|
67 |
text += item |
|
68 |
elif i == len(error) - 1: |
|
1495
078047c3ab85
add i18n for some strings in DiscoveryDialog, DurationEditDialog, ProjectDialog and CodeFileEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
815
diff
changeset
|
69 |
text += _(" and %s")%item |
814 | 70 |
else: |
71 |
text += ", %s"%item |
|
72 |
dialog = wx.MessageDialog(self, |
|
73 |
_("Form isn't complete. %s must be filled!") % text, |
|
74 |
_("Error"), wx.OK|wx.ICON_ERROR) |
|
75 |
dialog.ShowModal() |
|
76 |
dialog.Destroy() |
|
77 |
else: |
|
78 |
self.EndModal(wx.ID_OK) |
|
79 |
||
80 |
def SetValues(self, values): |
|
81 |
self.ProjectProperties.SetValues(values) |
|
82 |
||
83 |
def GetValues(self): |
|
84 |
return self.ProjectProperties.GetValues() |