PageRenderTime 52ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/Companions/LibCompanions.py

https://bitbucket.org/cwt/boa-constructor
Python | 703 lines | 668 code | 16 blank | 19 comment | 6 complexity | dfe0bc4a8df56e76e596d748fe0242c2 MD5 | raw file
Possible License(s): GPL-2.0
  1. #-----------------------------------------------------------------------------
  2. # Name: LibCompanions.py
  3. # Purpose:
  4. #
  5. # Author: Riaan Booysen
  6. #
  7. # Created: 2003
  8. # RCS-ID: $Id$
  9. # Copyright: (c) 2003 - 2007
  10. # Licence: GPL
  11. #-----------------------------------------------------------------------------
  12. print 'importing Companions.LibCompanions'
  13. import wx
  14. from Utils import _
  15. import Constructors, ContainerCompanions, BasicCompanions
  16. from BaseCompanions import WindowDTC
  17. from BasicCompanions import StaticTextDTC, TextCtrlDTC, ComboBoxDTC
  18. from ContainerCompanions import PanelDTC
  19. from PropEdit import PropertyEditors, InspectorEditorControls
  20. import EventCollections
  21. from PropEdit import MaskedEditFmtCodeDlg, BitmapListEditorDlg
  22. class GenStaticTextDTC(StaticTextDTC):
  23. handledConstrParams = ('parent', 'ID')
  24. windowIdName = 'ID'
  25. def writeImports(self):
  26. return '\n'.join( (StaticTextDTC.writeImports(self), 'import wx.lib.stattext'))
  27. #-------------------------------------------------------------------------------
  28. ##class MaskConstrPropEdit(PropertyEditors.StrConstrPropEdit):
  29. ## def inspectorEdit(self):
  30. ## self.editorCtrl = InspectorEditorControls.TextCtrlButtonIEC(self, self.value)
  31. ## self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
  32. ##
  33. ## def edit(self, event):
  34. ## pass
  35. class FormatCodePropEdit(PropertyEditors.StrPropEdit):
  36. def inspectorEdit(self):
  37. self.editorCtrl = InspectorEditorControls.TextCtrlButtonIEC(self, self.value)
  38. self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
  39. def edit(self, event):
  40. dlg = MaskedEditFmtCodeDlg.MaskedEditFormatCodesDlg(self.parent, self.value)
  41. try:
  42. if dlg.ShowModal() != wx.ID_OK:
  43. return
  44. self.value = dlg.getFormatCode()
  45. self.editorCtrl.setValue(self.value)
  46. self.inspectorPost(False)
  47. finally:
  48. dlg.Destroy()
  49. class AutoFormatPropMixin:
  50. dependents = ['mask', 'datestyle', 'formatcodes',
  51. 'description', 'excludeChars', 'validRegex']
  52. def __init__(self):
  53. self.editors['Autoformat'] = PropertyEditors.StringEnumPropEdit
  54. from wx.lib.masked import maskededit
  55. autofmt = maskededit.masktags.keys()
  56. autofmt.sort()
  57. self.options['Autoformat'] = [s for s in ['']+autofmt]
  58. self.names['Autoformat'] = {}
  59. for opt in self.options['Autoformat']:
  60. self.names['Autoformat'][opt] = opt
  61. self.mutualDepProps += ['Autoformat'] + [s[0].upper()+s[1:]
  62. for s in self.dependents]
  63. def properties(self):
  64. props = {'Autoformat': ('CompnRoute', self.GetAutoformat,
  65. self.SetAutoformat)}
  66. return props
  67. def GetAutoformat(self, x):
  68. return self.control.GetAutoformat()
  69. def SetAutoformat(self, val):
  70. currVals = {}
  71. for dp in self.dependents:
  72. currVals[dp] = self.control.GetCtrlParameter(dp)
  73. self.control.SetAutoformat(val)
  74. # call delayed so that Inspector may update first
  75. wx.CallAfter(self.revertAutoFormatDeps, currVals)
  76. def revertAutoFormatDeps(self, currVals):
  77. # revert source for properties that were changed to default values
  78. for dp in self.dependents:
  79. newVal = self.control.GetCtrlParameter(dp)
  80. if newVal != currVals[dp]:
  81. prop = dp[0].upper()+dp[1:]
  82. self.propRevertToDefault(prop, 'Set'+prop)
  83. class MaskedDTCMixin:
  84. def __init__(self):
  85. BoolPE = PropertyEditors.BoolPropEdit
  86. StrEnumPE = PropertyEditors.StringEnumPropEdit
  87. BITPropEdit = PropertyEditors.BITPropEditor
  88. self.editors.update({'AutoCompleteKeycodes': BITPropEdit,
  89. 'UseFixedWidthFont': BoolPE,
  90. 'RetainFieldValidation': BoolPE,
  91. 'Datestyle': StrEnumPE,
  92. 'Choices': BITPropEdit,
  93. 'ChoiceRequired': BoolPE,
  94. 'CompareNoCase': BoolPE,
  95. 'EmptyInvalid': BoolPE,
  96. 'ValidRequired': BoolPE,
  97. 'Formatcodes': FormatCodePropEdit,
  98. })
  99. self.options['Datestyle'] = ['YMD','MDY','YDM','DYM','DMY','MYD']
  100. self.names['Datestyle'] = {}
  101. for opt in self.options['Datestyle']:
  102. self.names['Datestyle'][opt] = opt
  103. def hideDesignTime(self):
  104. return ['Demo', 'Fields', 'Autoformat', 'ValidFunc']
  105. class BaseMaskedTextCtrlDTC(TextCtrlDTC, MaskedDTCMixin):
  106. def __init__(self, name, designer, parent, ctrlClass):
  107. TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
  108. MaskedDTCMixin.__init__(self)
  109. def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
  110. dts = TextCtrlDTC.designTimeSource(self, position, size)
  111. dts['value'] = "''"
  112. return dts
  113. def hideDesignTime(self):
  114. return TextCtrlDTC.hideDesignTime(self) + MaskedDTCMixin.hideDesignTime(self)
  115. class MaskedTextCtrlDTC(BaseMaskedTextCtrlDTC, AutoFormatPropMixin):
  116. def __init__(self, name, designer, parent, ctrlClass):
  117. BaseMaskedTextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
  118. AutoFormatPropMixin.__init__(self)
  119. def properties(self):
  120. props = BaseMaskedTextCtrlDTC.properties(self)
  121. props.update(AutoFormatPropMixin.properties(self))
  122. return props
  123. def writeImports(self):
  124. return '\n'.join( (BaseMaskedTextCtrlDTC.writeImports(self), 'import wx.lib.masked.textctrl'))
  125. class IpAddrCtrlDTC(BaseMaskedTextCtrlDTC):
  126. def writeImports(self):
  127. return '\n'.join( (BaseMaskedTextCtrlDTC.writeImports(self), 'import wx.lib.masked.ipaddrctrl'))
  128. class MaskedComboBoxDTC(ComboBoxDTC, MaskedDTCMixin, AutoFormatPropMixin):
  129. def __init__(self, name, designer, parent, ctrlClass):
  130. ComboBoxDTC.__init__(self, name, designer, parent, ctrlClass)
  131. MaskedDTCMixin.__init__(self)
  132. AutoFormatPropMixin.__init__(self)
  133. def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
  134. dts = ComboBoxDTC.designTimeSource(self, position, size)
  135. dts['value'] = "''"
  136. return dts
  137. def properties(self):
  138. props = ComboBoxDTC.properties(self)
  139. props.update(AutoFormatPropMixin.properties(self))
  140. return props
  141. def hideDesignTime(self):
  142. return ComboBoxDTC.hideDesignTime(self) + \
  143. MaskedDTCMixin.hideDesignTime(self)
  144. ## ['Mark', 'EmptyInvalid']
  145. def writeImports(self):
  146. return '\n'.join( (ComboBoxDTC.writeImports(self), 'import wx.lib.masked.combobox'))
  147. class MaskedNumCtrlDTC(TextCtrlDTC, MaskedDTCMixin):
  148. def __init__(self, name, designer, parent, ctrlClass):
  149. TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
  150. MaskedDTCMixin.__init__(self)
  151. self.editors.update({'Min': PropertyEditors.BITPropEditor,
  152. 'Max': PropertyEditors.BITPropEditor,
  153. 'Bounds': PropertyEditors.BITPropEditor})
  154. self.mutualDepProps += ['Bounds', 'Min', 'Max']
  155. def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
  156. dts = TextCtrlDTC.designTimeSource(self, position, size)
  157. dts['value'] = '0'
  158. return dts
  159. def events(self):
  160. return TextCtrlDTC.events(self) + ['MaskedNumCtrlEvent']
  161. def writeImports(self):
  162. return '\n'.join( (TextCtrlDTC.writeImports(self), 'import wx.lib.masked.numctrl'))
  163. def hideDesignTime(self):
  164. return TextCtrlDTC.hideDesignTime(self) + \
  165. MaskedDTCMixin.hideDesignTime(self)
  166. ## ['Datestyle', 'AutoCompleteKeycodes', 'ExcludeChars',
  167. ## 'IncludeChars', 'Choices', 'ChoiceRequired', 'CompareNoCase',
  168. ## 'ValidRange']
  169. #-------------------------------------------------------------------------------
  170. class SpinButtonEnumConstrPropEdit(PropertyEditors.ObjEnumConstrPropEdit):
  171. def getObjects(self):
  172. designer = self.companion.designer#.controllerView
  173. windows = designer.getObjectsOfClass(wx.SpinButton)
  174. windowNames = windows.keys()
  175. windowNames.sort()
  176. res = ['None'] + windowNames
  177. if self.value != 'None':
  178. res.insert(1, self.value)
  179. return res
  180. def getDisplayValue(self):
  181. return `self.valueToIECValue()`
  182. def getCtrlValue(self):
  183. return self.companion.GetSpinButton()
  184. def setCtrlValue(self, oldValue, value):
  185. self.companion.SetSpinButton(value)
  186. class SpinButtonClassLinkPropEdit(PropertyEditors.ClassLinkPropEdit):
  187. linkClass = wx.SpinButton
  188. #EventCollections.EventCategories['TimeCtrlEvent'] = (EVT_TIMEUPDATE,)
  189. #EventCollections.commandCategories.append('TimeCtrlEvent')
  190. # XXX min, max & limited params not supported yet
  191. # XXX should be implemented as a wxDateTime property editor using
  192. # XXX this very time ctrl, a problem is how to handle None values.
  193. class TimeCtrlDTC(MaskedTextCtrlDTC):
  194. def __init__(self, name, designer, parent, ctrlClass):
  195. MaskedTextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
  196. BoolPE = PropertyEditors.BoolConstrPropEdit
  197. ColourPE = PropertyEditors.ColourConstrPropEdit
  198. self.editors.update({'Format24Hours': BoolPE,
  199. 'SpinButton': SpinButtonClassLinkPropEdit,
  200. 'OutOfBoundsColour': ColourPE,
  201. 'DisplaySeconds': BoolPE,
  202. 'UseFixedWidthFont': BoolPE,
  203. 'Format': PropertyEditors.StringEnumPropEdit})
  204. format = ['24HHMMSS', '24HHMM', 'HHMMSS', 'HHMM']
  205. self.options['Format'] = format
  206. self.names['Format'] = {}
  207. for name in format: self.names['Format'][name] = name
  208. self._spinbutton = None
  209. self.initPropsThruCompanion.extend(['SpinButton', 'BindSpinButton'])
  210. def constructor(self):
  211. constr = MaskedTextCtrlDTC.constructor(self)
  212. constr.update({'Format24Hours': 'fmt24hr',
  213. 'DisplaySeconds': 'display_seconds',
  214. 'OutOfBoundsColour': 'oob_color',
  215. 'UseFixedWidthFont': 'useFixedWidthFont',
  216. })
  217. return constr
  218. def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
  219. dts = MaskedTextCtrlDTC.designTimeSource(self, position, size)
  220. dts.update({'value': "'12:00:00 AM'",
  221. 'fmt24hr': 'False',
  222. 'display_seconds': 'True',
  223. 'oob_color': "wx.NamedColour('Yellow')",
  224. 'useFixedWidthFont': 'True',
  225. })
  226. return dts
  227. def properties(self):
  228. props = MaskedTextCtrlDTC.properties(self)
  229. if 'Autoformat' in props:
  230. del props['Autoformat']
  231. props['SpinButton'] = ('CompnRoute', self.GetSpinButton,
  232. self.BindSpinButton)
  233. ## props['Format24Hours'] = ('CompnRoute', self.GetFormat24Hours,
  234. ## self.SetFormat24Hours)
  235. ## props['DisplaySeconds'] = ('CompnRoute', self.GetDisplaySeconds,
  236. ## self.SetDisplaySeconds)
  237. return props
  238. def dependentProps(self):
  239. return MaskedTextCtrlDTC.dependentProps(self) + ['SpinButton', 'BindSpinButton']
  240. def events(self):
  241. return MaskedTextCtrlDTC.events(self) + ['TimeCtrlEvent']
  242. def writeImports(self):
  243. return '\n'.join( (MaskedTextCtrlDTC.writeImports(self), 'import wx.lib.masked.timectrl'))
  244. ## def hideDesignTime(self):
  245. ## return MaskedTextCtrlDTC.hideDesignTime(self) + ['Mask',
  246. ## 'Datestyle', 'AutoCompleteKeycodes', 'EmptyBackgroundColour',
  247. ## 'SignedForegroundColour', 'GroupChar', 'DecimalChar',
  248. ## 'ShiftDecimalChar', 'UseParensForNegatives', 'ExcludeChars',
  249. ## 'IncludeChars', 'Choices', 'ChoiceRequired', 'CompareNoCase',
  250. ## 'AutoSelect', 'ValidRegex', 'ValidRange']
  251. def GetSpinButton(self, x):
  252. return self._spinbutton
  253. def BindSpinButton(self, value):
  254. self._spinbutton = value
  255. if value is not None:
  256. spins = self.designer.getObjectsOfClass(wx.SpinButton)
  257. if value in spins:
  258. self.control.BindSpinButton(spins[value])
  259. ## def GetDisplaySeconds(self, x):
  260. ## return self.eval(self.textConstr.params['display_seconds'])
  261. ##
  262. ## def SetDisplaySeconds(self, value):
  263. ## self.textConstr.params['display_seconds'] = self.eval(value)
  264. #-------------------------------------------------------------------------------
  265. #EventCollections.EventCategories['IntCtrlEvent'] = (EVT_INT,)
  266. #EventCollections.commandCategories.append('IntCtrlEvent')
  267. class IntCtrlDTC(TextCtrlDTC):
  268. def __init__(self, name, designer, parent, ctrlClass):
  269. TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
  270. BoolPE = PropertyEditors.BoolConstrPropEdit
  271. ColourPE = PropertyEditors.ColourConstrPropEdit
  272. self.editors.update({'Min': PropertyEditors.BITPropEditor,
  273. 'Max': PropertyEditors.BITPropEditor,
  274. 'Limited': BoolPE,
  275. 'AllowNone': BoolPE,
  276. 'AllowLong': BoolPE,
  277. 'DefaultColour': ColourPE,
  278. 'OutOfBoundsColour': ColourPE})
  279. def constructor(self):
  280. constr = TextCtrlDTC.constructor(self)
  281. constr.update({'Min': 'min', 'Max': 'max', 'Limited': 'limited',
  282. 'AllowNone': 'allow_none', 'AllowLong': 'allow_long',
  283. 'DefaultColour': 'default_color', 'OutOfBoundsColour': 'oob_color'})
  284. return constr
  285. def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
  286. dts = TextCtrlDTC.designTimeSource(self, position, size)
  287. dts.update({'value': '0',
  288. 'min': 'None',
  289. 'max': 'None',
  290. 'limited': 'False',
  291. 'allow_none': 'False',
  292. 'allow_long': 'False',
  293. 'default_color': 'wx.BLACK',
  294. 'oob_color': 'wx.RED'})
  295. return dts
  296. ## def hideDesignTime(self):
  297. ## return TextCtrlDTC.hideDesignTime(self) + ['Bounds', 'InsertionPoint']
  298. def events(self):
  299. return TextCtrlDTC.events(self) + ['IntCtrlEvent']
  300. def writeImports(self):
  301. return '\n'.join( (TextCtrlDTC.writeImports(self), 'import wx.lib.intctrl'))
  302. #-------------------------------------------------------------------------------
  303. class AnalogClockDTC(WindowDTC):
  304. def __init__(self, name, designer, parent, ctrlClass):
  305. WindowDTC.__init__(self, name, designer, parent, ctrlClass)
  306. ## wx.lib.analogclock.SHOW_QUARTERS_TICKS,
  307. ## wx.lib.analogclock.SHOW_HOURS_TICKS,
  308. ## wx.lib.analogclock.SHOW_MINUTES_TICKS,
  309. ## wx.lib.analogclock.ROTATE_TICKS,
  310. ## wx.lib.analogclock.SHOW_HOURS_HAND,
  311. ## wx.lib.analogclock.SHOW_MINUTES_HAND,
  312. ## wx.lib.analogclock.SHOW_SECONDS_HAND,
  313. ## wx.lib.analogclock.SHOW_SHADOWS,
  314. ## wx.lib.analogclock.OVERLAP_TICKS,
  315. ## wx.lib.analogclock.DEFAULT_CLOCK_STYLE,
  316. ## wx.lib.analogclock.TICKS_NONE,
  317. ## wx.lib.analogclock.TICKS_SQUARE,
  318. ## wx.lib.analogclock.TICKS_CIRCLE,
  319. ## wx.lib.analogclock.TICKS_POLY,
  320. ## wx.lib.analogclock.TICKS_DECIMAL,
  321. ## wx.lib.analogclock.TICKS_ROMAN,
  322. ## wx.lib.analogclock.TICKS_BINARY,
  323. ## wx.lib.analogclock.TICKS_HEX,
  324. def hideDesignTime(self):
  325. return WindowDTC.hideDesignTime(self) + ['HandSize', 'HandBorderWidth',
  326. 'HandBorderColour', 'HandFillColour', 'TickSize', 'TickStyle',
  327. 'TickOffset', 'TickBorderWidth', 'TickBorderColour',
  328. 'TickFillColour', 'TickFont', 'ClockStyle']
  329. def writeImports(self):
  330. return '\n'.join( (WindowDTC.writeImports(self), 'import wx.lib.analogclock'))
  331. #-------------------------------------------------------------------------------
  332. class ScrolledPanelDTC(Constructors.WindowConstr,
  333. ContainerCompanions.ScrolledWindowDTC):
  334. """Currently you need to manually add the following call to the source
  335. after self._init_ctrls(parent).
  336. e.g.
  337. self.panel1.SetupScrolling(scroll_x=True, scroll_y=True, rate_x=20, rate_y=20)
  338. """
  339. def __init__(self, name, designer, parent, ctrlClass):
  340. ContainerCompanions.ScrolledWindowDTC.__init__(self, name, designer, parent, ctrlClass)
  341. def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
  342. return {'pos': position,
  343. 'size': self.getDefCtrlSize(),
  344. 'style': 'wx.TAB_TRAVERSAL',
  345. 'name': `self.name`}
  346. def writeImports(self):
  347. return '\n'.join( (ContainerCompanions.ScrolledWindowDTC.writeImports(self),
  348. 'import wx.lib.scrolledpanel'))
  349. #-------------------------------------------------------------------------------
  350. EventCollections.EventCategories['HyperLinkEvent'] = (
  351. 'wx.lib.hyperlink.EVT_HYPERLINK_LEFT',
  352. 'wx.lib.hyperlink.EVT_HYPERLINK_MIDDLE',
  353. 'wx.lib.hyperlink.EVT_HYPERLINK_RIGHT')
  354. #Link Visited LinkRollover
  355. class HyperLinkCtrlDTC(BasicCompanions.StaticTextDTC):
  356. def __init__(self, name, designer, parent, ctrlClass):
  357. BasicCompanions.StaticTextDTC.__init__(self, name, designer, parent, ctrlClass)
  358. self.editors.update({
  359. 'AutoBrowse': PropertyEditors.BoolPropEdit,
  360. 'Bold': PropertyEditors.BoolPropEdit,
  361. 'DoPopup': PropertyEditors.BoolPropEdit,
  362. 'EnableRollover': PropertyEditors.BoolPropEdit,
  363. 'OpenInSameWindow': PropertyEditors.BoolPropEdit,
  364. 'ReportErrors': PropertyEditors.BoolPropEdit,
  365. 'Visited': PropertyEditors.BoolPropEdit,
  366. })
  367. def constructor(self):
  368. return {'Position': 'pos', 'Size': 'size', 'Label': 'label',
  369. 'Style': 'style', 'Name': 'name', 'URL': 'URL'}
  370. def initDesignTimeControl(self):
  371. BasicCompanions.StaticTextDTC.initDesignTimeControl(self)
  372. self.control.AutoBrowse(False)
  373. def writeImports(self):
  374. return '\n'.join( (BasicCompanions.StaticTextDTC.writeImports(self),
  375. 'import wx.lib.hyperlink'))
  376. def events(self):
  377. return BasicCompanions.StaticTextDTC.events(self) + ['HyperLinkEvent']
  378. def properties(self):
  379. return {
  380. 'AutoBrowse': ('CompnRoute', self.GetAutoBrowse, self.AutoBrowse),
  381. 'Bold': ('CompnRoute', self.GetBold, self.SetBold),
  382. }
  383. def GetAutoBrowse(self, x):
  384. for prop in self.textPropList:
  385. if prop.prop_setter == 'AutoBrowse':
  386. return prop.params[0].lower() == 'true'
  387. return True
  388. def AutoBrowse(self, value):
  389. pass
  390. def GetBold(self, x):
  391. return self.control.GetBold()
  392. def SetBold(self, value):
  393. self.control.SetBold(value)
  394. self.control.UpdateLink()
  395. #-------------------------------------------------------------------------------
  396. class FileBrowseButtonDTC(PanelDTC):
  397. def __init__(self, name, designer, parent, ctrlClass):
  398. PanelDTC.__init__(self, name, designer, parent, ctrlClass)
  399. StrPropEdit = PropertyEditors.StrConstrPropEdit
  400. self.editors.update({
  401. 'LabelText': StrPropEdit, 'ButtonText': StrPropEdit,
  402. 'ToolTip': StrPropEdit, 'DialogTitle': StrPropEdit,
  403. 'StartDirectory': StrPropEdit, 'InitialValue': StrPropEdit,
  404. 'FileMask': StrPropEdit,
  405. })
  406. def designTimeSource(self, position='wx.DefaultPosition', size='wx.DefaultSize'):
  407. return {'pos': position,
  408. 'size': 'wx.Size(296, 48)',
  409. 'style': 'wx.TAB_TRAVERSAL',
  410. 'labelText': `'File Entry:'`,
  411. 'buttonText': `'Browse'`,
  412. 'toolTip': `'Type filename or click browse to choose file'`,
  413. 'dialogTitle': `'Choose a file'`,
  414. 'startDirectory': `'.'`,
  415. 'initialValue': `''`,
  416. 'fileMask': `'*.*'`,
  417. }
  418. def constructor(self):
  419. return {'Position': 'pos', 'Size': 'size', 'Style': 'style',
  420. 'LabelText': 'labelText', 'ButtonText': 'buttonText',
  421. 'ToolTip': 'toolTip', 'DialogTitle': 'dialogTitle',
  422. 'StartDirectory': 'startDirectory',
  423. 'InitialValue': 'initialValue', 'FileMask': 'fileMask'}
  424. def writeImports(self):
  425. return '\n'.join( (PanelDTC.writeImports(self),
  426. 'import wx.lib.filebrowsebutton'))
  427. class FileBrowseButtonWithHistoryDTC(FileBrowseButtonDTC):
  428. pass
  429. class DirBrowseButtonDTC(FileBrowseButtonDTC):
  430. def designTimeSource(self, position='wx.DefaultPosition', size='wx.DefaultSize'):
  431. return {'pos': position,
  432. 'size': 'wx.Size(296, 48)',
  433. 'style': 'wx.TAB_TRAVERSAL',
  434. 'labelText': `'Select a directory:'`,
  435. 'buttonText': `'Browse'`,
  436. 'toolTip': `'Type directory name or browse to select'`,
  437. 'dialogTitle': `''`,
  438. 'startDirectory': `'.'`,
  439. 'newDirectory': 'False',
  440. }
  441. def constructor(self):
  442. return {'Position': 'pos', 'Size': 'size', 'Style': 'style',
  443. 'LabelText': 'labelText', 'ButtonText': 'buttonText',
  444. 'ToolTip': 'toolTip', 'DialogTitle': 'dialogTitle',
  445. 'StartDirectory': 'startDirectory',
  446. 'NewDirectory': 'newDirectory'}
  447. class MultiSplitterWindowDTC(PanelDTC):
  448. def __init__(self, name, designer, parent, ctrlClass):
  449. PanelDTC.__init__(self, name, designer, parent, ctrlClass)
  450. class BitmapsConstrPropEdit(PropertyEditors.ConstrPropEdit):
  451. def getValue(self):
  452. if self.editorCtrl:
  453. self.value = self.editorCtrl.getValue()
  454. else:
  455. self.value = self.getCtrlValue()
  456. return self.value
  457. def inspectorEdit(self):
  458. self.editorCtrl = InspectorEditorControls.ButtonIEC(self, self.value)
  459. self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
  460. def edit(self, event):
  461. dlg = BitmapListEditorDlg.BitmapListEditorDlg(self.parent, self.value, self.companion)
  462. try:
  463. if dlg.ShowModal() == wx.ID_OK:
  464. self.value = dlg.getBitmapsSource()
  465. self.editorCtrl.setValue(self.value)
  466. self.inspectorPost(False)
  467. finally:
  468. dlg.Destroy()
  469. class ThrobberDTC(PanelDTC):
  470. def __init__(self, name, designer, parent, ctrlClass):
  471. PanelDTC.__init__(self, name, designer, parent, ctrlClass)
  472. self.editors.update({'Bitmaps': BitmapsConstrPropEdit})
  473. def designTimeSource(self, position='wx.DefaultPosition', size='wx.DefaultSize'):
  474. return {'pos': position,
  475. 'size': self.getDefCtrlSize(),
  476. 'style': '0',
  477. 'name': `self.name`,
  478. 'bitmap': '[wx.NullBitmap]',
  479. 'frameDelay': '0.1',
  480. 'label': 'None',
  481. 'overlay': 'None',
  482. 'reverse': '0',
  483. 'rest': '0',
  484. 'current': '0',
  485. 'direction': '1'}
  486. def constructor(self):
  487. return {'Position': 'pos', 'Size': 'size', 'Style': 'style', 'Name': 'name',
  488. 'Bitmaps': 'bitmap', 'FrameDelay': 'frameDelay', 'Label': 'label',
  489. 'Overlay': 'overlay', 'Reverse': 'reverse', 'Rest': 'rest',
  490. 'Current': 'current', 'Direction': 'direction'}
  491. def writeImports(self):
  492. return '\n'.join( (PanelDTC.writeImports(self),
  493. 'import wx.lib.throbber'))
  494. class TickerDTC(WindowDTC):
  495. def __init__(self, name, designer, parent, ctrlClass):
  496. WindowDTC.__init__(self, name, designer, parent, ctrlClass)
  497. self.editors['Start'] = PropertyEditors.BoolConstrPropEdit
  498. def writeImports(self):
  499. return '\n'.join((WindowDTC.writeImports(self), 'import wx.lib.ticker'))
  500. def constructor(self):
  501. return {'Position': 'pos', 'Size': 'size', 'Style': 'style',
  502. 'Name': 'name', 'Text': 'text', 'Start': 'start',
  503. 'Direction': 'direction'}
  504. def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
  505. return {'text': `self.name`,
  506. 'start': 'False',
  507. 'direction': `'rtl'`,
  508. 'pos': position,
  509. 'size': size,
  510. 'style': '0',
  511. 'name': `self.name`}
  512. #-------------------------------------------------------------------------------
  513. import wx.lib.stattext
  514. import wx.lib.masked.textctrl
  515. import wx.lib.masked.ipaddrctrl
  516. import wx.lib.masked.combobox
  517. import wx.lib.masked.numctrl
  518. import wx.lib.masked.timectrl
  519. import wx.lib.intctrl
  520. import wx.lib.scrolledpanel
  521. import wx.lib.hyperlink
  522. import Plugins
  523. Plugins.registerPalettePage('Library', _('Library'))
  524. Plugins.registerComponents('Library',
  525. (wx.lib.stattext.GenStaticText, 'wx.lib.stattext.GenStaticText', GenStaticTextDTC),
  526. (wx.lib.masked.textctrl.TextCtrl, 'wx.lib.masked.textctrl.TextCtrl', MaskedTextCtrlDTC),
  527. (wx.lib.masked.ipaddrctrl.IpAddrCtrl, 'wx.lib.masked.ipaddrctrl.IpAddrCtrl', IpAddrCtrlDTC),
  528. (wx.lib.masked.combobox.ComboBox, 'wx.lib.masked.combobox.ComboBox', MaskedComboBoxDTC),
  529. (wx.lib.masked.numctrl.NumCtrl, 'wx.lib.masked.numctrl.NumCtrl', MaskedNumCtrlDTC),
  530. (wx.lib.masked.timectrl.TimeCtrl, 'wx.lib.masked.timectrl.TimeCtrl', TimeCtrlDTC),
  531. (wx.lib.intctrl.IntCtrl, 'wx.lib.intctrl.IntCtrl', IntCtrlDTC),
  532. (wx.lib.scrolledpanel.ScrolledPanel, 'wx.lib.scrolledpanel.ScrolledPanel', ScrolledPanelDTC),
  533. (wx.lib.hyperlink.HyperLinkCtrl, 'wx.lib.hyperlink.HyperLinkCtrl', HyperLinkCtrlDTC),
  534. )
  535. try:
  536. import wx.lib.splitter
  537. Plugins.registerComponent('Library', wx.lib.splitter.MultiSplitterWindow, 'wx.lib.splitter.MultiSplitterWindow', MultiSplitterWindowDTC)
  538. except ImportError: pass
  539. try:
  540. import wx.lib.analogclock
  541. Plugins.registerComponent('Library', wx.lib.analogclock.AnalogClock, 'wx.lib.analogclock.AnalogClock', AnalogClockDTC)
  542. except (ImportError, AttributeError): pass
  543. try:
  544. import wx.lib.filebrowsebutton
  545. Plugins.registerComponents('Library',
  546. (wx.lib.filebrowsebutton.FileBrowseButton, 'wx.lib.filebrowsebutton.FileBrowseButton', FileBrowseButtonDTC),
  547. (wx.lib.filebrowsebutton.FileBrowseButtonWithHistory, 'wx.lib.filebrowsebutton.FileBrowseButtonWithHistory', FileBrowseButtonWithHistoryDTC),
  548. (wx.lib.filebrowsebutton.DirBrowseButton, 'wx.lib.filebrowsebutton.DirBrowseButton', DirBrowseButtonDTC))
  549. except ImportError: pass
  550. try:
  551. import wx.lib.throbber
  552. Plugins.registerComponent('Library', wx.lib.throbber.Throbber, 'wx.lib.throbber.Throbber', ThrobberDTC)
  553. except ImportError: pass
  554. try:
  555. import wx.lib.ticker
  556. Plugins.registerComponent('Library', wx.lib.ticker.Ticker, 'wx.lib.ticker.Ticker', TickerDTC)
  557. except ImportError: pass
  558. EventCollections.EventCategories['MaskedNumCtrlEvent'] = ('wx.lib.masked.numctrl.EVT_NUM',)
  559. EventCollections.commandCategories.append('MaskedNumCtrlEvent')
  560. EventCollections.EventCategories['TimeCtrlEvent'] = ('wx.lib.masked.timectrl.EVT_TIMEUPDATE',)
  561. EventCollections.commandCategories.append('TimeCtrlEvent')
  562. EventCollections.EventCategories['IntCtrlEvent'] = ('wx.lib.intctrl.EVT_INT',)
  563. EventCollections.commandCategories.append('IntCtrlEvent')