author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Fri, 14 Oct 2016 18:04:22 +0300 | |
changeset 1543 | 61f0f31ef296 |
parent 1495 | 078047c3ab85 |
child 1571 | 486f94a8032c |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
|
5 |
#based on the plcopen standard. |
|
6 |
# |
|
7 |
#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD |
|
8 |
# |
|
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
12 |
#modify it under the terms of the GNU General Public |
|
13 |
#License as published by the Free Software Foundation; either |
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 |
#General Public License for more details. |
|
20 |
# |
|
21 |
#You should have received a copy of the GNU General Public |
|
22 |
#License along with this library; if not, write to the Free Software |
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
25 |
import wx |
|
26 |
||
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
27 |
from controls.ProjectPropertiesPanel import ProjectPropertiesPanel |
814 | 28 |
|
29 |
class ProjectDialog(wx.Dialog): |
|
30 |
||
31 |
def __init__(self, parent, enable_required=True): |
|
32 |
wx.Dialog.__init__(self, parent, title=_('Project properties'), |
|
33 |
size=wx.Size(500, 350), style=wx.DEFAULT_DIALOG_STYLE) |
|
34 |
||
35 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
|
36 |
main_sizer.AddGrowableCol(0) |
|
37 |
main_sizer.AddGrowableRow(0) |
|
38 |
||
39 |
self.ProjectProperties = ProjectPropertiesPanel(self, |
|
40 |
enable_required=enable_required) |
|
41 |
main_sizer.AddWindow(self.ProjectProperties, flag=wx.GROW) |
|
42 |
||
43 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
|
44 |
self.Bind(wx.EVT_BUTTON, self.OnOK, |
|
45 |
self.ButtonSizer.GetAffirmativeButton()) |
|
46 |
main_sizer.AddSizer(self.ButtonSizer, border=20, |
|
47 |
flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
|
48 |
||
49 |
self.SetSizer(main_sizer) |
|
50 |
||
51 |
def OnOK(self, event): |
|
52 |
values = self.ProjectProperties.GetValues() |
|
53 |
error = [] |
|
1495
078047c3ab85
add i18n for some strings in DiscoveryDialog, DurationEditDialog, ProjectDialog and CodeFileEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
815
diff
changeset
|
54 |
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
|
55 |
("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
|
56 |
("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
|
57 |
("companyName", _("Company Name"))]: |
814 | 58 |
if values[param] == "": |
59 |
error.append(name) |
|
60 |
if len(error) > 0: |
|
61 |
text = "" |
|
62 |
for i, item in enumerate(error): |
|
63 |
if i == 0: |
|
64 |
text += item |
|
65 |
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
|
66 |
text += _(" and %s")%item |
814 | 67 |
else: |
68 |
text += ", %s"%item |
|
69 |
dialog = wx.MessageDialog(self, |
|
70 |
_("Form isn't complete. %s must be filled!") % text, |
|
71 |
_("Error"), wx.OK|wx.ICON_ERROR) |
|
72 |
dialog.ShowModal() |
|
73 |
dialog.Destroy() |
|
74 |
else: |
|
75 |
self.EndModal(wx.ID_OK) |
|
76 |
||
77 |
def SetValues(self, values): |
|
78 |
self.ProjectProperties.SetValues(values) |
|
79 |
||
80 |
def GetValues(self): |
|
81 |
return self.ProjectProperties.GetValues() |