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,1885 @@
1
+ # --------------------------------------------------------------------------------- #
2
+ # RULERCTRL wxPython IMPLEMENTATION
3
+ #
4
+ # Andrea Gavana, @ 03 Nov 2006
5
+ # Latest Revision: 19 Dec 2012, 21.00 GMT
6
+ #
7
+ #
8
+ # TODO List
9
+ #
10
+ # 1. Any idea?
11
+ #
12
+ # For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
13
+ # Write To Me At:
14
+ #
15
+ # andrea.gavana@maerskoil.com
16
+ # andrea.gavana@gmail.com
17
+ #
18
+ # Or, Obviously, To The wxPython Mailing List!!!
19
+ #
20
+ # Tags: phoenix-port, unittest, documented, py3-port
21
+ #
22
+ # End Of Comments
23
+ # --------------------------------------------------------------------------------- #
24
+
25
+ """
26
+ :class:`~wx.lib.agw.rulerctrl.RulerCtrl` implements a ruler window that can be placed on top, bottom, left or right
27
+ to any wxPython widget.
28
+
29
+
30
+ Description
31
+ ===========
32
+
33
+ :class:`RulerCtrl` implements a ruler window that can be placed on top, bottom, left or right
34
+ to any wxPython widget. It is somewhat similar to the rulers you can find in text
35
+ editors software, though not so powerful.
36
+
37
+ :class:`RulerCtrl` has the following characteristics:
38
+
39
+ - Can be horizontal or vertical;
40
+ - 4 built-in formats: integer, real, time and linearDB formats;
41
+ - Units (as ``cm``, ``dB``, ``inches``) can be displayed together with the label values;
42
+ - Possibility to add a number of "paragraph indicators", small arrows that point at
43
+ the current indicator position;
44
+ - Customizable background colour, tick colour, label colour;
45
+ - Possibility to flip the ruler (i.e. changing the tick alignment);
46
+ - Changing individually the indicator colour (requires PIL at the moment);
47
+ - Different window borders are supported (``wx.STATIC_BORDER``, ``wx.SUNKEN_BORDER``,
48
+ ``wx.DOUBLE_BORDER``, ``wx.NO_BORDER``, ``wx.RAISED_BORDER``, ``wx.SIMPLE_BORDER``);
49
+ - Logarithmic scale available;
50
+ - Possibility to draw a thin line over a selected window when moving an indicator,
51
+ which emulates the text editors software.
52
+
53
+
54
+ And a lot more. See the demo for a review of the functionalities.
55
+
56
+
57
+ Usage
58
+ =====
59
+
60
+ Usage example::
61
+
62
+ import wx
63
+ import wx.lib.agw.rulerctrl as RC
64
+
65
+ class MyFrame(wx.Frame):
66
+
67
+ def __init__(self, parent):
68
+
69
+ wx.Frame.__init__(self, parent, -1, "RulerCtrl Demo")
70
+
71
+ panel = wx.Panel(self)
72
+
73
+ text = wx.TextCtrl(panel, -1, "Hello World! wxPython rules", style=wx.TE_MULTILINE)
74
+
75
+ ruler1 = RC.RulerCtrl(panel, -1, orient=wx.HORIZONTAL, style=wx.SUNKEN_BORDER)
76
+ ruler2 = RC.RulerCtrl(panel, -1, orient=wx.VERTICAL, style=wx.SUNKEN_BORDER)
77
+
78
+ mainsizer = wx.BoxSizer(wx.HORIZONTAL)
79
+ leftsizer = wx.BoxSizer(wx.VERTICAL)
80
+ bottomleftsizer = wx.BoxSizer(wx.HORIZONTAL)
81
+ topsizer = wx.BoxSizer(wx.HORIZONTAL)
82
+
83
+ leftsizer.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0)
84
+ topsizer.Add((39, 0), 0, wx.ADJUST_MINSIZE, 0)
85
+ topsizer.Add(ruler1, 1, wx.EXPAND, 0)
86
+ leftsizer.Add(topsizer, 0, wx.EXPAND, 0)
87
+
88
+ bottomleftsizer.Add((10, 0))
89
+ bottomleftsizer.Add(ruler2, 0, wx.EXPAND, 0)
90
+ bottomleftsizer.Add(text, 1, wx.EXPAND, 0)
91
+ leftsizer.Add(bottomleftsizer, 1, wx.EXPAND, 0)
92
+ mainsizer.Add(leftsizer, 3, wx.EXPAND, 0)
93
+
94
+ panel.SetSizer(mainsizer)
95
+
96
+
97
+ # our normal wxApp-derived class, as usual
98
+
99
+ app = wx.App(0)
100
+
101
+ frame = MyFrame(None)
102
+ app.SetTopWindow(frame)
103
+ frame.Show()
104
+
105
+ app.MainLoop()
106
+
107
+
108
+
109
+ Events
110
+ ======
111
+
112
+ :class:`RulerCtrl` implements the following events related to indicators:
113
+
114
+ - ``EVT_INDICATOR_CHANGING``: the user is about to change the position of one indicator;
115
+ - ``EVT_INDICATOR_CHANGED``: the user has changed the position of one indicator.
116
+
117
+
118
+ Supported Platforms
119
+ ===================
120
+
121
+ :class:`RulerCtrl` has been tested on the following platforms:
122
+ * Windows (Windows XP);
123
+ * Linux Ubuntu (Dapper 6.06)
124
+
125
+
126
+ Window Styles
127
+ =============
128
+
129
+ `No particular window styles are available for this class.`
130
+
131
+
132
+ Events Processing
133
+ =================
134
+
135
+ This class processes the following events:
136
+
137
+ ========================== ==================================================
138
+ Event Name Description
139
+ ========================== ==================================================
140
+ ``EVT_INDICATOR_CHANGED`` The user has changed the indicator value.
141
+ ``EVT_INDICATOR_CHANGING`` The user is about to change the indicator value.
142
+ ========================== ==================================================
143
+
144
+
145
+ License And Version
146
+ ===================
147
+
148
+ :class:`RulerCtrl` is distributed under the wxPython license.
149
+
150
+ Latest Revision: Andrea Gavana @ 19 Dec 2012, 21.00 GMT
151
+
152
+ Version 0.4
153
+
154
+ """
155
+
156
+ import io
157
+ import wx
158
+ import math
159
+ import zlib
160
+
161
+ # Try to import PIL, if possible.
162
+ # This is used only to change the colour for an indicator arrow.
163
+ _hasPIL = False
164
+ try:
165
+ import Image
166
+ _hasPIL = True
167
+ except:
168
+ pass
169
+
170
+ # Built-in formats
171
+ IntFormat = 1
172
+ """ Integer format. """
173
+ RealFormat = 2
174
+ """ Real format. """
175
+ TimeFormat = 3
176
+ """ Time format. """
177
+ LinearDBFormat = 4
178
+ """ Linear DB format. """
179
+ HHMMSS_Format = 5
180
+ """ HHMMSS format. """
181
+
182
+ # Events
183
+ wxEVT_INDICATOR_CHANGING = wx.NewEventType()
184
+ wxEVT_INDICATOR_CHANGED = wx.NewEventType()
185
+
186
+ EVT_INDICATOR_CHANGING = wx.PyEventBinder(wxEVT_INDICATOR_CHANGING, 2)
187
+ """ The user is about to change the indicator value. """
188
+ EVT_INDICATOR_CHANGED = wx.PyEventBinder(wxEVT_INDICATOR_CHANGED, 2)
189
+ """ The user has changed the indicator value. """
190
+
191
+
192
+ # Some accessor functions
193
+ #----------------------------------------------------------------------
194
+
195
+ def GetIndicatorData():
196
+ """ Returns the image indicator as a decompressed stream of characters. """
197
+
198
+ return zlib.decompress(
199
+ b'x\xda\x01x\x01\x87\xfe\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\n\x00\
200
+ \x00\x00\n\x08\x06\x00\x00\x00\x8d2\xcf\xbd\x00\x00\x00\x04sBIT\x08\x08\x08\
201
+ \x08|\x08d\x88\x00\x00\x01/IDAT\x18\x95m\xceO(\x83q\x1c\xc7\xf1\xf7\xef\xf9\
202
+ \xcd\xf6D6\xca\x1c\xc8\x9f\x14\'J-\xc4A9(9(-\xe5 \xed\xe4\xe2\xe2\xb2\x928\
203
+ \xb9\xec\xc2\x01\x17.\x0e\xe4\xe6B\xed\xb2\x1c\xdc$5\x97\xf9S\xb3\x14+\x0eO\
204
+ \xdb\xccZ\x9e\xfd\xf9\xba\x98E{\x1d\xbf\xbd\xfb\xf4U\x00\x18\x9d\xc3\xad\x1d\
205
+ \xa1+\xa7S\x15\xf8\xa1\xb5i\xbc\xc4\xd7\x0f\xca\xc5\xd82U3[\x97\xb1\x82\xc4S\
206
+ "\x89\xb4\xc8SZ\xc4\xb2E\xfa\x06CR)\x1c\x00\xb8\x8cb"-|\x94@\x01\x0e\r\xee&\
207
+ \xf8\x12\xc5\xdf\xd0\xd4\xf2\xf6i\x90/\x82\xe9\x82\xdb\xe72\xa7\xe7%\x92\x99\
208
+ \xdfA\xb4j\x9b]\xa5\xaek\xbag|\xaa\xdd\xca)\xceb\x10\xbe\x87\xacm VT\xd0N\
209
+ \x0f\xf9\xd7\x94\xd6\xde\xb1\xdd\xf9\xcdm_\x83\xdb\x81\x95W\x88\x02\xad\x159\
210
+ \x01\xcc!U2}\xa3$\x0f\x1dZR\xd1\xfd\xbb\x9b\xc7\x89\xc99\x7f\xb7\xb7\xd1\x00\
211
+ \xc0.B\xbe\xac\xc8\xbe?P\x8e\x8c\x1ccg\x02\xd5\x1f\x9a\x07\xf6\x82a[6.D\xfc\
212
+ \'"\x9e\xc0\xb5\xa0\xeb\xd7\xa8\xc9\xdd\xbf\xb3pdI\xefRD\xc0\x08\xd6\x8e*\\-\
213
+ +\xa0\x17\xff\x9f\xbf\x01{\xb5t\x9e\x99]a\x97\x00\x00\x00\x00IEND\xaeB`\x82G\
214
+ \xbf\xa8>' )
215
+
216
+
217
+ def GetIndicatorBitmap():
218
+ """ Returns the image indicator as a :class:`wx.Bitmap`. """
219
+
220
+ return wx.Bitmap(GetIndicatorImage())
221
+
222
+
223
+ def GetIndicatorImage():
224
+ """ Returns the image indicator as a :class:`wx.Image`. """
225
+
226
+ stream = io.BytesIO(GetIndicatorData())
227
+ return wx.Image(stream)
228
+
229
+
230
+ def MakePalette(tr, tg, tb):
231
+ """
232
+ Creates a palette to be applied on an image based on input colour.
233
+
234
+ :param `tr`: the red intensity of the input colour;
235
+ :param `tg`: the green intensity of the input colour;
236
+ :param `tb`: the blue intensity of the input colour.
237
+ """
238
+
239
+ l = []
240
+ for i in range(255):
241
+ l.extend([tr*i // 255, tg*i // 255, tb*i // 255])
242
+
243
+ return l
244
+
245
+
246
+ def ConvertWXToPIL(bmp):
247
+ """
248
+ Converts a :class:`wx.Image` into a PIL image.
249
+
250
+ :param `bmp`: an instance of :class:`wx.Image`.
251
+
252
+ :note: Requires PIL (Python Imaging Library), which can be downloaded from
253
+ http://www.pythonware.com/products/pil/
254
+ """
255
+
256
+ width = bmp.GetWidth()
257
+ height = bmp.GetHeight()
258
+ img = Image.frombytes("RGBA", (width, height), bmp.GetData())
259
+
260
+ return img
261
+
262
+
263
+ def ConvertPILToWX(pil, alpha=True):
264
+ """
265
+ Converts a PIL image into a :class:`wx.Image`.
266
+
267
+ :param `pil`: a PIL image;
268
+ :param `alpha`: ``True`` if the image contains alpha transparency, ``False``
269
+ otherwise.
270
+
271
+ :note: Requires PIL (Python Imaging Library), which can be downloaded from
272
+ http://www.pythonware.com/products/pil/
273
+ """
274
+
275
+ if alpha:
276
+ image = wx.Image(*pil.size)
277
+ image.SetData(pil.convert("RGB").tobytes())
278
+ image.SetAlpha(pil.convert("RGBA").tobytes()[3::4])
279
+ else:
280
+ image = wx.Image(pil.size[0], pil.size[1])
281
+ new_image = pil.convert('RGB')
282
+ data = new_image.tobytes()
283
+ image.SetData(data)
284
+
285
+ return image
286
+
287
+ # ---------------------------------------------------------------------------- #
288
+ # Class RulerCtrlEvent
289
+ # ---------------------------------------------------------------------------- #
290
+
291
+ class RulerCtrlEvent(wx.CommandEvent):
292
+ """
293
+ Represent details of the events that the :class:`RulerCtrl` object sends.
294
+ """
295
+
296
+ def __init__(self, eventType, eventId=1):
297
+ """
298
+ Default class constructor.
299
+
300
+ :param `eventType`: the event type;
301
+ :param `eventId`: the event identifier.
302
+ """
303
+
304
+ wx.CommandEvent.__init__(self, eventType, eventId)
305
+
306
+
307
+ def SetValue(self, value):
308
+ """
309
+ Sets the event value.
310
+
311
+ :param `value`: the new indicator position.
312
+ """
313
+
314
+ self._value = value
315
+
316
+
317
+ def GetValue(self):
318
+ """ Returns the event value. """
319
+
320
+ return self._value
321
+
322
+
323
+ def SetOldValue(self, oldValue):
324
+ """
325
+ Sets the event old value.
326
+
327
+ :param `value`: the old indicator position.
328
+ """
329
+
330
+ self._oldValue = oldValue
331
+
332
+
333
+ def GetOldValue(self):
334
+ """ Returns the event old value. """
335
+
336
+ return self._oldValue
337
+
338
+
339
+ # ---------------------------------------------------------------------------- #
340
+ # Class Label
341
+ # ---------------------------------------------------------------------------- #
342
+
343
+ class Label(object):
344
+ """
345
+ Auxiliary class. Just holds information about a label in :class:`RulerCtrl`.
346
+ """
347
+
348
+ def __init__(self, pos=-1, lx=-1, ly=-1, text=""):
349
+ """
350
+ Default class constructor.
351
+
352
+ :param `pos`: the indicator position;
353
+ :param `lx`: the indicator `x` coordinate;
354
+ :param `ly`: the indicator `y` coordinate;
355
+ :param `text`: the label text.
356
+ """
357
+
358
+ self.pos = pos
359
+ self.lx = lx
360
+ self.ly = ly
361
+ self.text = text
362
+
363
+
364
+ # ---------------------------------------------------------------------------- #
365
+ # Class Indicator
366
+ # ---------------------------------------------------------------------------- #
367
+
368
+ class Indicator(object):
369
+ """
370
+ This class holds all the information about a single indicator inside :class:`RulerCtrl`.
371
+
372
+ You should not call this class directly. Use::
373
+
374
+ ruler.AddIndicator(id, value)
375
+
376
+
377
+ to add an indicator to your :class:`RulerCtrl`.
378
+ """
379
+
380
+ def __init__(self, parent, id=wx.ID_ANY, value=0):
381
+ """
382
+ Default class constructor.
383
+
384
+ :param `parent`: the parent window, an instance of :class:`RulerCtrl`;
385
+ :param `id`: the indicator identifier;
386
+ :param `value`: the initial value of the indicator.
387
+ """
388
+
389
+ self._parent = parent
390
+ if id == wx.ID_ANY:
391
+ id = wx.NewIdRef()
392
+
393
+ self._id = id
394
+ self._colour = None
395
+
396
+ self.RotateImage(GetIndicatorImage())
397
+ self.SetValue(value)
398
+
399
+
400
+ def GetPosition(self):
401
+ """ Returns the position at which we should draw the indicator bitmap. """
402
+
403
+ orient = self._parent._orientation
404
+ flip = self._parent._flip
405
+ left, top, right, bottom = self._parent.GetBounds()
406
+ minval = self._parent._min
407
+ maxval = self._parent._max
408
+
409
+ value = self._value
410
+
411
+ if self._parent._log:
412
+ value = math.log10(value)
413
+ maxval = math.log10(maxval)
414
+ minval = math.log10(minval)
415
+
416
+ pos = float(value-minval)/abs(maxval - minval)
417
+
418
+ if orient == wx.HORIZONTAL:
419
+ xpos = int(pos*right) - self._img.GetWidth()//2
420
+ if flip:
421
+ ypos = top
422
+ else:
423
+ ypos = bottom - self._img.GetHeight()
424
+ else:
425
+ ypos = int(pos*bottom) - self._img.GetHeight()//2
426
+ if flip:
427
+ xpos = left
428
+ else:
429
+ xpos = right - self._img.GetWidth()
430
+
431
+ return xpos, ypos
432
+
433
+
434
+ def GetImageSize(self):
435
+ """ Returns the indicator bitmap size. """
436
+
437
+ return self._img.GetWidth(), self._img.GetHeight()
438
+
439
+
440
+ def GetRect(self):
441
+ """ Returns the indicator client rectangle. """
442
+
443
+ return self._rect
444
+
445
+
446
+ def RotateImage(self, img=None):
447
+ """
448
+ Rotates the default indicator bitmap.
449
+
450
+ :param `img`: if not ``None``, the indicator image.
451
+ """
452
+
453
+ if img is None:
454
+ img = GetIndicatorImage()
455
+
456
+ orient = self._parent._orientation
457
+ flip = self._parent._flip
458
+ left, top, right, bottom = self._parent.GetBounds()
459
+
460
+ if orient == wx.HORIZONTAL:
461
+ if flip:
462
+ img = img.Rotate(math.pi, (5, 5), True)
463
+ else:
464
+ if flip:
465
+ img = img.Rotate(-math.pi/2.0, (5, 5), True)
466
+ else:
467
+ img = img.Rotate(math.pi/2.0, (5, 5), True)
468
+
469
+ self._img = img
470
+
471
+
472
+ def SetValue(self, value):
473
+ """
474
+ Sets the indicator value.
475
+
476
+ :param `value`: the new indicator value.
477
+ """
478
+
479
+ if value < self._parent._min:
480
+ value = self._parent._min
481
+ if value > self._parent._max:
482
+ value = self._parent._max
483
+
484
+ self._value = value
485
+ self._rect = wx.Rect()
486
+
487
+ self._parent.Refresh()
488
+
489
+
490
+ def GetValue(self):
491
+ """ Returns the indicator value. """
492
+
493
+ return self._value
494
+
495
+
496
+ def Draw(self, dc):
497
+ """
498
+ Actually draws the indicator.
499
+
500
+ :param `dc`: an instance of :class:`wx.DC`.
501
+ """
502
+
503
+ xpos, ypos = self.GetPosition()
504
+ bmp = wx.Bitmap(self._img)
505
+ dc.DrawBitmap(bmp, xpos, ypos, True)
506
+ self._rect = wx.Rect(xpos, ypos, self._img.GetWidth(), self._img.GetHeight())
507
+
508
+
509
+ def GetId(self):
510
+ """ Returns the indicator id. """
511
+
512
+ return self._id
513
+
514
+
515
+ def SetColour(self, colour):
516
+ """
517
+ Sets the indicator colour.
518
+
519
+ :param `colour`: the new indicator colour, an instance of :class:`wx.Colour`.
520
+
521
+ :note: Requires PIL (Python Imaging Library), which can be downloaded from
522
+ http://www.pythonware.com/products/pil/
523
+ """
524
+
525
+ if not _hasPIL:
526
+ return
527
+
528
+ palette = colour.Red(), colour.Green(), colour.Blue()
529
+
530
+ img = ConvertWXToPIL(GetIndicatorBitmap())
531
+ l = MakePalette(*palette)
532
+ # The Palette Can Be Applied Only To "L" And "P" Images, Not "RGBA"
533
+ img = img.convert("L")
534
+ # Apply The New Palette
535
+ img.putpalette(l)
536
+ # Convert The Image Back To RGBA
537
+ img = img.convert("RGBA")
538
+ img = ConvertPILToWX(img)
539
+ self.RotateImage(img)
540
+
541
+ self._parent.Refresh()
542
+
543
+
544
+ # ---------------------------------------------------------------------------- #
545
+ # Class RulerCtrl
546
+ # ---------------------------------------------------------------------------- #
547
+
548
+ class RulerCtrl(wx.Panel):
549
+ """
550
+ :class:`RulerCtrl` implements a ruler window that can be placed on top, bottom, left or right
551
+ to any wxPython widget. It is somewhat similar to the rulers you can find in text
552
+ editors software, though not so powerful.
553
+ """
554
+
555
+ def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize,
556
+ style=wx.STATIC_BORDER, orient=wx.HORIZONTAL):
557
+ """
558
+ Default class constructor.
559
+
560
+ :param `parent`: parent window. Must not be ``None``;
561
+ :param `id`: window identifier. A value of -1 indicates a default value;
562
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
563
+ chosen by either the windowing system or wxPython, depending on platform;
564
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
565
+ chosen by either the windowing system or wxPython, depending on platform;
566
+ :param `style`: the window style;
567
+ :param `orient`: sets the orientation of the :class:`RulerCtrl`, and can be either
568
+ ``wx.HORIZONTAL`` of ``wx.VERTICAL``.
569
+ """
570
+
571
+ wx.Panel.__init__(self, parent, id, pos, size, style)
572
+
573
+ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
574
+ width, height = size
575
+
576
+ self._min = 0.0
577
+ self._max = 10.0
578
+ self._orientation = orient
579
+ self._spacing = 5
580
+ self._hassetspacing = False
581
+ self._format = RealFormat
582
+ self._flip = False
583
+ self._log = False
584
+ self._labeledges = False
585
+ self._units = ""
586
+
587
+ self._drawingparent = None
588
+ self._drawingpen = wx.Pen(wx.BLACK, 2)
589
+
590
+ self._left = -1
591
+ self._top = -1
592
+ self._right = -1
593
+ self._bottom = -1
594
+
595
+ self._major = 1
596
+ self._minor = 1
597
+
598
+ self._indicators = []
599
+ self._currentIndicator = None
600
+
601
+ fontsize = 10
602
+ if wx.Platform == "__WXMSW__":
603
+ fontsize = 8
604
+
605
+ self._minorfont = wx.Font(fontsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
606
+ self._majorfont = wx.Font(fontsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
607
+
608
+ self._bits = []
609
+ self._userbits = []
610
+ self._userbitlen = 0
611
+ self._tickmajor = True
612
+ self._tickminor = True
613
+ self._timeformat = IntFormat
614
+ self._labelmajor = True
615
+ self._labelminor = True
616
+ self._tickpen = wx.Pen(wx.BLACK)
617
+ self._textcolour = wx.BLACK
618
+ self._background = wx.WHITE
619
+
620
+ self._valid = False
621
+ self._state = 0
622
+
623
+ self._style = style
624
+ self._orientation = orient
625
+ wbound, hbound = self.CheckStyle()
626
+
627
+ if orient & wx.VERTICAL:
628
+ self.SetInitialSize((28, height))
629
+ else:
630
+ self.SetInitialSize((width, 28))
631
+
632
+ self.SetBounds(0, 0, wbound, hbound)
633
+
634
+ self.Bind(wx.EVT_SIZE, self.OnSize)
635
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
636
+ self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
637
+ self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseEvents)
638
+ self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, lambda evt: True)
639
+
640
+
641
+ def OnMouseEvents(self, event):
642
+ """
643
+ Handles the ``wx.EVT_MOUSE_EVENTS`` event for :class:`RulerCtrl`.
644
+
645
+ :param `event`: a :class:`MouseEvent` event to be processed.
646
+ """
647
+
648
+ if not self._indicators:
649
+ event.Skip()
650
+ return
651
+
652
+ mousePos = event.GetPosition()
653
+
654
+ if event.LeftDown():
655
+ self.CaptureMouse()
656
+ self.GetIndicator(mousePos)
657
+ self._mousePosition = mousePos
658
+ self.SetIndicatorValue(sendEvent=False)
659
+ elif event.Dragging() and self._currentIndicator:
660
+ self._mousePosition = mousePos
661
+ self.SetIndicatorValue()
662
+ elif event.LeftUp():
663
+ if self.HasCapture():
664
+ self.ReleaseMouse()
665
+ self.SetIndicatorValue(sendEvent=False)
666
+ if self._drawingparent:
667
+ self._drawingparent.Refresh()
668
+ self._currentIndicator = None
669
+ #else:
670
+ # self._currentIndicator = None
671
+
672
+ event.Skip()
673
+
674
+
675
+ def OnPaint(self, event):
676
+ """
677
+ Handles the ``wx.EVT_PAINT`` event for :class:`RulerCtrl`.
678
+
679
+ :param `event`: a :class:`PaintEvent` event to be processed.
680
+ """
681
+
682
+ dc = wx.BufferedPaintDC(self)
683
+ dc.SetBackground(wx.Brush(self._background))
684
+ dc.Clear()
685
+ self.Draw(dc)
686
+
687
+
688
+ def OnSize(self, event):
689
+ """
690
+ Handles the ``wx.EVT_SIZE`` event for :class:`RulerCtrl`.
691
+
692
+ :param `event`: a :class:`wx.SizeEvent` event to be processed.
693
+ """
694
+
695
+ width, height = event.GetSize()
696
+ self.SetBounds(0, 0, width, height)
697
+
698
+ self.Invalidate()
699
+ event.Skip()
700
+
701
+
702
+ def OnEraseBackground(self, event):
703
+ """
704
+ Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`RulerCtrl`.
705
+
706
+ :param `event`: a :class:`EraseEvent` event to be processed.
707
+
708
+ :note: This method is intentionally empty to reduce flicker.
709
+ """
710
+
711
+ pass
712
+
713
+
714
+ def SetIndicatorValue(self, sendEvent=True):
715
+ """
716
+ Sets the indicator value.
717
+
718
+ :param `sendEvent`: ``True`` to send a :class:`RulerCtrlEvent`, ``False`` otherwise.
719
+ """
720
+
721
+ if self._currentIndicator is None:
722
+ return
723
+
724
+ left, top, right, bottom = self.GetBounds()
725
+
726
+ x = self._mousePosition.x
727
+ y = self._mousePosition.y
728
+
729
+ maxvalue = self._max
730
+ minvalue = self._min
731
+
732
+ if self._log:
733
+ minvalue = math.log10(minvalue)
734
+ maxvalue = math.log10(maxvalue)
735
+
736
+ deltarange = abs(self._max - self._min)
737
+
738
+ if self._orientation == wx.HORIZONTAL: # only x moves
739
+ value = deltarange*float(x)/(right - left)
740
+ else:
741
+ value = deltarange*float(y)/(bottom - top)
742
+
743
+ value += minvalue
744
+
745
+ if self._log:
746
+ value = 10**value
747
+
748
+ if value < self._min or value > self._max:
749
+ return
750
+
751
+ self.DrawOnParent(self._currentIndicator)
752
+
753
+ if sendEvent:
754
+ event = RulerCtrlEvent(wxEVT_INDICATOR_CHANGING, self._currentIndicator.GetId())
755
+ event.SetOldValue(self._currentIndicator.GetValue())
756
+
757
+ event.SetValue(value)
758
+ event.SetEventObject(self)
759
+
760
+ if self.GetEventHandler().ProcessEvent(event):
761
+ self.DrawOnParent(self._currentIndicator)
762
+ return
763
+
764
+ self._currentIndicator.SetValue(value)
765
+
766
+ if sendEvent:
767
+ event.SetEventType(wxEVT_INDICATOR_CHANGED)
768
+ event.SetOldValue(value)
769
+ self.GetEventHandler().ProcessEvent(event)
770
+ self.DrawOnParent(self._currentIndicator)
771
+
772
+ self.Refresh()
773
+
774
+
775
+ def GetIndicator(self, mousePos):
776
+ """
777
+ Returns the indicator located at the mouse position `mousePos` (if any).
778
+
779
+ :param `mousePos`: the mouse position, an instance of :class:`wx.Point`.
780
+ """
781
+
782
+ for indicator in self._indicators:
783
+ if indicator.GetRect().Contains(mousePos):
784
+ self._currentIndicator = indicator
785
+ break
786
+
787
+
788
+ def CheckStyle(self):
789
+ """ Adjust the :class:`RulerCtrl` style accordingly to borders, units, etc..."""
790
+
791
+ width, height = self.GetSize()
792
+
793
+ if self._orientation & wx.HORIZONTAL:
794
+ if self._style & wx.NO_BORDER:
795
+ hbound = 28
796
+ wbound = width-1
797
+ elif self._style & wx.SIMPLE_BORDER:
798
+ hbound = 27
799
+ wbound = width-1
800
+ elif self._style & wx.STATIC_BORDER:
801
+ hbound = 26
802
+ wbound = width-3
803
+ elif self._style & wx.SUNKEN_BORDER:
804
+ hbound = 24
805
+ wbound = width-5
806
+ elif self._style & wx.RAISED_BORDER:
807
+ hbound = 22
808
+ wbound = width-7
809
+ elif self._style & wx.DOUBLE_BORDER:
810
+ hbound = 22
811
+ wbound = width-7
812
+ else:
813
+ if self._style & wx.NO_BORDER:
814
+ wbound = 28
815
+ hbound = height-1
816
+ elif self._style & wx.SIMPLE_BORDER:
817
+ wbound = 27
818
+ hbound = height-1
819
+ elif self._style & wx.STATIC_BORDER:
820
+ wbound = 26
821
+ hbound = height-3
822
+ elif self._style & wx.SUNKEN_BORDER:
823
+ wbound = 24
824
+ hbound = height-5
825
+ elif self._style & wx.RAISED_BORDER:
826
+ wbound = 22
827
+ hbound = height-7
828
+ elif self._style & wx.DOUBLE_BORDER:
829
+ wbound = 22
830
+ hbound = height-7
831
+
832
+ minText = self.LabelString(self._min, major=True)
833
+ maxText = self.LabelString(self._max, major=True)
834
+
835
+ dc = wx.ClientDC(self)
836
+ minWidth, minHeight = dc.GetTextExtent(minText)
837
+ maxWidth, maxHeight = dc.GetTextExtent(maxText)
838
+
839
+ maxWidth = max(maxWidth, minWidth)
840
+ maxHeight = max(maxHeight, minHeight)
841
+
842
+ if self._orientation == wx.HORIZONTAL:
843
+ if maxHeight + 4 > hbound:
844
+ hbound = maxHeight
845
+ self.SetInitialSize((-1, maxHeight + 4))
846
+ if self.GetContainingSizer():
847
+ self.GetContainingSizer().Layout()
848
+ else:
849
+ if maxWidth + 4 > wbound:
850
+ wbound = maxWidth
851
+ self.SetInitialSize((maxWidth + 4, -1))
852
+ if self.GetContainingSizer():
853
+ self.GetContainingSizer().Layout()
854
+
855
+ return wbound, hbound
856
+
857
+
858
+ def TickMajor(self, tick=True):
859
+ """
860
+ Sets whether the major ticks should be ticked or not.
861
+
862
+ :param `tick`: ``True`` to show major ticks, ``False`` otherwise.
863
+ """
864
+
865
+ if self._tickmajor != tick:
866
+ self._tickmajor = tick
867
+ self.Invalidate()
868
+
869
+
870
+ def TickMinor(self, tick=True):
871
+ """
872
+ Sets whether the minor ticks should be ticked or not.
873
+
874
+ :param `tick`: ``True`` to show minor ticks, ``False`` otherwise.
875
+ """
876
+
877
+ if self._tickminor != tick:
878
+ self._tickminor = tick
879
+ self.Invalidate()
880
+
881
+
882
+ def LabelMinor(self, label=True):
883
+ """
884
+ Sets whether the minor ticks should be labeled or not.
885
+
886
+ :param `label`: ``True`` to label minor ticks, ``False`` otherwise.
887
+ """
888
+
889
+ if self._labelminor != label:
890
+ self._labelminor = label
891
+ self.Invalidate()
892
+
893
+
894
+ def LabelMajor(self, label=True):
895
+ """
896
+ Sets whether the major ticks should be labeled or not.
897
+
898
+ :param `label`: ``True`` to label major ticks, ``False`` otherwise.
899
+ """
900
+
901
+ if self._labelmajor != label:
902
+ self._labelmajor = label
903
+ self.Invalidate()
904
+
905
+
906
+ def GetTimeFormat(self):
907
+ """ Returns the time format. """
908
+
909
+ return self._timeformat
910
+
911
+
912
+ def SetTimeFormat(self, format=TimeFormat):
913
+ """
914
+ Sets the time format.
915
+
916
+ :param `format`: the format used to display time values.
917
+ """
918
+
919
+ if self._timeformat != format:
920
+ self._timeformat = format
921
+ self.Invalidate()
922
+
923
+
924
+ def SetFormat(self, format):
925
+ """
926
+ Sets the format for :class:`RulerCtrl`.
927
+
928
+ :param `format`: the format used to display values in :class:`RulerCtrl`. This can be
929
+ one of the following bits:
930
+
931
+ ====================== ======= ==============================
932
+ Format Value Description
933
+ ====================== ======= ==============================
934
+ ``IntFormat`` 1 Integer format
935
+ ``RealFormat`` 2 Real format
936
+ ``TimeFormat`` 3 Time format
937
+ ``LinearDBFormat`` 4 Linear DB format
938
+ ``HHMMSS_Format`` 5 HHMMSS format
939
+ ====================== ======= ==============================
940
+ """
941
+
942
+ if self._format != format:
943
+ self._format = format
944
+ self.Invalidate()
945
+
946
+
947
+ def GetFormat(self):
948
+ """
949
+ Returns the format used to display values in :class:`RulerCtrl`.
950
+
951
+ :see: :meth:`RulerCtrl.SetFormat` for a list of possible formats.
952
+ """
953
+
954
+ return self._format
955
+
956
+
957
+ def SetLog(self, log=True):
958
+ """
959
+ Sets whether :class:`RulerCtrl` should have a logarithmic scale or not.
960
+
961
+ :param `log`: ``True`` to use a logarithmic scale, ``False`` to use a
962
+ linear one.
963
+ """
964
+
965
+ if self._log != log:
966
+ self._log = log
967
+ self.Invalidate()
968
+
969
+
970
+ def SetUnits(self, units):
971
+ """
972
+ Sets the units that should be displayed beside the labels.
973
+
974
+ :param `units`: the units that should be displayed beside the labels.
975
+ """
976
+
977
+ # Specify the name of the units (like "dB") if you
978
+ # want numbers like "1.6" formatted as "1.6 dB".
979
+
980
+ if self._units != units:
981
+ self._units = units
982
+ self.Invalidate()
983
+
984
+
985
+ def SetBackgroundColour(self, colour):
986
+ """
987
+ Sets the :class:`RulerCtrl` background colour.
988
+
989
+ :param `colour`: an instance of :class:`wx.Colour`.
990
+
991
+ :note: Overridden from :class:`Panel`.
992
+ """
993
+
994
+ self._background = colour
995
+ wx.Panel.SetBackgroundColour(self, colour)
996
+ self.Refresh()
997
+
998
+
999
+ def SetOrientation(self, orient=None):
1000
+ """
1001
+ Sets the :class:`RulerCtrl` orientation.
1002
+
1003
+ :param `orient`: can be ``wx.HORIZONTAL`` or ``wx.VERTICAL``.
1004
+ """
1005
+
1006
+ if orient is None:
1007
+ orient = wx.HORIZONTAL
1008
+
1009
+ if self._orientation != orient:
1010
+ self._orientation = orient
1011
+
1012
+ if self._orientation == wx.VERTICAL and not self._hassetspacing:
1013
+ self._spacing = 2
1014
+
1015
+ self.Invalidate()
1016
+
1017
+
1018
+ def SetRange(self, minVal, maxVal):
1019
+ """
1020
+ Sets the :class:`RulerCtrl` range.
1021
+
1022
+ :param `minVal`: the minimum value of :class:`RulerCtrl`;
1023
+ :param `maxVal`: the maximum value of :class:`RulerCtrl`.
1024
+ """
1025
+
1026
+ # For a horizontal ruler,
1027
+ # minVal is the value in the center of pixel "left",
1028
+ # maxVal is the value in the center of pixel "right".
1029
+
1030
+ if self._min != minVal or self._max != maxVal:
1031
+ self._min = minVal
1032
+ self._max = maxVal
1033
+ self.Invalidate()
1034
+
1035
+
1036
+ def SetSpacing(self, spacing):
1037
+ """
1038
+ Sets the :class:`RulerCtrl` spacing between labels.
1039
+
1040
+ :param `spacing`: the spacing between labels, in pixels.
1041
+ """
1042
+
1043
+ self._hassetspacing = True
1044
+
1045
+ if self._spacing != spacing:
1046
+ self._spacing = spacing
1047
+ self.Invalidate()
1048
+
1049
+
1050
+ def SetLabelEdges(self, labelEdges=True):
1051
+ """
1052
+ Sets whether the edge values should always be displayed or not.
1053
+
1054
+ :param `labelEdges`: ``True`` to always display edge labels, ``False`` otherwise/
1055
+ """
1056
+
1057
+ # If this is True, the edges of the ruler will always
1058
+ # receive a label. If not, the nearest round number is
1059
+ # labeled (which may or may not be the edge).
1060
+
1061
+ if self._labeledges != labelEdges:
1062
+ self._labeledges = labelEdges
1063
+ self.Invalidate()
1064
+
1065
+
1066
+ def SetFlip(self, flip=True):
1067
+ """
1068
+ Sets whether the orientation of the tick marks should be reversed.
1069
+
1070
+ :param `flip`: ``True`` to reverse the orientation of the tick marks, ``False``
1071
+ otherwise.
1072
+ """
1073
+
1074
+ # If this is True, the orientation of the tick marks
1075
+ # is reversed from the default eg. above the line
1076
+ # instead of below
1077
+
1078
+ if self._flip != flip:
1079
+ self._flip = flip
1080
+ self.Invalidate()
1081
+ for indicator in self._indicators:
1082
+ indicator.RotateImage()
1083
+
1084
+
1085
+ def SetFonts(self, minorFont, majorFont):
1086
+ """
1087
+ Sets the fonts for minor and major tick labels.
1088
+
1089
+ :param `minorFont`: the font used to draw minor ticks, a valid :class:`wx.Font` object;
1090
+ :param `majorFont`: the font used to draw major ticks, a valid :class:`wx.Font` object.
1091
+ """
1092
+
1093
+ self._minorfont = minorFont
1094
+ self._majorfont = majorFont
1095
+
1096
+ self.Invalidate()
1097
+
1098
+
1099
+ def SetTickPenColour(self, colour=wx.BLACK):
1100
+ """
1101
+ Sets the pen colour to draw the ticks.
1102
+
1103
+ :param `colour`: a valid :class:`wx.Colour` object.
1104
+ """
1105
+
1106
+ self._tickpen = wx.Pen(colour)
1107
+ self.Refresh()
1108
+
1109
+
1110
+ def SetLabelColour(self, colour=wx.BLACK):
1111
+ """
1112
+ Sets the labels colour.
1113
+
1114
+ :param `colour`: a valid :class:`wx.Colour` object.
1115
+ """
1116
+
1117
+ self._textcolour = colour
1118
+ self.Refresh()
1119
+
1120
+
1121
+ def OfflimitsPixels(self, start, end):
1122
+ """ Used internally. """
1123
+
1124
+ if not self._userbits:
1125
+ if self._orientation == wx.HORIZONTAL:
1126
+ self._length = self._right-self._left
1127
+ else:
1128
+ self._length = self._bottom-self._top
1129
+
1130
+ self._userbits = [0]*self._length
1131
+ self._userbitlen = self._length+1
1132
+
1133
+ if end < start:
1134
+ i = end
1135
+ end = start
1136
+ start = i
1137
+
1138
+ if start < 0:
1139
+ start = 0
1140
+ if end > self._length:
1141
+ end = self._length
1142
+
1143
+ for ii in range(start, end+1):
1144
+ self._userbits[ii] = 1
1145
+
1146
+
1147
+ def SetBounds(self, left, top, right, bottom):
1148
+ """
1149
+ Sets the bounds for :class:`RulerCtrl` (its client rectangle).
1150
+
1151
+ :param `left`: the left corner of the client rectangle;
1152
+ :param `top`: the top corner of the client rectangle;
1153
+ :param `right`: the right corner of the client rectangle;
1154
+ :param `bottom`: the bottom corner of the client rectangle.
1155
+ """
1156
+
1157
+ if self._left != left or self._top != top or self._right != right or \
1158
+ self._bottom != bottom:
1159
+
1160
+ self._left = left
1161
+ self._top = top
1162
+ self._right = right
1163
+ self._bottom = bottom
1164
+
1165
+ self.Invalidate()
1166
+
1167
+
1168
+ def GetBounds(self):
1169
+ """ Returns the :class:`RulerCtrl` bounds (its client rectangle). """
1170
+
1171
+ return self._left, self._top, self._right, self._bottom
1172
+
1173
+
1174
+ def AddIndicator(self, id, value):
1175
+ """
1176
+ Adds an indicator to :class:`RulerCtrl`. You should pass a unique `id` and a starting
1177
+ `value` for the indicator.
1178
+
1179
+ :param `id`: the indicator identifier;
1180
+ :param `value`: the indicator initial value.
1181
+ """
1182
+
1183
+ self._indicators.append(Indicator(self, id, value))
1184
+ self.Refresh()
1185
+
1186
+
1187
+ def SetIndicatorColour(self, id, colour=None):
1188
+ """
1189
+ Sets the indicator colour.
1190
+
1191
+ :param `id`: the indicator identifier;
1192
+ :param `colour`: a valid :class:`wx.Colour` object.
1193
+
1194
+ :note: This method requires PIL to change the image palette.
1195
+ """
1196
+
1197
+ if not _hasPIL:
1198
+ return
1199
+
1200
+ if colour is None:
1201
+ colour = wx.WHITE
1202
+
1203
+ for indicator in self._indicators:
1204
+ if indicator.GetId() == id:
1205
+ indicator.SetColour(colour)
1206
+ break
1207
+
1208
+
1209
+ def Invalidate(self):
1210
+ """ Invalidates the ticks calculations. """
1211
+
1212
+ self._valid = False
1213
+
1214
+ if self._orientation == wx.HORIZONTAL:
1215
+ self._length = self._right - self._left
1216
+ else:
1217
+ self._length = self._bottom - self._top
1218
+
1219
+ self._majorlabels = []
1220
+ self._minorlabels = []
1221
+ self._bits = []
1222
+ self._userbits = []
1223
+ self._userbitlen = 0
1224
+ self.Refresh()
1225
+
1226
+
1227
+ def FindLinearTickSizes(self, UPP):
1228
+ """ Used internally. """
1229
+
1230
+ # Given the dimensions of the ruler, the range of values it
1231
+ # has to display, and the format (i.e. Int, Real, Time),
1232
+ # figure out how many units are in one Minor tick, and
1233
+ # in one Major tick.
1234
+ #
1235
+ # The goal is to always put tick marks on nice round numbers
1236
+ # that are easy for humans to grok. This is the most tricky
1237
+ # with time.
1238
+
1239
+ # As a heuristic, we want at least 16 pixels
1240
+ # between each minor tick
1241
+ units = 16.0*abs(UPP)
1242
+
1243
+ self._digits = 0
1244
+
1245
+ if self._format == LinearDBFormat:
1246
+
1247
+ if units < 0.1:
1248
+ self._minor = 0.1
1249
+ self._major = 0.5
1250
+ return
1251
+
1252
+ if units < 1.0:
1253
+ self._minor = 1.0
1254
+ self._major = 6.0
1255
+ return
1256
+
1257
+ self._minor = 3.0
1258
+ self._major = 12.0
1259
+ return
1260
+
1261
+ elif self._format == IntFormat:
1262
+
1263
+ d = 1.0
1264
+ while 1:
1265
+ if units < d:
1266
+ self._minor = d
1267
+ self._major = d*5.0
1268
+ return
1269
+
1270
+ d = d*5.0
1271
+ if units < d:
1272
+ self._minor = d
1273
+ self._major = d*2.0
1274
+ return
1275
+
1276
+ d = 2.0*d
1277
+
1278
+ elif self._format == TimeFormat:
1279
+
1280
+ if units > 0.5:
1281
+ if units < 1.0: # 1 sec
1282
+ self._minor = 1.0
1283
+ self._major = 5.0
1284
+ return
1285
+
1286
+ if units < 5.0: # 5 sec
1287
+ self._minor = 5.0
1288
+ self._major = 15.0
1289
+ return
1290
+
1291
+ if units < 10.0:
1292
+ self._minor = 10.0
1293
+ self._major = 30.0
1294
+ return
1295
+
1296
+ if units < 15.0:
1297
+ self._minor = 15.0
1298
+ self._major = 60.0
1299
+ return
1300
+
1301
+ if units < 30.0:
1302
+ self._minor = 30.0
1303
+ self._major = 60.0
1304
+ return
1305
+
1306
+ if units < 60.0: # 1 min
1307
+ self._minor = 60.0
1308
+ self._major = 300.0
1309
+ return
1310
+
1311
+ if units < 300.0: # 5 min
1312
+ self._minor = 300.0
1313
+ self._major = 900.0
1314
+ return
1315
+
1316
+ if units < 600.0: # 10 min
1317
+ self._minor = 600.0
1318
+ self._major = 1800.0
1319
+ return
1320
+
1321
+ if units < 900.0: # 15 min
1322
+ self._minor = 900.0
1323
+ self._major = 3600.0
1324
+ return
1325
+
1326
+ if units < 1800.0: # 30 min
1327
+ self._minor = 1800.0
1328
+ self._major = 3600.0
1329
+ return
1330
+
1331
+ if units < 3600.0: # 1 hr
1332
+ self._minor = 3600.0
1333
+ self._major = 6*3600.0
1334
+ return
1335
+
1336
+ if units < 6*3600.0: # 6 hrs
1337
+ self._minor = 6*3600.0
1338
+ self._major = 24*3600.0
1339
+ return
1340
+
1341
+ if units < 24*3600.0: # 1 day
1342
+ self._minor = 24*3600.0
1343
+ self._major = 7*24*3600.0
1344
+ return
1345
+
1346
+ self._minor = 24.0*7.0*3600.0 # 1 week
1347
+ self._major = 24.0*7.0*3600.0
1348
+
1349
+ # Otherwise fall through to RealFormat
1350
+ # (fractions of a second should be dealt with
1351
+ # the same way as for RealFormat)
1352
+
1353
+ elif self._format == RealFormat:
1354
+
1355
+ d = 0.000001
1356
+ self._digits = 6
1357
+
1358
+ while 1:
1359
+ if units < d:
1360
+ self._minor = d
1361
+ self._major = d*5.0
1362
+ return
1363
+
1364
+ d = d*5.0
1365
+ if units < d:
1366
+ self._minor = d
1367
+ self._major = d*2.0
1368
+ return
1369
+
1370
+ d = d*2.0
1371
+ self._digits = self._digits - 1
1372
+
1373
+
1374
+ def LabelString(self, d, major=None):
1375
+ """ Used internally. """
1376
+
1377
+ # Given a value, turn it into a string according
1378
+ # to the current ruler format. The number of digits of
1379
+ # accuracy depends on the resolution of the ruler,
1380
+ # i.e. how far zoomed in or out you are.
1381
+
1382
+ s = ""
1383
+
1384
+ if d < 0.0 and d + self._minor > 0.0:
1385
+ d = 0.0
1386
+
1387
+ if self._format == IntFormat:
1388
+ s = "%d"%int(math.floor(d+0.5))
1389
+
1390
+ elif self._format == LinearDBFormat:
1391
+ if self._minor >= 1.0:
1392
+ s = "%d"%int(math.floor(d+0.5))
1393
+ else:
1394
+ s = "%0.1f"%d
1395
+
1396
+ elif self._format == RealFormat:
1397
+ if self._minor >= 1.0:
1398
+ s = "%d"%int(math.floor(d+0.5))
1399
+ else:
1400
+ s = (("%." + str(self._digits) + "f")%d).strip()
1401
+
1402
+ elif self._format == TimeFormat:
1403
+ if major:
1404
+ if d < 0:
1405
+ s = "-"
1406
+ d = -d
1407
+
1408
+ if self.GetTimeFormat() == HHMMSS_Format:
1409
+
1410
+ secs = int(d + 0.5)
1411
+ if self._minor >= 1.0:
1412
+ s = ("%d:%02d:%02d")%(secs//3600, (secs//60)%60, secs%60)
1413
+
1414
+ else:
1415
+ t1 = ("%d:%02d:")%(secs//3600, (secs//60)%60)
1416
+ format = "%" + "%0d.%dlf"%(self._digits+3, self._digits)
1417
+ t2 = format%(d%60.0)
1418
+ s = s + t1 + t2
1419
+
1420
+ else:
1421
+
1422
+ if self._minor >= 3600.0:
1423
+ hrs = int(d/3600.0 + 0.5)
1424
+ h = "%d:00:00"%hrs
1425
+ s = s + h
1426
+
1427
+ elif self._minor >= 60.0:
1428
+ minutes = int(d/60.0 + 0.5)
1429
+ if minutes >= 60:
1430
+ m = "%d:%02d:00"%(minutes//60, minutes%60)
1431
+ else:
1432
+ m = "%d:00"%minutes
1433
+
1434
+ s = s + m
1435
+
1436
+ elif self._minor >= 1.0:
1437
+ secs = int(d + 0.5)
1438
+ if secs >= 3600:
1439
+ t = "%d:%02d:%02d"%(secs//3600, (secs//60)%60, secs%60)
1440
+ elif secs >= 60:
1441
+ t = "%d:%02d"%(secs//60, secs%60)
1442
+ else:
1443
+ t = "%d"%secs
1444
+
1445
+ s = s + t
1446
+
1447
+ else:
1448
+ secs = int(d)
1449
+ if secs >= 3600:
1450
+ t1 = "%d:%02d:"%(secs//3600, (secs//60)%60)
1451
+ elif secs >= 60:
1452
+ t1 = "%d:"%(secs//60)
1453
+
1454
+ if secs >= 60:
1455
+ format = "%%0%d.%dlf"%(self._digits+3, self._digits)
1456
+ else:
1457
+ format = "%%%d.%dlf"%(self._digits+3, self._digits)
1458
+
1459
+ t2 = format%(d%60.0)
1460
+
1461
+ s = s + t1 + t2
1462
+
1463
+ if self._units != "":
1464
+ s = s + " " + self._units
1465
+
1466
+ return s
1467
+
1468
+
1469
+ def Tick(self, dc, pos, d, major):
1470
+ """
1471
+ Ticks a particular position.
1472
+
1473
+ :param `dc`: an instance of :class:`wx.DC`;
1474
+ :param `pos`: the label position;
1475
+ :param `d`: the current label value;
1476
+ :param `major`: ``True`` if it is a major ticks, ``False`` if it is a minor one.
1477
+ """
1478
+
1479
+ if major:
1480
+ label = Label()
1481
+ self._majorlabels.append(label)
1482
+ else:
1483
+ label = Label()
1484
+ self._minorlabels.append(label)
1485
+
1486
+ label.pos = pos
1487
+ label.lx = self._left - 2000 # don't display
1488
+ label.ly = self._top - 2000 # don't display
1489
+ label.text = ""
1490
+
1491
+ dc.SetFont((major and [self._majorfont] or [self._minorfont])[0])
1492
+
1493
+ l = self.LabelString(d, major)
1494
+ strw, strh = dc.GetTextExtent(l)
1495
+
1496
+ if self._orientation == wx.HORIZONTAL:
1497
+ strlen = strw
1498
+ strpos = pos - strw//2
1499
+ if strpos < 0:
1500
+ strpos = 0
1501
+ if strpos + strw >= self._length:
1502
+ strpos = self._length - strw
1503
+ strleft = self._left + strpos
1504
+ if self._flip:
1505
+ strtop = self._top + 4
1506
+ self._maxheight = max(self._maxheight, 4 + strh)
1507
+ else:
1508
+ strtop = self._bottom - strh - 6
1509
+ self._maxheight = max(self._maxheight, strh + 6)
1510
+
1511
+ else:
1512
+ strlen = strh
1513
+ strpos = pos - strh//2
1514
+ if strpos < 0:
1515
+ strpos = 0
1516
+ if strpos + strh >= self._length:
1517
+ strpos = self._length - strh
1518
+ strtop = self._top + strpos
1519
+ if self._flip:
1520
+ strleft = self._left + 5
1521
+ self._maxwidth = max(self._maxwidth, 5 + strw)
1522
+ else:
1523
+ strleft = self._right - strw - 6
1524
+ self._maxwidth = max(self._maxwidth, strw + 6)
1525
+
1526
+ # See if any of the pixels we need to draw this
1527
+ # label is already covered
1528
+
1529
+ if major and self._labelmajor or not major and self._labelminor:
1530
+ for ii in range(strlen):
1531
+ if self._bits[strpos+ii]:
1532
+ return
1533
+
1534
+ # If not, position the label and give it text
1535
+
1536
+ label.lx = strleft
1537
+ label.ly = strtop
1538
+ label.text = l
1539
+
1540
+ if major:
1541
+ if self._tickmajor and not self._labelmajor:
1542
+ label.text = ""
1543
+ self._majorlabels[-1] = label
1544
+
1545
+ else:
1546
+ if self._tickminor and not self._labelminor:
1547
+ label.text = ""
1548
+ label.text = label.text.replace(self._units, "")
1549
+ self._minorlabels[-1] = label
1550
+
1551
+ # And mark these pixels, plus some surrounding
1552
+ # ones (the spacing between labels), as covered
1553
+
1554
+ if (not major and self._labelminor) or (major and self._labelmajor):
1555
+
1556
+ leftmargin = self._spacing
1557
+
1558
+ if strpos < leftmargin:
1559
+ leftmargin = strpos
1560
+
1561
+ strpos = strpos - leftmargin
1562
+ strlen = strlen + leftmargin
1563
+
1564
+ rightmargin = self._spacing
1565
+
1566
+ if strpos + strlen > self._length - self._spacing:
1567
+ rightmargin = self._length - strpos - strlen
1568
+
1569
+ strlen = strlen + rightmargin
1570
+
1571
+ for ii in range(strlen):
1572
+ self._bits[strpos+ii] = 1
1573
+
1574
+
1575
+ def Update(self, dc):
1576
+ """
1577
+ Updates all the ticks calculations.
1578
+
1579
+ :param `dc`: an instance of :class:`wx.DC`.
1580
+ """
1581
+
1582
+ # This gets called when something has been changed
1583
+ # (i.e. we've been invalidated). Recompute all
1584
+ # tick positions.
1585
+
1586
+ if self._orientation == wx.HORIZONTAL:
1587
+ self._maxwidth = self._length
1588
+ self._maxheight = 0
1589
+ else:
1590
+ self._maxwidth = 0
1591
+ self._maxheight = self._length
1592
+
1593
+ self._bits = [0]*(self._length+1)
1594
+ self._middlepos = []
1595
+
1596
+ if self._userbits:
1597
+ for ii in range(self._length):
1598
+ self._bits[ii] = self._userbits[ii]
1599
+ else:
1600
+ for ii in range(self._length):
1601
+ self._bits[ii] = 0
1602
+
1603
+ if not self._log:
1604
+
1605
+ UPP = (self._max - self._min)/float(self._length) # Units per pixel
1606
+
1607
+ self.FindLinearTickSizes(UPP)
1608
+
1609
+ # Left and Right Edges
1610
+ if self._labeledges:
1611
+ self.Tick(dc, 0, self._min, True)
1612
+ self.Tick(dc, self._length, self._max, True)
1613
+
1614
+ # Zero (if it's in the middle somewhere)
1615
+ if self._min*self._max < 0.0:
1616
+ mid = int(self._length*(self._min/(self._min-self._max)) + 0.5)
1617
+ self.Tick(dc, mid, 0.0, True)
1618
+
1619
+ sg = ((UPP > 0.0) and [1.0] or [-1.0])[0]
1620
+
1621
+ # Major ticks
1622
+ d = self._min - UPP/2.0
1623
+ lastd = d
1624
+ majorint = int(math.floor(sg*d/self._major))
1625
+ ii = -1
1626
+
1627
+ while ii <= self._length:
1628
+ ii = ii + 1
1629
+ lastd = d
1630
+ d = d + UPP
1631
+
1632
+ if int(math.floor(sg*d/self._major)) > majorint:
1633
+ majorint = int(math.floor(sg*d/self._major))
1634
+ self.Tick(dc, ii, sg*majorint*self._major, True)
1635
+
1636
+ # Minor ticks
1637
+ d = self._min - UPP/2.0
1638
+ lastd = d
1639
+ minorint = int(math.floor(sg*d/self._minor))
1640
+ ii = -1
1641
+
1642
+ while ii <= self._length:
1643
+ ii = ii + 1
1644
+ lastd = d
1645
+ d = d + UPP
1646
+
1647
+ if int(math.floor(sg*d/self._minor)) > minorint:
1648
+ minorint = int(math.floor(sg*d/self._minor))
1649
+ self.Tick(dc, ii, sg*minorint*self._minor, False)
1650
+
1651
+ # Left and Right Edges
1652
+ if self._labeledges:
1653
+ self.Tick(dc, 0, self._min, True)
1654
+ self.Tick(dc, self._length, self._max, True)
1655
+
1656
+ else:
1657
+ # log case
1658
+
1659
+ lolog = math.log10(self._min)
1660
+ hilog = math.log10(self._max)
1661
+ scale = self._length/(hilog - lolog)
1662
+ lodecade = int(math.floor(lolog))
1663
+ hidecade = int(math.ceil(hilog))
1664
+
1665
+ # Left and Right Edges
1666
+ if self._labeledges:
1667
+ self.Tick(dc, 0, self._min, True)
1668
+ self.Tick(dc, self._length, self._max, True)
1669
+
1670
+ startdecade = 10.0**lodecade
1671
+
1672
+ # Major ticks are the decades
1673
+ decade = startdecade
1674
+ for ii in range(lodecade, hidecade):
1675
+ if ii != lodecade:
1676
+ val = decade
1677
+ if val > self._min and val < self._max:
1678
+ pos = int(((math.log10(val) - lolog)*scale)+0.5)
1679
+ self.Tick(dc, pos, val, True)
1680
+
1681
+ decade = decade*10.0
1682
+
1683
+ # Minor ticks are multiples of decades
1684
+ decade = startdecade
1685
+
1686
+ for ii in range(lodecade, hidecade):
1687
+ for jj in range(2, 10):
1688
+ val = decade*jj
1689
+ if val >= self._min and val < self._max:
1690
+ pos = int(((math.log10(val) - lolog)*scale)+0.5)
1691
+ self.Tick(dc, pos, val, False)
1692
+
1693
+ decade = decade*10.0
1694
+
1695
+ self._valid = True
1696
+
1697
+
1698
+ def Draw(self, dc):
1699
+ """
1700
+ Actually draws the whole :class:`RulerCtrl`.
1701
+
1702
+ :param `dc`: an instance of :class:`wx.DC`.
1703
+ """
1704
+
1705
+ if not self._valid:
1706
+ self.Update(dc)
1707
+
1708
+ dc.SetBrush(wx.Brush(self._background))
1709
+ dc.SetPen(self._tickpen)
1710
+ dc.SetTextForeground(self._textcolour)
1711
+
1712
+ dc.DrawRectangle(self.GetClientRect())
1713
+
1714
+ if self._orientation == wx.HORIZONTAL:
1715
+ if self._flip:
1716
+ dc.DrawLine(self._left, self._top, self._right+1, self._top)
1717
+ else:
1718
+ dc.DrawLine(self._left, self._bottom-1, self._right+1, self._bottom-1)
1719
+
1720
+ else:
1721
+ if self._flip:
1722
+ dc.DrawLine(self._left, self._top, self._left, self._bottom+1)
1723
+ else:
1724
+ dc.DrawLine(self._right-1, self._top, self._right-1, self._bottom+1)
1725
+
1726
+ dc.SetFont(self._majorfont)
1727
+
1728
+ for label in self._majorlabels:
1729
+ pos = label.pos
1730
+
1731
+ if self._orientation == wx.HORIZONTAL:
1732
+ if self._flip:
1733
+ dc.DrawLine(self._left + pos, self._top,
1734
+ self._left + pos, self._top + 5)
1735
+ else:
1736
+ dc.DrawLine(self._left + pos, self._bottom - 5,
1737
+ self._left + pos, self._bottom)
1738
+
1739
+ else:
1740
+ if self._flip:
1741
+ dc.DrawLine(self._left, self._top + pos,
1742
+ self._left + 5, self._top + pos)
1743
+ else:
1744
+ dc.DrawLine(self._right - 5, self._top + pos,
1745
+ self._right, self._top + pos)
1746
+
1747
+ if label.text != "":
1748
+ dc.DrawText(label.text, label.lx, label.ly)
1749
+
1750
+ dc.SetFont(self._minorfont)
1751
+
1752
+ for label in self._minorlabels:
1753
+ pos = label.pos
1754
+
1755
+ if self._orientation == wx.HORIZONTAL:
1756
+ if self._flip:
1757
+ dc.DrawLine(self._left + pos, self._top,
1758
+ self._left + pos, self._top + 3)
1759
+ else:
1760
+ dc.DrawLine(self._left + pos, self._bottom - 3,
1761
+ self._left + pos, self._bottom)
1762
+
1763
+ else:
1764
+ if self._flip:
1765
+ dc.DrawLine(self._left, self._top + pos,
1766
+ self._left + 3, self._top + pos)
1767
+ else:
1768
+ dc.DrawLine(self._right - 3, self._top + pos,
1769
+ self._right, self._top + pos)
1770
+
1771
+ if label.text != "":
1772
+ dc.DrawText(label.text, label.lx, label.ly)
1773
+
1774
+ for indicator in self._indicators:
1775
+ indicator.Draw(dc)
1776
+
1777
+
1778
+ def SetDrawingParent(self, dparent):
1779
+ """
1780
+ Sets the window to which :class:`RulerCtrl` draws a thin line over.
1781
+
1782
+ :param `dparent`: an instance of :class:`wx.Window`, representing the window to
1783
+ which :class:`RulerCtrl` draws a thin line over.
1784
+ """
1785
+
1786
+ self._drawingparent = dparent
1787
+
1788
+
1789
+ def GetDrawingParent(self):
1790
+ """ Returns the window to which :class:`RulerCtrl` draws a thin line over. """
1791
+
1792
+ return self._drawingparent
1793
+
1794
+
1795
+ def DrawOnParent(self, indicator):
1796
+ """
1797
+ Actually draws the thin line over the drawing parent window.
1798
+
1799
+ :param `indicator`: the current indicator, an instance of :class:`Indicator`.
1800
+
1801
+ :note: This method is currently not available on wxMac as it uses :class:`ScreenDC`.
1802
+ """
1803
+
1804
+ if not self._drawingparent:
1805
+ return
1806
+
1807
+ xpos, ypos = indicator.GetPosition()
1808
+ parentrect = self._drawingparent.GetClientRect()
1809
+
1810
+ dc = wx.ScreenDC()
1811
+ dc.SetLogicalFunction(wx.INVERT)
1812
+ dc.SetPen(self._drawingpen)
1813
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
1814
+
1815
+ imgx, imgy = indicator.GetImageSize()
1816
+
1817
+ if self._orientation == wx.HORIZONTAL:
1818
+
1819
+ x1 = xpos+ imgx//2
1820
+ y1 = parentrect.y
1821
+ x2 = x1
1822
+ y2 = parentrect.height
1823
+ x1, y1 = self._drawingparent.ClientToScreen((x1, y1))
1824
+ x2, y2 = self._drawingparent.ClientToScreen((x2, y2))
1825
+
1826
+ elif self._orientation == wx.VERTICAL:
1827
+
1828
+ x1 = parentrect.x
1829
+ y1 = ypos + imgy//2
1830
+ x2 = parentrect.width
1831
+ y2 = y1
1832
+
1833
+ x1, y1 = self._drawingparent.ClientToScreen((x1, y1))
1834
+ x2, y2 = self._drawingparent.ClientToScreen((x2, y2))
1835
+
1836
+ dc.DrawLine(x1, y1, x2, y2)
1837
+ dc.SetLogicalFunction(wx.COPY)
1838
+
1839
+
1840
+ if __name__ == '__main__':
1841
+
1842
+ import wx
1843
+
1844
+ class MyFrame(wx.Frame):
1845
+
1846
+ def __init__(self, parent):
1847
+
1848
+ wx.Frame.__init__(self, parent, -1, "RulerCtrl Demo")
1849
+
1850
+ panel = wx.Panel(self)
1851
+
1852
+ text = wx.TextCtrl(panel, -1, "Hello World! wxPython rules", style=wx.TE_MULTILINE)
1853
+
1854
+ ruler1 = RulerCtrl(panel, -1, orient=wx.HORIZONTAL, style=wx.SUNKEN_BORDER)
1855
+ ruler2 = RulerCtrl(panel, -1, orient=wx.VERTICAL, style=wx.SUNKEN_BORDER)
1856
+
1857
+ mainsizer = wx.BoxSizer(wx.HORIZONTAL)
1858
+ leftsizer = wx.BoxSizer(wx.VERTICAL)
1859
+ bottomleftsizer = wx.BoxSizer(wx.HORIZONTAL)
1860
+ topsizer = wx.BoxSizer(wx.HORIZONTAL)
1861
+
1862
+ leftsizer.Add((20, 20))
1863
+ topsizer.Add((39, 0))
1864
+ topsizer.Add(ruler1, 1, wx.EXPAND, 0)
1865
+ leftsizer.Add(topsizer, 0, wx.EXPAND, 0)
1866
+
1867
+ bottomleftsizer.Add(10, 0)
1868
+ bottomleftsizer.Add(ruler2, 0, wx.EXPAND, 0)
1869
+ bottomleftsizer.Add(text, 1, wx.EXPAND, 0)
1870
+ leftsizer.Add(bottomleftsizer, 1, wx.EXPAND, 0)
1871
+ mainsizer.Add(leftsizer, 3, wx.EXPAND, 0)
1872
+
1873
+ panel.SetSizer(mainsizer)
1874
+
1875
+
1876
+ # our normal wxApp-derived class, as usual
1877
+
1878
+ app = wx.App(0)
1879
+
1880
+ frame = MyFrame(None)
1881
+ app.SetTopWindow(frame)
1882
+ frame.Show()
1883
+
1884
+ app.MainLoop()
1885
+