wrap.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. """
  2. @package gui_core.wrap
  3. @brief Core wrapped wxpython widgets
  4. Classes:
  5. - wrap::GSpinCtrl
  6. (C) 2016 by the GRASS Development Team
  7. This program is free software under the GNU General Public License
  8. (>=v2). Read the file COPYING that comes with GRASS for details.
  9. @author Anna Petrasova <kratochanna gmail.com>
  10. """
  11. import sys
  12. import wx
  13. import wx.lib.agw.floatspin as fs
  14. import wx.lib.colourselect as csel
  15. import wx.lib.filebrowsebutton as filebrowse
  16. import wx.lib.scrolledpanel as scrolled
  17. from wx.lib import expando
  18. from wx.lib import buttons
  19. try:
  20. import wx.lib.agw.customtreectrl as CT
  21. except ImportError:
  22. import wx.lib.customtreectrl as CT
  23. from core.globalvar import CheckWxVersion, gtk3, wxPythonPhoenix
  24. if wxPythonPhoenix:
  25. import wx.adv
  26. from wx.adv import OwnerDrawnComboBox as OwnerDrawnComboBox_
  27. from wx.adv import ODCB_PAINTING_CONTROL, ODCB_PAINTING_SELECTED
  28. from wx.adv import BitmapComboBox as BitmapComboBox_
  29. from wx.adv import HyperlinkCtrl as HyperlinkCtrl_
  30. from wx.adv import HL_ALIGN_LEFT, HL_CONTEXTMENU
  31. ComboPopup = wx.ComboPopup
  32. wxComboCtrl = wx.ComboCtrl
  33. else:
  34. import wx.combo
  35. from wx.combo import OwnerDrawnComboBox as OwnerDrawnComboBox_
  36. from wx.combo import ODCB_PAINTING_CONTROL, ODCB_PAINTING_SELECTED
  37. from wx.combo import BitmapComboBox as BitmapComboBox_
  38. from wx import HyperlinkCtrl as HyperlinkCtrl_
  39. from wx import HL_ALIGN_LEFT, HL_CONTEXTMENU
  40. ComboPopup = wx.combo.ComboPopup
  41. wxComboCtrl = wx.combo.ComboCtrl
  42. if wxPythonPhoenix and CheckWxVersion([4, 0, 3, 0]):
  43. from wx import NewIdRef as NewId
  44. else:
  45. from wx import NewId
  46. def BitmapFromImage(image, depth=-1):
  47. if wxPythonPhoenix:
  48. return wx.Bitmap(img=image, depth=depth)
  49. else:
  50. return wx.BitmapFromImage(image, depth=depth)
  51. def ImageFromBitmap(bitmap):
  52. if wxPythonPhoenix:
  53. return bitmap.ConvertToImage()
  54. else:
  55. return wx.ImageFromBitmap(bitmap)
  56. def EmptyBitmap(width, height, depth=-1):
  57. if wxPythonPhoenix:
  58. return wx.Bitmap(width=width, height=height, depth=depth)
  59. else:
  60. return wx.EmptyBitmap(width=width, height=height, depth=depth)
  61. def EmptyImage(width, height, clear=True):
  62. if wxPythonPhoenix:
  63. return wx.Image(width=width, height=height, clear=clear)
  64. else:
  65. return wx.EmptyImage(width=width, height=height, clear=clear)
  66. def StockCursor(cursorId):
  67. if wxPythonPhoenix:
  68. return wx.Cursor(cursorId=cursorId)
  69. else:
  70. return wx.StockCursor(cursorId)
  71. class Window(wx.Window):
  72. """Wrapper around wx.Window to have more control
  73. over the widget on different platforms/wxpython versions"""
  74. def __init__(self, *args, **kwargs):
  75. wx.Window.__init__(self, *args, **kwargs)
  76. def SetToolTip(self, tip):
  77. if wxPythonPhoenix:
  78. if tip is None:
  79. wx.Window.UnsetToolTip(self)
  80. else:
  81. wx.Window.SetToolTip(self, tipString=tip)
  82. else:
  83. if tip is None:
  84. wx.Window.SetToolTip(self, tip)
  85. else:
  86. wx.Window.SetToolTipString(self, tip)
  87. class Panel(wx.Panel):
  88. """Wrapper around wx.Panel to have more control
  89. over the widget on different platforms/wxpython versions"""
  90. def __init__(self, *args, **kwargs):
  91. wx.Panel.__init__(self, *args, **kwargs)
  92. def SetToolTip(self, tip):
  93. if wxPythonPhoenix:
  94. wx.Panel.SetToolTip(self, tipString=tip)
  95. else:
  96. wx.Panel.SetToolTipString(self, tip)
  97. class SpinCtrl(wx.SpinCtrl):
  98. """Wrapper around wx.SpinCtrl to have more control
  99. over the widget on different platforms"""
  100. gtk3MinSize = 130
  101. def __init__(self, *args, **kwargs):
  102. if gtk3:
  103. if 'size' in kwargs:
  104. kwargs['size'] = wx.Size(max(self.gtk3MinSize, kwargs['size'][0]), kwargs['size'][1])
  105. else:
  106. kwargs['size'] = wx.Size(self.gtk3MinSize, -1)
  107. wx.SpinCtrl.__init__(self, *args, **kwargs)
  108. def SetToolTip(self, tip):
  109. if wxPythonPhoenix:
  110. wx.SpinCtrl.SetToolTip(self, tipString=tip)
  111. else:
  112. wx.SpinCtrl.SetToolTipString(self, tip)
  113. class FloatSpin(fs.FloatSpin):
  114. """Wrapper around fs.FloatSpin to have more control
  115. over the widget on different platforms"""
  116. gtk3MinSize = 130
  117. def __init__(self, *args, **kwargs):
  118. if gtk3:
  119. if 'size' in kwargs:
  120. kwargs['size'] = wx.Size(max(self.gtk3MinSize, kwargs['size'][0]), kwargs['size'][1])
  121. else:
  122. kwargs['size'] = wx.Size(self.gtk3MinSize, -1)
  123. fs.FloatSpin.__init__(self, *args, **kwargs)
  124. def SetToolTip(self, tip):
  125. if wxPythonPhoenix:
  126. fs.FloatSpin.SetToolTip(self, tipString=tip)
  127. else:
  128. fs.FloatSpin.SetToolTipString(self, tip)
  129. class Button(wx.Button):
  130. """Wrapper around wx.Button to have more control
  131. over the widget on different platforms/wxpython versions"""
  132. def __init__(self, *args, **kwargs):
  133. wx.Button.__init__(self, *args, **kwargs)
  134. def SetToolTip(self, tip):
  135. if wxPythonPhoenix:
  136. wx.Button.SetToolTip(self, tipString=tip)
  137. else:
  138. wx.Button.SetToolTipString(self, tip)
  139. class ClearButton(Button):
  140. """Wrapper around a Button with stock id wx.ID_CLEAR,
  141. to disable default key binding on certain platforms"""
  142. def __init__(self, *args, **kwargs):
  143. Button.__init__(self, *args, **kwargs)
  144. self.SetId(wx.ID_CLEAR)
  145. if sys.platform == "darwin":
  146. self.SetLabel(_("Clear"))
  147. else:
  148. self.SetLabel(_("&Clear"))
  149. class CancelButton(Button):
  150. """Wrapper around a Button with stock id wx.ID_CANCEL, to disable
  151. default key binding on certain platforms/wxpython versions"""
  152. def __init__(self, *args, **kwargs):
  153. Button.__init__(self, *args, **kwargs)
  154. self.SetId(wx.ID_CANCEL)
  155. if sys.platform == "darwin" and not CheckWxVersion([4, 1, 0]):
  156. self.SetLabel(_("Cancel"))
  157. else:
  158. self.SetLabel(_("&Cancel"))
  159. class CloseButton(Button):
  160. """Wrapper around a Close labeled Button with stock id wx.ID_CANCEL
  161. to disable default key binding on certain platforms/wxpython versions"""
  162. def __init__(self, *args, **kwargs):
  163. Button.__init__(self, *args, **kwargs)
  164. self.SetId(wx.ID_CANCEL)
  165. if sys.platform == "darwin" and not CheckWxVersion([4, 1, 0]):
  166. self.SetLabel(_("Close"))
  167. else:
  168. self.SetLabel(_("&Close"))
  169. class ApplyButton(Button):
  170. """Wrapper around a Button with stock id wx.ID_APPLY,
  171. to disable default key binding on certain platforms"""
  172. def __init__(self, *args, **kwargs):
  173. Button.__init__(self, *args, **kwargs)
  174. self.SetId(wx.ID_APPLY)
  175. if sys.platform == "darwin":
  176. self.SetLabel(_("Apply"))
  177. else:
  178. self.SetLabel(_("&Apply"))
  179. class RadioButton(wx.RadioButton):
  180. """Wrapper around wx.RadioButton to have more control
  181. over the widget on different platforms/wxpython versions"""
  182. def __init__(self, *args, **kwargs):
  183. wx.RadioButton.__init__(self, *args, **kwargs)
  184. def SetToolTip(self, tip):
  185. if wxPythonPhoenix:
  186. wx.RadioButton.SetToolTip(self, tipString=tip)
  187. else:
  188. wx.RadioButton.SetToolTipString(self, tip)
  189. class BitmapButton(wx.BitmapButton):
  190. """Wrapper around wx.BitmapButton to have more control
  191. over the widget on different platforms/wxpython versions"""
  192. def __init__(self, *args, **kwargs):
  193. wx.BitmapButton.__init__(self, *args, **kwargs)
  194. def SetToolTip(self, tip):
  195. if wxPythonPhoenix:
  196. wx.BitmapButton.SetToolTip(self, tipString=tip)
  197. else:
  198. wx.BitmapButton.SetToolTipString(self, tip)
  199. class GenBitmapButton(buttons.GenBitmapButton):
  200. """Wrapper around GenBitmapButton to have more control
  201. over the widget on different platforms/wxpython versions"""
  202. def __init__(self, *args, **kwargs):
  203. buttons.GenBitmapButton.__init__(self, *args, **kwargs)
  204. def SetToolTip(self, tip):
  205. if wxPythonPhoenix:
  206. buttons.GenBitmapButton.SetToolTip(self, tipString=tip)
  207. else:
  208. buttons.GenBitmapButton.SetToolTipString(self, tip)
  209. class ToggleButton(wx.ToggleButton):
  210. """Wrapper around wx.ToggleButton to have more control
  211. over the widget on different platforms/wxpython versions"""
  212. def __init__(self, *args, **kwargs):
  213. wx.ToggleButton.__init__(self, *args, **kwargs)
  214. def SetToolTip(self, tip):
  215. if wxPythonPhoenix:
  216. wx.ToggleButton.SetToolTip(self, tipString=tip)
  217. else:
  218. wx.ToggleButton.SetToolTipString(self, tip)
  219. class StaticText(wx.StaticText):
  220. """Wrapper around wx.StaticText to have more control
  221. over the widget on different platforms/wxpython versions"""
  222. def __init__(self, *args, **kwargs):
  223. wx.StaticText.__init__(self, *args, **kwargs)
  224. def SetToolTip(self, tip):
  225. if wxPythonPhoenix:
  226. wx.StaticText.SetToolTip(self, tip)
  227. else:
  228. wx.StaticText.SetToolTipString(self, tip)
  229. class StaticBox(wx.StaticBox):
  230. """Wrapper around wx.StaticBox to have more control
  231. over the widget on different platforms/wxpython versions"""
  232. def __init__(self, *args, **kwargs):
  233. wx.StaticBox.__init__(self, *args, **kwargs)
  234. def SetToolTip(self, tip):
  235. if wxPythonPhoenix:
  236. wx.StaticBox.SetToolTip(self, tipString=tip)
  237. else:
  238. wx.StaticBox.SetToolTipString(self, tip)
  239. class CheckListBox(wx.CheckListBox):
  240. """Wrapper around wx.CheckListBox to have more control
  241. over the widget on different platforms/wxpython versions"""
  242. def __init__(self, *args, **kwargs):
  243. wx.CheckListBox.__init__(self, *args, **kwargs)
  244. def SetToolTip(self, tip):
  245. if wxPythonPhoenix:
  246. wx.CheckListBox.SetToolTip(self, tipString=tip)
  247. else:
  248. wx.CheckListBox.SetToolTipString(self, tip)
  249. class TextCtrl(wx.TextCtrl):
  250. """Wrapper around wx.TextCtrl to have more control
  251. over the widget on different platforms/wxpython versions"""
  252. def __init__(self, *args, **kwargs):
  253. wx.TextCtrl.__init__(self, *args, **kwargs)
  254. def SetToolTip(self, tip):
  255. if wxPythonPhoenix:
  256. wx.TextCtrl.SetToolTip(self, tipString=tip)
  257. else:
  258. wx.TextCtrl.SetToolTipString(self, tip)
  259. class SearchCtrl(wx.SearchCtrl):
  260. """Wrapper around wx.SearchCtrl to have more control
  261. over the widget on different platforms/wxpython versions"""
  262. def __init__(self, *args, **kwargs):
  263. wx.SearchCtrl.__init__(self, *args, **kwargs)
  264. def SetToolTip(self, tip):
  265. if wxPythonPhoenix:
  266. wx.SearchCtrl.SetToolTip(self, tipString=tip)
  267. else:
  268. wx.SearchCtrl.SetToolTipString(self, tip)
  269. class ListCtrl(wx.ListCtrl):
  270. """Wrapper around wx.ListCtrl to have more control
  271. over the widget on different platforms/wxpython versions"""
  272. def __init__(self, *args, **kwargs):
  273. wx.ListCtrl.__init__(self, *args, **kwargs)
  274. def InsertItem(self, index, label, imageIndex=-1):
  275. if wxPythonPhoenix:
  276. return wx.ListCtrl.InsertItem(self, index=index, label=label, imageIndex=imageIndex)
  277. else:
  278. return wx.ListCtrl.InsertStringItem(self, index=index, label=label, imageIndex=imageIndex)
  279. def SetItem(self, index, column, label, imageId=-1):
  280. if wxPythonPhoenix:
  281. return wx.ListCtrl.SetItem(self, index=index, column=column, label=label, imageId=imageId)
  282. else:
  283. return wx.ListCtrl.SetStringItem(self, index=index, col=column, label=label, imageId=imageId)
  284. def CheckItem(self, item, check=True):
  285. """Uses either deprecated listmix.CheckListCtrlMixin
  286. or new checkbox implementation in wx.ListCtrl since 4.1.0"""
  287. if hasattr(self, 'HasCheckBoxes'):
  288. wx.ListCtrl.CheckItem(self, item, check)
  289. else:
  290. super(ListCtrl, self).CheckItem(item, check)
  291. def IsItemChecked(self, item):
  292. if hasattr(self, 'HasCheckBoxes'):
  293. return wx.ListCtrl.IsItemChecked(self, item)
  294. else:
  295. return super(ListCtrl, self).IsChecked(item)
  296. if CheckWxVersion([4, 1, 0]):
  297. class CheckListCtrlMixin():
  298. """This class pretends to be deprecated CheckListCtrlMixin mixin and
  299. only enables checkboxes in new versions of ListCtrl"""
  300. def __init__(self):
  301. self.EnableCheckBoxes(True)
  302. self.AssignImageList(wx.ImageList(16, 16), wx.IMAGE_LIST_SMALL)
  303. else:
  304. import wx.lib.mixins.listctrl as listmix
  305. class CheckListCtrlMixin(listmix.CheckListCtrlMixin):
  306. """Wrapper for deprecated mixin"""
  307. def __init__(self):
  308. listmix.CheckListCtrlMixin.__init__(self)
  309. class TreeCtrl(wx.TreeCtrl):
  310. """Wrapper around wx.TreeCtrl to have more control
  311. over the widget on different platforms/wxpython versions"""
  312. def __init__(self, *args, **kwargs):
  313. wx.TreeCtrl.__init__(self, *args, **kwargs)
  314. def AppendItem(self, parent, text, image=-1, selImage=-1, data=None):
  315. if wxPythonPhoenix:
  316. return wx.TreeCtrl.AppendItem(self, parent, text, image, selImage, data)
  317. else:
  318. return wx.TreeCtrl.AppendItem(self, parent, text, image, selImage, wx.TreeItemData(data))
  319. def GetItemData(self, item):
  320. if wxPythonPhoenix:
  321. return wx.TreeCtrl.GetItemData(self, item)
  322. else:
  323. return wx.TreeCtrl.GetPyData(self, item)
  324. class CustomTreeCtrl(CT.CustomTreeCtrl):
  325. """Wrapper around wx.lib.agw.customtreectrl to have more control
  326. over the widget on different platforms/wxpython versions"""
  327. def __init__(self, *args, **kwargs):
  328. CT.CustomTreeCtrl.__init__(self, *args, **kwargs)
  329. def SetToolTip(self, tip):
  330. if wxPythonPhoenix:
  331. CT.CustomTreeCtrl.SetToolTip(self, tipString=tip)
  332. else:
  333. CT.CustomTreeCtrl.SetToolTipString(self, tip)
  334. class ToolBar(wx.ToolBar):
  335. """Wrapper around wx.ToolBar to have more control
  336. over the widget on different platforms/wxpython versions"""
  337. def __init__(self, *args, **kwargs):
  338. wx.ToolBar.__init__(self, *args, **kwargs)
  339. def AddLabelTool(self, toolId, label, bitmap, bmpDisabled=wx.NullBitmap, kind=0,
  340. shortHelpString='', longHelpString='', clientData=None):
  341. if wxPythonPhoenix:
  342. return wx.ToolBar.AddTool(self, toolId=toolId, label=label, bitmap=bitmap, bmpDisabled=bmpDisabled,
  343. kind=kind, shortHelp=shortHelpString, longHelp=longHelpString,
  344. clientData=clientData)
  345. else:
  346. return wx.ToolBar.AddLabelTool(self, toolId, label, bitmap, bmpDisabled, kind,
  347. shortHelpString, longHelpString, clientData)
  348. def InsertLabelTool(self, pos, toolId, label, bitmap, bmpDisabled=wx.NullBitmap, kind=0,
  349. shortHelpString='', longHelpString='', clientData=None):
  350. if wxPythonPhoenix:
  351. return wx.ToolBar.InsertTool(self, pos, toolId=toolId, label=label, bitmap=bitmap, bmpDisabled=bmpDisabled,
  352. kind=kind, shortHelp=shortHelpString, longHelp=longHelpString,
  353. clientData=clientData)
  354. else:
  355. return wx.ToolBar.InsertLabelTool(self, pos, toolId, label, bitmap, bmpDisabled, kind,
  356. shortHelpString, longHelpString, clientData)
  357. class Menu(wx.Menu):
  358. """Wrapper around wx.Menu to have more control
  359. over the widget on different platforms/wxpython versions"""
  360. def __init__(self, *args, **kwargs):
  361. wx.Menu.__init__(self, *args, **kwargs)
  362. def AppendItem(self, menuItem):
  363. if wxPythonPhoenix:
  364. wx.Menu.Append(self, menuItem=menuItem)
  365. else:
  366. wx.Menu.AppendItem(self, menuItem)
  367. def AppendMenu(self, id, text, submenu, help=""):
  368. if wxPythonPhoenix:
  369. wx.Menu.Append(self, id=id, item=text, subMenu=submenu, helpString=help)
  370. else:
  371. wx.Menu.AppendMenu(self, id=id, text=text, submenu=submenu, help=help)
  372. class DragImage(wx.GenericDragImage if wxPythonPhoenix else wx.DragImage):
  373. """Wrapper around wx.DragImage to have more control
  374. over the widget on different platforms/wxpython versions"""
  375. def __init__(self, *args, **kwargs):
  376. super(DragImage, self).__init__(*args, **kwargs)
  377. class PseudoDC(wx.adv.PseudoDC if wxPythonPhoenix else wx.PseudoDC):
  378. """Wrapper around wx.PseudoDC to have more control
  379. over the widget on different platforms/wxpython versions"""
  380. def __init__(self, *args, **kwargs):
  381. super(PseudoDC, self).__init__(*args, **kwargs)
  382. def DrawLinePoint(self, pt1, pt2):
  383. if wxPythonPhoenix:
  384. super(PseudoDC, self).DrawLine(pt1, pt2)
  385. else:
  386. super(PseudoDC, self).DrawLinePoint(pt1, pt2)
  387. def DrawRectangleRect(self, rect):
  388. if wxPythonPhoenix:
  389. super(PseudoDC, self).DrawRectangle(rect=rect)
  390. else:
  391. super(PseudoDC, self).DrawRectangleRect(rect)
  392. def BeginDrawing(self):
  393. if not wxPythonPhoenix:
  394. super(PseudoDC, self).BeginDrawing()
  395. def EndDrawing(self):
  396. if not wxPythonPhoenix:
  397. super(PseudoDC, self).EndDrawing()
  398. class ClientDC(wx.ClientDC):
  399. """Wrapper around wx.ClientDC to have more control
  400. over the widget on different platforms/wxpython versions"""
  401. def __init__(self, *args, **kwargs):
  402. super(ClientDC, self).__init__(*args, **kwargs)
  403. def GetFullMultiLineTextExtent(self, string, font=None):
  404. if wxPythonPhoenix:
  405. return super(ClientDC, self).GetFullMultiLineTextExtent(string, font)
  406. else:
  407. return super(ClientDC, self).GetMultiLineTextExtent(string, font)
  408. class Rect(wx.Rect):
  409. """Wrapper around wx.Rect to have more control
  410. over the widget on different platforms/wxpython versions"""
  411. def __init__(self, *args, **kwargs):
  412. wx.Rect.__init__(self, *args, **kwargs)
  413. def ContainsXY(self, x, y):
  414. if wxPythonPhoenix:
  415. return wx.Rect.Contains(self, x=x, y=y)
  416. else:
  417. return wx.Rect.ContainsXY(self, x, y)
  418. def ContainsRect(self, rect):
  419. if wxPythonPhoenix:
  420. return wx.Rect.Contains(self, rect=rect)
  421. else:
  422. return wx.Rect.ContainsRect(self, rect)
  423. def OffsetXY(self, dx, dy):
  424. if wxPythonPhoenix:
  425. return wx.Rect.Offset(self, dx, dy)
  426. else:
  427. return wx.Rect.OffsetXY(self, dx, dy)
  428. class CheckBox(wx.CheckBox):
  429. """Wrapper around wx.CheckBox to have more control
  430. over the widget on different platforms/wxpython versions"""
  431. def __init__(self, *args, **kwargs):
  432. wx.CheckBox.__init__(self, *args, **kwargs)
  433. def SetToolTip(self, tip):
  434. if wxPythonPhoenix:
  435. wx.CheckBox.SetToolTip(self, tipString=tip)
  436. else:
  437. wx.CheckBox.SetToolTipString(self, tip)
  438. class Choice(wx.Choice):
  439. """Wrapper around wx.Choice to have more control
  440. over the widget on different platforms/wxpython versions"""
  441. def __init__(self, *args, **kwargs):
  442. wx.Choice.__init__(self, *args, **kwargs)
  443. def SetToolTip(self, tip):
  444. if wxPythonPhoenix:
  445. wx.Choice.SetToolTip(self, tipString=tip)
  446. else:
  447. wx.Choice.SetToolTipString(self, tip)
  448. class TextEntryDialog(wx.TextEntryDialog):
  449. """Wrapper around wx.TextEntryDialog to have more control
  450. over the widget on different platforms/wxpython versions"""
  451. def __init__(self, parent, message, caption="Please enter text", value="",
  452. style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition):
  453. if wxPythonPhoenix:
  454. super(TextEntryDialog, self).__init__(parent=parent, message=message, caption=caption,
  455. value=value, style=style, pos=pos)
  456. else:
  457. super(TextEntryDialog, self).__init__(parent=parent, message=message, caption=caption,
  458. defaultValue=value, style=style, pos=pos)
  459. class ColourSelect(csel.ColourSelect):
  460. """Wrapper around wx.lib.colourselect.ColourSelect to have more control
  461. over the widget on different platforms/wxpython versions"""
  462. def __init__(self, *args, **kwargs):
  463. csel.ColourSelect.__init__(self, *args, **kwargs)
  464. def SetToolTip(self, tip):
  465. if wxPythonPhoenix:
  466. csel.ColourSelect.SetToolTip(self, tipString=tip)
  467. else:
  468. csel.ColourSelect.SetToolTipString(self, tip)
  469. class ComboCtrl(wxComboCtrl):
  470. def __init__(self, *args, **kwargs):
  471. wxComboCtrl.__init__(self, *args, **kwargs)
  472. def SetToolTip(self, tip):
  473. if wxPythonPhoenix:
  474. wxComboCtrl.SetToolTip(self, tipString=tip)
  475. else:
  476. wxComboCtrl.SetToolTipString(self, tip)
  477. class Dialog(wx.Dialog):
  478. """Wrapper around wx.Dialog to have more control
  479. over the widget on different platforms/wxpython versions"""
  480. def __init__(self, *args, **kwargs):
  481. wx.Dialog.__init__(self, *args, **kwargs)
  482. class Notebook(wx.Notebook):
  483. """Wrapper around NoteBook to have more control
  484. over the widget on different platforms/wxpython versions"""
  485. def __init__(self, *args, **kwargs):
  486. wx.Notebook.__init__(self, *args, **kwargs)
  487. class OwnerDrawnComboBox(OwnerDrawnComboBox_):
  488. """Wrapper around OwnerDrawnComboBox to have more control
  489. over the widget on different platforms/wxpython versions"""
  490. ODCB_PAINTING_CONTROL = ODCB_PAINTING_CONTROL
  491. ODCB_PAINTING_SELECTED = ODCB_PAINTING_SELECTED
  492. def __init__(self, *args, **kwargs):
  493. OwnerDrawnComboBox_.__init__(self, *args, **kwargs)
  494. def SetToolTip(self, tip):
  495. if wxPythonPhoenix:
  496. OwnerDrawnComboBox_.SetToolTip(self, tipString=tip)
  497. else:
  498. OwnerDrawnComboBox_.SetToolTipString(self, tip)
  499. class BitmapComboBox(BitmapComboBox_):
  500. """Wrapper around BitmapComboBox to have more control
  501. over the widget on different platforms/wxpython versions"""
  502. def __init__(self, *args, **kwargs):
  503. BitmapComboBox_.__init__(self, *args, **kwargs)
  504. def SetToolTip(self, tip):
  505. if wxPythonPhoenix:
  506. BitmapComboBox_.SetToolTip(self, tipString=tip)
  507. else:
  508. BitmapComboBox_.SetToolTipString(self, tip)
  509. class ScrolledPanel(scrolled.ScrolledPanel):
  510. """Wrapper around scrolled.ScrolledPanel to have more control
  511. over the widget on different platforms/wxpython versions"""
  512. def __init__(self, *args, **kwargs):
  513. scrolled.ScrolledPanel.__init__(self, *args, **kwargs)
  514. def SetToolTip(self, tip):
  515. if wxPythonPhoenix:
  516. scrolled.ScrolledPanel.SetToolTip(self, tipString=tip)
  517. else:
  518. scrolled.ScrolledPanel.SetToolTipString(self, tip)
  519. class FileBrowseButton(filebrowse.FileBrowseButton):
  520. """Wrapper around filebrowse.FileBrowseButton to have more control
  521. over the widget on different platforms/wxpython versions"""
  522. def __init__(self, *args, **kwargs):
  523. filebrowse.FileBrowseButton.__init__(self, *args, **kwargs)
  524. class DirBrowseButton(filebrowse.DirBrowseButton):
  525. """Wrapper around filebrowse.DirBrowseButton to have more control
  526. over the widget on different platforms/wxpython versions"""
  527. def __init__(self, *args, **kwargs):
  528. filebrowse.DirBrowseButton.__init__(self, *args, **kwargs)
  529. class ExpandoTextCtrl(expando.ExpandoTextCtrl):
  530. """Wrapper around expando.ExpandoTextCtrl to have more control
  531. over the widget on different platforms/wxpython versions"""
  532. EVT_ETC_LAYOUT_NEEDED = expando.EVT_ETC_LAYOUT_NEEDED
  533. def __init__(self, *args, **kwargs):
  534. expando.ExpandoTextCtrl.__init__(self, *args, **kwargs)
  535. class ColourPickerCtrl(wx.ColourPickerCtrl):
  536. """Wrapper around wx.ColourPickerCtrl to have more control
  537. over the widget on different platforms/wxpython versions"""
  538. def __init__(self, *args, **kwargs):
  539. wx.ColourPickerCtrl.__init__(self, *args, **kwargs)
  540. class ListBox(wx.ListBox):
  541. """Wrapper around wx.ListBox to have more control
  542. over the widget on different platforms/wxpython versions"""
  543. def __init__(self, *args, **kwargs):
  544. wx.ListBox.__init__(self, *args, **kwargs)
  545. def SetToolTip(self, tip):
  546. if wxPythonPhoenix:
  547. wx.ListBox.SetToolTip(self, tipString=tip)
  548. else:
  549. wx.ListBox.SetToolTipString(self, tip)
  550. class HyperlinkCtrl(HyperlinkCtrl_):
  551. """Wrapper around HyperlinkCtrl to have more control
  552. over the widget on different platforms/wxpython versions"""
  553. HL_ALIGN_LEFT = HL_ALIGN_LEFT
  554. HL_CONTEXTMENU = HL_CONTEXTMENU
  555. def __init__(self, *args, **kwargs):
  556. HyperlinkCtrl_.__init__(self, *args, **kwargs)
  557. def SetToolTip(self, tip):
  558. if wxPythonPhoenix:
  559. HyperlinkCtrl_.SetToolTip(self, tipString=tip)
  560. else:
  561. HyperlinkCtrl_.SetToolTipString(self, tip)
  562. class ComboBox(wx.ComboBox):
  563. """Wrapper around wx.ComboBox to have more control
  564. over the widget on different platforms/wxpython versions"""
  565. def __init__(self, *args, **kwargs):
  566. wx.ComboBox.__init__(self, *args, **kwargs)
  567. def SetToolTip(self, tip):
  568. if wxPythonPhoenix:
  569. wx.ComboBox.SetToolTip(self, tipString=tip)
  570. else:
  571. wx.ComboBox.SetToolTipString(self, tip)