dialogs/ProjectDialog.py
changeset 1784 64beb9e9c749
parent 1768 691083b5682a
child 1881 091005ec69c4
equal deleted inserted replaced
1729:31e63e25b4cc 1784:64beb9e9c749
    25 
    25 
    26 import wx
    26 import wx
    27 
    27 
    28 from controls.ProjectPropertiesPanel import ProjectPropertiesPanel
    28 from controls.ProjectPropertiesPanel import ProjectPropertiesPanel
    29 
    29 
       
    30 
    30 class ProjectDialog(wx.Dialog):
    31 class ProjectDialog(wx.Dialog):
    31     
    32 
    32     def __init__(self, parent, enable_required=True):
    33     def __init__(self, parent, enable_required=True):
    33         wx.Dialog.__init__(self, parent, title=_('Project properties'), 
    34         wx.Dialog.__init__(self, parent, title=_('Project properties'),
    34               style=wx.DEFAULT_DIALOG_STYLE)
    35                            style=wx.DEFAULT_DIALOG_STYLE)
    35         
    36 
    36         main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
    37         main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
    37         main_sizer.AddGrowableCol(0)
    38         main_sizer.AddGrowableCol(0)
    38         main_sizer.AddGrowableRow(0)
    39         main_sizer.AddGrowableRow(0)
    39         
    40 
    40         self.ProjectProperties = ProjectPropertiesPanel(self, 
    41         self.ProjectProperties = ProjectPropertiesPanel(
    41               enable_required=enable_required)
    42             self,
       
    43             enable_required=enable_required)
       
    44 
    42         main_sizer.AddWindow(self.ProjectProperties, flag=wx.GROW)
    45         main_sizer.AddWindow(self.ProjectProperties, flag=wx.GROW)
    43         
    46 
    44         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
    47         self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
    45         self.Bind(wx.EVT_BUTTON, self.OnOK, 
    48         self.Bind(wx.EVT_BUTTON, self.OnOK,
    46                   self.ButtonSizer.GetAffirmativeButton())
    49                   self.ButtonSizer.GetAffirmativeButton())
    47         main_sizer.AddSizer(self.ButtonSizer, border=20, 
    50         main_sizer.AddSizer(self.ButtonSizer, border=20,
    48               flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
    51                             flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
    49         
    52 
    50         self.SetSizer(main_sizer)
    53         self.SetSizer(main_sizer)
    51         self.ProjectProperties.Fit()
    54         self.ProjectProperties.Fit()
    52         self.Fit()
    55         self.Fit()
    53         
    56 
    54     def OnOK(self, event):
    57     def OnOK(self, event):
    55         values = self.ProjectProperties.GetValues()
    58         values = self.ProjectProperties.GetValues()
    56         error = []
    59         error = []
    57         for param, name in [("projectName", _("Project Name")),
    60         for param, name in [("projectName", _("Project Name")),
    58                             ("productName", _("Product Name")),
    61                             ("productName", _("Product Name")),
    64             text = ""
    67             text = ""
    65             for i, item in enumerate(error):
    68             for i, item in enumerate(error):
    66                 if i == 0:
    69                 if i == 0:
    67                     text += item
    70                     text += item
    68                 elif i == len(error) - 1:
    71                 elif i == len(error) - 1:
    69                     text += _(" and %s")%item
    72                     text += _(" and %s") % item
    70                 else:
    73                 else:
    71                     text += ", %s"%item
    74                     text += ", %s" % item
    72             dialog = wx.MessageDialog(self, 
    75             dialog = wx.MessageDialog(
    73                 _("Form isn't complete. %s must be filled!") % text, 
    76                 self,
    74                 _("Error"), wx.OK|wx.ICON_ERROR)
    77                 _("Form isn't complete. %s must be filled!") % text,
       
    78                 _("Error"), wx.OK | wx.ICON_ERROR)
    75             dialog.ShowModal()
    79             dialog.ShowModal()
    76             dialog.Destroy()
    80             dialog.Destroy()
    77         else:
    81         else:
    78             self.EndModal(wx.ID_OK)
    82             self.EndModal(wx.ID_OK)
    79 
    83 
    80     def SetValues(self, values):
    84     def SetValues(self, values):
    81         self.ProjectProperties.SetValues(values)
    85         self.ProjectProperties.SetValues(values)
    82         
    86 
    83     def GetValues(self):
    87     def GetValues(self):
    84         return self.ProjectProperties.GetValues()
    88         return self.ProjectProperties.GetValues()