wxPython 4.3.2__cp315-cp315-win_amd64.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 (472) 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_amd64.pyd +0 -0
  7. wx/_aui.cp315-win_amd64.pyd +0 -0
  8. wx/_core.cp315-win_amd64.pyd +0 -0
  9. wx/_dataview.cp315-win_amd64.pyd +0 -0
  10. wx/_glcanvas.cp315-win_amd64.pyd +0 -0
  11. wx/_grid.cp315-win_amd64.pyd +0 -0
  12. wx/_html.cp315-win_amd64.pyd +0 -0
  13. wx/_html2.cp315-win_amd64.pyd +0 -0
  14. wx/_media.cp315-win_amd64.pyd +0 -0
  15. wx/_msw.cp315-win_amd64.pyd +0 -0
  16. wx/_propgrid.cp315-win_amd64.pyd +0 -0
  17. wx/_ribbon.cp315-win_amd64.pyd +0 -0
  18. wx/_richtext.cp315-win_amd64.pyd +0 -0
  19. wx/_stc.cp315-win_amd64.pyd +0 -0
  20. wx/_xml.cp315-win_amd64.pyd +0 -0
  21. wx/_xrc.cp315-win_amd64.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/libcairo-2.dll +0 -0
  330. wx/locale/af/LC_MESSAGES/wxstd.mo +0 -0
  331. wx/locale/an/LC_MESSAGES/wxstd.mo +0 -0
  332. wx/locale/ar/LC_MESSAGES/wxstd.mo +0 -0
  333. wx/locale/ca/LC_MESSAGES/wxstd.mo +0 -0
  334. wx/locale/ca@valencia/LC_MESSAGES/wxstd.mo +0 -0
  335. wx/locale/co/LC_MESSAGES/wxstd.mo +0 -0
  336. wx/locale/cs/LC_MESSAGES/wxstd.mo +0 -0
  337. wx/locale/da/LC_MESSAGES/wxstd.mo +0 -0
  338. wx/locale/de/LC_MESSAGES/wxstd.mo +0 -0
  339. wx/locale/el/LC_MESSAGES/wxstd.mo +0 -0
  340. wx/locale/es/LC_MESSAGES/wxstd.mo +0 -0
  341. wx/locale/eu/LC_MESSAGES/wxstd.mo +0 -0
  342. wx/locale/fa_IR/LC_MESSAGES/wxstd.mo +0 -0
  343. wx/locale/fi/LC_MESSAGES/wxstd.mo +0 -0
  344. wx/locale/fr/LC_MESSAGES/wxstd.mo +0 -0
  345. wx/locale/gl_ES/LC_MESSAGES/wxstd.mo +0 -0
  346. wx/locale/hi/LC_MESSAGES/wxstd.mo +0 -0
  347. wx/locale/hr/LC_MESSAGES/wxstd.mo +0 -0
  348. wx/locale/hu/LC_MESSAGES/wxstd.mo +0 -0
  349. wx/locale/id/LC_MESSAGES/wxstd.mo +0 -0
  350. wx/locale/it/LC_MESSAGES/wxstd.mo +0 -0
  351. wx/locale/ja/LC_MESSAGES/wxstd.mo +0 -0
  352. wx/locale/ka/LC_MESSAGES/wxstd.mo +0 -0
  353. wx/locale/ko_KR/LC_MESSAGES/wxstd.mo +0 -0
  354. wx/locale/lt/LC_MESSAGES/wxstd.mo +0 -0
  355. wx/locale/lv/LC_MESSAGES/wxstd.mo +0 -0
  356. wx/locale/ms/LC_MESSAGES/wxstd.mo +0 -0
  357. wx/locale/nb/LC_MESSAGES/wxstd.mo +0 -0
  358. wx/locale/ne/LC_MESSAGES/wxstd.mo +0 -0
  359. wx/locale/nl/LC_MESSAGES/wxstd.mo +0 -0
  360. wx/locale/pl/LC_MESSAGES/wxstd.mo +0 -0
  361. wx/locale/pt/LC_MESSAGES/wxstd.mo +0 -0
  362. wx/locale/pt_BR/LC_MESSAGES/wxstd.mo +0 -0
  363. wx/locale/ro/LC_MESSAGES/wxstd.mo +0 -0
  364. wx/locale/ru/LC_MESSAGES/wxstd.mo +0 -0
  365. wx/locale/sk/LC_MESSAGES/wxstd.mo +0 -0
  366. wx/locale/sl/LC_MESSAGES/wxstd.mo +0 -0
  367. wx/locale/sq/LC_MESSAGES/wxstd.mo +0 -0
  368. wx/locale/sr/LC_MESSAGES/wxstd.mo +0 -0
  369. wx/locale/sv/LC_MESSAGES/wxstd.mo +0 -0
  370. wx/locale/ta/LC_MESSAGES/wxstd.mo +0 -0
  371. wx/locale/tr/LC_MESSAGES/wxstd.mo +0 -0
  372. wx/locale/uk/LC_MESSAGES/wxstd.mo +0 -0
  373. wx/locale/vi/LC_MESSAGES/wxstd.mo +0 -0
  374. wx/locale/zh_CN/LC_MESSAGES/wxstd.mo +0 -0
  375. wx/locale/zh_TW/LC_MESSAGES/wxstd.mo +0 -0
  376. wx/media.py +30 -0
  377. wx/media.pyi +272 -0
  378. wx/msw.py +16 -0
  379. wx/msw.pyi +91 -0
  380. wx/propgrid.py +498 -0
  381. wx/propgrid.pyi +7427 -0
  382. wx/py/CHANGES.txt +796 -0
  383. wx/py/Py.ico +0 -0
  384. wx/py/PyAlaCarte.py +34 -0
  385. wx/py/PyAlaMode.py +34 -0
  386. wx/py/PyAlaModeTest.py +33 -0
  387. wx/py/PyCrust.ico +0 -0
  388. wx/py/PyCrust.py +78 -0
  389. wx/py/PyCrust_16.png +0 -0
  390. wx/py/PyCrust_32.png +0 -0
  391. wx/py/PyFilling.py +35 -0
  392. wx/py/PyShell.py +78 -0
  393. wx/py/PySlices.ico +0 -0
  394. wx/py/PySlices.py +98 -0
  395. wx/py/PySlicesShell.py +94 -0
  396. wx/py/PySlices_16.png +0 -0
  397. wx/py/PySlices_32.png +0 -0
  398. wx/py/PyWrap.py +52 -0
  399. wx/py/README.txt +77 -0
  400. wx/py/__init__.py +20 -0
  401. wx/py/buffer.py +136 -0
  402. wx/py/crust.py +403 -0
  403. wx/py/crustslices.py +403 -0
  404. wx/py/dispatcher.py +259 -0
  405. wx/py/document.py +37 -0
  406. wx/py/editor.py +844 -0
  407. wx/py/editwindow.py +316 -0
  408. wx/py/filling.py +358 -0
  409. wx/py/frame.py +976 -0
  410. wx/py/images.py +212 -0
  411. wx/py/interpreter.py +161 -0
  412. wx/py/introspect.py +402 -0
  413. wx/py/magic.py +98 -0
  414. wx/py/parse.py +134 -0
  415. wx/py/path.py +36 -0
  416. wx/py/pseudo.py +99 -0
  417. wx/py/shell.py +1579 -0
  418. wx/py/sliceshell.py +3805 -0
  419. wx/py/tests/test_interpreter.py +71 -0
  420. wx/py/tests/test_introspect.py +810 -0
  421. wx/py/tests/test_pseudo.py +70 -0
  422. wx/py/tests/test_version.py +36 -0
  423. wx/py/tests/testall.py +22 -0
  424. wx/py/version.py +7 -0
  425. wx/py.typed +0 -0
  426. wx/ribbon.py +48 -0
  427. wx/ribbon.pyi +3099 -0
  428. wx/richtext.py +141 -0
  429. wx/richtext.pyi +13581 -0
  430. wx/siplib.cp315-win_amd64.pyd +0 -0
  431. wx/siplib.pyi +19 -0
  432. wx/stc.py +59 -0
  433. wx/stc.pyi +9918 -0
  434. wx/svg/__init__.py +363 -0
  435. wx/svg/_nanosvg.cp315-win_amd64.pyd +0 -0
  436. wx/tools/__init__.py +18 -0
  437. wx/tools/dbg.py +268 -0
  438. wx/tools/genaxmodule.py +50 -0
  439. wx/tools/helpviewer.py +92 -0
  440. wx/tools/img2img.py +85 -0
  441. wx/tools/img2png.py +54 -0
  442. wx/tools/img2py.py +306 -0
  443. wx/tools/img2xpm.py +54 -0
  444. wx/tools/pywxrc.py +951 -0
  445. wx/tools/wxget.py +254 -0
  446. wx/tools/wxget_docs_demo.py +183 -0
  447. wx/wxbase334u_net_vc140_x64.dll +0 -0
  448. wx/wxbase334u_vc140_x64.dll +0 -0
  449. wx/wxbase334u_xml_vc140_x64.dll +0 -0
  450. wx/wxmsw334u_adv_vc140_x64.dll +0 -0
  451. wx/wxmsw334u_aui_vc140_x64.dll +0 -0
  452. wx/wxmsw334u_core_vc140_x64.dll +0 -0
  453. wx/wxmsw334u_gl_vc140_x64.dll +0 -0
  454. wx/wxmsw334u_html_vc140_x64.dll +0 -0
  455. wx/wxmsw334u_media_vc140_x64.dll +0 -0
  456. wx/wxmsw334u_propgrid_vc140_x64.dll +0 -0
  457. wx/wxmsw334u_qa_vc140_x64.dll +0 -0
  458. wx/wxmsw334u_ribbon_vc140_x64.dll +0 -0
  459. wx/wxmsw334u_richtext_vc140_x64.dll +0 -0
  460. wx/wxmsw334u_stc_vc140_x64.dll +0 -0
  461. wx/wxmsw334u_webview_vc140_x64.dll +0 -0
  462. wx/wxmsw334u_xrc_vc140_x64.dll +0 -0
  463. wx/xml.py +18 -0
  464. wx/xml.pyi +728 -0
  465. wx/xrc.py +68 -0
  466. wx/xrc.pyi +896 -0
  467. wxpython-4.3.2.dist-info/METADATA +71 -0
  468. wxpython-4.3.2.dist-info/RECORD +472 -0
  469. wxpython-4.3.2.dist-info/WHEEL +5 -0
  470. wxpython-4.3.2.dist-info/entry_points.txt +13 -0
  471. wxpython-4.3.2.dist-info/licenses/LICENSE.txt +610 -0
  472. wxpython-4.3.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1820 @@
