preferences.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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. row += 1
  216. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  217. label = _("Table:")),
  218. flag = wx.ALIGN_LEFT |
  219. wx.ALIGN_CENTER_VERTICAL,
  220. pos = (row, 0))
  221. tColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  222. colour = self.settings.Get(group='modeler', key='data', subkey=('color', 'dbtable')),
  223. size = globalvar.DIALOG_COLOR_SIZE)
  224. tColor.SetName('GetColour')
  225. self.winId['modeler:data:color:dbtable'] = tColor.GetId()
  226. gridSizer.Add(item = tColor,
  227. flag = wx.ALIGN_RIGHT |
  228. wx.ALIGN_CENTER_VERTICAL,
  229. pos = (row, 1))
  230. gridSizer.AddGrowableCol(0)
  231. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  232. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  233. # size
  234. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  235. label = " %s " % _("Shape size"))
  236. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  237. gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
  238. row = 0
  239. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  240. label = _("Width:")),
  241. flag = wx.ALIGN_LEFT |
  242. wx.ALIGN_CENTER_VERTICAL,
  243. pos = (row, 0))
  244. width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  245. min = 0, max = 500,
  246. initial = self.settings.Get(group='modeler', key='data', subkey=('size', 'width')))
  247. width.SetName('GetValue')
  248. self.winId['modeler:data:size:width'] = width.GetId()
  249. gridSizer.Add(item = width,
  250. flag = wx.ALIGN_RIGHT |
  251. wx.ALIGN_CENTER_VERTICAL,
  252. pos = (row, 1))
  253. row += 1
  254. gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
  255. label=_("Height:")),
  256. flag = wx.ALIGN_LEFT |
  257. wx.ALIGN_CENTER_VERTICAL,
  258. pos=(row, 0))
  259. height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  260. min = 0, max = 500,
  261. initial = self.settings.Get(group='modeler', key='data', subkey=('size', 'height')))
  262. height.SetName('GetValue')
  263. self.winId['modeler:data:size:height'] = height.GetId()
  264. gridSizer.Add(item = height,
  265. flag = wx.ALIGN_RIGHT |
  266. wx.ALIGN_CENTER_VERTICAL,
  267. pos = (row, 1))
  268. gridSizer.AddGrowableCol(0)
  269. sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
  270. border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
  271. panel.SetSizer(border)
  272. return panel
  273. def _createLoopPage(self, notebook):
  274. """Create notebook page for loop settings"""
  275. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  276. notebook.AddPage(page = panel, text = _("Loop"))
  277. # colors
  278. border = wx.BoxSizer(wx.VERTICAL)
  279. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  280. label = " %s " % _("Color"))
  281. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  282. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  283. row = 0
  284. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  285. label = _("Valid:")),
  286. flag = wx.ALIGN_LEFT |
  287. wx.ALIGN_CENTER_VERTICAL,
  288. pos = (row, 0))
  289. vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  290. colour = self.settings.Get(group='modeler', key='loop', subkey=('color', 'valid')),
  291. size = globalvar.DIALOG_COLOR_SIZE)
  292. vColor.SetName('GetColour')
  293. self.winId['modeler:loop:color:valid'] = vColor.GetId()
  294. gridSizer.Add(item = vColor,
  295. flag = wx.ALIGN_RIGHT |
  296. wx.ALIGN_CENTER_VERTICAL,
  297. pos = (row, 1))
  298. gridSizer.AddGrowableCol(0)
  299. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  300. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  301. # size
  302. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  303. label = " %s " % _("Shape size"))
  304. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  305. gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
  306. row = 0
  307. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  308. label = _("Width:")),
  309. flag = wx.ALIGN_LEFT |
  310. wx.ALIGN_CENTER_VERTICAL,
  311. pos = (row, 0))
  312. width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  313. min = 0, max = 500,
  314. initial = self.settings.Get(group='modeler', key='loop', subkey=('size', 'width')))
  315. width.SetName('GetValue')
  316. self.winId['modeler:loop:size:width'] = width.GetId()
  317. gridSizer.Add(item = width,
  318. flag = wx.ALIGN_RIGHT |
  319. wx.ALIGN_CENTER_VERTICAL,
  320. pos = (row, 1))
  321. row += 1
  322. gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
  323. label=_("Height:")),
  324. flag = wx.ALIGN_LEFT |
  325. wx.ALIGN_CENTER_VERTICAL,
  326. pos=(row, 0))
  327. height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  328. min = 0, max = 500,
  329. initial = self.settings.Get(group='modeler', key='loop', subkey=('size', 'height')))
  330. height.SetName('GetValue')
  331. self.winId['modeler:loop:size:height'] = height.GetId()
  332. gridSizer.Add(item = height,
  333. flag = wx.ALIGN_RIGHT |
  334. wx.ALIGN_CENTER_VERTICAL,
  335. pos = (row, 1))
  336. gridSizer.AddGrowableCol(0)
  337. sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
  338. border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
  339. panel.SetSizer(border)
  340. return panel
  341. def _createCommentPage(self, notebook):
  342. """Create notebook page for comment settings"""
  343. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  344. notebook.AddPage(page = panel, text = _("Comment"))
  345. # colors
  346. border = wx.BoxSizer(wx.VERTICAL)
  347. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  348. label = " %s " % _("Color"))
  349. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  350. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  351. row = 0
  352. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  353. label = _("Valid:")),
  354. flag = wx.ALIGN_LEFT |
  355. wx.ALIGN_CENTER_VERTICAL,
  356. pos = (row, 0))
  357. vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  358. colour = self.settings.Get(group='modeler', key='comment', subkey='color'),
  359. size = globalvar.DIALOG_COLOR_SIZE)
  360. vColor.SetName('GetColour')
  361. self.winId['modeler:comment:color'] = vColor.GetId()
  362. gridSizer.Add(item = vColor,
  363. flag = wx.ALIGN_RIGHT |
  364. wx.ALIGN_CENTER_VERTICAL,
  365. pos = (row, 1))
  366. gridSizer.AddGrowableCol(0)
  367. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  368. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  369. # size
  370. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  371. label = " %s " % _("Shape size"))
  372. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  373. gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
  374. row = 0
  375. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  376. label = _("Width:")),
  377. flag = wx.ALIGN_LEFT |
  378. wx.ALIGN_CENTER_VERTICAL,
  379. pos = (row, 0))
  380. width = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  381. min = 0, max = 500,
  382. initial = self.settings.Get(group='modeler', key='comment', subkey=('size', 'width')))
  383. width.SetName('GetValue')
  384. self.winId['modeler:comment:size:width'] = width.GetId()
  385. gridSizer.Add(item = width,
  386. flag = wx.ALIGN_RIGHT |
  387. wx.ALIGN_CENTER_VERTICAL,
  388. pos = (row, 1))
  389. row += 1
  390. gridSizer.Add(item = wx.StaticText(parent=panel, id=wx.ID_ANY,
  391. label=_("Height:")),
  392. flag = wx.ALIGN_LEFT |
  393. wx.ALIGN_CENTER_VERTICAL,
  394. pos=(row, 0))
  395. height = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  396. min = 0, max = 500,
  397. initial = self.settings.Get(group='modeler', key='comment', subkey=('size', 'height')))
  398. height.SetName('GetValue')
  399. self.winId['modeler:comment:size:height'] = height.GetId()
  400. gridSizer.Add(item = height,
  401. flag = wx.ALIGN_RIGHT |
  402. wx.ALIGN_CENTER_VERTICAL,
  403. pos = (row, 1))
  404. gridSizer.AddGrowableCol(0)
  405. sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
  406. border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
  407. panel.SetSizer(border)
  408. return panel
  409. def OnApply(self, event):
  410. """Button 'Apply' pressed"""
  411. PreferencesBaseDialog.OnApply(self, event)
  412. self.parent.GetModel().Update()
  413. self.parent.GetCanvas().Refresh()
  414. def OnSave(self, event):
  415. """Button 'Save' pressed"""
  416. PreferencesBaseDialog.OnSave(self, event)
  417. self.parent.GetModel().Update()
  418. self.parent.GetCanvas().Refresh()
  419. class PropertiesDialog(wx.Dialog):
  420. """Model properties dialog
  421. """
  422. def __init__(self, parent, id = wx.ID_ANY,
  423. title = _('Model properties'),
  424. size = (350, 400),
  425. style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
  426. wx.Dialog.__init__(self, parent, id, title, size = size,
  427. style = style)
  428. self.metaBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
  429. label=" %s " % _("Metadata"))
  430. self.cmdBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
  431. label=" %s " % _("Commands"))
  432. self.name = wx.TextCtrl(parent = self, id = wx.ID_ANY,
  433. size = (300, 25))
  434. self.desc = wx.TextCtrl(parent = self, id = wx.ID_ANY,
  435. style = wx.TE_MULTILINE,
  436. size = (300, 50))
  437. self.author = wx.TextCtrl(parent = self, id = wx.ID_ANY,
  438. size = (300, 25))
  439. # commands
  440. self.overwrite = wx.CheckBox(parent = self, id=wx.ID_ANY,
  441. label=_("Allow output files to overwrite existing files"))
  442. self.overwrite.SetValue(UserSettings.Get(group='cmd', key='overwrite', subkey='enabled'))
  443. # buttons
  444. self.btnOk = wx.Button(self, wx.ID_OK)
  445. self.btnCancel = wx.Button(self, wx.ID_CANCEL)
  446. self.btnOk.SetDefault()
  447. self.btnOk.SetToolTipString(_("Apply properties"))
  448. self.btnOk.SetDefault()
  449. self.btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
  450. self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
  451. self._layout()
  452. def _layout(self):
  453. metaSizer = wx.StaticBoxSizer(self.metaBox, wx.VERTICAL)
  454. gridSizer = wx.GridBagSizer(hgap = 3, vgap = 3)
  455. gridSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
  456. label = _("Name:")),
  457. flag = wx.ALIGN_LEFT |
  458. wx.ALIGN_CENTER_VERTICAL,
  459. pos = (0, 0))
  460. gridSizer.Add(item = self.name,
  461. flag = wx.ALIGN_LEFT |
  462. wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
  463. pos = (0, 1))
  464. gridSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
  465. label = _("Description:")),
  466. flag = wx.ALIGN_LEFT |
  467. wx.ALIGN_CENTER_VERTICAL,
  468. pos = (1, 0))
  469. gridSizer.Add(item = self.desc,
  470. flag = wx.ALIGN_LEFT |
  471. wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
  472. pos = (1, 1))
  473. gridSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
  474. label = _("Author(s):")),
  475. flag = wx.ALIGN_LEFT |
  476. wx.ALIGN_CENTER_VERTICAL,
  477. pos = (2, 0))
  478. gridSizer.Add(item = self.author,
  479. flag = wx.ALIGN_LEFT |
  480. wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
  481. pos = (2, 1))
  482. gridSizer.AddGrowableCol(1)
  483. gridSizer.AddGrowableRow(1)
  484. metaSizer.Add(item = gridSizer, proportion = 1, flag = wx.EXPAND)
  485. cmdSizer = wx.StaticBoxSizer(self.cmdBox, wx.VERTICAL)
  486. cmdSizer.Add(item = self.overwrite,
  487. flag = wx.EXPAND | wx.ALL, border = 3)
  488. btnStdSizer = wx.StdDialogButtonSizer()
  489. btnStdSizer.AddButton(self.btnCancel)
  490. btnStdSizer.AddButton(self.btnOk)
  491. btnStdSizer.Realize()
  492. mainSizer = wx.BoxSizer(wx.VERTICAL)
  493. mainSizer.Add(item=metaSizer, proportion=1,
  494. flag=wx.EXPAND | wx.ALL, border=5)
  495. mainSizer.Add(item=cmdSizer, proportion=0,
  496. flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
  497. mainSizer.Add(item=btnStdSizer, proportion=0,
  498. flag=wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border=5)
  499. self.SetSizer(mainSizer)
  500. mainSizer.Fit(self)
  501. def OnCloseWindow(self, event):
  502. self.Hide()
  503. def GetValues(self):
  504. """Get values"""
  505. return { 'name' : self.name.GetValue(),
  506. 'description' : self.desc.GetValue(),
  507. 'author' : self.author.GetValue(),
  508. 'overwrite' : self.overwrite.IsChecked() }
  509. def Init(self, prop):
  510. """Initialize dialog"""
  511. self.name.SetValue(prop['name'])
  512. self.desc.SetValue(prop['description'])
  513. self.author.SetValue(prop['author'])
  514. if 'overwrite' in prop:
  515. self.overwrite.SetValue(prop['overwrite'])