preferences.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. """
  2. @package gmodeler.preferences
  3. @brief wxGUI Graphical Modeler - preferences
  4. Classes:
  5. - preferences::PreferencesDialog
  6. - preferences::PropertiesDialog
  7. (C) 2010-2013 by the GRASS Development Team
  8. This program is free software under the GNU General Public License
  9. (>=v2). Read the file COPYING that comes with GRASS for details.
  10. @author Martin Landa <landa.martin gmail.com>
  11. """
  12. import wx
  13. import wx.lib.colourselect as csel
  14. from core import globalvar
  15. from gui_core.preferences import PreferencesBaseDialog
  16. from core.settings import UserSettings
  17. from core.utils import _
  18. class PreferencesDialog(PreferencesBaseDialog):
  19. """User preferences dialog"""
  20. def __init__(self, parent, giface, settings = UserSettings,
  21. title = _("Modeler settings")):
  22. PreferencesBaseDialog.__init__(self, parent = parent, giface = giface, title = title,
  23. settings = settings)
  24. # create notebook pages
  25. self._createGeneralPage(self.notebook)
  26. self._createActionPage(self.notebook)
  27. self._createDataPage(self.notebook)
  28. self._createLoopPage(self.notebook)
  29. self._createCommentPage(self.notebook)
  30. self.SetMinSize(self.GetBestSize())
  31. self.SetSize(self.size)
  32. def _createGeneralPage(self, notebook):
  33. """Create notebook page for action settings"""
  34. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  35. notebook.AddPage(page = panel, text = _("General"))
  36. # colors
  37. border = wx.BoxSizer(wx.VERTICAL)
  38. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  39. label = " %s " % _("Item properties"))
  40. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  41. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  42. row = 0
  43. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  44. label = _("Disabled:")),
  45. flag = wx.ALIGN_LEFT |
  46. wx.ALIGN_CENTER_VERTICAL,
  47. pos = (row, 0))
  48. rColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  49. colour = self.settings.Get(group='modeler', key='disabled', subkey='color'),
  50. size = globalvar.DIALOG_COLOR_SIZE)
  51. rColor.SetName('GetColour')
  52. self.winId['modeler:disabled:color'] = rColor.GetId()
  53. gridSizer.Add(item = rColor,
  54. flag = wx.ALIGN_RIGHT |
  55. wx.ALIGN_CENTER_VERTICAL,
  56. pos = (row, 1))
  57. gridSizer.AddGrowableCol(0)
  58. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  59. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  60. panel.SetSizer(border)
  61. return panel
  62. def _createActionPage(self, notebook):
  63. """Create notebook page for action settings"""
  64. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  65. notebook.AddPage(page = panel, text = _("Command"))
  66. # colors
  67. border = wx.BoxSizer(wx.VERTICAL)
  68. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  69. label = " %s " % _("Color"))
  70. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  71. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  72. row = 0
  73. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  74. label = _("Valid:")),
  75. flag = wx.ALIGN_LEFT |
  76. wx.ALIGN_CENTER_VERTICAL,
  77. pos = (row, 0))
  78. vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  79. colour = self.settings.Get(group='modeler', key='action', subkey=('color', 'valid')),
  80. size = globalvar.DIALOG_COLOR_SIZE)
  81. vColor.SetName('GetColour')
  82. self.winId['modeler:action:color:valid'] = vColor.GetId()
  83. gridSizer.Add(item = vColor,
  84. flag = wx.ALIGN_RIGHT |
  85. wx.ALIGN_CENTER_VERTICAL,
  86. pos = (row, 1))
  87. row += 1
  88. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  89. label = _("Invalid:")),
  90. flag = wx.ALIGN_LEFT |
  91. wx.ALIGN_CENTER_VERTICAL,
  92. pos = (row, 0))
  93. iColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  94. colour = self.settings.Get(group='modeler', key='action', subkey=('color', 'invalid')),
  95. size = globalvar.DIALOG_COLOR_SIZE)
  96. iColor.SetName('GetColour')
  97. self.winId['modeler:action:color:invalid'] = iColor.GetId()
  98. gridSizer.Add(item = iColor,
  99. flag = wx.ALIGN_RIGHT |
  100. wx.ALIGN_CENTER_VERTICAL,
  101. pos = (row, 1))
  102. row += 1
  103. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  104. label = _("Running:")),
  105. flag = wx.ALIGN_LEFT |
  106. wx.ALIGN_CENTER_VERTICAL,
  107. pos = (row, 0))
  108. rColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  109. colour = self.settings.Get(group='modeler', key='action', subkey=('color', 'running')),
  110. size = globalvar.DIALOG_COLOR_SIZE)
  111. rColor.SetName('GetColour')
  112. self.winId['modeler:action:color:running'] = rColor.GetId()
  113. gridSizer.Add(item = rColor,
  114. flag = wx.ALIGN_RIGHT |
  115. wx.ALIGN_CENTER_VERTICAL,
  116. pos = (row, 1))
  117. gridSizer.AddGrowableCol(0)
  118. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  119. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  120. # size
  121. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  122. label = " %s " % _("Shape size"))
  123. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  124. gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
  125. row = 0
  126. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  127. label = _("Width:")),
  128. flag = wx.ALIGN_LEFT |
  129. wx.ALIGN_CENTER_VERTICAL,
  130. pos = (row, 0))
  131. width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  132. min = 0, max = 500,
  133. initial = self.settings.Get(group='modeler', key='action', subkey=('size', 'width')))
  134. width.SetName('GetValue')
  135. self.winId['modeler:action:size:width'] = width.GetId()
  136. gridSizer.Add(item = width,
  137. flag = wx.ALIGN_RIGHT |
  138. wx.ALIGN_CENTER_VERTICAL,
  139. pos = (row, 1))
  140. row += 1
  141. gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
  142. label=_("Height:")),
  143. flag = wx.ALIGN_LEFT |
  144. wx.ALIGN_CENTER_VERTICAL,
  145. pos=(row, 0))
  146. height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  147. min = 0, max = 500,
  148. initial = self.settings.Get(group='modeler', key='action', subkey=('size', 'height')))
  149. height.SetName('GetValue')
  150. self.winId['modeler:action:size:height'] = height.GetId()
  151. gridSizer.Add(item = height,
  152. flag = wx.ALIGN_RIGHT |
  153. wx.ALIGN_CENTER_VERTICAL,
  154. pos = (row, 1))
  155. gridSizer.AddGrowableCol(0)
  156. sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
  157. border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
  158. panel.SetSizer(border)
  159. return panel
  160. def _createDataPage(self, notebook):
  161. """Create notebook page for data settings"""
  162. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  163. notebook.AddPage(page = panel, text = _("Data"))
  164. # colors
  165. border = wx.BoxSizer(wx.VERTICAL)
  166. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  167. label = " %s " % _("Type"))
  168. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  169. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  170. row = 0
  171. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  172. label = _("Raster:")),
  173. flag = wx.ALIGN_LEFT |
  174. wx.ALIGN_CENTER_VERTICAL,
  175. pos = (row, 0))
  176. rColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  177. colour = self.settings.Get(group='modeler', key='data', subkey=('color', 'raster')),
  178. size = globalvar.DIALOG_COLOR_SIZE)
  179. rColor.SetName('GetColour')
  180. self.winId['modeler:data:color:raster'] = rColor.GetId()
  181. gridSizer.Add(item = rColor,
  182. flag = wx.ALIGN_RIGHT |
  183. wx.ALIGN_CENTER_VERTICAL,
  184. pos = (row, 1))
  185. row += 1
  186. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  187. label = _("3D raster:")),
  188. flag = wx.ALIGN_LEFT |
  189. wx.ALIGN_CENTER_VERTICAL,
  190. pos = (row, 0))
  191. r3Color = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  192. colour = self.settings.Get(group='modeler', key='data', subkey=('color', 'raster3d')),
  193. size = globalvar.DIALOG_COLOR_SIZE)
  194. r3Color.SetName('GetColour')
  195. self.winId['modeler:data:color:raster3d'] = r3Color.GetId()
  196. gridSizer.Add(item = r3Color,
  197. flag = wx.ALIGN_RIGHT |
  198. wx.ALIGN_CENTER_VERTICAL,
  199. pos = (row, 1))
  200. row += 1
  201. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  202. label = _("Vector:")),
  203. flag = wx.ALIGN_LEFT |
  204. wx.ALIGN_CENTER_VERTICAL,
  205. pos = (row, 0))
  206. vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  207. colour = self.settings.Get(group='modeler', key='data', subkey=('color', 'vector')),
  208. size = globalvar.DIALOG_COLOR_SIZE)
  209. vColor.SetName('GetColour')
  210. self.winId['modeler:data:color:vector'] = vColor.GetId()
  211. gridSizer.Add(item = vColor,
  212. flag = wx.ALIGN_RIGHT |
  213. wx.ALIGN_CENTER_VERTICAL,
  214. pos = (row, 1))
  215. gridSizer.AddGrowableCol(0)
  216. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  217. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  218. # size
  219. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  220. label = " %s " % _("Shape size"))
  221. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  222. gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
  223. row = 0
  224. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  225. label = _("Width:")),
  226. flag = wx.ALIGN_LEFT |
  227. wx.ALIGN_CENTER_VERTICAL,
  228. pos = (row, 0))
  229. width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  230. min = 0, max = 500,
  231. initial = self.settings.Get(group='modeler', key='data', subkey=('size', 'width')))
  232. width.SetName('GetValue')
  233. self.winId['modeler:data:size:width'] = width.GetId()
  234. gridSizer.Add(item = width,
  235. flag = wx.ALIGN_RIGHT |
  236. wx.ALIGN_CENTER_VERTICAL,
  237. pos = (row, 1))
  238. row += 1
  239. gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
  240. label=_("Height:")),
  241. flag = wx.ALIGN_LEFT |
  242. wx.ALIGN_CENTER_VERTICAL,
  243. pos=(row, 0))
  244. height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  245. min = 0, max = 500,
  246. initial = self.settings.Get(group='modeler', key='data', subkey=('size', 'height')))
  247. height.SetName('GetValue')
  248. self.winId['modeler:data:size:height'] = height.GetId()
  249. gridSizer.Add(item = height,
  250. flag = wx.ALIGN_RIGHT |
  251. wx.ALIGN_CENTER_VERTICAL,
  252. pos = (row, 1))
  253. gridSizer.AddGrowableCol(0)
  254. sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
  255. border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
  256. panel.SetSizer(border)
  257. return panel
  258. def _createLoopPage(self, notebook):
  259. """Create notebook page for loop settings"""
  260. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  261. notebook.AddPage(page = panel, text = _("Loop"))
  262. # colors
  263. border = wx.BoxSizer(wx.VERTICAL)
  264. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  265. label = " %s " % _("Color"))
  266. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  267. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  268. row = 0
  269. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  270. label = _("Valid:")),
  271. flag = wx.ALIGN_LEFT |
  272. wx.ALIGN_CENTER_VERTICAL,
  273. pos = (row, 0))
  274. vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  275. colour = self.settings.Get(group='modeler', key='loop', subkey=('color', 'valid')),
  276. size = globalvar.DIALOG_COLOR_SIZE)
  277. vColor.SetName('GetColour')
  278. self.winId['modeler:loop:color:valid'] = vColor.GetId()
  279. gridSizer.Add(item = vColor,
  280. flag = wx.ALIGN_RIGHT |
  281. wx.ALIGN_CENTER_VERTICAL,
  282. pos = (row, 1))
  283. gridSizer.AddGrowableCol(0)
  284. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  285. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  286. # size
  287. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  288. label = " %s " % _("Shape size"))
  289. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  290. gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
  291. row = 0
  292. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  293. label = _("Width:")),
  294. flag = wx.ALIGN_LEFT |
  295. wx.ALIGN_CENTER_VERTICAL,
  296. pos = (row, 0))
  297. width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  298. min = 0, max = 500,
  299. initial = self.settings.Get(group='modeler', key='loop', subkey=('size', 'width')))
  300. width.SetName('GetValue')
  301. self.winId['modeler:loop:size:width'] = width.GetId()
  302. gridSizer.Add(item = width,
  303. flag = wx.ALIGN_RIGHT |
  304. wx.ALIGN_CENTER_VERTICAL,
  305. pos = (row, 1))
  306. row += 1
  307. gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
  308. label=_("Height:")),
  309. flag = wx.ALIGN_LEFT |
  310. wx.ALIGN_CENTER_VERTICAL,
  311. pos=(row, 0))
  312. height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  313. min = 0, max = 500,
  314. initial = self.settings.Get(group='modeler', key='loop', subkey=('size', 'height')))
  315. height.SetName('GetValue')
  316. self.winId['modeler:loop:size:height'] = height.GetId()
  317. gridSizer.Add(item = height,
  318. flag = wx.ALIGN_RIGHT |
  319. wx.ALIGN_CENTER_VERTICAL,
  320. pos = (row, 1))
  321. gridSizer.AddGrowableCol(0)
  322. sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
  323. border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
  324. panel.SetSizer(border)
  325. return panel
  326. def _createCommentPage(self, notebook):
  327. """Create notebook page for comment settings"""
  328. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  329. notebook.AddPage(page = panel, text = _("Comment"))
  330. # colors
  331. border = wx.BoxSizer(wx.VERTICAL)
  332. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  333. label = " %s " % _("Color"))
  334. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  335. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  336. row = 0
  337. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  338. label = _("Valid:")),
  339. flag = wx.ALIGN_LEFT |
  340. wx.ALIGN_CENTER_VERTICAL,
  341. pos = (row, 0))
  342. vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  343. colour = self.settings.Get(group='modeler', key='comment', subkey='color'),
  344. size = globalvar.DIALOG_COLOR_SIZE)
  345. vColor.SetName('GetColour')
  346. self.winId['modeler:comment:color'] = vColor.GetId()
  347. gridSizer.Add(item = vColor,
  348. flag = wx.ALIGN_RIGHT |
  349. wx.ALIGN_CENTER_VERTICAL,
  350. pos = (row, 1))
  351. gridSizer.AddGrowableCol(0)
  352. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  353. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  354. # size
  355. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  356. label = " %s " % _("Shape size"))
  357. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  358. gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
  359. row = 0
  360. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  361. label = _("Width:")),
  362. flag = wx.ALIGN_LEFT |
  363. wx.ALIGN_CENTER_VERTICAL,
  364. pos = (row, 0))
  365. width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  366. min = 0, max = 500,
  367. initial = self.settings.Get(group='modeler', key='comment', subkey=('size', 'width')))
  368. width.SetName('GetValue')
  369. self.winId['modeler:comment:size:width'] = width.GetId()
  370. gridSizer.Add(item = width,
  371. flag = wx.ALIGN_RIGHT |
  372. wx.ALIGN_CENTER_VERTICAL,
  373. pos = (row, 1))
  374. row += 1
  375. gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
  376. label=_("Height:")),
  377. flag = wx.ALIGN_LEFT |
  378. wx.ALIGN_CENTER_VERTICAL,
  379. pos=(row, 0))
  380. height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  381. min = 0, max = 500,
  382. initial = self.settings.Get(group='modeler', key='comment', subkey=('size', 'height')))
  383. height.SetName('GetValue')
  384. self.winId['modeler:comment:size:height'] = height.GetId()
  385. gridSizer.Add(item = height,
  386. flag = wx.ALIGN_RIGHT |
  387. wx.ALIGN_CENTER_VERTICAL,
  388. pos = (row, 1))
  389. gridSizer.AddGrowableCol(0)
  390. sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
  391. border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
  392. panel.SetSizer(border)
  393. return panel
  394. def OnApply(self, event):
  395. """Button 'Apply' pressed"""
  396. PreferencesBaseDialog.OnApply(self, event)
  397. self.parent.GetModel().Update()
  398. self.parent.GetCanvas().Refresh()
  399. def OnSave(self, event):
  400. """Button 'Save' pressed"""
  401. PreferencesBaseDialog.OnSave(self, event)
  402. self.parent.GetModel().Update()
  403. self.parent.GetCanvas().Refresh()
  404. class PropertiesDialog(wx.Dialog):
  405. """Model properties dialog
  406. """
  407. def __init__(self, parent, id = wx.ID_ANY,
  408. title = _('Model properties'),
  409. size = (350, 400),
  410. style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
  411. wx.Dialog.__init__(self, parent, id, title, size = size,
  412. style = style)
  413. self.metaBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
  414. label=" %s " % _("Metadata"))
  415. self.cmdBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
  416. label=" %s " % _("Commands"))
  417. self.name = wx.TextCtrl(parent = self, id = wx.ID_ANY,
  418. size = (300, 25))
  419. self.desc = wx.TextCtrl(parent = self, id = wx.ID_ANY,
  420. style = wx.TE_MULTILINE,
  421. size = (300, 50))
  422. self.author = wx.TextCtrl(parent = self, id = wx.ID_ANY,
  423. size = (300, 25))
  424. # commands
  425. self.overwrite = wx.CheckBox(parent = self, id=wx.ID_ANY,
  426. label=_("Allow output files to overwrite existing files"))
  427. self.overwrite.SetValue(UserSettings.Get(group='cmd', key='overwrite', subkey='enabled'))
  428. # buttons
  429. self.btnOk = wx.Button(self, wx.ID_OK)
  430. self.btnCancel = wx.Button(self, wx.ID_CANCEL)
  431. self.btnOk.SetDefault()
  432. self.btnOk.SetToolTipString(_("Apply properties"))
  433. self.btnOk.SetDefault()
  434. self.btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
  435. self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
  436. self._layout()
  437. def _layout(self):
  438. metaSizer = wx.StaticBoxSizer(self.metaBox, wx.VERTICAL)
  439. gridSizer = wx.GridBagSizer(hgap = 3, vgap = 3)
  440. gridSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
  441. label = _("Name:")),
  442. flag = wx.ALIGN_LEFT |
  443. wx.ALIGN_CENTER_VERTICAL,
  444. pos = (0, 0))
  445. gridSizer.Add(item = self.name,
  446. flag = wx.ALIGN_LEFT |
  447. wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
  448. pos = (0, 1))
  449. gridSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
  450. label = _("Description:")),
  451. flag = wx.ALIGN_LEFT |
  452. wx.ALIGN_CENTER_VERTICAL,
  453. pos = (1, 0))
  454. gridSizer.Add(item = self.desc,
  455. flag = wx.ALIGN_LEFT |
  456. wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
  457. pos = (1, 1))
  458. gridSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
  459. label = _("Author(s):")),
  460. flag = wx.ALIGN_LEFT |
  461. wx.ALIGN_CENTER_VERTICAL,
  462. pos = (2, 0))
  463. gridSizer.Add(item = self.author,
  464. flag = wx.ALIGN_LEFT |
  465. wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
  466. pos = (2, 1))
  467. gridSizer.AddGrowableCol(1)
  468. gridSizer.AddGrowableRow(1)
  469. metaSizer.Add(item = gridSizer, proportion = 1, flag = wx.EXPAND)
  470. cmdSizer = wx.StaticBoxSizer(self.cmdBox, wx.VERTICAL)
  471. cmdSizer.Add(item = self.overwrite,
  472. flag = wx.EXPAND | wx.ALL, border = 3)
  473. btnStdSizer = wx.StdDialogButtonSizer()
  474. btnStdSizer.AddButton(self.btnCancel)
  475. btnStdSizer.AddButton(self.btnOk)
  476. btnStdSizer.Realize()
  477. mainSizer = wx.BoxSizer(wx.VERTICAL)
  478. mainSizer.Add(item=metaSizer, proportion=1,
  479. flag=wx.EXPAND | wx.ALL, border=5)
  480. mainSizer.Add(item=cmdSizer, proportion=0,
  481. flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
  482. mainSizer.Add(item=btnStdSizer, proportion=0,
  483. flag=wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border=5)
  484. self.SetSizer(mainSizer)
  485. mainSizer.Fit(self)
  486. def OnCloseWindow(self, event):
  487. self.Hide()
  488. def GetValues(self):
  489. """Get values"""
  490. return { 'name' : self.name.GetValue(),
  491. 'description' : self.desc.GetValue(),
  492. 'author' : self.author.GetValue(),
  493. 'overwrite' : self.overwrite.IsChecked() }
  494. def Init(self, prop):
  495. """Initialize dialog"""
  496. self.name.SetValue(prop['name'])
  497. self.desc.SetValue(prop['description'])
  498. self.author.SetValue(prop['author'])
  499. if 'overwrite' in prop:
  500. self.overwrite.SetValue(prop['overwrite'])