1
+ # --------------------------------------------------------------------------- #
2
+ # FLOATSPIN Control wxPython IMPLEMENTATION
3
+ # Python Code By:
4
+ #
5
+ # Andrea Gavana, @ 16 Nov 2005
6
+ # Latest Revision: 03 Jan 2014, 23.00 GMT
7
+ #
8
+ #
9
+ # TODO List/Caveats
10
+ #
11
+ # 1. Ay Idea?
12
+ #
13
+ # For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
14
+ # Write To Me At:
15
+ #
16
+ # andrea.gavana@gmail.com
17
+ # andrea.gavana@maerskoil.com
18
+ #
19
+ # Or, Obviously, To The wxPython Mailing List!!!
20
+ #
21
+ # Tags: phoenix-port, unittest, documented
22
+ #
23
+ # End Of Comments
24
+ # --------------------------------------------------------------------------- #
25
+
26
+
27
+ """
28
+ :class:`~wx.lib.agw.floatspin.FloatSpin` implements a floating point :class:`SpinCtrl`.
29
+
30
+
31
+ Description
32
+ ===========
33
+
34
+ :class:`FloatSpin` implements a floating point :class:`SpinCtrl`. It is built using a custom
35
+ :class:`wx.Control`, composed by a :class:`TextCtrl` and a :class:`SpinButton`. In order to
36
+ correctly handle floating points numbers without rounding errors or non-exact
37
+ floating point representations, :class:`FloatSpin` uses the great :class:`FixedPoint` class
38
+ from Tim Peters.
39
+
40
+ What you can do:
41
+
42
+ - Set the number of representative digits for your floating point numbers;
43
+ - Set the floating point format (``%f``, ``%F``, ``%e``, ``%E``, ``%g``, ``%G``);
44
+ - Set the increment of every ``EVT_FLOATSPIN`` event;
45
+ - Set minimum, maximum values for :class:`FloatSpin` as well as its range;
46
+ - Change font and colour for the underline :class:`TextCtrl`.
47
+
48
+
49
+ Usage
50
+ =====
51
+
52
+ Usage example::
53
+
54
+ import wx
55
+ import wx.lib.agw.floatspin as FS
56
+
57
+ class MyFrame(wx.Frame):
58
+
59
+ def __init__(self, parent):
60
+
61
+ wx.Frame.__init__(self, parent, -1, "FloatSpin Demo")
62
+
63
+ panel = wx.Panel(self)
64
+
65
+ floatspin = FS.FloatSpin(panel, -1, pos=(50, 50), min_val=0, max_val=1,
66
+ increment=0.01, value=0.1, agwStyle=FS.FS_LEFT)
67
+ floatspin.SetFormat("%f")
68
+ floatspin.SetDigits(2)
69
+
70
+
71
+ # our normal wxApp-derived class, as usual
72
+
73
+ app = wx.App(0)
74
+
75
+ frame = MyFrame(None)
76
+ app.SetTopWindow(frame)
77
+ frame.Show()
78
+
79
+ app.MainLoop()
80
+
81
+
82
+
83
+ Events
84
+ ======
85
+
86
+ :class:`FloatSpin` catches 3 different types of events:
87
+
88
+ 1) Spin events: events generated by spinning up/down the spinbutton;
89
+ 2) Char events: playing with up/down arrows of the keyboard increase/decrease
90
+ the value of :class:`FloatSpin`;
91
+ 3) Mouse wheel event: using the wheel will change the value of :class:`FloatSpin`.
92
+
93
+ In addition, there are some other functionalities:
94
+
95
+ - It remembers the initial value as a default value, call :meth:`~FloatSpin.SetToDefaultValue`, or
96
+ press ``Esc`` to return to it;
97
+ - ``Shift`` + arrow = 2 * increment (or ``Shift`` + mouse wheel);
98
+ - ``Ctrl`` + arrow = 10 * increment (or ``Ctrl`` + mouse wheel);
99
+ - ``Alt`` + arrow = 100 * increment (or ``Alt`` + mouse wheel);
100
+ - Combinations of ``Shift``, ``Ctrl``, ``Alt`` increment the :class:`FloatSpin` value by the
101
+ product of the factors;
102
+ - ``PgUp`` & ``PgDn`` = 10 * increment * the product of the ``Shift``, ``Ctrl``, ``Alt``
103
+ factors;
104
+ - ``Space`` sets the control's value to it's last valid state.
105
+
106
+
107
+ Window Styles
108
+ =============
109
+
110
+ This class supports the following window styles:
111
+
112
+ =============== =========== ==================================================
113
+ Window Styles Hex Value Description
114
+ =============== =========== ==================================================
115
+ ``FS_READONLY`` 0x1 Sets :class:`FloatSpin` as read-only control.
116
+ ``FS_LEFT`` 0x2 Horizontally align the underlying :class:`TextCtrl` on the left.
117
+ ``FS_CENTRE`` 0x4 Horizontally align the underlying :class:`TextCtrl` on center.
118
+ ``FS_RIGHT`` 0x8 Horizontally align the underlying :class:`TextCtrl` on the right.
119
+ =============== =========== ==================================================
120
+
121
+
122
+ Events Processing
123
+ =================
124
+
125
+ This class processes the following events:
126
+
127
+ ================= ==================================================
128
+ Event Name Description
129
+ ================= ==================================================
130
+ ``EVT_FLOATSPIN`` Emitted when the user changes the value of :class:`FloatSpin`, either with the mouse or with the keyboard.
131
+ ================= ==================================================
132
+
133
+
134
+ License And Version
135
+ ===================
136
+
137
+ :class:`FloatSpin` control is distributed under the wxPython license.
138
+
139
+ Latest revision: Andrea Gavana @ 03 Jan 2014, 23.00 GMT
140
+
141
+ Version 1.0
142
+
143
+
144
+ Backward Incompatibilities
145
+ ==========================
146
+
147
+ Modifications to allow `min_val` or `max_val` to be ``None`` done by:
148
+
149
+ James Bigler,
150
+ SCI Institute, University of Utah,
151
+ March 14, 2007
152
+
153
+ :note: Note that the changes I made will break backward compatibility,
154
+ because I changed the contructor's parameters from `min` / `max` to
155
+ `min_val` / `max_val` to be consistent with the other functions and to
156
+ eliminate any potential confusion with the built in `min` and `max`
157
+ functions.
158
+
159
+ You specify open ranges like this (you can equally do this in the
160
+ constructor)::
161
+
162
+ SetRange(min_val=1, max_val=None) # [1, ]
163
+ SetRange(min_val=None, max_val=0) # [ , 0]
164
+
165
+ or no range::
166
+
167
+ SetRange(min_val=None, max_val=None) # [ , ]
168
+
169
+ """
170
+
171
+
172
+ #----------------------------------------------------------------------
173
+ # Beginning Of FLOATSPIN wxPython Code
174
+ #----------------------------------------------------------------------
175
+
176
+ import wx
177
+ import locale
178
+ from math import ceil, floor
179
+
180
+ long = int
181
+
182
+ # Set The Styles For The Underline wx.TextCtrl
183
+ FS_READONLY = 1
184
+ """ Sets :class:`FloatSpin` as read-only control. """
185
+ FS_LEFT = 2
186
+ """ Horizontally align the underlying :class:`TextCtrl` on the left. """
187
+ FS_CENTRE = 4
188
+ """ Horizontally align the underlying :class:`TextCtrl` on center. """
189
+ FS_RIGHT = 8
190
+ """ Horizontally align the underlying :class:`TextCtrl` on the right. """
191
+
192
+ # Define The FloatSpin Event
193
+ wxEVT_FLOATSPIN = wx.NewEventType()
194
+
195
+ #-----------------------------------#
196
+ # FloatSpinEvent
197
+ #-----------------------------------#
198
+
199
+ EVT_FLOATSPIN = wx.PyEventBinder(wxEVT_FLOATSPIN, 1)
200
+ """ Emitted when the user changes the value of :class:`FloatSpin`, either with the mouse or""" \
201
+ """ with the keyboard. """
202
+
203
+ # ---------------------------------------------------------------------------- #
204
+ # Class FloatSpinEvent
205
+ # ---------------------------------------------------------------------------- #
206
+
207
+ class FloatSpinEvent(wx.CommandEvent):
208
+ """ This event will be sent when a ``EVT_FLOATSPIN`` event is mapped in the parent. """
209
+
210
+ def __init__(self, eventType, eventId=1, nSel=-1, nOldSel=-1):
211
+ """
212
+ Default class constructor.
213
+
214
+ :param `eventType`: the event type;
215
+ :param `eventId`: the event identifier;
216
+ :param `nSel`: the current selection;
217
+ :param `nOldSel`: the old selection.
218
+ """
219
+
220
+ wx.CommandEvent.__init__(self, eventType, eventId)
221
+ self._eventType = eventType
222
+
223
+
224
+ def SetPosition(self, pos):
225
+ """
226
+ Sets event position.
227
+
228
+ :param `pos`: an integer specyfing the event position.
229
+ """
230
+
231
+ self._position = pos
232
+
233
+
234
+ def GetPosition(self):
235
+ """ Returns event position. """
236
+
237
+ return self._position
238
+
239
+
240
+ #----------------------------------------------------------------------------
241
+ # FloatTextCtrl
242
+ #----------------------------------------------------------------------------
243
+
244
+
245
+ class FloatTextCtrl(wx.TextCtrl):
246
+ """
247
+ A class which holds a :class:`TextCtrl`, one of the two building blocks
248
+ of :class:`FloatSpin`.
249
+ """
250
+
251
+ def __init__(self, parent, id=wx.ID_ANY, value="", pos=wx.DefaultPosition,
252
+ size=wx.DefaultSize, style=wx.TE_NOHIDESEL | wx.TE_PROCESS_ENTER,
253
+ validator=wx.DefaultValidator,
254
+ name=wx.TextCtrlNameStr):
255
+ """
256
+ Default class constructor.
257
+ Used internally. Do not call directly this class in your code!
258
+
259
+ :param `parent`: the :class:`FloatTextCtrl` parent;
260
+ :param `id`: an identifier for the control: a value of -1 is taken to mean a default;
261
+ :param `value`: default text value;
262
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
263
+ chosen by either the windowing system or wxPython, depending on platform;
264
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
265
+ chosen by either the windowing system or wxPython, depending on platform;
266
+ :param `style`: the window style;
267
+ :param `validator`: the window validator;
268
+ :param `name`: the window name.
269
+
270
+ """
271
+
272
+ wx.TextCtrl.__init__(self, parent, id, value, pos, size, style, validator, name)
273
+
274
+ self._parent = parent
275
+ self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
276
+ self.Bind(wx.EVT_CHAR, self.OnChar)
277
+ self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
278
+
279
+
280
+ def OnDestroy(self, event):
281
+ """
282
+ Handles the ``wx.EVT_WINDOW_DESTROY`` event for :class:`FloatTextCtrl`.
283
+
284
+ :param `event`: a :class:`wx.WindowDestroyEvent` event to be processed.
285
+
286
+ :note: This method tries to correctly handle the control destruction under MSW.
287
+ """
288
+
289
+ if self._parent:
290
+ self._parent._textctrl = None
291
+ self._parent = None
292
+
293
+
294
+ def OnChar(self, event):
295
+ """
296
+ Handles the ``wx.EVT_CHAR`` event for :class:`FloatTextCtrl`.
297
+
298
+ :param `event`: a :class:`KeyEvent` event to be processed.
299
+ """
300
+
301
+ if self._parent:
302
+ self._parent.OnChar(event)
303
+
304
+
305
+ def OnKillFocus(self, event):
306
+ """
307
+ Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`FloatTextCtrl`.
308
+
309
+ :param `event`: a :class:`FocusEvent` event to be processed.
310
+
311
+ :note: This method synchronizes the :class:`SpinButton` and the :class:`TextCtrl`
312
+ when focus is lost.
313
+ """
314
+
315
+ if self._parent:
316
+ self._parent.SyncSpinToText(True)
317
+
318
+ event.Skip()
319
+
320
+
321
+ #---------------------------------------------------------------------------- #
322
+ # FloatSpin
323
+ # This Is The Main Class Implementation
324
+ # ---------------------------------------------------------------------------- #
325
+
326
+ class FloatSpin(wx.Control):
327
+ """
328
+ :class:`FloatSpin` implements a floating point :class:`SpinCtrl`. It is built using a custom
329
+ :class:`wx.Control`, composed by a :class:`TextCtrl` and a :class:`SpinButton`. In order to
330
+ correctly handle floating points numbers without rounding errors or non-exact
331
+ floating point representations, :class:`FloatSpin` uses the great :class:`FixedPoint` class
332
+ from Tim Peters.
333
+ """
334
+
335
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
336
+ size=wx.DefaultSize, style=0, value=0.0, min_val=None, max_val=None,
337
+ increment=1.0, digits=-1, agwStyle=FS_LEFT,
338
+ name="FloatSpin"):
339
+ """
340
+ Default class constructor.
341
+
342
+ :param `parent`: the :class:`FloatSpin` parent;
343
+ :param `id`: an identifier for the control: a value of -1 is taken to mean a default;
344
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
345
+ chosen by either the windowing system or wxPython, depending on platform;
346
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
347
+ chosen by either the windowing system or wxPython, depending on platform;
348
+ :param `style`: the window style;
349
+ :param `value`: is the current value for :class:`FloatSpin`;
350
+ :param `min_val`: the minimum value, ignored if ``None``;
351
+ :param `max_val`: the maximum value, ignored if ``None``;
352
+ :param `increment`: the increment for every :class:`FloatSpinEvent` event;
353
+ :param `digits`: number of representative digits for your floating point numbers;
354
+ :param `agwStyle`: one of the following bits:
355
+
356
+ =============== =========== ==================================================
357
+ Window Styles Hex Value Description
358
+ =============== =========== ==================================================
359
+ ``FS_READONLY`` 0x1 Sets :class:`FloatSpin` as read-only control.
360
+ ``FS_LEFT`` 0x2 Horizontally align the underlying :class:`TextCtrl` on the left.
361
+ ``FS_CENTRE`` 0x4 Horizontally align the underlying :class:`TextCtrl` on center.
362
+ ``FS_RIGHT`` 0x8 Horizontally align the underlying :class:`TextCtrl` on the right.
363
+ =============== =========== ==================================================
364
+
365
+ :param `name`: the window name.
366
+
367
+ """
368
+
369
+ wx.Control.__init__(self, parent, id, pos, size, style|wx.NO_BORDER|
370
+ wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_CHILDREN,
371
+ wx.DefaultValidator, name)
372
+
373
+ # Don't call SetRange here, because it will try to modify
374
+ # self._value whose value doesn't exist yet.
375
+ self.SetRangeDontClampValue(min_val, max_val)
376
+ self._value = self.ClampValue(FixedPoint(str(value), 20))
377
+ self._defaultvalue = self._value
378
+ self._increment = FixedPoint(str(increment), 20)
379
+ self._spinmodifier = FixedPoint(str(1.0), 20)
380
+ self._digits = digits
381
+ self._snapticks = False
382
+ self._spinbutton = None
383
+ self._textctrl = None
384
+ self._spinctrl_bestsize = wx.Size(-999, -999)
385
+
386
+ # start Philip Semanchuk addition
387
+ # The textbox & spin button are drawn slightly differently
388
+ # depending on the platform. The difference is most pronounced
389
+ # under OS X.
390
+ if "__WXMAC__" in wx.PlatformInfo:
391
+ self._gap = 8
392
+ self._spin_top = 3
393
+ self._text_left = 4
394
+ self._text_top = 4
395
+ elif "__WXMSW__" in wx.PlatformInfo:
396
+ self._gap = 1
397
+ self._spin_top = 0
398
+ self._text_left = 0
399
+ self._text_top = 0
400
+ else:
401
+ # GTK
402
+ self._gap = -1
403
+ self._spin_top = 0
404
+ self._text_left = 0
405
+ self._text_top = 0
406
+ # end Philip Semanchuk addition
407
+
408
+ self.SetLabel(name)
409
+ self.SetForegroundColour(parent.GetForegroundColour())
410
+
411
+ width = size[0]
412
+ height = size[1]
413
+ best_size = self.DoGetBestSize()
414
+
415
+ if width == -1:
416
+ width = best_size.GetWidth()
417
+ if height == -1:
418
+ height = best_size.GetHeight()
419
+
420
+ self._validkeycode = [43, 44, 45, 46, 69, 101, 127, 314]
421
+ self._validkeycode.extend(list(range(48, 58)))
422
+ self._validkeycode.extend([wx.WXK_RETURN, wx.WXK_TAB, wx.WXK_BACK,
423
+ wx.WXK_LEFT, wx.WXK_RIGHT])
424
+
425
+ self._spinbutton = wx.SpinButton(self, wx.ID_ANY, wx.DefaultPosition,
426
+ size=(-1, height),
427
+ style=wx.SP_ARROW_KEYS | wx.SP_VERTICAL |
428
+ wx.SP_WRAP)
429
+
430
+ txtstyle = wx.TE_NOHIDESEL | wx.TE_PROCESS_ENTER
431
+
432
+ if agwStyle & FS_RIGHT:
433
+ txtstyle = txtstyle | wx.TE_RIGHT
434
+ elif agwStyle & FS_CENTRE:
435
+ txtstyle = txtstyle | wx.TE_CENTER
436
+
437
+ if agwStyle & FS_READONLY:
438
+ txtstyle = txtstyle | wx.TE_READONLY
439
+
440
+ self._textctrl = FloatTextCtrl(self, wx.ID_ANY, str(self._value),
441
+ wx.DefaultPosition,
442
+ (width-self._spinbutton.GetSize().GetWidth(), height),
443
+ txtstyle)
444
+
445
+ # start Philip Semanchuk addition
446
+ # Setting the textctrl's size in the ctor also sets its min size.
447
+ # But the textctrl is entirely controlled by the parent floatspin
448
+ # control and should accept whatever size its parent dictates, so
449
+ # here we tell it to forget its min size.
450
+ self._textctrl.SetMinSize(wx.DefaultSize)
451
+ # Setting the spin buttons's size in the ctor also sets its min size.
452
+ # Under OS X that results in a rendering artifact because spin buttons
453
+ # are a little shorter than textboxes.
454
+ # Setting the min size to the default allows OS X to draw the spin
455
+ # button correctly. However, Windows and KDE take the call to
456
+ # SetMinSize() as a cue to size the spin button taller than the
457
+ # textbox, so we avoid the call there.
458
+ if "__WXMAC__" in wx.PlatformInfo:
459
+ self._spinbutton.SetMinSize(wx.DefaultSize)
460
+ # end Philip Semanchuk addition
461
+
462
+ self._mainsizer = wx.BoxSizer(wx.HORIZONTAL)
463
+ # Ensure the spin button is shown, and the text widget takes
464
+ # all remaining free space
465
+ self._mainsizer.Add(self._textctrl, 1)
466
+ self._mainsizer.Add(self._spinbutton, 0)
467
+ self.SetSizer(self._mainsizer)
468
+ self._mainsizer.Layout()
469
+
470
+ self.SetFormat()
471
+ self.SetDigits(digits)
472
+
473
+ # set the value here without generating an event
474
+
475
+ decimal = locale.localeconv()["decimal_point"]
476
+ strs = ("%100." + str(self._digits) + self._textformat[1])%self._value
477
+ strs = strs.replace(".", decimal)
478
+
479
+ strs = strs.strip()
480
+ strs = self.ReplaceDoubleZero(strs)
481
+
482
+ self._textctrl.SetValue(strs)
483
+
484
+ if not (agwStyle & FS_READONLY):
485
+ self.Bind(wx.EVT_SPIN_UP, self.OnSpinUp)
486
+ self.Bind(wx.EVT_SPIN_DOWN, self.OnSpinDown)
487
+ self._spinbutton.Bind(wx.EVT_LEFT_DOWN, self.OnSpinMouseDown)
488
+
489
+ self._textctrl.Bind(wx.EVT_TEXT_ENTER, self.OnTextEnter)
490
+ self._textctrl.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
491
+ self._spinbutton.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
492
+
493
+ self.Bind(wx.EVT_SET_FOCUS, self.OnFocus)
494
+ self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
495
+ self.Bind(wx.EVT_SIZE, self.OnSize)
496
+
497
+ # start Philip Semanchuk move
498
+ self.SetInitialSize((width, height))
499
+ # end Philip Semanchuk move
500
+
501
+
502
+ def OnDestroy(self, event):
503
+ """
504
+ Handles the ``wx.EVT_WINDOW_DESTROY`` event for :class:`FloatSpin`.
505
+
506
+ :param `event`: a :class:`wx.WindowDestroyEvent` event to be processed.
507
+
508
+ :note: This method tries to correctly handle the control destruction under MSW.
509
+ """
510
+
511
+ # Null This Since MSW Sends KILL_FOCUS On Deletion
512
+ if self._textctrl:
513
+ self._textctrl._parent = None
514
+ self._textctrl.Destroy()
515
+ self._textctrl = None
516
+
517
+ self._spinbutton.Destroy()
518
+ self._spinbutton = None
519
+
520
+
521
+ def DoGetBestSize(self):
522
+ """
523
+ Gets the size which best suits the window: for a control, it would be the
524
+ minimal size which doesn't truncate the control, for a panel - the same
525
+ size as it would have after a call to `Fit()`.
526
+
527
+ :note: Overridden from :class:`wx.Control`.
528
+ """
529
+
530
+ if self._spinctrl_bestsize.x == -999:
531
+
532
+ spin = wx.SpinCtrl(self, -1)
533
+ self._spinctrl_bestsize = spin.GetBestSize()
534
+
535
+ # oops something went wrong, set to reasonable value
536
+ if self._spinctrl_bestsize.GetWidth() < 20:
537
+ self._spinctrl_bestsize.SetWidth(95)
538
+ if self._spinctrl_bestsize.GetHeight() < 10:
539
+ self._spinctrl_bestsize.SetHeight(22)
540
+
541
+ spin.Destroy()
542
+
543
+ return self._spinctrl_bestsize
544
+
545
+
546
+ def DoSendEvent(self):
547
+ """ Send the event to the parent. """
548
+
549
+ event = wx.CommandEvent(wx.wxEVT_COMMAND_SPINCTRL_UPDATED, self.GetId())
550
+ event.SetEventObject(self)
551
+ event.SetInt(int(self._value + 0.5))
552
+
553
+ if self._textctrl:
554
+ event.SetString(self._textctrl.GetValue())
555
+
556
+ self.GetEventHandler().ProcessEvent(event)
557
+
558
+ eventOut = FloatSpinEvent(wxEVT_FLOATSPIN, self.GetId())
559
+ eventOut.SetPosition(int(self._value + 0.5))
560
+ eventOut.SetEventObject(self)
561
+ self.GetEventHandler().ProcessEvent(eventOut)
562
+
563
+
564
+ def OnSpinMouseDown(self, event):
565
+ """
566
+ Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`FloatSpin`.
567
+
568
+ :param `event`: a :class:`MouseEvent` event to be processed.
569
+
570
+ :note: This method works on the underlying :class:`SpinButton`.
571
+ """
572
+
573
+ modifier = FixedPoint(str(1.0), 20)
574
+ if event.ShiftDown():
575
+ modifier = modifier*2.0
576
+ if event.ControlDown():
577
+ modifier = modifier*10.0
578
+ if event.AltDown():
579
+ modifier = modifier*100.0
580
+
581
+ self._spinmodifier = modifier
582
+
583
+ event.Skip()
584
+
585
+
586
+ def OnSpinUp(self, event):
587
+ """
588
+ Handles the ``wx.EVT_SPIN_UP`` event for :class:`FloatSpin`.
589
+
590
+ :param `event`: a :class:`SpinEvent` event to be processed.
591
+ """
592
+
593
+ if self._textctrl and self._textctrl.IsModified():
594
+ self.SyncSpinToText(False)
595
+
596
+ if self.InRange(self._value + self._increment*self._spinmodifier):
597
+
598
+ self._value = self._value + self._increment*self._spinmodifier
599
+ self.SetValue(self._value)
600
+ self.DoSendEvent()
601
+
602
+
603
+ def OnSpinDown(self, event):
604
+ """
605
+ Handles the ``wx.EVT_SPIN_DOWN`` event for :class:`FloatSpin`.
606
+
607
+ :param `event`: a :class:`SpinEvent` event to be processed.
608
+ """
609
+
610
+ if self._textctrl and self._textctrl.IsModified():
611
+ self.SyncSpinToText(False)
612
+
613
+ if self.InRange(self._value - self._increment*self._spinmodifier):
614
+
615
+ self._value = self._value - self._increment*self._spinmodifier
616
+ self.SetValue(self._value)
617
+ self.DoSendEvent()
618
+
619
+
620
+ def OnTextEnter(self, event):
621
+ """
622
+ Handles the ``wx.EVT_TEXT_ENTER`` event for :class:`FloatSpin`.
623
+
624
+ :param `event`: a :class:`KeyEvent` event to be processed.
625
+
626
+ :note: This method works on the underlying :class:`TextCtrl`.
627
+ """
628
+
629
+ self.SyncSpinToText(True)
630
+ event.Skip()
631
+
632
+
633
+ def OnChar(self, event):
634
+ """
635
+ Handles the ``wx.EVT_CHAR`` event for :class:`FloatSpin`.
636
+
637
+ :param `event`: a :class:`KeyEvent` event to be processed.
638
+
639
+ :note: This method works on the underlying :class:`TextCtrl`.
640
+ """
641
+
642
+ modifier = FixedPoint(str(1.0), 20)
643
+ if event.ShiftDown():
644
+ modifier = modifier*2.0
645
+ if event.ControlDown():
646
+ modifier = modifier*10.0
647
+ if event.AltDown():
648
+ modifier = modifier*100.0
649
+
650
+ keycode = event.GetKeyCode()
651
+
652
+ if keycode == wx.WXK_UP:
653
+
654
+ if self._textctrl and self._textctrl.IsModified():
655
+ self.SyncSpinToText(False)
656
+
657
+ self.SetValue(self._value + self._increment*modifier)
658
+ self.DoSendEvent()
659
+
660
+ elif keycode == wx.WXK_DOWN:
661
+
662
+ if self._textctrl and self._textctrl.IsModified():
663
+ self.SyncSpinToText(False)
664
+
665
+ self.SetValue(self._value - self._increment*modifier)
666
+ self.DoSendEvent()
667
+
668
+ elif keycode == wx.WXK_PAGEUP:
669
+
670
+ if self._textctrl and self._textctrl.IsModified():
671
+ self.SyncSpinToText(False)
672
+
673
+ self.SetValue(self._value + 10.0*self._increment*modifier)
674
+ self.DoSendEvent()
675
+
676
+ elif keycode == wx.WXK_PAGEDOWN:
677
+
678
+ if self._textctrl and self._textctrl.IsModified():
679
+ self.SyncSpinToText(False)
680
+
681
+ self.SetValue(self._value - 10.0*self._increment*modifier)
682
+ self.DoSendEvent()
683
+
684
+ elif keycode == wx.WXK_SPACE:
685
+
686
+ self.SetValue(self._value)
687
+ event.Skip(False)
688
+
689
+ elif keycode == wx.WXK_ESCAPE:
690
+
691
+ self.SetToDefaultValue()
692
+ self.DoSendEvent()
693
+
694
+ elif keycode == wx.WXK_TAB:
695
+
696
+ new_event = wx.NavigationKeyEvent()
697
+ new_event.SetEventObject(self.GetParent())
698
+ new_event.SetDirection(not event.ShiftDown())
699
+ # CTRL-TAB changes the (parent) window, i.e. switch notebook page
700
+ new_event.SetWindowChange(event.ControlDown())
701
+ new_event.SetCurrentFocus(self)
702
+ self.GetParent().GetEventHandler().ProcessEvent(new_event)
703
+
704
+ else:
705
+ if keycode not in self._validkeycode:
706
+ return
707
+
708
+ event.Skip()
709
+
710
+
711
+ def OnMouseWheel(self, event):
712
+ """
713
+ Handles the ``wx.EVT_MOUSEWHEEL`` event for :class:`FloatSpin`.
714
+
715
+ :param `event`: a :class:`MouseEvent` event to be processed.
716
+ """
717
+
718
+ modifier = FixedPoint(str(1.0), 20)
719
+ if event.ShiftDown():
720
+ modifier = modifier*2.0
721
+ if event.ControlDown():
722
+ modifier = modifier*10.0
723
+ if event.AltDown():
724
+ modifier = modifier*100.0
725
+
726
+ if self._textctrl and self._textctrl.IsModified():
727
+ self.SyncSpinToText(False)
728
+
729
+ if event.GetWheelRotation() > 0:
730
+ self.SetValue(self._value + self._increment*modifier)
731
+ self.DoSendEvent()
732
+
733
+ else:
734
+
735
+ self.SetValue(self._value - self._increment*modifier)
736
+ self.DoSendEvent()
737
+
738
+
739
+ def OnSize(self, event):
740
+ """
741
+ Handles the ``wx.EVT_SIZE`` event for :class:`FloatSpin`.
742
+
743
+ :param `event`: a :class:`wx.SizeEvent` event to be processed.
744
+
745
+ :note: This method resizes the text control and reposition the spin button when
746
+ resized.
747
+ """
748
+ # start Philip Semanchuk addition
749
+ event_width = event.GetSize().width
750
+
751
+ self._textctrl.SetPosition((self._text_left, self._text_top))
752
+
753
+ text_width, text_height = self._textctrl.GetSize()
754
+
755
+ spin_width, _ = self._spinbutton.GetSize()
756
+
757
+ text_width = event_width - (spin_width + self._gap + self._text_left)
758
+
759
+ self._textctrl.SetSize(wx.Size(text_width, event.GetSize().height))
760
+
761
+ # The spin button is always snug against the right edge of the
762
+ # control.
763
+ self._spinbutton.SetPosition((event_width - spin_width, self._spin_top))
764
+
765
+ event.Skip()
766
+ # end Philip Semanchuk addition
767
+
768
+
769
+ def ReplaceDoubleZero(self, strs):
770
+ """
771
+ Replaces the (somewhat) python ugly `+e000` with `+e00`.
772
+
773
+ :param `strs`: a string (possibly) containing a `+e00` substring.
774
+ """
775
+
776
+ if self._textformat not in ["%g", "%e", "%E", "%G"]:
777
+ return strs
778
+
779
+ if strs.find("e+00") >= 0:
780
+ strs = strs.replace("e+00", "e+0")
781
+ elif strs.find("e-00") >= 0:
782
+ strs = strs.replace("e-00", "e-0")
783
+ elif strs.find("E+00") >= 0:
784
+ strs = strs.replace("E+00", "E+0")
785
+ elif strs.find("E-00") >= 0:
786
+ strs = strs.replace("E-00", "E-0")
787
+
788
+ return strs
789
+
790
+
791
+ def SetValue(self, value):
792
+ """
793
+ Sets the :class:`FloatSpin` value.
794
+
795
+ :param `value`: the new value.
796
+ """
797
+ if not self._textctrl or not self.InRange(value):
798
+ return
799
+
800
+ if self._snapticks and self._increment != 0.0:
801
+
802
+ finite, snap_value = self.IsFinite(value)
803
+
804
+ if not finite: # FIXME What To Do About A Failure?
805
+
806
+ if (snap_value - floor(snap_value) < ceil(snap_value) - snap_value):
807
+ value = self._defaultvalue + floor(snap_value)*self._increment
808
+ else:
809
+ value = self._defaultvalue + ceil(snap_value)*self._increment
810
+
811
+ decimal = locale.localeconv()["decimal_point"]
812
+ strs = ("%100." + str(self._digits) + self._textformat[1])%value
813
+ strs = strs.replace(".", decimal)
814
+ strs = strs.strip()
815
+ strs = self.ReplaceDoubleZero(strs)
816
+
817
+ if value != self._value or strs != self._textctrl.GetValue():
818
+
819
+ self._textctrl.SetValue(strs)
820
+ self._textctrl.DiscardEdits()
821
+ self._value = value
822
+
823
+
824
+ def GetValue(self):
825
+ """ Returns the :class:`FloatSpin` value. """
826
+
827
+ return float(self._value)
828
+
829
+
830
+ def SetRangeDontClampValue(self, min_val, max_val):
831
+ """
832
+ Sets the allowed range.
833
+
834
+ :param `min_val`: the minimum value for :class:`FloatSpin`. If it is ``None`` it is
835
+ ignored;
836
+ :param `max_val`: the maximum value for :class:`FloatSpin`. If it is ``None`` it is
837
+ ignored.
838
+
839
+ :note: This method doesn't modify the current value.
840
+ """
841
+
842
+ if (min_val is not None):
843
+ self._min = FixedPoint(str(min_val), 20)
844
+ else:
845
+ self._min = None
846
+ if (max_val is not None):
847
+ self._max = FixedPoint(str(max_val), 20)
848
+ else:
849
+ self._max = None
850
+
851
+
852
+ def SetRange(self, min_val, max_val):
853
+ """
854
+ Sets the allowed range.
855
+
856
+ :param `min_val`: the minimum value for :class:`FloatSpin`. If it is ``None`` it is
857
+ ignored;
858
+ :param `max_val`: the maximum value for :class:`FloatSpin`. If it is ``None`` it is
859
+ ignored.
860
+
861
+ :note: This method doesn't modify the current value.
862
+
863
+ :note: You specify open ranges like this (you can equally do this in the
864
+ constructor)::
865
+
866
+ SetRange(min_val=1, max_val=None)
867
+ SetRange(min_val=None, max_val=0)
868
+
869
+
870
+ or no range::
871
+
872
+ SetRange(min_val=None, max_val=None)
873
+
874
+ """
875
+
876
+ self.SetRangeDontClampValue(min_val, max_val)
877
+
878
+ value = self.ClampValue(self._value)
879
+ if (value != self._value):
880
+ self.SetValue(value)
881
+
882
+
883
+ def ClampValue(self, var):
884
+ """
885
+ Clamps `var` between `_min` and `_max` depending if the range has
886
+ been specified.
887
+
888
+ :param `var`: the value to be clamped.
889
+
890
+ :return: A clamped copy of `var`.
891
+ """
892
+
893
+ if (self._min is not None):
894
+ if (var < self._min):
895
+ var = self._min
896
+ return var
897
+
898
+ if (self._max is not None):
899
+ if (var > self._max):
900
+ var = self._max
901
+
902
+ return var
903
+
904
+
905
+ def SetIncrement(self, increment):
906
+ """
907
+ Sets the increment for every ``EVT_FLOATSPIN`` event.
908
+
909
+ :param `increment`: a floating point number specifying the :class:`FloatSpin` increment.
910
+ """
911
+
912
+ if increment < 1./10.0**self._digits:
913
+ raise Exception("\nERROR: Increment Should Be Greater Or Equal To 1/(10**digits).")
914
+
915
+ self._increment = FixedPoint(str(increment), 20)
916
+ self.SetValue(self._value)
917
+
918
+
919
+ def GetIncrement(self):
920
+ """ Returns the increment for every ``EVT_FLOATSPIN`` event. """
921
+
922
+ return self._increment
923
+
924
+
925
+ def SetDigits(self, digits=-1):
926
+ """
927
+ Sets the number of digits to show.
928
+
929
+ :param `digits`: the number of digits to show. If `digits` < 0, :class:`FloatSpin`
930
+ tries to calculate the best number of digits based on input values passed
931
+ in the constructor.
932
+ """
933
+
934
+ if digits < 0:
935
+ incr = str(self._increment)
936
+ if incr.find(".") < 0:
937
+ digits = 0
938
+ else:
939
+ digits = len(incr[incr.find(".")+1:])
940
+
941
+ self._digits = digits
942
+
943
+ self.SetValue(self._value)
944
+
945
+
946
+ def GetDigits(self):
947
+ """ Returns the number of digits shown. """
948
+
949
+ return self._digits
950
+
951
+
952
+ def SetFormat(self, fmt="%f"):
953
+ """
954
+ Set the string format to use.
955
+
956
+ :param `fmt`: the new string format to use. One of the following strings:
957
+
958
+ ====== =================================
959
+ Format Description
960
+ ====== =================================
961
+ 'e' Floating point exponential format (lowercase)
962
+ 'E' Floating point exponential format (uppercase)
963
+ 'f' Floating point decimal format
964
+ 'F' Floating point decimal format
965
+ 'g' Floating point format. Uses lowercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise
966
+ 'G' Floating point format. Uses uppercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise
967
+ ====== =================================
968
+
969
+ """
970
+
971
+ if fmt not in ["%f", "%g", "%e", "%E", "%F", "%G"]:
972
+ raise Exception('\nERROR: Bad Float Number Format: ' + repr(fmt) + '. It Should Be ' \
973
+ 'One Of "%f", "%g", "%e", "%E", "%F", "%G"')
974
+
975
+ self._textformat = fmt
976
+
977
+ if self._digits < 0:
978
+ self.SetDigits()
979
+
980
+ self.SetValue(self._value)
981
+
982
+
983
+ def GetFormat(self):
984
+ """
985
+ Returns the string format in use.
986
+
987
+ :see: :meth:`~FloatSpin.SetFormat` for a list of valid string formats.
988
+ """
989
+
990
+ return self._textformat
991
+
992
+
993
+ def SetDefaultValue(self, defaultvalue):
994
+ """
995
+ Sets the :class:`FloatSpin` default value.
996
+
997
+ :param `defaultvalue`: a floating point value representing the new default
998
+ value for :class:`FloatSpin`.
999
+ """
1000
+
1001
+ if self.InRange(defaultvalue):
1002
+ self._defaultvalue = FixedPoint(str(defaultvalue), 20)
1003
+
1004
+
1005
+ def GetDefaultValue(self):
1006
+ """ Returns the :class:`FloatSpin` default value. """
1007
+
1008
+ return self._defaultvalue
1009
+
1010
+
1011
+ def IsDefaultValue(self):
1012
+ """ Returns whether the current value is the default value or not. """
1013
+
1014
+ return self._value == self._defaultvalue
1015
+
1016
+
1017
+ def SetToDefaultValue(self):
1018
+ """ Sets :class:`FloatSpin` value to its default value. """
1019
+
1020
+ self.SetValue(self._defaultvalue)
1021
+
1022
+
1023
+ def SetSnapToTicks(self, forceticks=True):
1024
+ """
1025
+ Force the value to always be divisible by the increment. Initially ``False``.
1026
+
1027
+ :param `forceticks`: ``True`` to force the snap to ticks option, ``False`` otherwise.
1028
+
1029
+ :note: This uses the default value as the basis, you will get strange results
1030
+ for very large differences between the current value and default value
1031
+ when the increment is very small.
1032
+ """
1033
+
1034
+ if self._snapticks != forceticks:
1035
+
1036
+ self._snapticks = forceticks
1037
+ self.SetValue(self._value)
1038
+
1039
+
1040
+ def GetSnapToTicks(self):
1041
+ """ Returns whether the snap to ticks option is active or not. """
1042
+
1043
+ return self._snapticks
1044
+
1045
+
1046
+ def OnFocus(self, event):
1047
+ """
1048
+ Handles the ``wx.EVT_SET_FOCUS`` event for :class:`FloatSpin`.
1049
+
1050
+ :param `event`: a :class:`FocusEvent` event to be processed.
1051
+ """
1052
+
1053
+ if self._textctrl:
1054
+ self._textctrl.SetFocus()
1055
+
1056
+ event.Skip()
1057
+
1058
+
1059
+ def OnKillFocus(self, event):
1060
+ """
1061
+ Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`FloatSpin`.
1062
+
1063
+ :param `event`: a :class:`FocusEvent` event to be processed.
1064
+ """
1065
+
1066
+ self.SyncSpinToText(True)
1067
+ event.Skip()
1068
+
1069
+
1070
+ def SyncSpinToText(self, send_event=True, force_valid=True):
1071
+ """
1072
+ Synchronize the underlying :class:`TextCtrl` with :class:`SpinButton`.
1073
+
1074
+ :param `send_event`: ``True`` to send a ``EVT_FLOATSPIN`` event, ``False``
1075
+ otherwise;
1076
+ :param `force_valid`: ``True`` to force a valid value (i.e. inside the
1077
+ provided range), ``False`` otherwise.
1078
+ """
1079
+
1080
+ if not self._textctrl:
1081
+ return
1082
+
1083
+ curr = self._textctrl.GetValue()
1084
+ curr = curr.strip()
1085
+ decimal = locale.localeconv()["decimal_point"]
1086
+ curr = curr.replace(decimal, ".")
1087
+
1088
+ if curr:
1089
+ try:
1090
+ curro = float(curr)
1091
+ curr = FixedPoint(curr, 20)
1092
+ except:
1093
+ self.SetValue(self._value)
1094
+ return
1095
+
1096
+ if force_valid or not self.HasRange() or self.InRange(curr):
1097
+
1098
+ if force_valid and self.HasRange():
1099
+
1100
+ curr = self.ClampValue(curr)
1101
+
1102
+ if self._value != curr:
1103
+ self.SetValue(curr)
1104
+
1105
+ if send_event:
1106
+ self.DoSendEvent()
1107
+
1108
+ elif force_valid:
1109
+
1110
+ # textctrl is out of sync, discard and reset
1111
+ self.SetValue(self.GetValue())
1112
+
1113
+
1114
+ def SetFont(self, font=None):
1115
+ """
1116
+ Sets the underlying :class:`TextCtrl` font.
1117
+
1118
+ :param `font`: a valid instance of :class:`wx.Font`.
1119
+ """
1120
+
1121
+ if font is None:
1122
+ font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
1123
+
1124
+ if not self._textctrl:
1125
+ return False
1126
+
1127
+ return self._textctrl.SetFont(font)
1128
+
1129
+
1130
+ def GetFont(self):
1131
+ """ Returns the underlying :class:`TextCtrl` font. """
1132
+
1133
+ if not self._textctrl:
1134
+ return self.GetFont()
1135
+
1136
+ return self._textctrl.GetFont()
1137
+
1138
+
1139
+ def GetMin(self):
1140
+ """
1141
+ Returns the minimum value for :class:`FloatSpin`. It can be a
1142
+ number or ``None`` if no minimum is present.
1143
+ """
1144
+
1145
+ return self._min
1146
+
1147
+
1148
+ def SetMin(self, min_val):
1149
+ """
1150
+ Sets the minimum value for :class:`FloatSpin`.
1151
+
1152
+ :param `min_val`: the minimum value for :class:`FloatSpin`. If it is ``None`` it is
1153
+ ignored.
1154
+
1155
+ :note: This method doesn't modify the current value.
1156
+ """
1157
+
1158
+ if (min_val is not None):
1159
+ self._min = FixedPoint(str(min_val), 20)
1160
+ else:
1161
+ self._min = None
1162
+
1163
+
1164
+ def GetMax(self):
1165
+ """
1166
+ Returns the maximum value for :class:`FloatSpin`. It can be a
1167
+ number or ``None`` if no minimum is present.
1168
+ """
1169
+
1170
+ return self._max
1171
+
1172
+
1173
+ def SetMax(self, max_val):
1174
+ """
1175
+ Sets the maximum value for :class:`FloatSpin`.
1176
+
1177
+ :param `max_val`: the maximum value for :class:`FloatSpin`. If it is ``None`` it is
1178
+ ignored.
1179
+
1180
+ :note: This method doesn't modify the current value.
1181
+ """
1182
+
1183
+ if (max_val is not None):
1184
+ self._max = FixedPoint(str(max_val), 20)
1185
+ else:
1186
+ self._max = None
1187
+
1188
+
1189
+ def HasRange(self):
1190
+ """ Returns whether :class:`FloatSpin` range has been set or not. """
1191
+
1192
+ return (self._min is not None) or (self._max is not None)
1193
+
1194
+
1195
+ def InRange(self, value):
1196
+ """
1197
+ Returns whether a value is inside :class:`FloatSpin` range.
1198
+
1199
+ :param `value`: the value to test.
1200
+ """
1201
+
1202
+ if (not self.HasRange()):
1203
+ return True
1204
+ if (self._min is not None):
1205
+ if (value < self._min):
1206
+ return False
1207
+ if (self._max is not None):
1208
+ if (value > self._max):
1209
+ return False
1210
+ return True
1211
+
1212
+
1213
+ def GetTextCtrl(self):
1214
+ """ Returns the underlying :class:`TextCtrl`. """
1215
+
1216
+ return self._textctrl
1217
+
1218
+
1219
+ def IsFinite(self, value):
1220
+ """
1221
+ Tries to determine if a value is finite or infinite/NaN.
1222
+
1223
+ :param `value`: the value to test.
1224
+ """
1225
+
1226
+ try:
1227
+ snap_value = (value - self._defaultvalue)/self._increment
1228
+ finite = True
1229
+ except:
1230
+ finite = False
1231
+ snap_value = None
1232
+
1233
+ return finite, snap_value
1234
+
1235
+
1236
+ DefaultValue = property(GetDefaultValue, SetDefaultValue)
1237
+ Digits = property(GetDigits, SetDigits)
1238
+ Font = property(GetFont, SetFont)
1239
+ Format = property(GetFormat, SetFormat)
1240
+ Increment = property(GetIncrement, SetIncrement)
1241
+ Min = property(GetMin, SetMin)
1242
+ Max = property(GetMax, SetMax)
1243
+ Value = property(GetValue, SetValue)
1244
+
1245
+
1246
+
1247
+ # Class FixedPoint, version 0.0.4.
1248
+ # Released to the public domain 28-Mar-2001,
1249
+ # by Tim Peters (tim.one@home.com).
1250
+
1251
+ # Provided as-is; use at your own risk; no warranty; no promises; enjoy!
1252
+
1253
+
1254
+ # 28-Mar-01 ver 0.0,4
1255
+ # Use repr() instead of str() inside __str__, because str(long) changed
1256
+ # since this was first written (used to produce trailing "L", doesn't
1257
+ # now).
1258
+ #
1259
+ # 09-May-99 ver 0,0,3
1260
+ # Repaired __sub__(FixedPoint, string); was blowing up.
1261
+ # Much more careful conversion of float (now best possible).
1262
+ # Implemented exact % and divmod.
1263
+ #
1264
+ # 14-Oct-98 ver 0,0,2
1265
+ # Added int, long, frac. Beefed up docs. Removed DECIMAL_POINT
1266
+ # and MINUS_SIGN globals to discourage bloating this class instead
1267
+ # of writing formatting wrapper classes (or subclasses)
1268
+ #
1269
+ # 11-Oct-98 ver 0,0,1
1270
+ # posted to c.l.py
1271
+
1272
+ __version__ = 0, 0, 4
1273
+
1274
+ # The default value for the number of decimal digits carried after the
1275
+ # decimal point. This only has effect at compile-time.
1276
+ DEFAULT_PRECISION = 2
1277
+ """ The default value for the number of decimal digits carried after the decimal point. This only has effect at compile-time. """
1278
+
1279
+ class FixedPoint(object):
1280
+ """
1281
+ FixedPoint objects support decimal arithmetic with a fixed number of
1282
+ digits (called the object's precision) after the decimal point. The
1283
+ number of digits before the decimal point is variable & unbounded.
1284
+
1285
+ The precision is user-settable on a per-object basis when a FixedPoint
1286
+ is constructed, and may vary across FixedPoint objects. The precision
1287
+ may also be changed after construction via `FixedPoint.set_precision(p)`.
1288
+ Note that if the precision of a FixedPoint is reduced via :meth:`FixedPoint.set_precision() <FixedPoint.set_precision>`,
1289
+ information may be lost to rounding.
1290
+
1291
+ Example::
1292
+
1293
+ >>> x = FixedPoint("5.55") # precision defaults to 2
1294
+ >>> print(x)
1295
+ 5.55
1296
+ >>> x.set_precision(1) # round to one fraction digit
1297
+ >>> print(x)
1298
+ 5.6
1299
+ >>> print(FixedPoint("5.55", 1)) # same thing setting to 1 in constructor
1300
+ 5.6
1301
+ >>> repr(x) # returns constructor string that reproduces object exactly
1302
+ "FixedPoint('5.6', 1)"
1303
+ >>>
1304
+
1305
+
1306
+ When :class:`FixedPoint` objects of different precision are combined via + - * /,
1307
+ the result is computed to the larger of the inputs' precisions, which also
1308
+ becomes the precision of the resulting :class:`FixedPoint` object. Example::
1309
+
1310
+ >>> print FixedPoint("3.42") + FixedPoint("100.005", 3)
1311
+ 103.425
1312
+ >>>
1313
+
1314
+
1315
+ When a :class:`FixedPoint` is combined with other numeric types (ints, floats,
1316
+ strings representing a number) via + - * /, then similarly the computation
1317
+ is carried out using -- and the result inherits -- the :class:`FixedPoint`'s
1318
+ precision. Example::
1319
+
1320
+ >>> print(FixedPoint(1) / 7)
1321
+ 0.14
1322
+ >>> print(FixedPoint(1, 30) / 7)
1323
+ 0.142857142857142857142857142857
1324
+ >>>
1325
+
1326
+
1327
+ The string produced by `str(x)` (implicitly invoked by `print`) always
1328
+ contains at least one digit before the decimal point, followed by a
1329
+ decimal point, followed by exactly `x.get_precision()` digits. If `x` is
1330
+ negative, `str(x)[0] == "-"`.
1331
+
1332
+ The :class:`FixedPoint` constructor can be passed an int, long, string, float,
1333
+ :class:`FixedPoint`, or any object convertible to a float via `float()` or to an
1334
+ integer via `int()`. Passing a precision is optional; if specified, the
1335
+ precision must be a non-negative int. There is no inherent limit on
1336
+ the size of the precision, but if very very large you'll probably run
1337
+ out of memory.
1338
+
1339
+ Note that conversion of floats to :class:`FixedPoint` can be surprising, and
1340
+ should be avoided whenever possible. Conversion from string is exact
1341
+ (up to final rounding to the requested precision), so is greatly
1342
+ preferred. Example::
1343
+
1344
+ >>> print(FixedPoint(1.1e30))
1345
+ 1099999999999999993725589651456.00
1346
+ >>> print(FixedPoint("1.1e30"))
1347
+ 1100000000000000000000000000000.00
1348
+ >>>
1349
+
1350
+
1351
+ """
1352
+
1353
+ # the exact value is self.n / 10**self.p;
1354
+ # self.n is a long; self.p is an int
1355
+
1356
+ def __init__(self, value=0, precision=DEFAULT_PRECISION):
1357
+ """
1358
+ Default class constructor.
1359
+
1360
+ :param `value`: the initial value;
1361
+ :param `precision`: must be an int >= 0, and defaults to ``DEFAULT_PRECISION``.
1362
+ """
1363
+
1364
+ self.n = self.p = 0
1365
+ self.set_precision(precision)
1366
+ p = self.p
1367
+
1368
+ if isinstance(value, type("42.3e5")):
1369
+ n, exp = _string2exact(value)
1370
+ # exact value is n*10**exp = n*10**(exp+p)/10**p
1371
+ effective_exp = exp + p
1372
+ if effective_exp > 0:
1373
+ n = n * _tento(effective_exp)
1374
+ elif effective_exp < 0:
1375
+ n = _roundquotient(n, _tento(-effective_exp))
1376
+ self.n = n
1377
+ return
1378
+
1379
+ if isinstance(value, int):
1380
+ self.n = int(value) * _tento(p)
1381
+ return
1382
+
1383
+ if isinstance(value, FixedPoint):
1384
+ temp = value.copy()
1385
+ temp.set_precision(p)
1386
+ self.n, self.p = temp.n, temp.p
1387
+ return
1388
+
1389
+ if isinstance(value, type(42.0)):
1390
+ # XXX ignoring infinities and NaNs and overflows for now
1391
+ import math
1392
+ f, e = math.frexp(abs(value))
1393
+ assert f == 0 or 0.5 <= f < 1.0
1394
+ # |value| = f * 2**e exactly
1395
+
1396
+ # Suck up CHUNK bits at a time; 28 is enough so that we suck
1397
+ # up all bits in 2 iterations for all known binary double-
1398
+ # precision formats, and small enough to fit in an int.
1399
+ CHUNK = 28
1400
+ top = 0
1401
+ # invariant: |value| = (top + f) * 2**e exactly
1402
+ while f:
1403
+ f = math.ldexp(f, CHUNK)
1404
+ digit = int(f)
1405
+ assert digit >> CHUNK == 0
1406
+ top = (top << CHUNK) | digit
1407
+ f = f - digit
1408
+ assert 0.0 <= f < 1.0
1409
+ e = e - CHUNK
1410
+
1411
+ # now |value| = top * 2**e exactly
1412
+ # want n such that n / 10**p = top * 2**e, or
1413
+ # n = top * 10**p * 2**e
1414
+ top = top * _tento(p)
1415
+ if e >= 0:
1416
+ n = top << e
1417
+ else:
1418
+ n = _roundquotient(top, 1 << -e)
1419
+ if value < 0:
1420
+ n = -n
1421
+ self.n = n
1422
+ return
1423
+
1424
+ if isinstance(value, type(42-42j)):
1425
+ raise TypeError("can't convert complex to FixedPoint: " +
1426
+ repr(value))
1427
+
1428
+ # can we coerce to a float?
1429
+ yes = 1
1430
+ try:
1431
+ asfloat = float(value)
1432
+ except:
1433
+ yes = 0
1434
+ if yes:
1435
+ self.__init__(asfloat, p)
1436
+ return
1437
+
1438
+ # similarly for long
1439
+ yes = 1
1440
+ try:
1441
+ aslong = int(value)
1442
+ except:
1443
+ yes = 0
1444
+ if yes:
1445
+ self.__init__(aslong, p)
1446
+ return
1447
+
1448
+ raise TypeError("can't convert to FixedPoint: " + repr(value))
1449
+
1450
+
1451
+ def get_precision(self):
1452
+ """
1453
+ Return the precision of this :class:`FixedPoint`.
1454
+
1455
+ :note: The precision is the number of decimal digits carried after
1456
+ the decimal point, and is an int >= 0.
1457
+ """
1458
+
1459
+ return self.p
1460
+
1461
+
1462
+ def set_precision(self, precision=DEFAULT_PRECISION):
1463
+ """
1464
+ Change the precision carried by this :class:`FixedPoint` to `precision`.
1465
+
1466
+ :param `precision`: must be an int >= 0, and defaults to
1467
+ ``DEFAULT_PRECISION``.
1468
+
1469
+ :note: If `precision` is less than this :class:`FixedPoint`'s current precision,
1470
+ information may be lost to rounding.
1471
+ """
1472
+
1473
+ try:
1474
+ p = int(precision)
1475
+ except:
1476
+ raise TypeError("precision not convertible to int: " +
1477
+ repr(precision))
1478
+ if p < 0:
1479
+ raise ValueError("precision must be >= 0: " + repr(precision))
1480
+
1481
+ if p > self.p:
1482
+ self.n = self.n * _tento(p - self.p)
1483
+ elif p < self.p:
1484
+ self.n = _roundquotient(self.n, _tento(self.p - p))
1485
+ self.p = p
1486
+
1487
+
1488
+ def __str__(self):
1489
+
1490
+ n, p = self.n, self.p
1491
+ i, f = divmod(abs(n), _tento(p))
1492
+ if p:
1493
+ frac = repr(f)[:-1]
1494
+ frac = "0" * (p - len(frac)) + frac
1495
+ else:
1496
+ frac = ""
1497
+ return "-"[:n<0] + \
1498
+ repr(i)[:-1] + \
1499
+ "." + frac
1500
+
1501
+
1502
+ def __repr__(self):
1503
+
1504
+ return "FixedPoint" + repr((str(self), self.p))
1505
+
1506
+
1507
+ def copy(self):
1508
+ """ Create a copy of the current :class:`FixedPoint`. """
1509
+
1510
+ return _mkFP(self.n, self.p)
1511
+
1512
+ __copy__ = __deepcopy__ = copy
1513
+
1514
+ def __eq__(self, other):
1515
+ if other is None:
1516
+ return False
1517
+ xn, yn, p = _norm(self, other)
1518
+ return not _cmp(xn, yn)
1519
+
1520
+ def __ge__(self, other):
1521
+ if other is None:
1522
+ return False
1523
+ xn, yn, p = _norm(self, other)
1524
+ return xn >= yn
1525
+
1526
+ def __le__(self, other):
1527
+ if other is None:
1528
+ return False
1529
+ xn, yn, p = _norm(self, other)
1530
+ return xn <= yn
1531
+
1532
+ def __hash__(self):
1533
+ # caution! == values must have equal hashes, and a FixedPoint
1534
+ # is essentially a rational in unnormalized form. There's
1535
+ # really no choice here but to normalize it, so hash is
1536
+ # potentially expensive.
1537
+ n, p = self.__reduce()
1538
+
1539
+ # Obscurity: if the value is an exact integer, p will be 0 now,
1540
+ # so the hash expression reduces to hash(n). So FixedPoints
1541
+ # that happen to be exact integers hash to the same things as
1542
+ # their int or long equivalents. This is Good. But if a
1543
+ # FixedPoint happens to have a value exactly representable as
1544
+ # a float, their hashes may differ. This is a teensy bit Bad.
1545
+ return hash(n) ^ hash(p)
1546
+
1547
+ def __nonzero__(self):
1548
+ return self.n != 0
1549
+
1550
+ def __bool__(self):
1551
+ return self.n != 0
1552
+
1553
+ def __neg__(self):
1554
+ return _mkFP(-self.n, self.p)
1555
+
1556
+ def __abs__(self):
1557
+ if self.n >= 0:
1558
+ return self.copy()
1559
+ else:
1560
+ return -self
1561
+
1562
+ def __add__(self, other):
1563
+ n1, n2, p = _norm(self, other)
1564
+ # n1/10**p + n2/10**p = (n1+n2)/10**p
1565
+ return _mkFP(n1 + n2, p)
1566
+
1567
+ __radd__ = __add__
1568
+
1569
+ def __sub__(self, other):
1570
+ if not isinstance(other, FixedPoint):
1571
+ other = FixedPoint(other, self.p)
1572
+ return self.__add__(-other)
1573
+
1574
+ def __rsub__(self, other):
1575
+ return (-self) + other
1576
+
1577
+ def __mul__(self, other):
1578
+ n1, n2, p = _norm(self, other)
1579
+ # n1/10**p * n2/10**p = (n1*n2/10**p)/10**p
1580
+ return _mkFP(_roundquotient(n1 * n2, _tento(p)), p)
1581
+
1582
+ __rmul__ = __mul__
1583
+
1584
+ def __div__(self, other):
1585
+ n1, n2, p = _norm(self, other)
1586
+ if n2 == 0:
1587
+ raise ZeroDivisionError("FixedPoint division")
1588
+ if n2 < 0:
1589
+ n1, n2 = -n1, -n2
1590
+ # n1/10**p / (n2/10**p) = n1/n2 = (n1*10**p/n2)/10**p
1591
+ return _mkFP(_roundquotient(n1 * _tento(p), n2), p)
1592
+
1593
+ def __rdiv__(self, other):
1594
+ n1, n2, p = _norm(self, other)
1595
+ return _mkFP(n2, p) / self
1596
+
1597
+ def __divmod__(self, other):
1598
+ n1, n2, p = _norm(self, other)
1599
+ if n2 == 0:
1600
+ raise ZeroDivisionError("FixedPoint modulo")
1601
+ # floor((n1/10**p)/(n2*10**p)) = floor(n1/n2)
1602
+ q = n1 / n2
1603
+ # n1/10**p - q * n2/10**p = (n1 - q * n2)/10**p
1604
+ return q, _mkFP(n1 - q * n2, p)
1605
+
1606
+ def __rdivmod__(self, other):
1607
+ n1, n2, p = _norm(self, other)
1608
+ return divmod(_mkFP(n2, p), self)
1609
+
1610
+ def __mod__(self, other):
1611
+ return self.__divmod__(other)[1]
1612
+
1613
+ def __rmod__(self, other):
1614
+ n1, n2, p = _norm(self, other)
1615
+ return _mkFP(n2, p).__mod__(self)
1616
+
1617
+ # caution! float can lose precision
1618
+ def __float__(self):
1619
+ n, p = self.__reduce()
1620
+ return float(n) / float(_tento(p))
1621
+
1622
+ # XXX should this round instead?
1623
+ # XXX note e.g. int(-1.9) == -1L and int(1.9) == 1L in Python
1624
+ # XXX note that __int__ inherits whatever __long__ does,
1625
+ # XXX and .frac() is affected too
1626
+ def __long__(self):
1627
+ answer = abs(self.n) // _tento(self.p)
1628
+ if self.n < 0:
1629
+ answer = -answer
1630
+ return answer
1631
+
1632
+ def __int__(self):
1633
+ return int(self.__long__())
1634
+
1635
+ def __lt__(self, other):
1636
+ if other is None:
1637
+ return 1
1638
+ xn, yn, p = _norm(self, other)
1639
+ return xn < yn
1640
+
1641
+ def __gt__(self, other):
1642
+ if other is None:
1643
+ return 1
1644
+ xn, yn, p = _norm(self, other)
1645
+ return xn > yn
1646
+
1647
+ def frac(self):
1648
+ """
1649
+ Returns fractional portion as a :class:`FixedPoint`.
1650
+
1651
+ :note: In :class:`FixedPoint`,
1652
+
1653
+ this equality holds true::
1654
+
1655
+ x = x.frac() + int(x)
1656
+
1657
+
1658
+ """
1659
+ return self - int(self)
1660
+
1661
+ # return n, p s.t. self == n/10**p and n % 10 != 0
1662
+ def __reduce(self):
1663
+ n, p = self.n, self.p
1664
+ if n == 0:
1665
+ p = 0
1666
+ while p and n % 10 == 0:
1667
+ p = p - 1
1668
+ n = n // 10
1669
+ return n, p
1670
+
1671
+ # return 10L**n
1672
+
1673
+ def _tento(n, cache={}):
1674
+ try:
1675
+ return cache[n]
1676
+ except KeyError:
1677
+ answer = cache[n] = 10 ** n
1678
+ return answer
1679
+
1680
+ # return xn, yn, p s.t.
1681
+ # p = max(x.p, y.p)
1682
+ # x = xn / 10**p
1683
+ # y = yn / 10**p
1684
+ #
1685
+ # x must be FixedPoint to begin with; if y is not FixedPoint,
1686
+ # it inherits its precision from x.
1687
+ #
1688
+ # Note that this is called a lot, so default-arg tricks are helpful.
1689
+
1690
+ def _norm(x, y, isinstance=isinstance, FixedPoint=FixedPoint,
1691
+ _tento=_tento):
1692
+ assert isinstance(x, FixedPoint)
1693
+ if not isinstance(y, FixedPoint):
1694
+ y = FixedPoint(y, x.p)
1695
+ xn, yn = x.n, y.n
1696
+ xp, yp = x.p, y.p
1697
+ if xp > yp:
1698
+ yn = yn * _tento(xp - yp)
1699
+ p = xp
1700
+ elif xp < yp:
1701
+ xn = xn * _tento(yp - xp)
1702
+ p = yp
1703
+ else:
1704
+ p = xp # same as yp
1705
+ return xn, yn, p
1706
+
1707
+ def _mkFP(n, p, FixedPoint=FixedPoint):
1708
+ f = FixedPoint()
1709
+ f.n = n
1710
+ f.p = p
1711
+ return f
1712
+
1713
+ # divide x by y, rounding to int via nearest-even
1714
+ # y must be > 0
1715
+ # XXX which rounding modes are useful?
1716
+
1717
+ def _roundquotient(x, y):
1718
+ assert y > 0
1719
+ n, leftover = divmod(x, y)
1720
+ c = _cmp(leftover << 1, y)
1721
+ # c < 0 <-> leftover < y/2, etc
1722
+ if c > 0 or (c == 0 and (n & 1) == 1):
1723
+ n = n + 1
1724
+ return n
1725
+
1726
+
1727
+ def _cmp(a, b):
1728
+ return a - b
1729
+
1730
+
1731
+ # crud for parsing strings
1732
+ import re
1733
+
1734
+ # There's an optional sign at the start, and an optional exponent
1735
+ # at the end. The exponent has an optional sign and at least one
1736
+ # digit. In between, must have either at least one digit followed
1737
+ # by an optional fraction, or a decimal point followed by at least
1738
+ # one digit. Yuck.
1739
+
1740
+ _parser = re.compile(r"""
1741
+ \s*
1742
+ (?P<sign>[-+])?
1743
+ (
1744
+ (?P<int>\d+) (\. (?P<frac>\d*))?
1745
+ |
1746
+ \. (?P<onlyfrac>\d+)
1747
+ )
1748
+ ([eE](?P<exp>[-+]? \d+))?
1749
+ \s* $
1750
+ """, re.VERBOSE).match
1751
+
1752
+ del re
1753
+
1754
+ # return n, p s.t. float string value == n * 10**p exactly
1755
+
1756
+ def _string2exact(s):
1757
+ m = _parser(s)
1758
+ if m is None:
1759
+ raise ValueError("can't parse as number: " + repr(s))
1760
+
1761
+ exp = m.group('exp')
1762
+ if exp is None:
1763
+ exp = 0
1764
+ else:
1765
+ exp = int(exp)
1766
+
1767
+ intpart = m.group('int')
1768
+ if intpart is None:
1769
+ intpart = "0"
1770
+ fracpart = m.group('onlyfrac')
1771
+ else:
1772
+ fracpart = m.group('frac')
1773
+ if fracpart is None or fracpart == "":
1774
+ fracpart = "0"
1775
+ assert intpart
1776
+ assert fracpart
1777
+
1778
+ i, f = int(intpart), int(fracpart)
1779
+ nfrac = len(fracpart)
1780
+ i = i * _tento(nfrac) + f
1781
+ exp = exp - nfrac
1782
+
1783
+ if m.group('sign') == "-":
1784
+ i = -i
1785
+
1786
+ return i, exp
1787
+
1788
+
1789
+ if __name__ == '__main__':
1790
+
1791
+ import wx
1792
+
1793
+ class MyFrame(wx.Frame):
1794
+
1795
+ def __init__(self, parent):
1796
+
1797
+ wx.Frame.__init__(self, parent, -1, "FloatSpin Demo")
1798
+
1799
+ panel = wx.Panel(self)
1800
+
1801
+ floatspin = FloatSpin(panel, -1, pos=(50, 50), min_val=0, max_val=1,
1802
+ increment=0.01, value=0.1, agwStyle=FS_LEFT)
1803
+ floatspin.Format = "%f"
1804
+ floatspin.Digits = 2
1805
+ floatspin.Min = -1
1806
+ floatspin.Max = 10
1807
+ floatspin.Increment = 0.02
1808
+ floatspin.Value = 0.2
1809
+
1810
+
1811
+ # our normal wxApp-derived class, as usual
1812
+
1813
+ app = wx.App(0)
1814
+
1815
+ frame = MyFrame(None)
1816
+ app.SetTopWindow(frame)
1817
+ frame.Show()
1818
+
1819
+ app.MainLoop()
1820
+