wxPython 4.3.2__cp315-cp315-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (471) hide show
  1. wx/WebView2Loader.dll +0 -0
  2. wx/__init__.py +22 -0
  3. wx/__init__.pyi +10 -0
  4. wx/__version__.py +9 -0
  5. wx/__version__.pyi +15 -0
  6. wx/_adv.cp315-win_arm64.pyd +0 -0
  7. wx/_aui.cp315-win_arm64.pyd +0 -0
  8. wx/_core.cp315-win_arm64.pyd +0 -0
  9. wx/_dataview.cp315-win_arm64.pyd +0 -0
  10. wx/_glcanvas.cp315-win_arm64.pyd +0 -0
  11. wx/_grid.cp315-win_arm64.pyd +0 -0
  12. wx/_html.cp315-win_arm64.pyd +0 -0
  13. wx/_html2.cp315-win_arm64.pyd +0 -0
  14. wx/_media.cp315-win_arm64.pyd +0 -0
  15. wx/_msw.cp315-win_arm64.pyd +0 -0
  16. wx/_propgrid.cp315-win_arm64.pyd +0 -0
  17. wx/_ribbon.cp315-win_arm64.pyd +0 -0
  18. wx/_richtext.cp315-win_arm64.pyd +0 -0
  19. wx/_stc.cp315-win_arm64.pyd +0 -0
  20. wx/_xml.cp315-win_arm64.pyd +0 -0
  21. wx/_xrc.cp315-win_arm64.pyd +0 -0
  22. wx/adv.py +127 -0
  23. wx/adv.pyi +5931 -0
  24. wx/aui.py +70 -0
  25. wx/aui.pyi +4805 -0
  26. wx/core.py +3417 -0
  27. wx/core.pyi +62949 -0
  28. wx/dataview.py +176 -0
  29. wx/dataview.pyi +3828 -0
  30. wx/gizmos.py +18 -0
  31. wx/glcanvas.py +13 -0
  32. wx/glcanvas.pyi +544 -0
  33. wx/grid.py +237 -0
  34. wx/grid.pyi +5678 -0
  35. wx/html.py +38 -0
  36. wx/html.pyi +3283 -0
  37. wx/html2.py +46 -0
  38. wx/html2.pyi +1301 -0
  39. wx/include/wxPython/sip.h +1938 -0
  40. wx/include/wxPython/wxpy_api.h +418 -0
  41. wx/lib/CDate.py +201 -0
  42. wx/lib/ClickableHtmlWindow.py +57 -0
  43. wx/lib/__init__.py +0 -0
  44. wx/lib/activex.py +178 -0
  45. wx/lib/activexwrapper.py +153 -0
  46. wx/lib/agw/__init__.py +128 -0
  47. wx/lib/agw/advancedsplash.py +563 -0
  48. wx/lib/agw/aquabutton.py +1127 -0
  49. wx/lib/agw/artmanager.py +2110 -0
  50. wx/lib/agw/aui/__init__.py +295 -0
  51. wx/lib/agw/aui/aui_constants.py +2616 -0
  52. wx/lib/agw/aui/aui_switcherdialog.py +1232 -0
  53. wx/lib/agw/aui/aui_utilities.py +648 -0
  54. wx/lib/agw/aui/auibar.py +4045 -0
  55. wx/lib/agw/aui/auibook.py +6288 -0
  56. wx/lib/agw/aui/dockart.py +1198 -0
  57. wx/lib/agw/aui/framemanager.py +10485 -0
  58. wx/lib/agw/aui/tabart.py +2749 -0
  59. wx/lib/agw/aui/tabmdi.py +679 -0
  60. wx/lib/agw/balloontip.py +1157 -0
  61. wx/lib/agw/buttonpanel.py +2787 -0
  62. wx/lib/agw/cubecolourdialog.py +3529 -0
  63. wx/lib/agw/customtreectrl.py +9908 -0
  64. wx/lib/agw/data/ShortcutEditor_1.png +0 -0
  65. wx/lib/agw/data/ShortcutEditor_1_thumb.png +0 -0
  66. wx/lib/agw/data/ShortcutEditor_2.png +0 -0
  67. wx/lib/agw/data/ShortcutEditor_2_thumb.png +0 -0
  68. wx/lib/agw/data/ShortcutEditor_3.png +0 -0
  69. wx/lib/agw/data/ShortcutEditor_3_thumb.png +0 -0
  70. wx/lib/agw/data/ShortcutEditor_4.png +0 -0
  71. wx/lib/agw/data/ShortcutEditor_4_thumb.png +0 -0
  72. wx/lib/agw/data/default_help_text.html +105 -0
  73. wx/lib/agw/flatmenu.py +7392 -0
  74. wx/lib/agw/flatnotebook.py +6669 -0
  75. wx/lib/agw/floatspin.py +1820 -0
  76. wx/lib/agw/fmcustomizedlg.py +535 -0
  77. wx/lib/agw/fmresources.py +407 -0
  78. wx/lib/agw/foldpanelbar.py +2282 -0
  79. wx/lib/agw/fourwaysplitter.py +1130 -0
  80. wx/lib/agw/genericmessagedialog.py +1549 -0
  81. wx/lib/agw/gradientbutton.py +731 -0
  82. wx/lib/agw/hyperlink.py +664 -0
  83. wx/lib/agw/hypertreelist.py +5756 -0
  84. wx/lib/agw/infobar.py +885 -0
  85. wx/lib/agw/knobctrl.py +944 -0
  86. wx/lib/agw/labelbook.py +3028 -0
  87. wx/lib/agw/multidirdialog.py +581 -0
  88. wx/lib/agw/peakmeter.py +1028 -0
  89. wx/lib/agw/persist/__init__.py +188 -0
  90. wx/lib/agw/persist/persist_constants.py +283 -0
  91. wx/lib/agw/persist/persist_handlers.py +2614 -0
  92. wx/lib/agw/persist/persistencemanager.py +863 -0
  93. wx/lib/agw/piectrl.py +1082 -0
  94. wx/lib/agw/pybusyinfo.py +399 -0
  95. wx/lib/agw/pycollapsiblepane.py +940 -0
  96. wx/lib/agw/pygauge.py +570 -0
  97. wx/lib/agw/pyprogress.py +916 -0
  98. wx/lib/agw/ribbon/__init__.py +198 -0
  99. wx/lib/agw/ribbon/art.py +219 -0
  100. wx/lib/agw/ribbon/art_aui.py +1283 -0
  101. wx/lib/agw/ribbon/art_default.py +81 -0
  102. wx/lib/agw/ribbon/art_internal.py +248 -0
  103. wx/lib/agw/ribbon/art_msw.py +2735 -0
  104. wx/lib/agw/ribbon/art_osx.py +52 -0
  105. wx/lib/agw/ribbon/bar.py +1259 -0
  106. wx/lib/agw/ribbon/buttonbar.py +1317 -0
  107. wx/lib/agw/ribbon/control.py +205 -0
  108. wx/lib/agw/ribbon/gallery.py +973 -0
  109. wx/lib/agw/ribbon/page.py +946 -0
  110. wx/lib/agw/ribbon/panel.py +1170 -0
  111. wx/lib/agw/ribbon/toolbar.py +1441 -0
  112. wx/lib/agw/rulerctrl.py +1885 -0
  113. wx/lib/agw/scrolledthumbnail.py +2116 -0
  114. wx/lib/agw/shapedbutton.py +1809 -0
  115. wx/lib/agw/shortcuteditor.py +2642 -0
  116. wx/lib/agw/speedmeter.py +1800 -0
  117. wx/lib/agw/supertooltip.py +1443 -0
  118. wx/lib/agw/thumbnailctrl.py +529 -0
  119. wx/lib/agw/toasterbox.py +1327 -0
  120. wx/lib/agw/ultimatelistctrl.py +13671 -0
  121. wx/lib/agw/xlsgrid.py +2111 -0
  122. wx/lib/agw/zoombar.py +1336 -0
  123. wx/lib/analogclock/__init__.py +140 -0
  124. wx/lib/analogclock/analogclock.py +630 -0
  125. wx/lib/analogclock/helpers.py +986 -0
  126. wx/lib/analogclock/lib_setup/__init__.py +0 -0
  127. wx/lib/analogclock/lib_setup/buttontreectrlpanel.py +297 -0
  128. wx/lib/analogclock/lib_setup/fontselect.py +57 -0
  129. wx/lib/analogclock/setup.py +490 -0
  130. wx/lib/analogclock/styles.py +47 -0
  131. wx/lib/anchors.py +103 -0
  132. wx/lib/art/__init__.py +4 -0
  133. wx/lib/art/flagart.py +1583 -0
  134. wx/lib/art/img2pyartprov.py +56 -0
  135. wx/lib/busy.py +152 -0
  136. wx/lib/buttons.py +1140 -0
  137. wx/lib/calendar.py +1596 -0
  138. wx/lib/checkbox.py +837 -0
  139. wx/lib/colourchooser/__init__.py +36 -0
  140. wx/lib/colourchooser/canvas.py +145 -0
  141. wx/lib/colourchooser/intl.py +24 -0
  142. wx/lib/colourchooser/pycolourbox.py +89 -0
  143. wx/lib/colourchooser/pycolourchooser.py +626 -0
  144. wx/lib/colourchooser/pycolourslider.py +98 -0
  145. wx/lib/colourchooser/pypalette.py +208 -0
  146. wx/lib/colourdb.py +740 -0
  147. wx/lib/colourselect.py +385 -0
  148. wx/lib/colourutils.py +118 -0
  149. wx/lib/combotreebox.py +944 -0
  150. wx/lib/delayedresult.py +420 -0
  151. wx/lib/dialogs.py +510 -0
  152. wx/lib/docview.py +3210 -0
  153. wx/lib/dragscroller.py +79 -0
  154. wx/lib/editor/README.txt +77 -0
  155. wx/lib/editor/__init__.py +24 -0
  156. wx/lib/editor/editor.py +974 -0
  157. wx/lib/editor/images.py +15 -0
  158. wx/lib/editor/selection.py +44 -0
  159. wx/lib/embeddedimage.py +76 -0
  160. wx/lib/eventStack.py +136 -0
  161. wx/lib/eventwatcher.py +440 -0
  162. wx/lib/evtmgr.py +521 -0
  163. wx/lib/expando.py +393 -0
  164. wx/lib/fancytext.py +494 -0
  165. wx/lib/filebrowsebutton.py +461 -0
  166. wx/lib/flashwin.py +262 -0
  167. wx/lib/flashwin_old.py +651 -0
  168. wx/lib/floatcanvas/FCEvents.py +53 -0
  169. wx/lib/floatcanvas/FCObjects.py +2910 -0
  170. wx/lib/floatcanvas/FloatCanvas.py +1025 -0
  171. wx/lib/floatcanvas/GUIMode.py +396 -0
  172. wx/lib/floatcanvas/NavCanvas.py +162 -0
  173. wx/lib/floatcanvas/Resources.py +319 -0
  174. wx/lib/floatcanvas/ScreenShot.py +1788 -0
  175. wx/lib/floatcanvas/Utilities/BBox.py +313 -0
  176. wx/lib/floatcanvas/Utilities/Colors.py +137 -0
  177. wx/lib/floatcanvas/Utilities/GUI.py +91 -0
  178. wx/lib/floatcanvas/Utilities/__init__.py +7 -0
  179. wx/lib/floatcanvas/__init__.py +124 -0
  180. wx/lib/foldmenu.py +89 -0
  181. wx/lib/gestures.py +310 -0
  182. wx/lib/gizmos/__init__.py +18 -0
  183. wx/lib/gizmos/dynamicsash.py +1202 -0
  184. wx/lib/gizmos/ledctrl.py +299 -0
  185. wx/lib/gizmos/treelistctrl.py +87 -0
  186. wx/lib/graphics.py +1942 -0
  187. wx/lib/gridmovers.py +516 -0
  188. wx/lib/iewin.py +249 -0
  189. wx/lib/iewin_old.py +894 -0
  190. wx/lib/imagebrowser.py +853 -0
  191. wx/lib/imageutils.py +163 -0
  192. wx/lib/infoframe.py +490 -0
  193. wx/lib/inspection.py +1254 -0
  194. wx/lib/intctrl.py +990 -0
  195. wx/lib/itemspicker.py +256 -0
  196. wx/lib/langlistctrl.py +480 -0
  197. wx/lib/layoutf.py +271 -0
  198. wx/lib/masked/__init__.py +27 -0
  199. wx/lib/masked/combobox.py +839 -0
  200. wx/lib/masked/ctrl.py +108 -0
  201. wx/lib/masked/ipaddrctrl.py +241 -0
  202. wx/lib/masked/maskededit.py +7262 -0
  203. wx/lib/masked/numctrl.py +2000 -0
  204. wx/lib/masked/textctrl.py +465 -0
  205. wx/lib/masked/timectrl.py +1465 -0
  206. wx/lib/mixins/__init__.py +17 -0
  207. wx/lib/mixins/grid.py +47 -0
  208. wx/lib/mixins/gridlabelrenderer.py +277 -0
  209. wx/lib/mixins/imagelist.py +77 -0
  210. wx/lib/mixins/inspection.py +184 -0
  211. wx/lib/mixins/listctrl.py +893 -0
  212. wx/lib/mixins/rubberband.py +403 -0
  213. wx/lib/mixins/treemixin.py +678 -0
  214. wx/lib/msgpanel.py +95 -0
  215. wx/lib/multisash.py +746 -0
  216. wx/lib/myole4ax.idl +178 -0
  217. wx/lib/myole4ax.tlb +0 -0
  218. wx/lib/newevent.py +229 -0
  219. wx/lib/newevent.pyi +25 -0
  220. wx/lib/nvdlg.py +156 -0
  221. wx/lib/ogl/__init__.py +13 -0
  222. wx/lib/ogl/basic.py +3989 -0
  223. wx/lib/ogl/bmpshape.py +86 -0
  224. wx/lib/ogl/canvas.py +467 -0
  225. wx/lib/ogl/composit.py +1576 -0
  226. wx/lib/ogl/diagram.py +230 -0
  227. wx/lib/ogl/divided.py +482 -0
  228. wx/lib/ogl/drawn.py +898 -0
  229. wx/lib/ogl/lines.py +1809 -0
  230. wx/lib/ogl/oglmisc.py +607 -0
  231. wx/lib/pdfviewer/__init__.py +113 -0
  232. wx/lib/pdfviewer/bitmaps/ArrowLeft.png +0 -0
  233. wx/lib/pdfviewer/bitmaps/ArrowRight.png +0 -0
  234. wx/lib/pdfviewer/bitmaps/DirectionH.png +0 -0
  235. wx/lib/pdfviewer/bitmaps/DirectionV.png +0 -0
  236. wx/lib/pdfviewer/bitmaps/PlayerFirst.png +0 -0
  237. wx/lib/pdfviewer/bitmaps/PlayerLast.png +0 -0
  238. wx/lib/pdfviewer/bitmaps/PlayerNext.png +0 -0
  239. wx/lib/pdfviewer/bitmaps/PlayerPrev.png +0 -0
  240. wx/lib/pdfviewer/bitmaps/Printer.png +0 -0
  241. wx/lib/pdfviewer/bitmaps/ReadMe.txt +28 -0
  242. wx/lib/pdfviewer/bitmaps/Save.png +0 -0
  243. wx/lib/pdfviewer/bitmaps/ZoomIn.png +0 -0
  244. wx/lib/pdfviewer/bitmaps/ZoomOut.png +0 -0
  245. wx/lib/pdfviewer/bitmaps/encode_bitmaps.py +37 -0
  246. wx/lib/pdfviewer/buttonpanel.py +285 -0
  247. wx/lib/pdfviewer/images.py +240 -0
  248. wx/lib/pdfviewer/viewer.py +1118 -0
  249. wx/lib/pdfwin.py +295 -0
  250. wx/lib/pdfwin_old.py +789 -0
  251. wx/lib/platebtn.py +789 -0
  252. wx/lib/plot/CHANGELOG.md +150 -0
  253. wx/lib/plot/README.md +16 -0
  254. wx/lib/plot/__init__.py +46 -0
  255. wx/lib/plot/__main__.py +5 -0
  256. wx/lib/plot/examples/__init__.py +0 -0
  257. wx/lib/plot/examples/demo.py +1010 -0
  258. wx/lib/plot/examples/simple_example.py +56 -0
  259. wx/lib/plot/plotcanvas.py +2985 -0
  260. wx/lib/plot/polyobjects.py +1524 -0
  261. wx/lib/plot/utils.py +334 -0
  262. wx/lib/popupctl.py +251 -0
  263. wx/lib/printout.py +1155 -0
  264. wx/lib/progressindicator.py +151 -0
  265. wx/lib/pubsub/LICENSE_BSD_Simple.txt +23 -0
  266. wx/lib/pubsub/README_WxPython.txt +22 -0
  267. wx/lib/pubsub/RELEASE_NOTES.txt +71 -0
  268. wx/lib/pubsub/__init__.py +25 -0
  269. wx/lib/pubsub/core/__init__.py +92 -0
  270. wx/lib/pubsub/core/arg1/__init__.py +16 -0
  271. wx/lib/pubsub/core/arg1/listenerimpl.py +97 -0
  272. wx/lib/pubsub/core/arg1/publisher.py +40 -0
  273. wx/lib/pubsub/core/arg1/publishermixin.py +34 -0
  274. wx/lib/pubsub/core/arg1/topicargspecimpl.py +66 -0
  275. wx/lib/pubsub/core/arg1/topicmgrimpl.py +19 -0
  276. wx/lib/pubsub/core/callables.py +198 -0
  277. wx/lib/pubsub/core/imp2.py +62 -0
  278. wx/lib/pubsub/core/itopicdefnprovider.py +0 -0
  279. wx/lib/pubsub/core/kwargs/__init__.py +16 -0
  280. wx/lib/pubsub/core/kwargs/datamsg.py +27 -0
  281. wx/lib/pubsub/core/kwargs/listenerimpl.py +93 -0
  282. wx/lib/pubsub/core/kwargs/publisher.py +77 -0
  283. wx/lib/pubsub/core/kwargs/publishermixin.py +65 -0
  284. wx/lib/pubsub/core/kwargs/topicargspecimpl.py +216 -0
  285. wx/lib/pubsub/core/kwargs/topicmgrimpl.py +13 -0
  286. wx/lib/pubsub/core/listener.py +40 -0
  287. wx/lib/pubsub/core/listenerbase.py +185 -0
  288. wx/lib/pubsub/core/notificationmgr.py +185 -0
  289. wx/lib/pubsub/core/publisherbase.py +189 -0
  290. wx/lib/pubsub/core/topicargspec.py +77 -0
  291. wx/lib/pubsub/core/topicdefnprovider.py +631 -0
  292. wx/lib/pubsub/core/topicexc.py +72 -0
  293. wx/lib/pubsub/core/topicmgr.py +454 -0
  294. wx/lib/pubsub/core/topicobj.py +472 -0
  295. wx/lib/pubsub/core/topictreetraverser.py +143 -0
  296. wx/lib/pubsub/core/topicutils.py +119 -0
  297. wx/lib/pubsub/core/treeconfig.py +21 -0
  298. wx/lib/pubsub/core/validatedefnargs.py +29 -0
  299. wx/lib/pubsub/core/weakmethod.py +102 -0
  300. wx/lib/pubsub/policies.py +24 -0
  301. wx/lib/pubsub/pub.py +199 -0
  302. wx/lib/pubsub/setuparg1.py +47 -0
  303. wx/lib/pubsub/setupkwargs.py +29 -0
  304. wx/lib/pubsub/utils/__init__.py +27 -0
  305. wx/lib/pubsub/utils/exchandling.py +100 -0
  306. wx/lib/pubsub/utils/misc.py +99 -0
  307. wx/lib/pubsub/utils/notification.py +331 -0
  308. wx/lib/pubsub/utils/topictreeprinter.py +195 -0
  309. wx/lib/pubsub/utils/xmltopicdefnprovider.py +286 -0
  310. wx/lib/pydocview.py +3300 -0
  311. wx/lib/rcsizer.py +227 -0
  312. wx/lib/resizewidget.py +357 -0
  313. wx/lib/scrolledpanel.py +243 -0
  314. wx/lib/sheet.py +350 -0
  315. wx/lib/sized_controls.py +691 -0
  316. wx/lib/softwareupdate.py +355 -0
  317. wx/lib/splitter.py +925 -0
  318. wx/lib/statbmp.py +199 -0
  319. wx/lib/stattext.py +321 -0
  320. wx/lib/throbber.py +424 -0
  321. wx/lib/ticker.py +306 -0
  322. wx/lib/ticker_xrc.py +48 -0
  323. wx/lib/utils.py +89 -0
  324. wx/lib/wordwrap.py +97 -0
  325. wx/lib/wxcairo/__init__.py +139 -0
  326. wx/lib/wxcairo/wx_cairocffi.py +200 -0
  327. wx/lib/wxcairo/wx_pycairo.py +455 -0
  328. wx/lib/wxpTag.py +274 -0
  329. wx/locale/af/LC_MESSAGES/wxstd.mo +0 -0
  330. wx/locale/an/LC_MESSAGES/wxstd.mo +0 -0
  331. wx/locale/ar/LC_MESSAGES/wxstd.mo +0 -0
  332. wx/locale/ca/LC_MESSAGES/wxstd.mo +0 -0
  333. wx/locale/ca@valencia/LC_MESSAGES/wxstd.mo +0 -0
  334. wx/locale/co/LC_MESSAGES/wxstd.mo +0 -0
  335. wx/locale/cs/LC_MESSAGES/wxstd.mo +0 -0
  336. wx/locale/da/LC_MESSAGES/wxstd.mo +0 -0
  337. wx/locale/de/LC_MESSAGES/wxstd.mo +0 -0
  338. wx/locale/el/LC_MESSAGES/wxstd.mo +0 -0
  339. wx/locale/es/LC_MESSAGES/wxstd.mo +0 -0
  340. wx/locale/eu/LC_MESSAGES/wxstd.mo +0 -0
  341. wx/locale/fa_IR/LC_MESSAGES/wxstd.mo +0 -0
  342. wx/locale/fi/LC_MESSAGES/wxstd.mo +0 -0
  343. wx/locale/fr/LC_MESSAGES/wxstd.mo +0 -0
  344. wx/locale/gl_ES/LC_MESSAGES/wxstd.mo +0 -0
  345. wx/locale/hi/LC_MESSAGES/wxstd.mo +0 -0
  346. wx/locale/hr/LC_MESSAGES/wxstd.mo +0 -0
  347. wx/locale/hu/LC_MESSAGES/wxstd.mo +0 -0
  348. wx/locale/id/LC_MESSAGES/wxstd.mo +0 -0
  349. wx/locale/it/LC_MESSAGES/wxstd.mo +0 -0
  350. wx/locale/ja/LC_MESSAGES/wxstd.mo +0 -0
  351. wx/locale/ka/LC_MESSAGES/wxstd.mo +0 -0
  352. wx/locale/ko_KR/LC_MESSAGES/wxstd.mo +0 -0
  353. wx/locale/lt/LC_MESSAGES/wxstd.mo +0 -0
  354. wx/locale/lv/LC_MESSAGES/wxstd.mo +0 -0
  355. wx/locale/ms/LC_MESSAGES/wxstd.mo +0 -0
  356. wx/locale/nb/LC_MESSAGES/wxstd.mo +0 -0
  357. wx/locale/ne/LC_MESSAGES/wxstd.mo +0 -0
  358. wx/locale/nl/LC_MESSAGES/wxstd.mo +0 -0
  359. wx/locale/pl/LC_MESSAGES/wxstd.mo +0 -0
  360. wx/locale/pt/LC_MESSAGES/wxstd.mo +0 -0
  361. wx/locale/pt_BR/LC_MESSAGES/wxstd.mo +0 -0
  362. wx/locale/ro/LC_MESSAGES/wxstd.mo +0 -0
  363. wx/locale/ru/LC_MESSAGES/wxstd.mo +0 -0
  364. wx/locale/sk/LC_MESSAGES/wxstd.mo +0 -0
  365. wx/locale/sl/LC_MESSAGES/wxstd.mo +0 -0
  366. wx/locale/sq/LC_MESSAGES/wxstd.mo +0 -0
  367. wx/locale/sr/LC_MESSAGES/wxstd.mo +0 -0
  368. wx/locale/sv/LC_MESSAGES/wxstd.mo +0 -0
  369. wx/locale/ta/LC_MESSAGES/wxstd.mo +0 -0
  370. wx/locale/tr/LC_MESSAGES/wxstd.mo +0 -0
  371. wx/locale/uk/LC_MESSAGES/wxstd.mo +0 -0
  372. wx/locale/vi/LC_MESSAGES/wxstd.mo +0 -0
  373. wx/locale/zh_CN/LC_MESSAGES/wxstd.mo +0 -0
  374. wx/locale/zh_TW/LC_MESSAGES/wxstd.mo +0 -0
  375. wx/media.py +30 -0
  376. wx/media.pyi +272 -0
  377. wx/msw.py +16 -0
  378. wx/msw.pyi +91 -0
  379. wx/propgrid.py +498 -0
  380. wx/propgrid.pyi +7427 -0
  381. wx/py/CHANGES.txt +796 -0
  382. wx/py/Py.ico +0 -0
  383. wx/py/PyAlaCarte.py +34 -0
  384. wx/py/PyAlaMode.py +34 -0
  385. wx/py/PyAlaModeTest.py +33 -0
  386. wx/py/PyCrust.ico +0 -0
  387. wx/py/PyCrust.py +78 -0
  388. wx/py/PyCrust_16.png +0 -0
  389. wx/py/PyCrust_32.png +0 -0
  390. wx/py/PyFilling.py +35 -0
  391. wx/py/PyShell.py +78 -0
  392. wx/py/PySlices.ico +0 -0
  393. wx/py/PySlices.py +98 -0
  394. wx/py/PySlicesShell.py +94 -0
  395. wx/py/PySlices_16.png +0 -0
  396. wx/py/PySlices_32.png +0 -0
  397. wx/py/PyWrap.py +52 -0
  398. wx/py/README.txt +77 -0
  399. wx/py/__init__.py +20 -0
  400. wx/py/buffer.py +136 -0
  401. wx/py/crust.py +403 -0
  402. wx/py/crustslices.py +403 -0
  403. wx/py/dispatcher.py +259 -0
  404. wx/py/document.py +37 -0
  405. wx/py/editor.py +844 -0
  406. wx/py/editwindow.py +316 -0
  407. wx/py/filling.py +358 -0
  408. wx/py/frame.py +976 -0
  409. wx/py/images.py +212 -0
  410. wx/py/interpreter.py +161 -0
  411. wx/py/introspect.py +402 -0
  412. wx/py/magic.py +98 -0
  413. wx/py/parse.py +134 -0
  414. wx/py/path.py +36 -0
  415. wx/py/pseudo.py +99 -0
  416. wx/py/shell.py +1579 -0
  417. wx/py/sliceshell.py +3805 -0
  418. wx/py/tests/test_interpreter.py +71 -0
  419. wx/py/tests/test_introspect.py +810 -0
  420. wx/py/tests/test_pseudo.py +70 -0
  421. wx/py/tests/test_version.py +36 -0
  422. wx/py/tests/testall.py +22 -0
  423. wx/py/version.py +7 -0
  424. wx/py.typed +0 -0
  425. wx/ribbon.py +48 -0
  426. wx/ribbon.pyi +3099 -0
  427. wx/richtext.py +141 -0
  428. wx/richtext.pyi +13581 -0
  429. wx/siplib.cp315-win_arm64.pyd +0 -0
  430. wx/siplib.pyi +19 -0
  431. wx/stc.py +59 -0
  432. wx/stc.pyi +9918 -0
  433. wx/svg/__init__.py +363 -0
  434. wx/svg/_nanosvg.cp315-win_arm64.pyd +0 -0
  435. wx/tools/__init__.py +18 -0
  436. wx/tools/dbg.py +268 -0
  437. wx/tools/genaxmodule.py +50 -0
  438. wx/tools/helpviewer.py +92 -0
  439. wx/tools/img2img.py +85 -0
  440. wx/tools/img2png.py +54 -0
  441. wx/tools/img2py.py +306 -0
  442. wx/tools/img2xpm.py +54 -0
  443. wx/tools/pywxrc.py +951 -0
  444. wx/tools/wxget.py +254 -0
  445. wx/tools/wxget_docs_demo.py +183 -0
  446. wx/wxbase334u_net_vc140_arm64.dll +0 -0
  447. wx/wxbase334u_vc140_arm64.dll +0 -0
  448. wx/wxbase334u_xml_vc140_arm64.dll +0 -0
  449. wx/wxmsw334u_adv_vc140_arm64.dll +0 -0
  450. wx/wxmsw334u_aui_vc140_arm64.dll +0 -0
  451. wx/wxmsw334u_core_vc140_arm64.dll +0 -0
  452. wx/wxmsw334u_gl_vc140_arm64.dll +0 -0
  453. wx/wxmsw334u_html_vc140_arm64.dll +0 -0
  454. wx/wxmsw334u_media_vc140_arm64.dll +0 -0
  455. wx/wxmsw334u_propgrid_vc140_arm64.dll +0 -0
  456. wx/wxmsw334u_qa_vc140_arm64.dll +0 -0
  457. wx/wxmsw334u_ribbon_vc140_arm64.dll +0 -0
  458. wx/wxmsw334u_richtext_vc140_arm64.dll +0 -0
  459. wx/wxmsw334u_stc_vc140_arm64.dll +0 -0
  460. wx/wxmsw334u_webview_vc140_arm64.dll +0 -0
  461. wx/wxmsw334u_xrc_vc140_arm64.dll +0 -0
  462. wx/xml.py +18 -0
  463. wx/xml.pyi +728 -0
  464. wx/xrc.py +68 -0
  465. wx/xrc.pyi +896 -0
  466. wxpython-4.3.2.dist-info/METADATA +71 -0
  467. wxpython-4.3.2.dist-info/RECORD +471 -0
  468. wxpython-4.3.2.dist-info/WHEEL +5 -0
  469. wxpython-4.3.2.dist-info/entry_points.txt +13 -0
  470. wxpython-4.3.2.dist-info/licenses/LICENSE.txt +610 -0
  471. wxpython-4.3.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1465 @@
