+################################################################################
+
+class PythonOptions(wx.Dialog):
+
+ def __init__(self, parent, cfg, dataFile):
+ pre = wx.PreDialog()
+ g.frame.res.LoadOnDialog(pre, parent, "PYTHON_OPTIONS")
+ self.PostCreate(pre)
+
+ self.cfg = cfg
+ self.dataFile = dataFile
+
+ self.AutoGenerateCB = xrc.XRCCTRL(self, "AutoGenerateCB")
+ self.EmbedCB = xrc.XRCCTRL(self, "EmbedCB")
+ self.GettextCB = xrc.XRCCTRL(self, "GettextCB")
+ self.MakeXRSFileCB = xrc.XRCCTRL(self, "MakeXRSFileCB")
+ self.FileNameTC = xrc.XRCCTRL(self, "FileNameTC")
+ self.BrowseBtn = xrc.XRCCTRL(self, "BrowseBtn")
+ self.GenerateBtn = xrc.XRCCTRL(self, "GenerateBtn")
+ self.SaveOptsBtn = xrc.XRCCTRL(self, "SaveOptsBtn")
+
+ self.Bind(wx.EVT_BUTTON, self.OnBrowse, self.BrowseBtn)
+ self.Bind(wx.EVT_BUTTON, self.OnGenerate, self.GenerateBtn)
+ self.Bind(wx.EVT_BUTTON, self.OnSaveOpts, self.SaveOptsBtn)
+
+ if self.cfg.Read("filename", "") != "":
+ self.FileNameTC.SetValue(self.cfg.Read("filename"))
+ else:
+ name = os.path.splitext(os.path.split(dataFile)[1])[0]
+ name += '_xrc.py'
+ self.FileNameTC.SetValue(name)
+ self.AutoGenerateCB.SetValue(self.cfg.ReadBool("autogenerate", False))
+ self.EmbedCB.SetValue(self.cfg.ReadBool("embedResource", False))
+ self.MakeXRSFileCB.SetValue(self.cfg.ReadBool("makeXRS", False))
+ self.GettextCB.SetValue(self.cfg.ReadBool("genGettext", False))
+
+
+ def OnBrowse(self, evt):
+ path = self.FileNameTC.GetValue()
+ dirname = os.path.abspath(os.path.dirname(path))
+ name = os.path.split(path)[1]
+ dlg = wx.FileDialog(self, 'Save As', dirname, name, '*.py',
+ wx.SAVE | wx.OVERWRITE_PROMPT)
+ if dlg.ShowModal() == wx.ID_OK:
+ path = dlg.GetPath()
+ self.FileNameTC.SetValue(path)
+ dlg.Destroy()
+
+
+ def OnGenerate(self, evt):
+ pypath = self.FileNameTC.GetValue()
+ embed = self.EmbedCB.GetValue()
+ genGettext = self.GettextCB.GetValue()
+ frame.GeneratePython(self.dataFile, pypath, embed, genGettext)
+ self.OnSaveOpts()
+
+
+ def OnSaveOpts(self, evt=None):
+ self.cfg.Write("filename", self.FileNameTC.GetValue())
+ self.cfg.WriteBool("autogenerate", self.AutoGenerateCB.GetValue())
+ self.cfg.WriteBool("embedResource", self.EmbedCB.GetValue())
+ self.cfg.WriteBool("makeXRS", self.MakeXRSFileCB.GetValue())
+ self.cfg.WriteBool("genGettext", self.GettextCB.GetValue())
+
+ self.EndModal(wx.ID_OK)
+
+################################################################################
+
+class PrefsDialog(wx.Dialog):
+
+ def __init__(self, parent):
+ pre = wx.PreDialog()
+ g.frame.res.LoadOnDialog(pre, parent, "DIALOG_PREFS")
+ self.PostCreate(pre)
+ self.checkControls = {} # map of check IDs to (control,dict,param)
+
+ ##xxx = sys.modules['xxx']
+ import xxx
+ d = xxx.xxxSizerItem.defaults_panel
+
+ self.check_proportion_panel = xrc.XRCCTRL(self, 'check_proportion_panel')
+ id = self.check_proportion_panel.GetId()
+ wx.EVT_CHECKBOX(self, id, self.OnCheck)
+ self.checkControls[id] = (xrc.XRCCTRL(self, 'spin_proportion_panel'),
+ d, 'option')
+
+ self.check_flag_panel = xrc.XRCCTRL(self, 'check_flag_panel')
+ id = self.check_flag_panel.GetId()
+ wx.EVT_CHECKBOX(self, id, self.OnCheck)
+ self.checkControls[id] = (xrc.XRCCTRL(self, 'text_flag_panel'),
+ d, 'flag')
+
+ d = xxx.xxxSizerItem.defaults_control
+
+ self.check_proportion_panel = xrc.XRCCTRL(self, 'check_proportion_control')
+ id = self.check_proportion_panel.GetId()
+ wx.EVT_CHECKBOX(self, id, self.OnCheck)
+ self.checkControls[id] = (xrc.XRCCTRL(self, 'spin_proportion_control'),
+ d, 'option')
+
+ self.check_flag_panel = xrc.XRCCTRL(self, 'check_flag_control')
+ id = self.check_flag_panel.GetId()
+ wx.EVT_CHECKBOX(self, id, self.OnCheck)
+ self.checkControls[id] = (xrc.XRCCTRL(self, 'text_flag_control'),
+ d, 'flag')
+
+ for id,cdp in self.checkControls.items():
+ c,d,p = cdp
+ try:
+ if isinstance(c, wx.SpinCtrl):
+ c.SetValue(int(d[p]))
+ else:
+ c.SetValue(d[p])
+ self.FindWindowById(id).SetValue(True)
+ except KeyError:
+ c.Enable(False)
+
+ self.radio_allow_exec = xrc.XRCCTRL(self, 'radio_allow_exec')
+ try:
+ radio = {'ask': 0, 'yes':1, 'no':2}[g.conf.allowExec]
+ except KeyError:
+ radio = 0
+ self.radio_allow_exec.SetSelection(radio)
+
+ def OnCheck(self, evt):
+ self.checkControls[evt.GetId()][0].Enable(evt.IsChecked())
+ evt.Skip()