1
+ #----------------------------------------------------------------------------
2
+ # Name: timectrl.py
3
+ # Author: Will Sadkin
4
+ # Created: 09/19/2002
5
+ # Copyright: (c) 2002 by Will Sadkin, 2002
6
+ # License: wxWindows license
7
+ #
8
+ # Tags: phoenix-port, unittest, documented
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ # NOTE:
12
+ # This was written way it is because of the lack of masked edit controls
13
+ # in wxWindows/wxPython. I would also have preferred to derive this
14
+ # control from a wxSpinCtrl rather than wxTextCtrl, but the wxTextCtrl
15
+ # component of that control is inaccessible through the interface exposed in
16
+ # wxPython.
17
+ #
18
+ # TimeCtrl does not use validators, because it does careful manipulation
19
+ # of the cursor in the text window on each keystroke, and validation is
20
+ # cursor-position specific, so the control intercepts the key codes before the
21
+ # validator would fire.
22
+ #
23
+ # TimeCtrl now also supports .SetValue() with either strings or wxDateTime
24
+ # values, as well as range limits, with the option of either enforcing them
25
+ # or simply coloring the text of the control if the limits are exceeded.
26
+ #
27
+ # Note: this class now makes heavy use of wxDateTime for parsing and
28
+ # regularization, but it always does so with ephemeral instances of
29
+ # wxDateTime, as the C++/Python validity of these instances seems to not
30
+ # persist. Because "today" can be a day for which an hour can "not exist"
31
+ # or be counted twice (1 day each per year, for DST adjustments), the date
32
+ # portion of all wxDateTimes used/returned have their date portion set to
33
+ # Jan 1, 1970 (the "epoch.")
34
+ #----------------------------------------------------------------------------
35
+ # 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net)
36
+ #
37
+ # o Updated for V2.5 compatibility
38
+ # o wx.SpinCtl has some issues that cause the control to
39
+ # lock up. Noted in other places using it too, it's not this module
40
+ # that's at fault.
41
+ #
42
+ # 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
43
+ #
44
+ # o wxMaskedTextCtrl -> masked.TextCtrl
45
+ # o wxTimeCtrl -> masked.TimeCtrl
46
+ #
47
+ # 2/4/2018 - jensgoe (mail@jensgoepfert.de)
48
+ # o wx.Validator_IsSilent() -> wx.Validator.IsSilent()
49
+ #
50
+
51
+
52
+ """
53
+ *TimeCtrl* provides a multi-cell control that allows manipulation of a time
54
+ value. It supports 12 or 24 hour format, and you can use wxDateTime or mxDateTime
55
+ to get/set values from the control.
56
+
57
+ Left/right/tab keys to switch cells within a TimeCtrl, and the up/down arrows act
58
+ like a spin control. TimeCtrl also allows for an actual spin button to be attached
59
+ to the control, so that it acts like the up/down arrow keys.
60
+
61
+ The ! or c key sets the value of the control to the current time.
62
+
63
+ Here's the API for TimeCtrl::
64
+
65
+ from wx.lib.masked import TimeCtrl
66
+
67
+ TimeCtrl(
68
+ parent, id = -1,
69
+ value = '00:00:00',
70
+ pos = wx.DefaultPosition,
71
+ size = wx.DefaultSize,
72
+ style = wxTE_PROCESS_TAB,
73
+ validator = wx.DefaultValidator,
74
+ name = "time",
75
+ format = 'HHMMSS',
76
+ fmt24hr = False,
77
+ displaySeconds = True,
78
+ spinButton = None,
79
+ min = None,
80
+ max = None,
81
+ limited = None,
82
+ oob_color = "Yellow"
83
+ )
84
+
85
+
86
+ value
87
+ If no initial value is set, the default will be midnight; if an illegal string
88
+ is specified, a ValueError will result. (You can always later set the initial time
89
+ with SetValue() after instantiation of the control.)
90
+
91
+ size
92
+ The size of the control will be automatically adjusted for 12/24 hour format
93
+ if wx.DefaultSize is specified. NOTE: due to a problem with wx.DateTime, if the
94
+ locale does not use 'AM/PM' for its values, the default format will automatically
95
+ change to 24 hour format, and an AttributeError will be thrown if a non-24 format
96
+ is specified.
97
+
98
+ style
99
+ By default, TimeCtrl will process TAB events, by allowing tab to the
100
+ different cells within the control.
101
+
102
+ validator
103
+ By default, TimeCtrl just uses the default (empty) validator, as all
104
+ of its validation for entry control is handled internally. However, a validator
105
+ can be supplied to provide data transfer capability to the control.
106
+
107
+ format
108
+ This parameter can be used instead of the fmt24hr and displaySeconds
109
+ parameters, respectively; it provides a shorthand way to specify the time
110
+ format you want. Accepted values are 'HHMMSS', 'HHMM', '24HHMMSS', and
111
+ '24HHMM'. If the format is specified, the other two arguments will be ignored.
112
+
113
+ fmt24hr
114
+ If True, control will display time in 24 hour time format; if False, it will
115
+ use 12 hour AM/PM format. SetValue() will adjust values accordingly for the
116
+ control, based on the format specified. (This value is ignored if the *format*
117
+ parameter is specified.)
118
+
119
+ displaySeconds
120
+ If True, control will include a seconds field; if False, it will
121
+ just show hours and minutes. (This value is ignored if the *format*
122
+ parameter is specified.)
123
+
124
+ spinButton
125
+ If specified, this button's events will be bound to the behavior of the
126
+ TimeCtrl, working like up/down cursor key events. (See BindSpinButton.)
127
+
128
+ min
129
+ Defines the lower bound for "valid" selections in the control.
130
+ By default, TimeCtrl doesn't have bounds. You must set both upper and lower
131
+ bounds to make the control pay attention to them, (as only one bound makes no sense
132
+ with times.) "Valid" times will fall between the min and max "pie wedge" of the
133
+ clock.
134
+ max
135
+ Defines the upper bound for "valid" selections in the control.
136
+ "Valid" times will fall between the min and max "pie wedge" of the
137
+ clock. (This can be a "big piece", ie. min = 11pm, max= 10pm
138
+ means *all but the hour from 10:00pm to 11pm are valid times.*)
139
+ limited
140
+ If True, the control will not permit entry of values that fall outside the
141
+ set bounds.
142
+
143
+ oob_color
144
+ Sets the background color used to indicate out-of-bounds values for the control
145
+ when the control is not limited. This is set to "Yellow" by default.
146
+
147
+ --------------------
148
+
149
+ EVT_TIMEUPDATE(win, id, func)
150
+ func is fired whenever the value of the control changes.
151
+
152
+
153
+ SetValue(time_string | wxDateTime | wxTimeSpan | mx.DateTime | mx.DateTimeDelta)
154
+ Sets the value of the control to a particular time, given a valid
155
+ value; raises ValueError on invalid value.
156
+
157
+ *NOTE:* This will only allow mx.DateTime or mx.DateTimeDelta if mx.DateTime
158
+ was successfully imported by the class module.
159
+
160
+ GetValue(as_wxDateTime = False, as_mxDateTime = False, as_wxTimeSpan=False, as mxDateTimeDelta=False)
161
+ Retrieves the value of the time from the control. By default this is
162
+ returned as a string, unless one of the other arguments is set; args are
163
+ searched in the order listed; only one value will be returned.
164
+
165
+ GetWxDateTime(value=None)
166
+ When called without arguments, retrieves the value of the control, and applies
167
+ it to the wxDateTimeFromHMS() constructor, and returns the resulting value.
168
+ The date portion will always be set to Jan 1, 1970. This form is the same
169
+ as GetValue(as_wxDateTime=True). GetWxDateTime can also be called with any of the
170
+ other valid time formats settable with SetValue, to regularize it to a single
171
+ wxDateTime form. The function will raise ValueError on an unconvertable argument.
172
+
173
+ GetMxDateTime()
174
+ Retrieves the value of the control and applies it to the DateTime.Time()
175
+ constructor,and returns the resulting value. (The date portion will always be
176
+ set to Jan 1, 1970.) (Same as GetValue(as_wxDateTime=True); provided for backward
177
+ compatibility with previous release.)
178
+
179
+
180
+ BindSpinButton(SpinBtton)
181
+ Binds an externally created spin button to the control, so that up/down spin
182
+ events change the active cell or selection in the control (in addition to the
183
+ up/down cursor keys.) (This is primarily to allow you to create a "standard"
184
+ interface to time controls, as seen in Windows.)
185
+
186
+
187
+ SetMin(min=None)
188
+ Sets the expected minimum value, or lower bound, of the control.
189
+ (The lower bound will only be enforced if the control is
190
+ configured to limit its values to the set bounds.)
191
+ If a value of *None* is provided, then the control will have
192
+ explicit lower bound. If the value specified is greater than
193
+ the current lower bound, then the function returns False and the
194
+ lower bound will not change from its current setting. On success,
195
+ the function returns True. Even if set, if there is no corresponding
196
+ upper bound, the control will behave as if it is unbounded.
197
+
198
+ If successful and the current value is outside the
199
+ new bounds, if the control is limited the value will be
200
+ automatically adjusted to the nearest bound; if not limited,
201
+ the background of the control will be colored with the current
202
+ out-of-bounds color.
203
+
204
+ GetMin(as_string=False)
205
+ Gets the current lower bound value for the control, returning
206
+ None, if not set, or a wxDateTime, unless the as_string parameter
207
+ is set to True, at which point it will return the string
208
+ representation of the lower bound.
209
+
210
+
211
+ SetMax(max=None)
212
+ Sets the expected maximum value, or upper bound, of the control.
213
+ (The upper bound will only be enforced if the control is
214
+ configured to limit its values to the set bounds.)
215
+ If a value of *None* is provided, then the control will
216
+ have no explicit upper bound. If the value specified is less
217
+ than the current lower bound, then the function returns False and
218
+ the maximum will not change from its current setting. On success,
219
+ the function returns True. Even if set, if there is no corresponding
220
+ lower bound, the control will behave as if it is unbounded.
221
+
222
+ If successful and the current value is outside the
223
+ new bounds, if the control is limited the value will be
224
+ automatically adjusted to the nearest bound; if not limited,
225
+ the background of the control will be colored with the current
226
+ out-of-bounds color.
227
+
228
+ GetMax(as_string = False)
229
+ Gets the current upper bound value for the control, returning
230
+ None, if not set, or a wxDateTime, unless the as_string parameter
231
+ is set to True, at which point it will return the string
232
+ representation of the lower bound.
233
+
234
+
235
+
236
+ SetBounds(min=None,max=None)
237
+ This function is a convenience function for setting the min and max
238
+ values at the same time. The function only applies the maximum bound
239
+ if setting the minimum bound is successful, and returns True
240
+ only if both operations succeed. *Note: leaving out an argument
241
+ will remove the corresponding bound, and result in the behavior of
242
+ an unbounded control.*
243
+
244
+ GetBounds(as_string = False)
245
+ This function returns a two-tuple (min,max), indicating the
246
+ current bounds of the control. Each value can be None if
247
+ that bound is not set. The values will otherwise be wxDateTimes
248
+ unless the as_string argument is set to True, at which point they
249
+ will be returned as string representations of the bounds.
250
+
251
+
252
+ IsInBounds(value=None)
253
+ Returns *True* if no value is specified and the current value
254
+ of the control falls within the current bounds. This function can also
255
+ be called with a value to see if that value would fall within the current
256
+ bounds of the given control. It will raise ValueError if the value
257
+ specified is not a wxDateTime, mxDateTime (if available) or parsable string.
258
+
259
+
260
+ IsValid(value)
261
+ Returns *True* if specified value is a legal time value and
262
+ falls within the current bounds of the given control.
263
+
264
+
265
+ SetLimited(bool)
266
+ If called with a value of True, this function will cause the control
267
+ to limit the value to fall within the bounds currently specified.
268
+ (Provided both bounds have been set.)
269
+ If the control's value currently exceeds the bounds, it will then
270
+ be set to the nearest bound.
271
+ If called with a value of False, this function will disable value
272
+ limiting, but coloring of out-of-bounds values will still take
273
+ place if bounds have been set for the control.
274
+ IsLimited()
275
+ Returns *True* if the control is currently limiting the
276
+ value to fall within the current bounds.
277
+
278
+
279
+ """
280
+
281
+ import copy
282
+
283
+ import wx
284
+
285
+ from wx.tools.dbg import Logger
286
+ from wx.lib.masked import Field, BaseMaskedTextCtrl
287
+
288
+ dbg = Logger()
289
+ ##dbg(enable=0)
290
+
291
+ try:
292
+ from mx import DateTime
293
+ accept_mx = True
294
+ except ImportError:
295
+ accept_mx = False
296
+
297
+ # This class of event fires whenever the value of the time changes in the control:
298
+ wxEVT_TIMEVAL_UPDATED = wx.NewEventType()
299
+ EVT_TIMEUPDATE = wx.PyEventBinder(wxEVT_TIMEVAL_UPDATED, 1)
300
+
301
+ class TimeUpdatedEvent(wx.PyCommandEvent):
302
+ """
303
+ Used to fire an EVT_TIMEUPDATE event whenever the value in a TimeCtrl changes.
304
+ """
305
+ def __init__(self, id, value ='12:00:00 AM'):
306
+ wx.PyCommandEvent.__init__(self, wxEVT_TIMEVAL_UPDATED, id)
307
+ self.value = value
308
+ def GetValue(self):
309
+ """Retrieve the value of the time control at the time this event was generated"""
310
+ return self.value
311
+
312
+ class TimeCtrlAccessorsMixin:
313
+ """
314
+ Defines TimeCtrl's list of attributes having their own Get/Set functions,
315
+ ignoring those in the base class that make no sense for a time control.
316
+ """
317
+ exposed_basectrl_params = (
318
+ 'defaultValue',
319
+ 'description',
320
+
321
+ 'useFixedWidthFont',
322
+ 'emptyBackgroundColour',
323
+ 'validBackgroundColour',
324
+ 'invalidBackgroundColour',
325
+
326
+ 'validFunc',
327
+ 'validRequired',
328
+ )
329
+ for param in exposed_basectrl_params:
330
+ propname = param[0].upper() + param[1:]
331
+ exec('def Set%s(self, value): self.SetCtrlParameters(%s=value)' % (propname, param))
332
+ exec('def Get%s(self): return self.GetCtrlParameter("%s")''' % (propname, param))
333
+
334
+ if param.find('Colour') != -1:
335
+ # add non-british spellings, for backward-compatibility
336
+ propname.replace('Colour', 'Color')
337
+
338
+ exec('def Set%s(self, value): self.SetCtrlParameters(%s=value)' % (propname, param))
339
+ exec('def Get%s(self): return self.GetCtrlParameter("%s")''' % (propname, param))
340
+
341
+
342
+ class TimeCtrl(BaseMaskedTextCtrl):
343
+ """
344
+ Masked control providing several time formats and manipulation of time values.
345
+ """
346
+
347
+ valid_ctrl_params = {
348
+ 'format' : 'HHMMSS', # default format code
349
+ 'displaySeconds' : True, # by default, shows seconds
350
+ 'min': None, # by default, no bounds set
351
+ 'max': None,
352
+ 'limited': False, # by default, no limiting even if bounds set
353
+ 'useFixedWidthFont': True, # by default, use a fixed-width font
354
+ 'oob_color': "Yellow" # by default, the default masked.TextCtrl "invalid" color
355
+ }
356
+
357
+ def __init__ (
358
+ self, parent, id=-1, value = '00:00:00',
359
+ pos = wx.DefaultPosition, size = wx.DefaultSize,
360
+ fmt24hr=False,
361
+ spinButton = None,
362
+ style = wx.TE_PROCESS_TAB,
363
+ validator = wx.DefaultValidator,
364
+ name = "time",
365
+ **kwargs ):
366
+
367
+ """
368
+ Default class constructor.
369
+
370
+ :param wx.Window `parent`: the window parent. Must not be ``None``;
371
+ :param integer `id`: window identifier. A value of -1 indicates a default value;
372
+ :param string `value`: value to be shown;
373
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
374
+ chosen by either the windowing system or wxPython, depending on platform;
375
+ :type `pos`: tuple or :class:`wx.Point`
376
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
377
+ chosen by either the windowing system or wxPython, depending on platform;
378
+ :param boolean `fmt24hr`: True to use 24 hour format (sometimes called military format;
379
+ :param SpinButton `spinButton`: an instance of :class:`SpinButton` or
380
+ None;
381
+ :param integer `style`: the window style;
382
+ :param wx.Validator `validator`: this is mainly provided for data-transfer, as control does
383
+ its own validation;
384
+ :param string `name`: the window name;
385
+
386
+ """
387
+
388
+ # set defaults for control:
389
+ ## dbg('setting defaults:')
390
+
391
+ self.__fmt24hr = False
392
+ wxdt = wx.DateTime.FromDMY(1, 0, 1970)
393
+ try:
394
+ if wxdt.Format('%p') != 'AM':
395
+ TimeCtrl.valid_ctrl_params['format'] = '24HHMMSS'
396
+ self.__fmt24hr = True
397
+ fmt24hr = True # force/change default positional argument
398
+ # (will countermand explicit set to False too.)
399
+ except:
400
+ TimeCtrl.valid_ctrl_params['format'] = '24HHMMSS'
401
+ self.__fmt24hr = True
402
+ fmt24hr = True # force/change default positional argument
403
+ # (will countermand explicit set to False too.)
404
+
405
+ for key, param_value in TimeCtrl.valid_ctrl_params.items():
406
+ # This is done this way to make setattr behave consistently with
407
+ # "private attribute" name mangling
408
+ setattr(self, "_TimeCtrl__" + key, copy.copy(param_value))
409
+
410
+ # create locals from current defaults, so we can override if
411
+ # specified in kwargs, and handle uniformly:
412
+ min = self.__min
413
+ max = self.__max
414
+ limited = self.__limited
415
+ self.__posCurrent = 0
416
+ # handle deprecated keyword argument name:
417
+ if 'display_seconds' in kwargs:
418
+ kwargs['displaySeconds'] = kwargs['display_seconds']
419
+ del kwargs['display_seconds']
420
+ if 'displaySeconds' not in kwargs:
421
+ kwargs['displaySeconds'] = True
422
+
423
+ # (handle positional arg (from original release) differently from rest of kwargs:)
424
+ if 'format' not in kwargs:
425
+ if fmt24hr:
426
+ if 'displaySeconds' in kwargs and kwargs['displaySeconds']:
427
+ kwargs['format'] = '24HHMMSS'
428
+ del kwargs['displaySeconds']
429
+ else:
430
+ kwargs['format'] = '24HHMM'
431
+ else:
432
+ if 'displaySeconds' in kwargs and kwargs['displaySeconds']:
433
+ kwargs['format'] = 'HHMMSS'
434
+ del kwargs['displaySeconds']
435
+ else:
436
+ kwargs['format'] = 'HHMM'
437
+
438
+ if 'useFixedWidthFont' not in kwargs:
439
+ # allow control over font selection:
440
+ kwargs['useFixedWidthFont'] = self.__useFixedWidthFont
441
+
442
+ maskededit_kwargs = self.SetParameters(**kwargs)
443
+
444
+ # allow for explicit size specification:
445
+ if size != wx.DefaultSize:
446
+ # override (and remove) "autofit" autoformat code in standard time formats:
447
+ maskededit_kwargs['formatcodes'] = 'T!'
448
+
449
+ # This allows range validation if set
450
+ maskededit_kwargs['validFunc'] = self.IsInBounds
451
+
452
+ # This allows range limits to affect insertion into control or not
453
+ # dynamically without affecting individual field constraint validation
454
+ maskededit_kwargs['retainFieldValidation'] = True
455
+
456
+ # Now we can initialize the base control:
457
+ BaseMaskedTextCtrl.__init__(
458
+ self, parent, id=id,
459
+ pos=pos, size=size,
460
+ style = style,
461
+ validator = validator,
462
+ name = name,
463
+ setupEventHandling = False,
464
+ **maskededit_kwargs)
465
+
466
+
467
+ # This makes ':' act like tab (after we fix each ':' key event to remove "shift")
468
+ self._SetKeyHandler(':', self._OnChangeField)
469
+
470
+
471
+ # This makes the up/down keys act like spin button controls:
472
+ self._SetKeycodeHandler(wx.WXK_UP, self.__OnSpinUp)
473
+ self._SetKeycodeHandler(wx.WXK_DOWN, self.__OnSpinDown)
474
+
475
+
476
+ # This allows ! and c/C to set the control to the current time:
477
+ self._SetKeyHandler('!', self.__OnSetToNow)
478
+ self._SetKeyHandler('c', self.__OnSetToNow)
479
+ self._SetKeyHandler('C', self.__OnSetToNow)
480
+
481
+
482
+ # Set up event handling ourselves, so we can insert special
483
+ # processing on the ":' key to remove the "shift" attribute
484
+ # *before* the default handlers have been installed, so
485
+ # that : takes you forward, not back, and so we can issue
486
+ # EVT_TIMEUPDATE events on changes:
487
+
488
+ self.Bind(wx.EVT_SET_FOCUS, self._OnFocus ) ## defeat automatic full selection
489
+ self.Bind(wx.EVT_KILL_FOCUS, self._OnKillFocus ) ## run internal validator
490
+ self.Bind(wx.EVT_LEFT_UP, self.__LimitSelection) ## limit selections to single field
491
+ self.Bind(wx.EVT_LEFT_DCLICK, self._OnDoubleClick ) ## select field under cursor on dclick
492
+ self.Bind(wx.EVT_KEY_DOWN, self._OnKeyDown ) ## capture control events not normally seen, eg ctrl-tab.
493
+ self.Bind(wx.EVT_CHAR, self.__OnChar ) ## remove "shift" attribute from colon key event,
494
+ ## then call BaseMaskedTextCtrl._OnChar with
495
+ ## the possibly modified event.
496
+ self.Bind(wx.EVT_TEXT, self.__OnTextChange, self ) ## color control appropriately and EVT_TIMEUPDATE events
497
+
498
+
499
+ # Validate initial value and set if appropriate
500
+ try:
501
+ self.SetBounds(min, max)
502
+ self.SetLimited(limited)
503
+ self.SetValue(value)
504
+ except:
505
+ self.SetValue('00:00:00')
506
+
507
+ if spinButton:
508
+ self.BindSpinButton(spinButton) # bind spin button up/down events to this control
509
+
510
+
511
+ def SetParameters(self, **kwargs):
512
+ """
513
+ Function providing access to the parameters governing TimeCtrl display
514
+ and bounds.
515
+ """
516
+ ## dbg('TimeCtrl::SetParameters(%s)' % repr(kwargs), indent=1)
517
+ maskededit_kwargs = {}
518
+ reset_format = False
519
+
520
+ if 'display_seconds' in kwargs:
521
+ kwargs['displaySeconds'] = kwargs['display_seconds']
522
+ del kwargs['display_seconds']
523
+ if 'format' in kwargs and 'displaySeconds' in kwargs:
524
+ del kwargs['displaySeconds'] # always apply format if specified
525
+
526
+ # assign keyword args as appropriate:
527
+ for key, param_value in kwargs.items():
528
+ if key not in TimeCtrl.valid_ctrl_params:
529
+ raise AttributeError('invalid keyword argument "%s"' % key)
530
+
531
+ if key == 'format':
532
+ wxdt = wx.DateTime.FromDMY(1, 0, 1970)
533
+ try:
534
+ if wxdt.Format('%p') != 'AM':
535
+ require24hr = True
536
+ else:
537
+ require24hr = False
538
+ except Exception:
539
+ require24hr = True
540
+
541
+ # handle both local or generic 'maskededit' autoformat codes:
542
+ if param_value == 'HHMMSS' or param_value == 'TIMEHHMMSS':
543
+ self.__displaySeconds = True
544
+ self.__fmt24hr = False
545
+ elif param_value == 'HHMM' or param_value == 'TIMEHHMM':
546
+ self.__displaySeconds = False
547
+ self.__fmt24hr = False
548
+ elif param_value == '24HHMMSS' or param_value == '24HRTIMEHHMMSS':
549
+ self.__displaySeconds = True
550
+ self.__fmt24hr = True
551
+ elif param_value == '24HHMM' or param_value == '24HRTIMEHHMM':
552
+ self.__displaySeconds = False
553
+ self.__fmt24hr = True
554
+ else:
555
+ raise AttributeError('"%s" is not a valid format' % param_value)
556
+
557
+ if require24hr and not self.__fmt24hr:
558
+ raise AttributeError('"%s" is an unsupported time format for the current locale' % param_value)
559
+
560
+ reset_format = True
561
+
562
+ elif key in ("displaySeconds", "display_seconds") and 'format' not in kwargs:
563
+ self.__displaySeconds = param_value
564
+ reset_format = True
565
+
566
+ elif key == "min": min = param_value
567
+ elif key == "max": max = param_value
568
+ elif key == "limited": limited = param_value
569
+
570
+ elif key == "useFixedWidthFont":
571
+ maskededit_kwargs[key] = param_value
572
+
573
+ elif key == "oob_color":
574
+ maskededit_kwargs['invalidBackgroundColor'] = param_value
575
+
576
+ if reset_format:
577
+ if self.__fmt24hr:
578
+ if self.__displaySeconds: maskededit_kwargs['autoformat'] = '24HRTIMEHHMMSS'
579
+ else: maskededit_kwargs['autoformat'] = '24HRTIMEHHMM'
580
+
581
+ # Set hour field to zero-pad, right-insert, require explicit field change,
582
+ # select entire field on entry, and require a resultant valid entry
583
+ # to allow character entry:
584
+ hourfield = Field(formatcodes='0r<SV', validRegex=r'0\d|1\d|2[0123]', validRequired=True)
585
+ else:
586
+ if self.__displaySeconds: maskededit_kwargs['autoformat'] = 'TIMEHHMMSS'
587
+ else: maskededit_kwargs['autoformat'] = 'TIMEHHMM'
588
+
589
+ # Set hour field to allow spaces (at start), right-insert,
590
+ # require explicit field change, select entire field on entry,
591
+ # and require a resultant valid entry to allow character entry:
592
+ hourfield = Field(formatcodes='_0<rSV', validRegex='0[1-9]| [1-9]|1[012]', validRequired=True)
593
+ ampmfield = Field(formatcodes='S', emptyInvalid = True, validRequired = True)
594
+
595
+ # Field 1 is always a zero-padded right-insert minute field,
596
+ # similarly configured as above:
597
+ minutefield = Field(formatcodes='0r<SV', validRegex=r'[0-5]\d', validRequired=True)
598
+
599
+ fields = [ hourfield, minutefield ]
600
+ if self.__displaySeconds:
601
+ fields.append(copy.copy(minutefield)) # second field has same constraints as field 1
602
+
603
+ if not self.__fmt24hr:
604
+ fields.append(ampmfield)
605
+
606
+ # set fields argument:
607
+ maskededit_kwargs['fields'] = fields
608
+
609
+ # This allows range validation if set
610
+ maskededit_kwargs['validFunc'] = self.IsInBounds
611
+
612
+ # This allows range limits to affect insertion into control or not
613
+ # dynamically without affecting individual field constraint validation
614
+ maskededit_kwargs['retainFieldValidation'] = True
615
+
616
+ if hasattr(self, 'controlInitialized') and self.controlInitialized:
617
+ self.SetCtrlParameters(**maskededit_kwargs) # set appropriate parameters
618
+
619
+ # Validate initial value and set if appropriate
620
+ try:
621
+ self.SetBounds(min, max)
622
+ self.SetLimited(limited)
623
+ self.SetValue(value)
624
+ except:
625
+ self.SetValue('00:00:00')
626
+ ## dbg(indent=0)
627
+ return {} # no arguments to return
628
+ else:
629
+ ## dbg(indent=0)
630
+ return maskededit_kwargs
631
+
632
+
633
+ def BindSpinButton(self, sb):
634
+ """
635
+ This function binds an externally created spin button to the control,
636
+ so that up/down events from the button automatically change the control.
637
+
638
+ :param SpinButton `sb`: an instance of :class:`SpinButton`
639
+
640
+ """
641
+ ## dbg('TimeCtrl::BindSpinButton')
642
+ self.__spinButton = sb
643
+ if self.__spinButton:
644
+ # bind event handlers to spin ctrl
645
+ self.__spinButton.Bind(wx.EVT_SPIN_UP, self.__OnSpinUp, self.__spinButton)
646
+ self.__spinButton.Bind(wx.EVT_SPIN_DOWN, self.__OnSpinDown, self.__spinButton)
647
+
648
+
649
+ def __repr__(self):
650
+ return "<TimeCtrl: %s>" % self.GetValue()
651
+
652
+
653
+ def SetValue(self, value):
654
+ """
655
+ Validating SetValue function for time values:
656
+ This function will do dynamic type checking on the value argument,
657
+ and convert :class:`DateTime`, mxDateTime, or 12/24 format time string
658
+ into the appropriate format string for the control.
659
+
660
+ :param `value`: the time value
661
+
662
+ """
663
+ ## dbg('TimeCtrl::SetValue(%s)' % repr(value), indent=1)
664
+ try:
665
+ strtime = self._toGUI(self.__validateValue(value))
666
+ except:
667
+ ## dbg('validation failed', indent=0)
668
+ raise
669
+
670
+ ## dbg('strtime:', strtime)
671
+ self._SetValue(strtime)
672
+ ## dbg(indent=0)
673
+
674
+ def ChangeValue(self, value):
675
+ """
676
+ Validating ChangeValue function for time values:
677
+ This function will do dynamic type checking on the value argument,
678
+ and convert :class:`DateTime`, mxDateTime, or 12/24 format time string
679
+ into the appropriate format string for the control.
680
+
681
+ No change event is fired by this method.
682
+
683
+ :param `value`: the time value
684
+
685
+ """
686
+ ## dbg('TimeCtrl::ChangeValue(%s)' % repr(value), indent=1)
687
+ try:
688
+ strtime = self._toGUI(self.__validateValue(value))
689
+ except:
690
+ ## dbg('validation failed', indent=0)
691
+ raise
692
+
693
+ ## dbg('strtime:', strtime)
694
+ self._ChangeValue(strtime)
695
+ ## dbg(indent=0)
696
+
697
+ def GetValue(self,
698
+ as_wxDateTime = False,
699
+ as_mxDateTime = False,
700
+ as_wxTimeSpan = False,
701
+ as_mxDateTimeDelta = False):
702
+ """
703
+ This function returns the value of the display as a string by default,
704
+ but supports return as a :class:`DateTime`, mx.DateTime, :class:`TimeSpan`,
705
+ or mx.DateTimeDelta, if requested.
706
+ (Evaluated in the order above-- first one wins!)
707
+
708
+ :param boolean `as_wxDateTime`: return value as :class:`DateTime`;
709
+ :param boolean `as_mxDateTime`: return value as mxDateTime;
710
+ :param boolean `as_wxTimeSpan`: return value as :class:`TimeSpan`;
711
+ :param boolean `as_mxDateTimeDelta`: return value as mxDateTimeDelta;
712
+
713
+ """
714
+
715
+ if as_wxDateTime or as_mxDateTime or as_wxTimeSpan or as_mxDateTimeDelta:
716
+ value = self.GetWxDateTime()
717
+ if as_wxDateTime:
718
+ pass
719
+ elif as_mxDateTime:
720
+ value = DateTime.DateTime(1970, 1, 1, value.GetHour(), value.GetMinute(), value.GetSecond())
721
+ elif as_wxTimeSpan:
722
+ value = wx.TimeSpan(value.GetHour(), value.GetMinute(), value.GetSecond())
723
+ elif as_mxDateTimeDelta:
724
+ value = DateTime.DateTimeDelta(0, value.GetHour(), value.GetMinute(), value.GetSecond())
725
+ else:
726
+ value = BaseMaskedTextCtrl.GetValue(self)
727
+ return value
728
+
729
+
730
+ def SetWxDateTime(self, wxdt):
731
+ """
732
+ Because SetValue can take a :class:`DateTime`, this is now just an alias.
733
+ """
734
+ self.SetValue(wxdt)
735
+
736
+
737
+ def GetWxDateTime(self, value=None):
738
+ """
739
+ This function is the conversion engine for TimeCtrl; it takes
740
+ one of the following types:
741
+
742
+ * time string
743
+ * :class:`DateTime`
744
+ * :class:`TimeSpan`
745
+ * mxDateTime
746
+ * mxDateTimeDelta
747
+
748
+ and converts it to a :class:`DateTime` that always has Jan 1, 1970 as
749
+ its date portion, so that range comparisons around values can work using
750
+ :class:`DateTime` built-in comparison function. If a value is not
751
+ provided to convert, the string value of the control will be used.
752
+ If the value is not one of the accepted types, a ValueError will be
753
+ raised.
754
+ """
755
+ global accept_mx
756
+ ## dbg(suspend=1)
757
+ ## dbg('TimeCtrl::GetWxDateTime(%s)' % repr(value), indent=1)
758
+ if value is None:
759
+ ## dbg('getting control value')
760
+ value = self.GetValue()
761
+ ## dbg('value = "%s"' % value)
762
+
763
+ valid = True # assume true
764
+ if isinstance(value, str):
765
+ value = str(value) # convert to regular string
766
+
767
+ # Construct constant wxDateTime, then try to parse the string:
768
+ wxdt = wx.DateTime.FromDMY(1, 0, 1970)
769
+ ## dbg('attempting conversion')
770
+ value = value.strip() # (parser doesn't like leading spaces)
771
+ valid = wxdt.ParseTime(value)
772
+
773
+ if not valid:
774
+ # deal with bug/deficiency in wx.DateTime:
775
+ try:
776
+ if wxdt.Format('%p') not in ('AM', 'PM') and checkTime in (5,8):
777
+ # couldn't parse the AM/PM field
778
+ raise ValueError('cannot convert string "%s" to valid time for the current locale; please use 24hr time instead' % value)
779
+ else:
780
+ ## dbg(indent=0, suspend=0)
781
+ raise ValueError('cannot convert string "%s" to valid time' % value)
782
+ except:
783
+ raise ValueError('cannot convert string "%s" to valid time for the current locale; please use 24hr time instead' % value)
784
+
785
+ else:
786
+ if isinstance(value, wx.DateTime):
787
+ hour, minute, second = value.GetHour(), value.GetMinute(), value.GetSecond()
788
+ elif isinstance(value, wx.TimeSpan):
789
+ totalseconds = value.GetSeconds()
790
+ hour = totalseconds / 3600
791
+ minute = totalseconds / 60 - (hour * 60)
792
+ second = totalseconds - ((hour * 3600) + (minute * 60))
793
+
794
+ elif accept_mx and isinstance(value, DateTime.DateTimeType):
795
+ hour, minute, second = value.hour, value.minute, value.second
796
+ elif accept_mx and isinstance(value, DateTime.DateTimeDeltaType):
797
+ hour, minute, second = value.hour, value.minute, value.second
798
+ else:
799
+ # Not a valid function argument
800
+ if accept_mx:
801
+ error = 'GetWxDateTime requires wxDateTime, mxDateTime or parsable time string, passed %s'% repr(value)
802
+ else:
803
+ error = 'GetWxDateTime requires wxDateTime or parsable time string, passed %s'% repr(value)
804
+ ## dbg(indent=0, suspend=0)
805
+ raise ValueError(error)
806
+
807
+ wxdt = wx.DateTime.FromDMY(1, 0, 1970)
808
+ wxdt.SetHour(hour)
809
+ wxdt.SetMinute(minute)
810
+ wxdt.SetSecond(second)
811
+
812
+ ## dbg('wxdt:', wxdt, indent=0, suspend=0)
813
+ return wxdt
814
+
815
+
816
+ def SetMxDateTime(self, mxdt):
817
+ """
818
+ Because SetValue can take an mx.DateTime, (if DateTime is importable),
819
+ this is now just an alias.
820
+ """
821
+ self.SetValue(value)
822
+
823
+
824
+ def GetMxDateTime(self, value=None):
825
+ """
826
+ Returns the value of the control as an mx.DateTime, with the date
827
+ portion set to January 1, 1970.
828
+ """
829
+ if value is None:
830
+ t = self.GetValue(as_mxDateTime=True)
831
+ else:
832
+ # Convert string 1st to wxDateTime, then use components, since
833
+ # mx' DateTime.Parser.TimeFromString() doesn't handle AM/PM:
834
+ wxdt = self.GetWxDateTime(value)
835
+ hour, minute, second = wxdt.GetHour(), wxdt.GetMinute(), wxdt.GetSecond()
836
+ t = DateTime.DateTime(1970,1,1) + DateTimeDelta(0, hour, minute, second)
837
+ return t
838
+
839
+
840
+ def SetMin(self, min=None):
841
+ """
842
+ Sets the minimum value of the control. If a value of None
843
+ is provided, then the control will have no explicit minimum value.
844
+ If the value specified is greater than the current maximum value,
845
+ then the function returns 0 and the minimum will not change from
846
+ its current setting. On success, the function returns 1.
847
+
848
+ If successful and the current value is lower than the new lower
849
+ bound, if the control is limited, the value will be automatically
850
+ adjusted to the new minimum value; if not limited, the value in the
851
+ control will be colored as invalid.
852
+
853
+ :param `min`: Minimum value for the control
854
+ :type `min`: integer or None
855
+
856
+ """
857
+ ## dbg('TimeCtrl::SetMin(%s)'% repr(min), indent=1)
858
+ if min is not None:
859
+ try:
860
+ min = self.GetWxDateTime(min)
861
+ self.__min = self._toGUI(min)
862
+ except:
863
+ ## dbg('exception occurred', indent=0)
864
+ return False
865
+ else:
866
+ self.__min = min
867
+
868
+ if self.IsLimited() and not self.IsInBounds():
869
+ self.SetLimited(self.__limited) # force limited value:
870
+ else:
871
+ self._CheckValid()
872
+ ret = True
873
+ ## dbg('ret:', ret, indent=0)
874
+ return ret
875
+
876
+
877
+ def GetMin(self, as_string = False):
878
+ """
879
+ Gets the minimum value of the control.
880
+ If None, it will return None. Otherwise it will return
881
+ the current minimum bound on the control, as a :class:`DateTime`
882
+ by default, or as a string if as_string argument is True.
883
+ """
884
+ ## dbg(suspend=1)
885
+ ## dbg('TimeCtrl::GetMin, as_string?', as_string, indent=1)
886
+ if self.__min is None:
887
+ ## dbg('(min is None)')
888
+ ret = self.__min
889
+ elif as_string:
890
+ ret = self.__min
891
+ ## dbg('ret:', ret)
892
+ else:
893
+ try:
894
+ ret = self.GetWxDateTime(self.__min)
895
+ except:
896
+ ## dbg(suspend=0)
897
+ ## dbg('exception occurred', indent=0)
898
+ raise
899
+ ## dbg('ret:', repr(ret))
900
+ ## dbg(indent=0, suspend=0)
901
+ return ret
902
+
903
+
904
+ def SetMax(self, max=None):
905
+ """
906
+ Sets the maximum value of the control. If a value of None
907
+ is provided, then the control will have no explicit maximum value.
908
+ If the value specified is less than the current minimum value, then
909
+ the function returns False and the maximum will not change from its
910
+ current setting. On success, the function returns True.
911
+
912
+ If successful and the current value is greater than the new upper
913
+ bound, if the control is limited the value will be automatically
914
+ adjusted to this maximum value; if not limited, the value in the
915
+ control will be colored as invalid.
916
+
917
+ :param `max`: Minimum value for the control
918
+ :type `max`: integer or None
919
+
920
+ """
921
+ ## dbg('TimeCtrl::SetMax(%s)' % repr(max), indent=1)
922
+ if max is not None:
923
+ try:
924
+ max = self.GetWxDateTime(max)
925
+ self.__max = self._toGUI(max)
926
+ except:
927
+ ## dbg('exception occurred', indent=0)
928
+ return False
929
+ else:
930
+ self.__max = max
931
+ ## dbg('max:', repr(self.__max))
932
+ if self.IsLimited() and not self.IsInBounds():
933
+ self.SetLimited(self.__limited) # force limited value:
934
+ else:
935
+ self._CheckValid()
936
+ ret = True
937
+ ## dbg('ret:', ret, indent=0)
938
+ return ret
939
+
940
+
941
+ def GetMax(self, as_string = False):
942
+ """
943
+ Gets the minimum value of the control.
944
+ If None, it will return None. Otherwise it will return
945
+ the current minimum bound on the control, as a :class:`DateTime`
946
+ by default, or as a string if as_string argument is True.
947
+ """
948
+ ## dbg(suspend=1)
949
+ ## dbg('TimeCtrl::GetMin, as_string?', as_string, indent=1)
950
+ if self.__max is None:
951
+ ## dbg('(max is None)')
952
+ ret = self.__max
953
+ elif as_string:
954
+ ret = self.__max
955
+ ## dbg('ret:', ret)
956
+ else:
957
+ try:
958
+ ret = self.GetWxDateTime(self.__max)
959
+ except:
960
+ ## dbg(suspend=0)
961
+ ## dbg('exception occurred', indent=0)
962
+ raise
963
+ ## dbg('ret:', repr(ret))
964
+ ## dbg(indent=0, suspend=0)
965
+ return ret
966
+
967
+
968
+ def SetBounds(self, min=None, max=None):
969
+ """
970
+ This function is a convenience function for setting the min and max
971
+ values at the same time. The function only applies the maximum bound
972
+ if setting the minimum bound is successful, and returns True
973
+ only if both operations succeed.
974
+
975
+ .. note:: Leaving out an argument will remove the corresponding bound.
976
+
977
+ :param `min`: Minimum value for the control
978
+ :type `min`: integer or None
979
+ :param `max`: Minimum value for the control
980
+ :type `max`: integer or None
981
+
982
+ """
983
+ ret = self.SetMin(min)
984
+ return ret and self.SetMax(max)
985
+
986
+
987
+ def GetBounds(self, as_string = False):
988
+ """
989
+ This function returns a two-tuple (min,max), indicating the
990
+ current bounds of the control. Each value can be None if
991
+ that bound is not set.
992
+ """
993
+ return (self.GetMin(as_string), self.GetMax(as_string))
994
+
995
+
996
+ def SetLimited(self, limited):
997
+ """
998
+ If called with a value of True, this function will cause the control
999
+ to limit the value to fall within the bounds currently specified.
1000
+ If the control's value currently exceeds the bounds, it will then
1001
+ be limited accordingly.
1002
+
1003
+ If called with a value of 0, this function will disable value
1004
+ limiting, but coloring of out-of-bounds values will still take
1005
+ place if bounds have been set for the control.
1006
+
1007
+ :param boolean `limited`: define value limiting
1008
+
1009
+ """
1010
+ ## dbg('TimeCtrl::SetLimited(%d)' % limited, indent=1)
1011
+ self.__limited = limited
1012
+
1013
+ if not limited:
1014
+ self.SetMaskParameters(validRequired = False)
1015
+ self._CheckValid()
1016
+ ## dbg(indent=0)
1017
+ return
1018
+
1019
+ ## dbg('requiring valid value')
1020
+ self.SetMaskParameters(validRequired = True)
1021
+
1022
+ min = self.GetMin()
1023
+ max = self.GetMax()
1024
+ if min is None or max is None:
1025
+ ## dbg('both bounds not set; no further action taken')
1026
+ return # can't limit without 2 bounds
1027
+
1028
+ elif not self.IsInBounds():
1029
+ # set value to the nearest bound:
1030
+ try:
1031
+ value = self.GetWxDateTime()
1032
+ except:
1033
+ ## dbg('exception occurred', indent=0)
1034
+ raise
1035
+
1036
+ if min <= max: # valid range doesn't span midnight
1037
+ ## dbg('min <= max')
1038
+ # which makes the "nearest bound" computation trickier...
1039
+
1040
+ # determine how long the "invalid" pie wedge is, and cut
1041
+ # this interval in half for comparison purposes:
1042
+
1043
+ # Note: relies on min and max and value date portions
1044
+ # always being the same.
1045
+ interval = (min + wx.TimeSpan(24, 0, 0, 0)) - max
1046
+
1047
+ half_interval = wx.TimeSpan(
1048
+ 0, # hours
1049
+ 0, # minutes
1050
+ interval.GetSeconds() / 2, # seconds
1051
+ 0) # msec
1052
+
1053
+ if value < min: # min is on next day, so use value on
1054
+ # "next day" for "nearest" interval calculation:
1055
+ cmp_value = value + wx.TimeSpan(24, 0, 0, 0)
1056
+ else: # "before midnight; ok
1057
+ cmp_value = value
1058
+
1059
+ if (cmp_value - max) > half_interval:
1060
+ ## dbg('forcing value to min (%s)' % min.FormatTime())
1061
+ self.SetValue(min)
1062
+ else:
1063
+ ## dbg('forcing value to max (%s)' % max.FormatTime())
1064
+ self.SetValue(max)
1065
+ else:
1066
+ ## dbg('max < min')
1067
+ # therefore max < value < min guaranteed to be true,
1068
+ # so "nearest bound" calculation is much easier:
1069
+ if (value - max) >= (min - value):
1070
+ # current value closer to min; pick that edge of pie wedge
1071
+ ## dbg('forcing value to min (%s)' % min.FormatTime())
1072
+ self.SetValue(min)
1073
+ else:
1074
+ ## dbg('forcing value to max (%s)' % max.FormatTime())
1075
+ self.SetValue(max)
1076
+
1077
+ ## dbg(indent=0)
1078
+
1079
+
1080
+ def IsLimited(self):
1081
+ """
1082
+ Returns True if the control is currently limiting the
1083
+ value to fall within any current bounds. *Note:* can
1084
+ be set even if there are no current bounds.
1085
+ """
1086
+ return self.__limited
1087
+
1088
+
1089
+ def IsInBounds(self, value=None):
1090
+ """
1091
+ Returns True if no value is specified and the current value
1092
+ of the control falls within the current bounds. As the clock
1093
+ is a "circle", both minimum and maximum bounds must be set for
1094
+ a value to ever be considered "out of bounds". This function can
1095
+ also be called with a value to see if that value would fall within
1096
+ the current bounds of the given control.
1097
+ """
1098
+ if value is not None:
1099
+ try:
1100
+ value = self.GetWxDateTime(value) # try to regularize passed value
1101
+ except ValueError:
1102
+ ## dbg('ValueError getting wxDateTime for %s' % repr(value), indent=0)
1103
+ raise
1104
+
1105
+ ## dbg('TimeCtrl::IsInBounds(%s)' % repr(value), indent=1)
1106
+ if self.__min is None or self.__max is None:
1107
+ ## dbg(indent=0)
1108
+ return True
1109
+
1110
+ elif value is None:
1111
+ try:
1112
+ value = self.GetWxDateTime()
1113
+ except:
1114
+ ## dbg('exception occurred', indent=0)
1115
+ raise
1116
+
1117
+ ## dbg('value:', value.FormatTime())
1118
+
1119
+ # Get wxDateTime representations of bounds:
1120
+ min = self.GetMin()
1121
+ max = self.GetMax()
1122
+
1123
+ midnight = wx.DateTime.FromDMY(1, 0, 1970)
1124
+ if min <= max: # they don't span midnight
1125
+ ret = min <= value <= max
1126
+
1127
+ else:
1128
+ # have to break into 2 tests; to be in bounds
1129
+ # either "min" <= value (<= midnight of *next day*)
1130
+ # or midnight <= value <= "max"
1131
+ ret = min <= value or (midnight <= value <= max)
1132
+ ## dbg('in bounds?', ret, indent=0)
1133
+ return ret
1134
+
1135
+
1136
+ def IsValid(self, value):
1137
+ """
1138
+ Can be used to determine if a given value would be a legal and
1139
+ in-bounds value for the control.
1140
+
1141
+ :param `value`: value to check
1142
+ """
1143
+ try:
1144
+ self.__validateValue(value)
1145
+ return True
1146
+ except ValueError:
1147
+ return False
1148
+
1149
+ def SetFormat(self, format):
1150
+ self.SetParameters(format=format)
1151
+
1152
+ def GetFormat(self):
1153
+ if self.__displaySeconds:
1154
+ if self.__fmt24hr: return '24HHMMSS'
1155
+ else: return 'HHMMSS'
1156
+ else:
1157
+ if self.__fmt24hr: return '24HHMM'
1158
+ else: return 'HHMM'
1159
+
1160
+ #-------------------------------------------------------------------------------------------------------------
1161
+ # these are private functions and overrides:
1162
+
1163
+
1164
+ def __OnTextChange(self, event=None):
1165
+ ## dbg('TimeCtrl::OnTextChange', indent=1)
1166
+
1167
+ # Allow Maskedtext base control to color as appropriate,
1168
+ # and Skip the EVT_TEXT event (if appropriate.)
1169
+ ##! WS: For some inexplicable reason, every wxTextCtrl.SetValue()
1170
+ ## call is generating two (2) EVT_TEXT events. (!)
1171
+ ## The the only mechanism I can find to mask this problem is to
1172
+ ## keep track of last value seen, and declare a valid EVT_TEXT
1173
+ ## event iff the value has actually changed. The masked edit
1174
+ ## OnTextChange routine does this, and returns True on a valid event,
1175
+ ## False otherwise.
1176
+ if not BaseMaskedTextCtrl._OnTextChange(self, event):
1177
+ return
1178
+
1179
+ ## dbg('firing TimeUpdatedEvent...')
1180
+ evt = TimeUpdatedEvent(self.GetId(), self.GetValue())
1181
+ evt.SetEventObject(self)
1182
+ self.GetEventHandler().ProcessEvent(evt)
1183
+ ## dbg(indent=0)
1184
+
1185
+
1186
+ def SetInsertionPoint(self, pos):
1187
+ """
1188
+ This override records the specified position and associated cell before
1189
+ calling base class' function. This is necessary to handle the optional
1190
+ spin button, because the insertion point is lost when the focus shifts
1191
+ to the spin button.
1192
+ """
1193
+ ## dbg('TimeCtrl::SetInsertionPoint', pos, indent=1)
1194
+ BaseMaskedTextCtrl.SetInsertionPoint(self, pos) # (causes EVT_TEXT event to fire)
1195
+ self.__posCurrent = self.GetInsertionPoint()
1196
+ ## dbg(indent=0)
1197
+
1198
+
1199
+ def SetSelection(self, sel_start, sel_to):
1200
+ ## dbg('TimeCtrl::SetSelection', sel_start, sel_to, indent=1)
1201
+
1202
+ # Adjust selection range to legal extent if not already
1203
+ if sel_start < 0:
1204
+ sel_start = 0
1205
+
1206
+ if self.__posCurrent != sel_start: # force selection and insertion point to match
1207
+ self.SetInsertionPoint(sel_start)
1208
+ cell_start, cell_end = self._FindField(sel_start)._extent
1209
+ if not cell_start <= sel_to <= cell_end:
1210
+ sel_to = cell_end
1211
+
1212
+ self.__bSelection = sel_start != sel_to
1213
+ BaseMaskedTextCtrl.SetSelection(self, sel_start, sel_to)
1214
+ ## dbg(indent=0)
1215
+
1216
+
1217
+ def __OnSpin(self, key):
1218
+ """
1219
+ This is the function that gets called in response to up/down arrow or
1220
+ bound spin button events.
1221
+ """
1222
+ self.__IncrementValue(key, self.__posCurrent) # changes the value
1223
+
1224
+ # Ensure adjusted control regains focus and has adjusted portion
1225
+ # selected:
1226
+ self.SetFocus()
1227
+ start, end = self._FindField(self.__posCurrent)._extent
1228
+ self.SetInsertionPoint(start)
1229
+ self.SetSelection(start, end)
1230
+ ## dbg('current position:', self.__posCurrent)
1231
+
1232
+
1233
+ def __OnSpinUp(self, event):
1234
+ """
1235
+ Event handler for any bound spin button on EVT_SPIN_UP;
1236
+ causes control to behave as if up arrow was pressed.
1237
+ """
1238
+ ## dbg('TimeCtrl::OnSpinUp', indent=1)
1239
+ self.__OnSpin(wx.WXK_UP)
1240
+ keep_processing = False
1241
+ ## dbg(indent=0)
1242
+ return keep_processing
1243
+
1244
+
1245
+ def __OnSpinDown(self, event):
1246
+ """
1247
+ Event handler for any bound spin button on EVT_SPIN_DOWN;
1248
+ causes control to behave as if down arrow was pressed.
1249
+ """
1250
+ ## dbg('TimeCtrl::OnSpinDown', indent=1)
1251
+ self.__OnSpin(wx.WXK_DOWN)
1252
+ keep_processing = False
1253
+ ## dbg(indent=0)
1254
+ return keep_processing
1255
+
1256
+
1257
+ def __OnChar(self, event):
1258
+ """
1259
+ Handler to explicitly look for ':' keyevents, and if found,
1260
+ clear the shiftDown field, so it will behave as forward tab.
1261
+ It then calls the base control's _OnChar routine with the modified
1262
+ event instance.
1263
+ """
1264
+ ## dbg('TimeCtrl::OnChar', indent=1)
1265
+ keycode = event.GetKeyCode()
1266
+ ## dbg('keycode:', keycode)
1267
+ if keycode == ord(':'):
1268
+ ## dbg('colon seen! removing shift attribute')
1269
+ event.shiftDown = False
1270
+ BaseMaskedTextCtrl._OnChar(self, event ) ## handle each keypress
1271
+ ## dbg(indent=0)
1272
+
1273
+
1274
+ def __OnSetToNow(self, event):
1275
+ """
1276
+ This is the key handler for '!' and 'c'; this allows the user to
1277
+ quickly set the value of the control to the current time.
1278
+ """
1279
+ self.SetValue(wx.DateTime.Now().FormatTime())
1280
+ keep_processing = False
1281
+ return keep_processing
1282
+
1283
+
1284
+ def __LimitSelection(self, event):
1285
+ """
1286
+ Event handler for motion events; this handler
1287
+ changes limits the selection to the new cell boundaries.
1288
+ """
1289
+ ## dbg('TimeCtrl::LimitSelection', indent=1)
1290
+ pos = self.GetInsertionPoint()
1291
+ self.__posCurrent = pos
1292
+ sel_start, sel_to = self.GetSelection()
1293
+ selection = sel_start != sel_to
1294
+ if selection:
1295
+ # only allow selection to end of current cell:
1296
+ start, end = self._FindField(sel_start)._extent
1297
+ if sel_to < pos: sel_to = start
1298
+ elif sel_to > pos: sel_to = end
1299
+
1300
+ ## dbg('new pos =', self.__posCurrent, 'select to ', sel_to)
1301
+ self.SetInsertionPoint(self.__posCurrent)
1302
+ self.SetSelection(self.__posCurrent, sel_to)
1303
+ if event: event.Skip()
1304
+ ## dbg(indent=0)
1305
+
1306
+
1307
+ def __IncrementValue(self, key, pos):
1308
+ ## dbg('TimeCtrl::IncrementValue', key, pos, indent=1)
1309
+ text = self.GetValue()
1310
+ field = self._FindField(pos)
1311
+ ## dbg('field: ', field._index)
1312
+ start, end = field._extent
1313
+ slice = text[start:end]
1314
+ if key == wx.WXK_UP: increment = 1
1315
+ else: increment = -1
1316
+
1317
+ if slice in ('A', 'P'):
1318
+ if slice == 'A': newslice = 'P'
1319
+ elif slice == 'P': newslice = 'A'
1320
+ newvalue = text[:start] + newslice + text[end:]
1321
+
1322
+ elif field._index == 0:
1323
+ # adjusting this field is trickier, as its value can affect the
1324
+ # am/pm setting. So, we use wxDateTime to generate a new value for us:
1325
+ # (Use a fixed date not subject to DST variations:)
1326
+ converter = wx.DateTime.FromDMY(1, 0, 1970)
1327
+ ## dbg('text: "%s"' % text)
1328
+ converter.ParseTime(text.strip())
1329
+ currenthour = converter.GetHour()
1330
+ ## dbg('current hour:', currenthour)
1331
+ newhour = (currenthour + increment) % 24
1332
+ ## dbg('newhour:', newhour)
1333
+ converter.SetHour(newhour)
1334
+ ## dbg('converter.GetHour():', converter.GetHour())
1335
+ newvalue = converter # take advantage of auto-conversion for am/pm in .SetValue()
1336
+
1337
+ else: # minute or second field; handled the same way:
1338
+ newslice = "%02d" % ((int(slice) + increment) % 60)
1339
+ newvalue = text[:start] + newslice + text[end:]
1340
+
1341
+ try:
1342
+ self.SetValue(newvalue)
1343
+
1344
+ except ValueError: # must not be in bounds:
1345
+ if not wx.Validator.IsSilent():
1346
+ wx.Bell()
1347
+ ## dbg(indent=0)
1348
+
1349
+
1350
+ def _toGUI( self, wxdt ):
1351
+ """
1352
+ This function takes a wxdt as an unambiguous representation of a time, and
1353
+ converts it to a string appropriate for the format of the control.
1354
+ """
1355
+ if self.__fmt24hr:
1356
+ if self.__displaySeconds: strval = wxdt.Format('%H:%M:%S')
1357
+ else: strval = wxdt.Format('%H:%M')
1358
+ else:
1359
+ if self.__displaySeconds: strval = wxdt.Format('%I:%M:%S %p')
1360
+ else: strval = wxdt.Format('%I:%M %p')
1361
+
1362
+ return strval
1363
+
1364
+
1365
+ def __validateValue( self, value ):
1366
+ """
1367
+ This function converts the value to a wxDateTime if not already one,
1368
+ does bounds checking and raises ValueError if argument is
1369
+ not a valid value for the control as currently specified.
1370
+ It is used by both the SetValue() and the IsValid() methods.
1371
+ """
1372
+ ## dbg('TimeCtrl::__validateValue(%s)' % repr(value), indent=1)
1373
+ if not value:
1374
+ ## dbg(indent=0)
1375
+ raise ValueError('%s not a valid time value' % repr(value))
1376
+
1377
+ valid = True # assume true
1378
+ try:
1379
+ value = self.GetWxDateTime(value) # regularize form; can generate ValueError if problem doing so
1380
+ except:
1381
+ ## dbg('exception occurred', indent=0)
1382
+ raise
1383
+
1384
+ if self.IsLimited() and not self.IsInBounds(value):
1385
+ ## dbg(indent=0)
1386
+ raise ValueError (
1387
+ 'value %s is not within the bounds of the control' % str(value) )
1388
+ ## dbg(indent=0)
1389
+ return value
1390
+
1391
+ #----------------------------------------------------------------------------
1392
+ # Test jig for TimeCtrl:
1393
+
1394
+ if __name__ == '__main__':
1395
+ import traceback
1396
+
1397
+ class TestPanel(wx.Panel):
1398
+ def __init__(self, parent, id,
1399
+ pos = wx.DefaultPosition, size = wx.DefaultSize,
1400
+ fmt24hr = 0, test_mx = 0,
1401
+ style = wx.TAB_TRAVERSAL ):
1402
+
1403
+ wx.Panel.__init__(self, parent, id, pos, size, style)
1404
+
1405
+ self.test_mx = test_mx
1406
+
1407
+ self.tc = TimeCtrl(self, 10, fmt24hr = fmt24hr)
1408
+ sb = wx.SpinButton( self, 20, wx.DefaultPosition, (-1,20), 0 )
1409
+ self.tc.BindSpinButton(sb)
1410
+
1411
+ sizer = wx.BoxSizer( wx.HORIZONTAL )
1412
+ sizer.Add( self.tc, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.TOP|wx.BOTTOM, 5 )
1413
+ sizer.Add( sb, 0, wx.ALIGN_CENTRE|wx.RIGHT|wx.TOP|wx.BOTTOM, 5 )
1414
+
1415
+ self.SetAutoLayout( True )
1416
+ self.SetSizer( sizer )
1417
+ sizer.Fit( self )
1418
+ sizer.SetSizeHints( self )
1419
+
1420
+ self.Bind(EVT_TIMEUPDATE, self.OnTimeChange, self.tc)
1421
+
1422
+ def OnTimeChange(self, event):
1423
+ ## dbg('OnTimeChange: value = ', event.GetValue())
1424
+ wxdt = self.tc.GetWxDateTime()
1425
+ ## dbg('wxdt =', wxdt.GetHour(), wxdt.GetMinute(), wxdt.GetSecond())
1426
+ if self.test_mx:
1427
+ mxdt = self.tc.GetMxDateTime()
1428
+ ## dbg('mxdt =', mxdt.hour, mxdt.minute, mxdt.second)
1429
+
1430
+
1431
+ class MyApp(wx.App):
1432
+ def OnInit(self):
1433
+ import sys
1434
+ fmt24hr = '24' in sys.argv
1435
+ test_mx = 'mx' in sys.argv
1436
+ try:
1437
+ frame = wx.Frame(None, -1, "TimeCtrl Test", (20,20), (100,100) )
1438
+ panel = TestPanel(frame, -1, (-1,-1), fmt24hr=fmt24hr, test_mx = test_mx)
1439
+ frame.Show(True)
1440
+ except:
1441
+ traceback.print_exc()
1442
+ return False
1443
+ return True
1444
+
1445
+ try:
1446
+ app = MyApp(0)
1447
+ app.MainLoop()
1448
+ except:
1449
+ traceback.print_exc()
1450
+ __i=0
1451
+
1452
+ ## CHANGELOG:
1453
+ ## ====================
1454
+ ## Version 1.3
1455
+ ## 1. Converted docstrings to reST format, added doc for ePyDoc.
1456
+ ## 2. Renamed helper functions, vars etc. not intended to be visible in public
1457
+ ## interface to code.
1458
+ ##
1459
+ ## Version 1.2
1460
+ ## 1. Changed parameter name display_seconds to displaySeconds, to follow
1461
+ ## other masked edit conventions.
1462
+ ## 2. Added format parameter, to remove need to use both fmt24hr and displaySeconds.
1463
+ ## 3. Changed inheritance to use BaseMaskedTextCtrl, to remove exposure of
1464
+ ## nonsensical parameter methods from the control, so it will work
1465
+ ## properly with Boa.