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,1800 @@
1
+ # --------------------------------------------------------------------------- #
2
+ # SPEEDMETER Control wxPython IMPLEMENTATION
3
+ # Python Code By:
4
+ #
5
+ # Andrea Gavana, @ 25 Sep 2005
6
+ # Latest Revision: 27 Dec 2012, 21.00 GMT
7
+ #
8
+ #
9
+ # TODO List/Caveats
10
+ #
11
+ # 1. Combination Of The Two Styles:
12
+ #
13
+ # SM_DRAW_PARTIAL_FILLER
14
+ # SM_DRAW_SECTORS
15
+ #
16
+ # Does Not Work Very Well. It Works Well Only In Case When The Sector Colours
17
+ # Are The Same For All Intervals.
18
+ #
19
+ #
20
+ # Thanks To Gerard Grazzini That Has Tried The Demo On MacOS, I Corrected A
21
+ # Bug On Line 246
22
+ #
23
+ #
24
+ # For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
25
+ # Write To Me At:
26
+ #
27
+ # andrea.gavana@gmail.com
28
+ # andrea.gavana@maerskoil.com
29
+ #
30
+ # Or, Obviously, To The wxPython Mailing List!!!
31
+ #
32
+ # Tags: phoenix-port, unittest, documented, py3-port
33
+ #
34
+ # End Of Comments
35
+ # --------------------------------------------------------------------------- #
36
+
37
+
38
+ """
39
+ :class:`~wx.lib.agw.speedmeter.SpeedMeter` tries to reproduce the behavior of some car controls (but not only),
40
+ by creating an "angular" control (actually, circular).
41
+
42
+
43
+ Description
44
+ ===========
45
+
46
+ :class:`SpeedMeter` tries to reproduce the behavior of some car controls (but not only),
47
+ by creating an "angular" control (actually, circular). I remember to have seen
48
+ it somewhere, and i decided to implement it in wxPython.
49
+
50
+ :class:`SpeedMeter` starts its construction from an empty bitmap, and it uses some
51
+ functions of the :class:`wx.DC` class to create the rounded effects. everything is
52
+ processed in the `Draw()` method of :class:`SpeedMeter` class.
53
+
54
+ This implementation allows you to use either directly the :class:`PaintDC`, or the
55
+ better (for me) double buffered style with :class:`BufferedPaintDC`. the double
56
+ buffered implementation has been adapted from the wxPython wiki example:
57
+
58
+ https://wiki.wxpython.org/DoubleBufferedDrawing
59
+
60
+
61
+ Usage
62
+ =====
63
+
64
+ Usage example::
65
+
66
+ import wx
67
+ import wx.lib.agw.speedmeter as SM
68
+
69
+ class MyFrame(wx.Frame):
70
+
71
+ def __init__(self, parent):
72
+
73
+ wx.Frame.__init__(self, parent, -1, "SpeedMeter Demo")
74
+
75
+ speed = SM.SpeedMeter(self, agwStyle=SM.SM_DRAW_HAND|SM.SM_DRAW_SECTORS|SM.SM_DRAW_MIDDLE_TEXT|SM.SM_DRAW_SECONDARY_TICKS)
76
+
77
+ # Set The Region Of Existence Of SpeedMeter (Always In Radians!!!!)
78
+ speed.SetAngleRange(-pi/6, 7*pi/6)
79
+
80
+ # Create The Intervals That Will Divide Our SpeedMeter In Sectors
81
+ intervals = range(0, 201, 20)
82
+ speed.SetIntervals(intervals)
83
+
84
+ # Assign The Same Colours To All Sectors (We Simulate A Car Control For Speed)
85
+ # Usually This Is Black
86
+ colours = [wx.BLACK]*10
87
+ speed.SetIntervalColours(colours)
88
+
89
+ # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals
90
+ ticks = [str(interval) for interval in intervals]
91
+ speed.SetTicks(ticks)
92
+ # Set The Ticks/Tick Markers Colour
93
+ speed.SetTicksColour(wx.WHITE)
94
+ # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
95
+ speed.SetNumberOfSecondaryTicks(5)
96
+
97
+ # Set The Font For The Ticks Markers
98
+ speed.SetTicksFont(wx.Font(7, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
99
+
100
+ # Set The Text In The Center Of SpeedMeter
101
+ speed.SetMiddleText("Km/h")
102
+ # Assign The Colour To The Center Text
103
+ speed.SetMiddleTextColour(wx.WHITE)
104
+ # Assign A Font To The Center Text
105
+ speed.SetMiddleTextFont(wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
106
+
107
+ # Set The Colour For The Hand Indicator
108
+ speed.SetHandColour(wx.Colour(255, 50, 0))
109
+
110
+ # Do Not Draw The External (Container) Arc. Drawing The External Arc May
111
+ # Sometimes Create Uglier Controls. Try To Comment This Line And See It
112
+ # For Yourself!
113
+ speed.DrawExternalArc(False)
114
+
115
+ # Set The Current Value For The SpeedMeter
116
+ speed.SetSpeedValue(44)
117
+
118
+
119
+ # our normal wxApp-derived class, as usual
120
+
121
+ app = wx.App(0)
122
+
123
+ frame = MyFrame(None)
124
+ app.SetTopWindow(frame)
125
+ frame.Show()
126
+
127
+ app.MainLoop()
128
+
129
+
130
+
131
+ Methods and Settings
132
+ ====================
133
+
134
+ :class:`SpeedMeter` is highly customizable, and in particular you can set:
135
+
136
+ - The start and end angle of existence for :class:`SpeedMeter`;
137
+ - The intervals in which you divide the :class:`SpeedMeter` (numerical values);
138
+ - The corresponding thicks for the intervals;
139
+ - The interval colours (different intervals may have different filling colours);
140
+ - The ticks font and colour;
141
+ - The background colour (outsize the :class:`SpeedMeter` region);
142
+ - The external arc colour;
143
+ - The hand (arrow) colour;
144
+ - The hand's shadow colour;
145
+ - The hand's style ("arrow" or "hand");
146
+ - The partial filler colour;
147
+ - The number of secondary (intermediate) ticks;
148
+ - The direction of increasing speed ("advance" or "reverse");
149
+ - The text to be drawn in the middle and its font;
150
+ - The icon to be drawn in the middle;
151
+ - The first and second gradient colours (that fills the :class:`SpeedMeter` control);
152
+ - The current value.
153
+
154
+
155
+ Window Styles
156
+ =============
157
+
158
+ This class supports the following window styles:
159
+
160
+ =========================== =========== ==================================================
161
+ Window Styles Hex Value Description
162
+ =========================== =========== ==================================================
163
+ ``SM_ROTATE_TEXT`` 0x1 Draws the ticks rotated: the ticks are rotated accordingly to the tick marks positions.
164
+ ``SM_DRAW_SECTORS`` 0x2 Different intervals are painted in different colours (every sector of the circle has its own colour).
165
+ ``SM_DRAW_PARTIAL_SECTORS`` 0x4 Every interval has its own colour, but only a circle corona is painted near the ticks.
166
+ ``SM_DRAW_HAND`` 0x8 The hand (arrow indicator) is drawn.
167
+ ``SM_DRAW_SHADOW`` 0x10 A shadow for the hand is drawn.
168
+ ``SM_DRAW_PARTIAL_FILLER`` 0x20 A circle corona that follows the hand position is drawn near the ticks.
169
+ ``SM_DRAW_SECONDARY_TICKS`` 0x40 Intermediate (smaller) ticks are drawn between principal ticks.
170
+ ``SM_DRAW_MIDDLE_TEXT`` 0x80 Some text is printed in the middle of the control near the center.
171
+ ``SM_DRAW_MIDDLE_ICON`` 0x100 An icon is drawn in the middle of the control near the center.
172
+ ``SM_DRAW_GRADIENT`` 0x200 A gradient of colours will fill the control.
173
+ ``SM_DRAW_FANCY_TICKS`` 0x400 With this style you can use xml tags to create some custom text and draw it at the ticks position. See :mod:`lib.fancytext` for the tags.
174
+ =========================== =========== ==================================================
175
+
176
+
177
+ Events Processing
178
+ =================
179
+
180
+ `No custom events are available for this class.`
181
+
182
+
183
+ License And Version
184
+ ===================
185
+
186
+ :class:`SpeedMeter` is distributed under the wxPython license.
187
+
188
+ Latest revision: Andrea Gavana @ 27 Dec 2012, 21.00 GMT
189
+
190
+ Version 0.3
191
+
192
+ """
193
+
194
+ #----------------------------------------------------------------------
195
+ # Beginning Of SPEEDMETER wxPython Code
196
+ #----------------------------------------------------------------------
197
+
198
+ import wx
199
+ import wx.lib.colourdb
200
+ import wx.lib.fancytext as fancytext
201
+
202
+ from math import pi, sin, cos, log, sqrt, atan2
203
+
204
+ #----------------------------------------------------------------------
205
+ # DC Drawing Options
206
+ #----------------------------------------------------------------------
207
+ # SM_NORMAL_DC Uses The Normal wx.PaintDC
208
+ # SM_BUFFERED_DC Uses The Double Buffered Drawing Style
209
+
210
+ SM_NORMAL_DC = 0
211
+ """ Uses the normal :class:`PaintDC`. """
212
+ SM_BUFFERED_DC = 1
213
+ """ Uses a double buffered drawing code. """
214
+
215
+ #----------------------------------------------------------------------
216
+ # SpeedMeter Styles
217
+ #----------------------------------------------------------------------
218
+ # SM_ROTATE_TEXT: Draws The Ticks Rotated: The Ticks Are Rotated
219
+ # Accordingly To The Tick Marks Positions
220
+ # SM_DRAW_SECTORS: Different Intervals Are Painted In Different Colours
221
+ # (Every Sector Of The Circle Has Its Own Colour)
222
+ # SM_DRAW_PARTIAL_SECTORS: Every Interval Has Its Own Colour, But Only
223
+ # A Circle Corona Is Painted Near The Ticks
224
+ # SM_DRAW_HAND: The Hand (Arrow Indicator) Is Drawn
225
+ # SM_DRAW_SHADOW: A Shadow For The Hand Is Drawn
226
+ # SM_DRAW_PARTIAL_FILLER: A Circle Corona That Follows The Hand Position
227
+ # Is Drawn Near The Ticks
228
+ # SM_DRAW_SECONDARY_TICKS: Intermediate (Smaller) Ticks Are Drawn Between
229
+ # Principal Ticks
230
+ # SM_DRAW_MIDDLE_TEXT: Some Text Is Printed In The Middle Of The Control
231
+ # Near The Center
232
+ # SM_DRAW_MIDDLE_ICON: An Icon Is Drawn In The Middle Of The Control Near
233
+ # The Center
234
+ # SM_DRAW_GRADIENT: A Gradient Of Colours Will Fill The Control
235
+ # SM_DRAW_FANCY_TICKS: With This Style You Can Use XML Tags To Create
236
+ # Some Custom Text And Draw It At The Ticks Position.
237
+ # See wx.lib.fancytext For The Tags.
238
+
239
+ SM_ROTATE_TEXT = 1
240
+ """ Draws the ticks rotated: the ticks are rotated accordingly to the tick marks positions. """
241
+ SM_DRAW_SECTORS = 2
242
+ """ Different intervals are painted in different colours (every sector of the circle has its own colour). """
243
+ SM_DRAW_PARTIAL_SECTORS = 4
244
+ """ Every interval has its own colour, but only a circle corona is painted near the ticks. """
245
+ SM_DRAW_HAND = 8
246
+ """ The hand (arrow indicator) is drawn. """
247
+ SM_DRAW_SHADOW = 16
248
+ """ A shadow for the hand is drawn. """
249
+ SM_DRAW_PARTIAL_FILLER = 32
250
+ """ A circle corona that follows the hand position is drawn near the ticks. """
251
+ SM_DRAW_SECONDARY_TICKS = 64
252
+ """ Intermediate (smaller) ticks are drawn between principal ticks. """
253
+ SM_DRAW_MIDDLE_TEXT = 128
254
+ """ Some text is printed in the middle of the control near the center. """
255
+ SM_DRAW_MIDDLE_ICON = 256
256
+ """ An icon is drawn in the middle of the control near the center. """
257
+ SM_DRAW_GRADIENT = 512
258
+ """ A gradient of colours will fill the control. """
259
+ SM_DRAW_FANCY_TICKS = 1024
260
+ """ With this style you can use xml tags to create some custom text and draw it at the ticks position. See :mod:`lib.fancytext` for the tags. """
261
+
262
+ #----------------------------------------------------------------------
263
+ # Event Binding
264
+ #----------------------------------------------------------------------
265
+ # SM_MOUSE_TRACK: The Mouse Left Click/Drag Allow You To Change The
266
+ # SpeedMeter Value Interactively
267
+
268
+ SM_MOUSE_TRACK = 1
269
+ """ Flag to allow the left/right click of the mouse to change the :class:`SpeedMeter` value interactively. """
270
+
271
+ fontfamily = [wx.FONTFAMILY_DEFAULT, wx.FONTFAMILY_DECORATIVE, wx.FONTFAMILY_ROMAN,
272
+ wx.FONTFAMILY_SCRIPT, wx.FONTFAMILY_SWISS, wx.FONTFAMILY_MODERN,
273
+ wx.FONTFAMILY_TELETYPE, wx.FONTFAMILY_UNKNOWN]
274
+ familyname = ["default", "decorative", "roman", "script", "swiss", "modern",
275
+ "teletype", "unknown"]
276
+
277
+ weights = [ wx.FONTWEIGHT_INVALID, wx.FONTWEIGHT_THIN, wx.FONTWEIGHT_EXTRALIGHT,
278
+ wx.FONTWEIGHT_LIGHT, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_MEDIUM,
279
+ wx.FONTWEIGHT_SEMIBOLD, wx.FONTWEIGHT_BOLD, wx.FONTWEIGHT_EXTRABOLD,
280
+ wx.FONTWEIGHT_HEAVY, wx.FONTWEIGHT_EXTRAHEAVY]
281
+ weightsname = ["invalid", "thin", "extra-light", "normal", "medium", "semi-bold",
282
+ "bold", "extra-bold", "heavy", "extra-heavy"]
283
+
284
+ styles = [ wx.FONTSTYLE_NORMAL, wx.FONTSTYLE_ITALIC, wx.FONTSTYLE_SLANT]
285
+ stylesname = ["normal", "italic", "slant"]
286
+
287
+
288
+
289
+ #----------------------------------------------------------------------
290
+ # BUFFERENDWINDOW Class
291
+ # This Class Has Been Taken From The wxPython Wiki, And Slightly
292
+ # Adapted To Fill My Needs. See:
293
+ #
294
+ # http://wiki.wxpython.org/index.cgi/DoubleBufferedDrawing
295
+ #
296
+ # For More Info About DC And Double Buffered Drawing.
297
+ #----------------------------------------------------------------------
298
+
299
+ class BufferedWindow(wx.Window):
300
+ """
301
+ A buffered window class.
302
+
303
+ To use it, subclass it and define a `Draw(dc)` method that takes a `dc`
304
+ to draw to. In that method, put the code needed to draw the picture
305
+ you want. The window will automatically be double buffered, and the
306
+ screen will be automatically updated when a Paint event is received.
307
+
308
+ When the drawing needs to change, you app needs to call the
309
+ :meth:`BufferedWindow.UpdateDrawing() <BufferedWindow.UpdateDrawing>` method. Since the drawing is stored in a bitmap, you
310
+ can also save the drawing to file by calling the
311
+ `SaveToFile(self, file_name, file_type)` method.
312
+ """
313
+
314
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
315
+ style=wx.NO_FULL_REPAINT_ON_RESIZE, bufferedstyle=SM_BUFFERED_DC):
316
+ """
317
+ Default class constructor.
318
+
319
+ :param `parent`: parent window. Must not be ``None``;
320
+ :param `id`: window identifier. A value of -1 indicates a default value;
321
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
322
+ chosen by either the windowing system or wxPython, depending on platform;
323
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
324
+ chosen by either the windowing system or wxPython, depending on platform;
325
+ :param `style`: the window style;
326
+ :param `bufferedstyle`: if set to ``SM_BUFFERED_DC``, double-buffering will
327
+ be used.
328
+ """
329
+
330
+ wx.Window.__init__(self, parent, id, pos, size, style)
331
+
332
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
333
+ self.Bind(wx.EVT_SIZE, self.OnSize)
334
+ self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: None)
335
+
336
+ self._isWindowCreated = False
337
+ if '__WXGTK__' in wx.PlatformInfo:
338
+ self.Bind(wx.EVT_WINDOW_CREATE, self.doSetWindowCreated)
339
+ else:
340
+ # OnSize called to make sure the buffer is initialized.
341
+ # This might result in OnSize getting called twice on some
342
+ # platforms at initialization, but little harm done.
343
+ self.doSetWindowCreated(None)
344
+
345
+
346
+ def doSetWindowCreated(self, evt):
347
+ """
348
+ Method to call OnSize on GTK when window is created.
349
+ """
350
+ self._isWindowCreated = True
351
+ self.OnSize(None)
352
+
353
+
354
+ def Draw(self, dc):
355
+ """
356
+ This method should be overridden when sub-classed.
357
+
358
+ :param `dc`: an instance of :class:`wx.DC`.
359
+ """
360
+ pass
361
+
362
+
363
+ def OnPaint(self, event):
364
+ """
365
+ Handles the ``wx.EVT_PAINT`` event for :class:`BufferedWindow`.
366
+
367
+ :param `event`: a :class:`PaintEvent` event to be processed.
368
+ """
369
+
370
+ if self._bufferedstyle == SM_BUFFERED_DC:
371
+ dc = wx.BufferedPaintDC(self, self._Buffer)
372
+ else:
373
+ dc = wx.PaintDC(self)
374
+ dc.DrawBitmap(self._Buffer,0,0)
375
+
376
+
377
+ def OnSize(self,event):
378
+ """
379
+ Handles the ``wx.EVT_SIZE`` event for :class:`BufferedWindow`.
380
+
381
+ :param `event`: a :class:`wx.SizeEvent` event to be processed.
382
+ """
383
+
384
+ self.Width, self.Height = self.GetClientSize()
385
+
386
+ # Make new off screen bitmap: this bitmap will always have the
387
+ # current drawing in it, so it can be used to save the image to
388
+ # a file, or whatever.
389
+
390
+ # Some platforms object to creating bitmaps with size < (1,1)
391
+ self.Width = max(self.Width, 1)
392
+ self.Height = max(self.Height, 1)
393
+
394
+ self._Buffer = wx.Bitmap(self.Width, self.Height)
395
+ if self._isWindowCreated:
396
+ self.UpdateDrawing()
397
+
398
+
399
+ def UpdateDrawing(self):
400
+ """
401
+ This would get called if the drawing needed to change, for whatever reason.
402
+
403
+ The idea here is that the drawing is based on some data generated
404
+ elsewhere in the system. if that data changes, the drawing needs to
405
+ be updated.
406
+ """
407
+
408
+ if self._bufferedstyle == SM_BUFFERED_DC:
409
+ dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
410
+ if 'wxMSW' in wx.PlatformInfo:
411
+ dc = wx.GCDC(dc)
412
+ self.Draw(dc)
413
+ else:
414
+ # update the buffer
415
+ dc = wx.MemoryDC()
416
+ dc.SelectObject(self._Buffer)
417
+
418
+ if 'wxMSW' in wx.PlatformInfo:
419
+ dc = wx.GCDC(dc)
420
+ self.Draw(dc)
421
+ # update the screen
422
+ wx.ClientDC(self).Blit(0, 0, self.Width, self.Height, dc, 0, 0)
423
+
424
+
425
+ #----------------------------------------------------------------------
426
+ # SPEEDMETER Class
427
+ # This Is The Main Class Implementation. See __init__() Method For
428
+ # Details.
429
+ #----------------------------------------------------------------------
430
+
431
+ class SpeedMeter(BufferedWindow):
432
+ """
433
+ :class:`SpeedMeter` tries to reproduce the behavior of some car controls (but not only),
434
+ by creating an "angular" control (actually, circular).
435
+
436
+ This is the main class implementation.
437
+ """
438
+ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
439
+ size=wx.DefaultSize, agwStyle=SM_DRAW_HAND,
440
+ bufferedstyle=SM_BUFFERED_DC,
441
+ mousestyle=0):
442
+ """
443
+ Default class constructor.
444
+
445
+ :param `parent`: parent window. Must not be ``None``;
446
+ :param `id`: window identifier. A value of -1 indicates a default value;
447
+ :param `pos`: the control position. A value of (-1, -1) indicates a default position,
448
+ chosen by either the windowing system or wxPython, depending on platform;
449
+ :param `size`: the control size. A value of (-1, -1) indicates a default size,
450
+ chosen by either the windowing system or wxPython, depending on platform;
451
+ :param `agwStyle`: this value specifies the :class:`SpeedMeter` styles, and can be a
452
+ combination of the following bits:
453
+
454
+ =========================== =========== ==================================================
455
+ Window Styles Hex Value Description
456
+ =========================== =========== ==================================================
457
+ ``SM_ROTATE_TEXT`` 0x1 Draws the ticks rotated: the ticks are rotated accordingly to the tick marks positions.
458
+ ``SM_DRAW_SECTORS`` 0x2 Different intervals are painted in different colours (every sector of the circle has its own colour).
459
+ ``SM_DRAW_PARTIAL_SECTORS`` 0x4 Every interval has its own colour, but only a circle corona is painted near the ticks.
460
+ ``SM_DRAW_HAND`` 0x8 The hand (arrow indicator) is drawn.
461
+ ``SM_DRAW_SHADOW`` 0x10 A shadow for the hand is drawn.
462
+ ``SM_DRAW_PARTIAL_FILLER`` 0x20 A circle corona that follows the hand position is drawn near the ticks.
463
+ ``SM_DRAW_SECONDARY_TICKS`` 0x40 Intermediate (smaller) ticks are drawn between principal ticks.
464
+ ``SM_DRAW_MIDDLE_TEXT`` 0x80 Some text is printed in the middle of the control near the center.
465
+ ``SM_DRAW_MIDDLE_ICON`` 0x100 An icon is drawn in the middle of the control near the center.
466
+ ``SM_DRAW_GRADIENT`` 0x200 A gradient of colours will fill the control.
467
+ ``SM_DRAW_FANCY_TICKS`` 0x400 With this style you can use xml tags to create some custom text and draw it at the ticks position. See :mod:`lib.fancytext` for the tags.
468
+ =========================== =========== ==================================================
469
+
470
+ :param `bufferedstyle`: this value allows you to use the normal :class:`PaintDC` or the
471
+ double buffered drawing options:
472
+
473
+ =========================== =========== ==================================================
474
+ Buffered Styles Hex Value Description
475
+ =========================== =========== ==================================================
476
+ ``SM_NORMAL_DC`` 0x0 Uses the normal :class:`PaintDC`
477
+ ``SM_BUFFERED_DC`` 0x1 Uses the double buffered drawing style
478
+ =========================== =========== ==================================================
479
+
480
+ :param `mousestyle`: this value allows you to use the mouse to change the :class:`SpeedMeter`
481
+ value interactively with left click/drag events. If set to ``SM_MOUSE_TRACK``, the mouse
482
+ left click/drag allow you to change the :class:`SpeedMeter` value interactively.
483
+ """
484
+
485
+ self._agwStyle = agwStyle
486
+ self._bufferedstyle = bufferedstyle
487
+ self._mousestyle = mousestyle
488
+ self._middleicon = None
489
+
490
+ if self._agwStyle & SM_DRAW_SECTORS and self._agwStyle & SM_DRAW_GRADIENT:
491
+ errstr = "\nERROR: Incompatible Options: SM_DRAW_SECTORS Can Not Be Used In "
492
+ errstr = errstr + "Conjunction With SM_DRAW_GRADIENT."
493
+ raise Exception(errstr)
494
+
495
+ if self._agwStyle & SM_DRAW_PARTIAL_SECTORS and self._agwStyle & SM_DRAW_SECTORS:
496
+ errstr = "\nERROR: Incompatible Options: SM_DRAW_SECTORS Can Not Be Used In "
497
+ errstr = errstr + "Conjunction With SM_DRAW_PARTIAL_SECTORS."
498
+ raise Exception(errstr)
499
+
500
+ if self._agwStyle & SM_DRAW_PARTIAL_SECTORS and self._agwStyle & SM_DRAW_PARTIAL_FILLER:
501
+ errstr = "\nERROR: Incompatible Options: SM_DRAW_PARTIAL_SECTORS Can Not Be Used In "
502
+ errstr = errstr + "Conjunction With SM_DRAW_PARTIAL_FILLER."
503
+ raise Exception(errstr)
504
+
505
+ if self._agwStyle & SM_DRAW_FANCY_TICKS and self._agwStyle & SM_ROTATE_TEXT:
506
+ errstr = "\nERROR: Incompatible Options: SM_DRAW_FANCY_TICKS Can Not Be Used In "
507
+ errstr = errstr + "Conjunction With SM_ROTATE_TEXT."
508
+ raise Exception(errstr)
509
+
510
+ if self._agwStyle & SM_DRAW_SHADOW and self._agwStyle & SM_DRAW_HAND == 0:
511
+ errstr = "\nERROR: Incompatible Options: SM_DRAW_SHADOW Can Be Used Only In "
512
+ errstr = errstr + "Conjunction With SM_DRAW_HAND."
513
+ raise Exception(errstr)
514
+
515
+ if self._agwStyle & SM_DRAW_FANCY_TICKS:
516
+ wx.lib.colourdb.updateColourDB()
517
+
518
+ self.SetAngleRange()
519
+ self.SetIntervals()
520
+ self.SetSpeedValue()
521
+ self.SetIntervalColours()
522
+ self.SetArcColour()
523
+ self.SetTicks()
524
+ self.SetTicksFont()
525
+ self.SetTicksColour()
526
+ self.SetSpeedBackground()
527
+ self.SetHandColour()
528
+ self.SetShadowColour()
529
+ self.SetFillerColour()
530
+ self.SetDirection()
531
+ self.SetNumberOfSecondaryTicks()
532
+ self.SetMiddleText()
533
+ self.SetMiddleTextFont()
534
+ self.SetMiddleTextColour()
535
+ self.SetFirstGradientColour()
536
+ self.SetSecondGradientColour()
537
+ self.SetHandStyle()
538
+ self.DrawExternalArc()
539
+
540
+ # If no initial size is set then use (1,1) instead of the (20,20) that
541
+ # wxWindow will default to. This is so we don't set the initial
542
+ # self.scale based on (20,20) but will instead wait until the initial
543
+ # size is set by the sizer. See Draw() implementation below.
544
+ if size == wx.DefaultSize:
545
+ size = wx.Size(1,1)
546
+
547
+ BufferedWindow.__init__(self, parent, id, pos, size,
548
+ style=wx.NO_FULL_REPAINT_ON_RESIZE,
549
+ bufferedstyle=bufferedstyle)
550
+ if self._mousestyle & SM_MOUSE_TRACK:
551
+ self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseMotion)
552
+
553
+
554
+ def Draw(self, dc):
555
+ """
556
+ Draws everything on the empty bitmap.
557
+ Here all the chosen styles are applied.
558
+
559
+ :param `dc`: an instance of :class:`wx.DC`.
560
+ """
561
+
562
+ size = self.GetClientSize()
563
+
564
+ if size.x < 2 or size.y < 2:
565
+ return
566
+
567
+ new_dim = size.Get()
568
+
569
+ if not hasattr(self, "dim"):
570
+ self.dim = new_dim
571
+
572
+ self.scale = min([float(new_dim[0]) / self.dim[0],
573
+ float(new_dim[1]) / self.dim[1]])
574
+
575
+ # Create An Empty Bitmap
576
+ self.faceBitmap = wx.Bitmap(size.width, size.height)
577
+
578
+ speedbackground = self.GetSpeedBackground()
579
+ # Set Background Of The Control
580
+ dc.SetBackground(wx.Brush(speedbackground))
581
+ dc.Clear()
582
+
583
+ centerX = self.faceBitmap.GetWidth()//2
584
+ centerY = self.faceBitmap.GetHeight()//2
585
+
586
+ self.CenterX = centerX
587
+ self.CenterY = centerY
588
+
589
+ # Get The Radius Of The Sector. Set It A Bit Smaller To Correct Draw After
590
+ radius = min(centerX, centerY) - 2
591
+
592
+ self.Radius = radius
593
+ self.Radius = radius
594
+
595
+ # Get The Angle Of Existence Of The Sector
596
+ anglerange = self.GetAngleRange()
597
+ startangle = anglerange[1]
598
+ endangle = anglerange[0]
599
+
600
+ self.StartAngle = startangle
601
+ self.EndAngle = endangle
602
+
603
+ # Initialize The Colours And The Intervals - Just For Reference To The
604
+ # Children Functions
605
+ colours = None
606
+ intervals = None
607
+
608
+ if self._agwStyle & SM_DRAW_SECTORS or self._agwStyle & SM_DRAW_PARTIAL_SECTORS:
609
+ # Get The Intervals Colours
610
+ colours = self.GetIntervalColours()[:]
611
+
612
+ textangles = []
613
+ colourangles = []
614
+ xcoords = []
615
+ ycoords = []
616
+
617
+ # Get The Intervals (Partial Sectors)
618
+ intervals = self.GetIntervals()[:]
619
+
620
+ start = min(intervals)
621
+ end = max(intervals)
622
+ span = end - start
623
+
624
+ self.StartValue = start
625
+ self.EndValue = end
626
+
627
+ self.Span = span
628
+
629
+ # Get The Current Value For The SpeedMeter
630
+ currentvalue = self.GetSpeedValue()
631
+
632
+ # Get The Direction Of The SpeedMeter
633
+ direction = self.GetDirection()
634
+ if direction == "Reverse":
635
+ intervals.reverse()
636
+
637
+ if self._agwStyle & SM_DRAW_SECTORS or self._agwStyle & SM_DRAW_PARTIAL_SECTORS:
638
+ colours.reverse()
639
+
640
+ currentvalue = end - currentvalue
641
+
642
+ # This Because DrawArc Does Not Draw Last Point
643
+ offset = 0.1*self.scale/180.0
644
+
645
+ xstart, ystart = self.CircleCoords(radius+1, -endangle, centerX, centerY)
646
+ xend, yend = self.CircleCoords(radius+1, -startangle-offset, centerX, centerY)
647
+
648
+ # Calculate The Angle For The Current Value Of SpeedMeter
649
+ accelangle = (currentvalue - start)/float(span)*(startangle-endangle) - startangle
650
+
651
+ dc.SetPen(wx.TRANSPARENT_PEN)
652
+
653
+ if self._agwStyle & SM_DRAW_PARTIAL_FILLER:
654
+
655
+ # Get Some Data For The Partial Filler
656
+ fillercolour = self.GetFillerColour()
657
+ fillerendradius = radius - 10.0*self.scale
658
+ fillerstartradius = radius
659
+
660
+ if direction == "Advance":
661
+ fillerstart = accelangle
662
+ fillerend = -startangle
663
+ else:
664
+ fillerstart = -endangle
665
+ fillerend = accelangle
666
+
667
+ xs1, ys1 = self.CircleCoords(fillerendradius, fillerstart, centerX, centerY)
668
+ xe1, ye1 = self.CircleCoords(fillerendradius, fillerend, centerX, centerY)
669
+ xs2, ys2 = self.CircleCoords(fillerstartradius, fillerstart, centerX, centerY)
670
+ xe2, ye2 = self.CircleCoords(fillerstartradius, fillerend, centerX, centerY)
671
+
672
+ # Get The Sector In Which The Current Value Is
673
+ intersection = self.GetIntersection(currentvalue, intervals)
674
+ sectorradius = radius - 10*self.scale
675
+
676
+ else:
677
+
678
+ sectorradius = radius
679
+
680
+ if self._agwStyle & SM_DRAW_PARTIAL_FILLER:
681
+ # Draw The Filler (Both In "Advance" And "Reverse" Directions)
682
+
683
+ dc.SetBrush(wx.Brush(fillercolour))
684
+ dc.DrawArc(xs2, ys2, xe2, ye2, int(centerX), int(centerY))
685
+
686
+ if self._agwStyle & SM_DRAW_SECTORS == 0:
687
+ dc.SetBrush(wx.Brush(speedbackground))
688
+ xclean1, yclean1 = self.CircleCoords(sectorradius, -endangle, centerX, centerY)
689
+ xclean2, yclean2 = self.CircleCoords(sectorradius, -startangle-offset, centerX, centerY)
690
+ dc.DrawArc(xclean1, yclean1, xclean2, yclean2, centerX, centerY)
691
+
692
+
693
+ # This Is Needed To Fill The Partial Sector Correctly
694
+ xold, yold = self.CircleCoords(radius, startangle+endangle, centerX, centerY)
695
+
696
+ # Draw The Sectors
697
+ for ii, interval in enumerate(intervals):
698
+
699
+ if direction == "Advance":
700
+ current = interval - start
701
+ else:
702
+ current = end - interval
703
+
704
+ angle = (current/float(span))*(startangle-endangle) - startangle
705
+ angletext = -((pi/2.0) + angle)*180/pi
706
+ textangles.append(angletext)
707
+ colourangles.append(angle)
708
+ xtick, ytick = self.CircleCoords(radius, angle, centerX, centerY)
709
+
710
+ # Keep The Coordinates, We Will Need Them After To Position The Ticks
711
+ xcoords.append(xtick)
712
+ ycoords.append(ytick)
713
+ x = xtick
714
+ y = ytick
715
+
716
+ if self._agwStyle & SM_DRAW_SECTORS:
717
+ if self._agwStyle & SM_DRAW_PARTIAL_FILLER:
718
+ if direction == "Advance":
719
+ if current > currentvalue:
720
+ x, y = self.CircleCoords(radius, angle, centerX, centerY)
721
+ else:
722
+ x, y = self.CircleCoords(sectorradius, angle, centerX, centerY)
723
+ else:
724
+ if current < end - currentvalue:
725
+ x, y = self.CircleCoords(radius, angle, centerX, centerY)
726
+ else:
727
+ x, y = self.CircleCoords(sectorradius, angle, centerX, centerY)
728
+ else:
729
+ x, y = self.CircleCoords(radius, angle, centerX, centerY)
730
+
731
+
732
+ if ii > 0:
733
+ if self._agwStyle & SM_DRAW_PARTIAL_FILLER and ii == intersection:
734
+ # We Got The Interval In Which There Is The Current Value. If We Choose
735
+ # A "Reverse" Direction, First We Draw The Partial Sector, Next The Filler
736
+
737
+ dc.SetBrush(wx.Brush(speedbackground))
738
+
739
+ if direction == "Reverse":
740
+ if self._agwStyle & SM_DRAW_SECTORS:
741
+ dc.SetBrush(wx.Brush(colours[ii-1]))
742
+
743
+ dc.DrawArc(xe2, ye2, xold, yold, centerX, centerY)
744
+
745
+ if self._agwStyle & SM_DRAW_SECTORS:
746
+ dc.SetBrush(wx.Brush(colours[ii-1]))
747
+ else:
748
+ dc.SetBrush(wx.Brush(speedbackground))
749
+
750
+
751
+ dc.DrawArc(xs1, ys1, xe1, ye1, centerX, centerY)
752
+
753
+ if self._agwStyle & SM_DRAW_SECTORS:
754
+ dc.SetBrush(wx.Brush(colours[ii-1]))
755
+ # Here We Draw The Rest Of The Sector In Which The Current Value Is
756
+ if direction == "Advance":
757
+ dc.DrawArc(xs1, ys1, x, y, centerX, centerY)
758
+ x = xs1
759
+ y = ys1
760
+ else:
761
+ dc.DrawArc(xe2, ye2, x, y, centerX, centerY)
762
+
763
+ elif self._agwStyle & SM_DRAW_SECTORS:
764
+ dc.SetBrush(wx.Brush(colours[ii-1]))
765
+
766
+ # Here We Still Use The SM_DRAW_PARTIAL_FILLER Style, But We Are Not
767
+ # In The Sector Where The Current Value Resides
768
+ if self._agwStyle & SM_DRAW_PARTIAL_FILLER and ii != intersection:
769
+ if direction == "Advance":
770
+ dc.DrawArc(x, y, xold, yold, centerX, centerY)
771
+ else:
772
+ if ii < intersection:
773
+ dc.DrawArc(x, y, xold, yold, centerX, centerY)
774
+
775
+ # This Is The Case Where No SM_DRAW_PARTIAL_FILLER Has Been Chosen
776
+ else:
777
+ dc.DrawArc(x, y, xold, yold, centerX, centerY)
778
+
779
+ else:
780
+ if self._agwStyle & SM_DRAW_PARTIAL_FILLER and self._agwStyle & SM_DRAW_SECTORS:
781
+ dc.SetBrush(wx.Brush(fillercolour))
782
+ dc.DrawArc(xs2, ys2, xe2, ye2, centerX, centerY)
783
+ x, y = self.CircleCoords(sectorradius, angle, centerX, centerY)
784
+ dc.SetBrush(wx.Brush(colours[ii]))
785
+ dc.DrawArc(xs1, ys1, xe1, ye1, centerX, centerY)
786
+ x = xs2
787
+ y = ys2
788
+
789
+ xold = x
790
+ yold = y
791
+
792
+ if self._agwStyle & SM_DRAW_PARTIAL_SECTORS:
793
+
794
+ sectorendradius = radius - 10.0*self.scale
795
+ sectorstartradius = radius
796
+
797
+ xps, yps = self.CircleCoords(sectorstartradius, angle, centerX, centerY)
798
+
799
+ if ii > 0:
800
+ dc.SetBrush(wx.Brush(colours[ii-1]))
801
+ dc.DrawArc(xps, yps, xpsold, ypsold, centerX, centerY)
802
+
803
+ xpsold = xps
804
+ ypsold = yps
805
+
806
+
807
+ if self._agwStyle & SM_DRAW_PARTIAL_SECTORS:
808
+
809
+ xps1, yps1 = self.CircleCoords(sectorendradius, -endangle+2*offset, centerX, centerY)
810
+ xps2, yps2 = self.CircleCoords(sectorendradius, -startangle-2*offset, centerX, centerY)
811
+
812
+ dc.SetBrush(wx.Brush(speedbackground))
813
+ dc.DrawArc(xps1, yps1, xps2, yps2, centerX, centerY)
814
+
815
+
816
+ if self._agwStyle & SM_DRAW_GRADIENT:
817
+
818
+ dc.SetPen(wx.TRANSPARENT_PEN)
819
+
820
+ xcurrent, ycurrent = self.CircleCoords(radius, accelangle, centerX, centerY)
821
+
822
+ # calculate gradient coefficients
823
+ col2 = self.GetSecondGradientColour()
824
+ col1 = self.GetFirstGradientColour()
825
+
826
+ r1, g1, b1 = int(col1.Red()), int(col1.Green()), int(col1.Blue())
827
+ r2, g2, b2 = int(col2.Red()), int(col2.Green()), int(col2.Blue())
828
+
829
+ flrect = float(radius+self.scale)
830
+
831
+ numsteps = 200
832
+
833
+ rstep = float((r2 - r1)) / numsteps
834
+ gstep = float((g2 - g1)) / numsteps
835
+ bstep = float((b2 - b1)) / numsteps
836
+
837
+ rf, gf, bf = 0, 0, 0
838
+
839
+ radiusteps = flrect/numsteps
840
+ interface = 0
841
+
842
+ for ind in range(numsteps+1):
843
+ currCol = (int(r1 + rf), int(g1 + gf), int(b1 + bf))
844
+ dc.SetBrush(wx.Brush(currCol))
845
+
846
+ gradradius = flrect - radiusteps*ind
847
+ xst1, yst1 = self.CircleCoords(gradradius, -endangle, centerX, centerY)
848
+ xen1, yen1 = self.CircleCoords(gradradius, -startangle-offset, centerX, centerY)
849
+
850
+ if self._agwStyle & SM_DRAW_PARTIAL_FILLER:
851
+ if gradradius >= fillerendradius:
852
+ if direction == "Advance":
853
+ dc.DrawArc(xstart, ystart, xcurrent, ycurrent, centerX, centerY)
854
+ else:
855
+ dc.DrawArc(xcurrent, ycurrent, xend, yend, centerX, centerY)
856
+ else:
857
+ if interface == 0:
858
+ interface = 1
859
+ myradius = fillerendradius + 1
860
+ xint1, yint1 = self.CircleCoords(myradius, -endangle, centerX, centerY)
861
+ xint2, yint2 = self.CircleCoords(myradius, -startangle-offset, centerX, centerY)
862
+ dc.DrawArc(xint1, yint1, xint2, yint2, centerX, centerY)
863
+
864
+ dc.DrawArc(xst1, yst1, xen1, yen1, centerX, centerY)
865
+ else:
866
+ if self._agwStyle & SM_DRAW_PARTIAL_SECTORS:
867
+ if gradradius <= sectorendradius:
868
+ if interface == 0:
869
+ interface = 1
870
+ myradius = sectorendradius + 1
871
+ xint1, yint1 = self.CircleCoords(myradius, -endangle, centerX, centerY)
872
+ xint2, yint2 = self.CircleCoords(myradius, -startangle-offset, centerX, centerY)
873
+ dc.DrawArc(xint1, yint1, xint2, yint2, centerX, centerY)
874
+ else:
875
+ dc.DrawArc(xst1, yst1, xen1, yen1, centerX, centerY)
876
+ else:
877
+ dc.DrawArc(xst1, yst1, xen1, yen1, centerX, centerY)
878
+
879
+ rf = rf + rstep
880
+ gf = gf + gstep
881
+ bf = bf + bstep
882
+
883
+ textheight = 0
884
+
885
+ # Get The Ticks And The Ticks Colour
886
+ ticks = self.GetTicks()[:]
887
+ tickscolour = self.GetTicksColour()
888
+
889
+ if direction == "Reverse":
890
+ ticks.reverse()
891
+
892
+ if self._agwStyle & SM_DRAW_SECONDARY_TICKS:
893
+ ticknum = self.GetNumberOfSecondaryTicks()
894
+ oldinterval = intervals[0]
895
+
896
+ dc.SetPen(wx.Pen(tickscolour, 1))
897
+ dc.SetBrush(wx.Brush(tickscolour))
898
+ dc.SetTextForeground(tickscolour)
899
+
900
+ # Get The Font For The Ticks
901
+ tfont, fontsize = self.GetTicksFont()
902
+ tfont = tfont[0]
903
+ myfamily = tfont.GetFamily()
904
+
905
+ fsize = self.scale*fontsize
906
+ tfont.SetPointSize(int(fsize))
907
+ tfont.SetFamily(myfamily)
908
+ dc.SetFont(tfont)
909
+
910
+ if self._agwStyle & SM_DRAW_FANCY_TICKS:
911
+ facename = tfont.GetFaceName()
912
+ ffamily = familyname[fontfamily.index(tfont.GetFamily())]
913
+ fweight = weightsname[weights.index(tfont.GetWeight())]
914
+ fstyle = stylesname[styles.index(tfont.GetStyle())]
915
+ fcolour = wx.TheColourDatabase.FindName(tickscolour)
916
+
917
+ textheight = 0
918
+
919
+ # Draw The Ticks And The Markers (Text Ticks)
920
+ for ii, angles in enumerate(textangles):
921
+
922
+ strings = ticks[ii]
923
+ if self._agwStyle & SM_DRAW_FANCY_TICKS == 0:
924
+ width, height, dummy, dummy = dc.GetFullTextExtent(strings, tfont)
925
+ textheight = height
926
+ else:
927
+ width, height, dummy = fancytext.GetFullExtent(strings, dc)
928
+ textheight = height
929
+
930
+ lX = dc.GetCharWidth()/2.0
931
+ lY = dc.GetCharHeight()/2.0
932
+
933
+ if self._agwStyle & SM_ROTATE_TEXT:
934
+ angis = colourangles[ii] - float(width)/(2.0*radius)
935
+ x, y = self.CircleCoords(radius-10.0*self.scale, angis, centerX, centerY)
936
+ dc.DrawRotatedText(strings, x, y, angles)
937
+ else:
938
+ angis = colourangles[ii]
939
+ if self._agwStyle & SM_DRAW_FANCY_TICKS == 0:
940
+ x, y = self.CircleCoords(radius-10*self.scale, angis, centerX, centerY)
941
+ lX = lX*len(strings)
942
+ x = x - lX - width*cos(angis)/2.0
943
+ y = y - lY - height*sin(angis)/2.0
944
+
945
+ if self._agwStyle & SM_DRAW_FANCY_TICKS:
946
+ fancystr = '<font family="' + ffamily + '" size="' + str(int(fsize)) + '" weight="' + fweight + '"'
947
+ fancystr = fancystr + ' color="' + fcolour + '"' + ' style="' + fstyle + '"> ' + strings + ' </font>'
948
+
949
+ width, height, dummy = fancytext.GetFullExtent(fancystr, dc)
950
+ x, y = self.CircleCoords(radius-10*self.scale, angis, centerX, centerY)
951
+ x = x - width/2.0 - width*cos(angis)/2.0
952
+ y = y - height/2.0 - height*sin(angis)/2.0
953
+ fancytext.RenderToDC(fancystr, dc, x, y)
954
+ else:
955
+ dc.DrawText(strings, int(x), int(y))
956
+
957
+ # This Is The Small Rectangle --> Tick Mark
958
+ rectangle = colourangles[ii] + pi/2.0
959
+
960
+ sinrect = sin(rectangle)
961
+ cosrect = cos(rectangle)
962
+ x1 = xcoords[ii] - self.scale*cosrect
963
+ y1 = ycoords[ii] - self.scale*sinrect
964
+ x2 = x1 + 3*self.scale*cosrect
965
+ y2 = y1 + 3*self.scale*sinrect
966
+ x3 = x1 - 10*self.scale*sinrect
967
+ y3 = y1 + 10*self.scale*cosrect
968
+ x4 = x3 + 3*self.scale*cosrect
969
+ y4 = y3 + 3*self.scale*sinrect
970
+
971
+ points = [(x1, y1), (x2, y2), (x4, y4), (x3, y3)]
972
+ points = [(int(p[0]), int(p[1])) for p in points]
973
+
974
+ dc.DrawPolygon(points)
975
+
976
+ if self._agwStyle & SM_DRAW_SECONDARY_TICKS:
977
+ if ii > 0:
978
+ newinterval = intervals[ii]
979
+ oldinterval = intervals[ii-1]
980
+
981
+ spacing = (newinterval - oldinterval)/float(ticknum+1)
982
+
983
+ for tcount in range(ticknum):
984
+ if direction == "Advance":
985
+ oldinterval = (oldinterval + spacing)
986
+ stint = oldinterval - start
987
+ else:
988
+ #oldinterval = start + (oldinterval + spacing)
989
+ oldinterval = (oldinterval + spacing)
990
+ stint = end - oldinterval
991
+
992
+ angle = (stint/float(span))*(startangle-endangle) - startangle
993
+ rectangle = angle + pi/2.0
994
+ sinrect = sin(rectangle)
995
+ cosrect = cos(rectangle)
996
+ xt, yt = self.CircleCoords(radius, angle, centerX, centerY)
997
+ x1 = xt - self.scale*cosrect
998
+ y1 = yt - self.scale*sinrect
999
+ x2 = x1 + self.scale*cosrect
1000
+ y2 = y1 + self.scale*sinrect
1001
+ x3 = x1 - 6*self.scale*sinrect
1002
+ y3 = y1 + 6*self.scale*cosrect
1003
+ x4 = x3 + self.scale*cosrect
1004
+ y4 = y3 + self.scale*sinrect
1005
+
1006
+ points = [(x1, y1), (x2, y2), (x4, y4), (x3, y3)]
1007
+ points = [(int(p[0]), int(p[1])) for p in points]
1008
+
1009
+ dc.DrawPolygon(points)
1010
+
1011
+ oldinterval = newinterval
1012
+
1013
+ tfont.SetPointSize(fontsize)
1014
+ tfont.SetFamily(myfamily)
1015
+
1016
+ self.SetTicksFont(tfont)
1017
+
1018
+ # Draw The External Arc
1019
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
1020
+
1021
+ if self._drawarc:
1022
+ dc.SetPen(wx.Pen(self.GetArcColour(), 2))
1023
+ # If It's Not A Complete Circle, Draw The Connecting Lines And The Arc
1024
+ if abs(abs(startangle - endangle) - 2*pi) > 1.0/180.0:
1025
+ dc.DrawArc(xstart, ystart, xend, yend, centerX, centerY)
1026
+ dc.DrawLine(xstart, ystart, centerX, centerY)
1027
+ dc.DrawLine(xend, yend, centerX, centerY)
1028
+ else:
1029
+ # Draw A Circle, Is A 2*pi Extension Arc = Complete Circle
1030
+ dc.DrawCircle(centerX, centerY, radius)
1031
+
1032
+
1033
+ # Here We Draw The Text In The Middle, Near The Start Of The Arrow (If Present)
1034
+ # This Is Like The "Km/h" Or "mph" Text In The Cars
1035
+ if self._agwStyle & SM_DRAW_MIDDLE_TEXT:
1036
+
1037
+ middlecolour = self.GetMiddleTextColour()
1038
+ middletext = self.GetMiddleText()
1039
+ middleangle = (startangle + endangle)/2.0
1040
+
1041
+ middlefont, middlesize = self.GetMiddleTextFont()
1042
+ middlesize = self.scale*middlesize
1043
+ middlefont.SetPointSize(int(middlesize))
1044
+ dc.SetFont(middlefont)
1045
+
1046
+ mw, mh, dummy, dummy = dc.GetFullTextExtent(middletext, middlefont)
1047
+
1048
+ newx = centerX + 1.5*mw*cos(middleangle) - mw/2.0
1049
+ newy = centerY - 1.5*mh*sin(middleangle) - mh/2.0
1050
+ dc.SetTextForeground(middlecolour)
1051
+ dc.DrawText(middletext, int(newx), int(newy))
1052
+
1053
+ # Here We Draw The Icon In The Middle, Near The Start Of The Arrow (If Present)
1054
+ # This Is Like The "Fuel" Icon In The Cars
1055
+ if self._agwStyle & SM_DRAW_MIDDLE_ICON and self.GetMiddleIcon():
1056
+
1057
+ middleicon = self.GetMiddleIcon()
1058
+ middlewidth, middleheight = self.GetMiddleIconDimens()
1059
+ middleicon.SetWidth(int(middlewidth*self.scale))
1060
+ middleicon.SetHeight(int(middleheight*self.scale))
1061
+ middleangle = (startangle + endangle)/2.0
1062
+
1063
+ mw = middleicon.GetWidth()
1064
+ mh = middleicon.GetHeight()
1065
+
1066
+ newx = centerX + 1.5*mw*cos(middleangle) - mw/2.0
1067
+ newy = centerY - 1.5*mh*sin(middleangle) - mh/2.0
1068
+
1069
+ dc.DrawIcon(middleicon, int(newx), int(newy))
1070
+
1071
+ # Restore Icon Dimension, If Not Something Strange Happens
1072
+ middleicon.SetWidth(middlewidth)
1073
+ middleicon.SetHeight(middleheight)
1074
+
1075
+
1076
+ # Requested To Draw The Hand
1077
+ if self._agwStyle & SM_DRAW_HAND:
1078
+
1079
+ handstyle = self.GetHandStyle()
1080
+ handcolour = self.GetHandColour()
1081
+
1082
+ # Calculate The Data For The Hand
1083
+ if textheight == 0:
1084
+ maxradius = radius-10*self.scale
1085
+ else:
1086
+ maxradius = radius-5*self.scale-textheight
1087
+
1088
+ xarr, yarr = self.CircleCoords(maxradius, accelangle, centerX, centerY)
1089
+
1090
+ if handstyle == "Arrow":
1091
+ x1, y1 = self.CircleCoords(maxradius, accelangle - 4.0/180, centerX, centerY)
1092
+ x2, y2 = self.CircleCoords(maxradius, accelangle + 4.0/180, centerX, centerY)
1093
+ x3, y3 = self.CircleCoords(maxradius+3*(abs(xarr-x1)), accelangle, centerX, centerY)
1094
+
1095
+ newx = centerX + 4*cos(accelangle)*self.scale
1096
+ newy = centerY + 4*sin(accelangle)*self.scale
1097
+
1098
+ else:
1099
+
1100
+ x1 = centerX + 4*self.scale*sin(accelangle)
1101
+ y1 = centerY - 4*self.scale*cos(accelangle)
1102
+ x2 = xarr
1103
+ y2 = yarr
1104
+ x3 = centerX - 4*self.scale*sin(accelangle)
1105
+ y3 = centerY + 4*self.scale*cos(accelangle)
1106
+
1107
+ x4, y4 = self.CircleCoords(5*self.scale*sqrt(3), accelangle+pi, centerX, centerY)
1108
+
1109
+ if self._agwStyle & SM_DRAW_SHADOW:
1110
+
1111
+ if handstyle == "Arrow":
1112
+ # Draw The Shadow
1113
+ shadowcolour = self.GetShadowColour()
1114
+ dc.SetPen(wx.Pen(shadowcolour, int(5*log(self.scale+1))))
1115
+ dc.SetBrush(wx.Brush(shadowcolour))
1116
+ shadowdistance = 2.0*self.scale
1117
+ dc.DrawLine(int(newx + shadowdistance), int(newy + shadowdistance),
1118
+ int(xarr + shadowdistance), int(yarr + shadowdistance))
1119
+
1120
+ points = [(x1+shadowdistance, y1+shadowdistance),
1121
+ (x2+shadowdistance, y2+shadowdistance),
1122
+ (x3+shadowdistance, y3+shadowdistance)]
1123
+ points = [(int(p[0]), int(p[1])) for p in points]
1124
+ dc.DrawPolygon(points)
1125
+ else:
1126
+ # Draw The Shadow
1127
+ shadowcolour = self.GetShadowColour()
1128
+ dc.SetBrush(wx.Brush(shadowcolour))
1129
+ dc.SetPen(wx.Pen(shadowcolour, 1))
1130
+ shadowdistance = 1.5*self.scale
1131
+
1132
+ points = [(x1+shadowdistance, y1+shadowdistance),
1133
+ (x2+shadowdistance, y2+shadowdistance),
1134
+ (x3+shadowdistance, y3+shadowdistance),
1135
+ (x4+shadowdistance, y4+shadowdistance)]
1136
+ points = [(int(p[0]), int(p[1])) for p in points]
1137
+ dc.DrawPolygon(points)
1138
+
1139
+ if handstyle == "Arrow":
1140
+
1141
+ dc.SetPen(wx.Pen(handcolour, 1))
1142
+
1143
+ # Draw The Small Circle In The Center --> The Hand "Holder"
1144
+ dc.SetBrush(wx.Brush(speedbackground))
1145
+ dc.DrawCircle(centerX, centerY, int(4*self.scale))
1146
+
1147
+ dc.SetPen(wx.Pen(handcolour, int(5*log(self.scale+1))))
1148
+ # Draw The "Hand", An Arrow
1149
+ dc.DrawLine(int(newx), int(newy), int(xarr), int(yarr))
1150
+
1151
+ # Draw The Arrow Pointer
1152
+ dc.SetBrush(wx.Brush(handcolour))
1153
+ points = [(x1, y1), (x2, y2), (x3, y3)]
1154
+ points = [(int(p[0]), int(p[1])) for p in points]
1155
+ dc.DrawPolygon(points)
1156
+
1157
+ else:
1158
+
1159
+ # Draw The Hand Pointer
1160
+ dc.SetPen(wx.Pen(handcolour, 1))
1161
+ dc.SetBrush(wx.Brush(handcolour))
1162
+ points = [(x1, y1), (x2, y2), (x3, y3), (x4, y4)]
1163
+ points = [(int(p[0]), int(p[1])) for p in points]
1164
+ dc.DrawPolygon(points)
1165
+
1166
+ # Draw The Small Circle In The Center --> The Hand "Holder"
1167
+ dc.SetBrush(wx.Brush(speedbackground))
1168
+ dc.DrawCircle(centerX, centerY, int(4*self.scale))
1169
+
1170
+
1171
+ def SetIntervals(self, intervals=None):
1172
+ """
1173
+ Sets the intervals for :class:`SpeedMeter` (main ticks numeric values).
1174
+
1175
+ :param `intervals`: a Python list of main ticks to be displayed. If defaulted
1176
+ to ``None``, the list `[0, 50, 100]` is used.
1177
+ """
1178
+
1179
+ if intervals is None:
1180
+ intervals = [0, 50, 100]
1181
+
1182
+ self._intervals = intervals
1183
+
1184
+
1185
+ def GetIntervals(self):
1186
+ """ Returns the intervals for :class:`SpeedMeter`, a Python list of main ticks displayed. """
1187
+
1188
+ return self._intervals
1189
+
1190
+
1191
+ def SetSpeedValue(self, value=None):
1192
+ """
1193
+ Sets the current value for :class:`SpeedMeter`.
1194
+
1195
+ :param `value`: a floating point number representing the current value. If defaulted
1196
+ to ``None``, the :class:`SpeedMeter` value will be the middle point of the control range.
1197
+ """
1198
+
1199
+ if value is None:
1200
+ value = (max(self._intervals) - min(self._intervals))/2.0
1201
+ else:
1202
+ if value < min(self._intervals):
1203
+ raise Exception("\nERROR: Value Is Smaller Than Minimum Element In Points List")
1204
+ return
1205
+ elif value > max(self._intervals):
1206
+ raise Exception("\nERROR: Value Is Greater Than Maximum Element In Points List")
1207
+ return
1208
+
1209
+ self._speedvalue = value
1210
+ try:
1211
+ self.UpdateDrawing()
1212
+ except:
1213
+ pass
1214
+
1215
+
1216
+ def GetSpeedValue(self):
1217
+ """ Returns the current value for :class:`SpeedMeter`. """
1218
+
1219
+ return self._speedvalue
1220
+
1221
+
1222
+ def SetAngleRange(self, start=0, end=pi):
1223
+ """
1224
+ Sets the range of existence for :class:`SpeedMeter`.
1225
+
1226
+ :param `start`: the starting angle, in radians;
1227
+ :param `end`: the ending angle, in radians.
1228
+ """
1229
+
1230
+ self._anglerange = [start, end]
1231
+
1232
+
1233
+ def GetAngleRange(self):
1234
+ """
1235
+ Returns the range of existence for :class:`SpeedMeter`.
1236
+ The returned values are in radians.
1237
+ """
1238
+
1239
+ return self._anglerange
1240
+
1241
+
1242
+ def SetIntervalColours(self, colours=None):
1243
+ """
1244
+ Sets the colours for the intervals.
1245
+
1246
+ :param `colours`: a Python list of colours. The length of this list should be
1247
+ the same as the number of circle sectors in :class:`SpeedMeter`. If defaulted to ``None``,
1248
+ all the intervals will have a white colour.
1249
+
1250
+ :note: Every interval (circle sector) should have a colour.
1251
+ """
1252
+
1253
+ if colours is None:
1254
+ if not hasattr(self, "_anglerange"):
1255
+ errstr = "\nERROR: Impossible To Set Interval Colours,"
1256
+ errstr = errstr + " Please Define The Intervals Ranges Before."
1257
+ raise Exception(errstr)
1258
+ return
1259
+
1260
+ colours = [wx.WHITE]*len(self._intervals)
1261
+ else:
1262
+ if len(colours) != len(self._intervals) - 1:
1263
+ errstr = "\nERROR: Length Of Colour List Does Not Match Length"
1264
+ errstr = errstr + " Of Intervals Ranges List."
1265
+ raise Exception(errstr)
1266
+ return
1267
+
1268
+ self._intervalcolours = colours
1269
+
1270
+
1271
+ def GetIntervalColours(self):
1272
+ """ Returns the colours for the intervals."""
1273
+
1274
+ if hasattr(self, "_intervalcolours"):
1275
+ return self._intervalcolours
1276
+ else:
1277
+ raise Exception("\nERROR: No Interval Colours Have Been Defined")
1278
+
1279
+
1280
+ def SetTicks(self, ticks=None):
1281
+ """
1282
+ Sets the ticks for :class:`SpeedMeter` intervals (main ticks string values).
1283
+
1284
+ :param `ticks`: a Python list of strings, representing the ticks values.
1285
+ If defaulted to ``None``, the ticks will be taken from the interval values.
1286
+ """
1287
+
1288
+ if ticks is None:
1289
+ if not hasattr(self, "_anglerange"):
1290
+ errstr = "\nERROR: Impossible To Set Interval Ticks,"
1291
+ errstr = errstr + " Please Define The Intervals Ranges Before."
1292
+ raise Exception(errstr)
1293
+ return
1294
+
1295
+ ticks = []
1296
+
1297
+ for values in self._intervals:
1298
+ ticks.append(str(values))
1299
+
1300
+ else:
1301
+ if len(ticks) != len(self._intervals):
1302
+ errstr = "\nERROR: Length Of Ticks List Does Not Match Length"
1303
+ errstr = errstr + " Of Intervals Ranges List."
1304
+ raise Exception(errstr)
1305
+ return
1306
+
1307
+ self._intervalticks = ticks
1308
+
1309
+
1310
+ def GetTicks(self):
1311
+ """ Returns the ticks for :class:`SpeedMeter` intervals (main ticks string values)."""
1312
+
1313
+ if hasattr(self, "_intervalticks"):
1314
+ return self._intervalticks
1315
+ else:
1316
+ raise Exception("\nERROR: No Interval Ticks Have Been Defined")
1317
+
1318
+
1319
+ def SetTicksFont(self, font=None):
1320
+ """
1321
+ Sets the ticks font.
1322
+
1323
+ :param `font`: a valid :class:`wx.Font` object. If defaulted to ``None``, some standard
1324
+ font will be chosen automatically.
1325
+ """
1326
+
1327
+ if font is None:
1328
+ self._originalfont = [wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False)]
1329
+ self._originalsize = 10
1330
+ else:
1331
+ self._originalfont = [font]
1332
+ self._originalsize = font.GetPointSize()
1333
+
1334
+
1335
+ def GetTicksFont(self):
1336
+ """ Returns the ticks font."""
1337
+
1338
+ return self._originalfont[:], self._originalsize
1339
+
1340
+
1341
+ def SetTicksColour(self, colour=None):
1342
+ """
1343
+ Sets the ticks colour.
1344
+
1345
+ :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the
1346
+ ticks colour will be set as blue.
1347
+ """
1348
+
1349
+ if colour is None:
1350
+ colour = wx.BLUE
1351
+
1352
+ self._tickscolour = colour
1353
+
1354
+
1355
+ def GetTicksColour(self):
1356
+ """ Returns the ticks colour."""
1357
+
1358
+ return self._tickscolour
1359
+
1360
+
1361
+ def SetSpeedBackground(self, colour=None):
1362
+ """
1363
+ Sets the background colour outside the :class:`SpeedMeter` control.
1364
+
1365
+ :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the
1366
+ :class:`SpeedMeter` background will be taken from the system default.
1367
+ """
1368
+
1369
+ if colour is None:
1370
+ colour = wx.SystemSettings.GetColour(0)
1371
+
1372
+ self._speedbackground = colour
1373
+
1374
+
1375
+ def GetSpeedBackground(self):
1376
+ """ Returns the background colour outside the :class:`SpeedMeter` control."""
1377
+
1378
+ return self._speedbackground
1379
+
1380
+
1381
+ def SetHandColour(self, colour=None):
1382
+ """
1383
+ Sets the hand (arrow indicator) colour.
1384
+
1385
+ :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the arrow
1386
+ indicator will be red.
1387
+ """
1388
+
1389
+ if colour is None:
1390
+ colour = wx.RED
1391
+
1392
+ self._handcolour = colour
1393
+
1394
+
1395
+ def GetHandColour(self):
1396
+ """ Returns the hand (arrow indicator) colour."""
1397
+
1398
+ return self._handcolour
1399
+
1400
+
1401
+ def SetArcColour(self, colour=None):
1402
+ """
1403
+ Sets the external arc colour (thicker line).
1404
+
1405
+ :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the arc
1406
+ colour will be black.
1407
+ """
1408
+
1409
+ if colour is None:
1410
+ colour = wx.BLACK
1411
+
1412
+ self._arccolour = colour
1413
+
1414
+
1415
+ def GetArcColour(self):
1416
+ """ Returns the external arc colour."""
1417
+
1418
+ return self._arccolour
1419
+
1420
+
1421
+ def SetShadowColour(self, colour=None):
1422
+ """
1423
+ Sets the hand's shadow colour.
1424
+
1425
+ :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the shadow
1426
+ colour will be light grey.
1427
+ """
1428
+
1429
+ if colour is None:
1430
+ colour = wx.Colour(150, 150, 150)
1431
+
1432
+ self._shadowcolour = colour
1433
+
1434
+
1435
+ def GetShadowColour(self):
1436
+ """ Returns the hand's shadow colour."""
1437
+
1438
+ return self._shadowcolour
1439
+
1440
+
1441
+ def SetFillerColour(self, colour=None):
1442
+ """
1443
+ Sets the partial filler colour.
1444
+
1445
+ A circle corona near the ticks will be filled with this colour, from
1446
+ the starting value to the current value of :class:`SpeedMeter`.
1447
+
1448
+ :param `colour`: a valid :class:`wx.Colour` object.
1449
+ """
1450
+
1451
+ if colour is None:
1452
+ colour = wx.Colour(255, 150, 50)
1453
+
1454
+ self._fillercolour = colour
1455
+
1456
+
1457
+ def GetFillerColour(self):
1458
+ """ Returns the partial filler colour."""
1459
+
1460
+ return self._fillercolour
1461
+
1462
+
1463
+ def SetDirection(self, direction=None):
1464
+ """
1465
+ Sets the direction of advancing :class:`SpeedMeter` value.
1466
+
1467
+ :param `direction`: specifying "advance" will move the hand in clock-wise direction
1468
+ (like normal car speed control), while using "reverse" will move it counterclock-wise
1469
+ direction. If defaulted to ``None``, then "advance" will be used.
1470
+ """
1471
+
1472
+ if direction is None:
1473
+ direction = "Advance"
1474
+
1475
+ if direction not in ["Advance", "Reverse"]:
1476
+ raise Exception('\nERROR: Direction Parameter Should Be One Of "Advance" Or "Reverse".')
1477
+
1478
+ self._direction = direction
1479
+
1480
+
1481
+ def GetDirection(self):
1482
+ """ Returns the direction of advancing :class:`SpeedMeter` value."""
1483
+
1484
+ return self._direction
1485
+
1486
+
1487
+ def SetNumberOfSecondaryTicks(self, ticknum=None):
1488
+ """
1489
+ Sets the number of secondary (intermediate) ticks.
1490
+
1491
+ :param `ticknum`: the number of intermediate ticks. If defaulted to ``None``,
1492
+ 3 ticks are used.
1493
+ """
1494
+
1495
+ if ticknum is None:
1496
+ ticknum = 3
1497
+
1498
+ if ticknum < 1:
1499
+ raise Exception("\nERROR: Number Of Ticks Must Be Greater Than 1.")
1500
+
1501
+ self._secondaryticks = ticknum
1502
+
1503
+
1504
+ def GetNumberOfSecondaryTicks(self):
1505
+ """ Returns the number of secondary (intermediate) ticks. """
1506
+
1507
+ return self._secondaryticks
1508
+
1509
+
1510
+ def SetMiddleText(self, text=None):
1511
+ """
1512
+ Sets the text to be drawn near the center of :class:`SpeedMeter`.
1513
+
1514
+ :param `text`: the text to be drawn near the center of :class:`SpeedMeter`. If
1515
+ defaulted to ``None``, an empty string will be used.
1516
+ """
1517
+
1518
+ if text is None:
1519
+ text = ""
1520
+
1521
+ self._middletext = text
1522
+
1523
+
1524
+ def GetMiddleText(self):
1525
+ """ Returns the text to be drawn near the center of :class:`SpeedMeter`. """
1526
+
1527
+ return self._middletext
1528
+
1529
+
1530
+ def SetMiddleTextFont(self, font=None):
1531
+ """
1532
+ Sets the font for the text in the middle.
1533
+
1534
+ :param `font`: a valid :class:`wx.Font` object. If defaulted to ``None``, some
1535
+ standard font will be generated.
1536
+ """
1537
+
1538
+ if font is None:
1539
+ self._middletextfont = wx.Font(1, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False)
1540
+ self._middletextsize = 10
1541
+ self._middletextfont.SetPointSize(self._middletextsize)
1542
+ else:
1543
+ self._middletextfont = font
1544
+ self._middletextsize = font.GetPointSize()
1545
+ self._middletextfont.SetPointSize(self._middletextsize)
1546
+
1547
+
1548
+ def GetMiddleTextFont(self):
1549
+ """ Returns the font for the text in the middle."""
1550
+
1551
+ return self._middletextfont, self._middletextsize
1552
+
1553
+
1554
+ def SetMiddleTextColour(self, colour=None):
1555
+ """
1556
+ Sets the colour for the text in the middle.
1557
+
1558
+ :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the text
1559
+ in the middle will be painted in blue.
1560
+ """
1561
+
1562
+ if colour is None:
1563
+ colour = wx.BLUE
1564
+
1565
+ self._middlecolour = colour
1566
+
1567
+
1568
+ def GetMiddleTextColour(self):
1569
+ """ Returns the colour for the text in the middle."""
1570
+
1571
+ return self._middlecolour
1572
+
1573
+
1574
+ def SetMiddleIcon(self, icon):
1575
+ """
1576
+ Sets the icon to be drawn near the center of :class:`SpeedMeter`.
1577
+
1578
+ :param `icon`: a valid :class:`wx.Bitmap` object.
1579
+ """
1580
+
1581
+ if icon.IsOk():
1582
+ self._middleicon = icon
1583
+ else:
1584
+ raise Exception("\nERROR: Invalid Icon Passed To SpeedMeter.")
1585
+
1586
+
1587
+ def GetMiddleIcon(self):
1588
+ """ Returns the icon to be drawn near the center of :class:`SpeedMeter`. """
1589
+
1590
+ return self._middleicon
1591
+
1592
+
1593
+ def GetMiddleIconDimens(self):
1594
+ """ Used internally. """
1595
+
1596
+ return self._middleicon.GetWidth(), self._middleicon.GetHeight()
1597
+
1598
+
1599
+ def CircleCoords(self, radius, angle, centerX, centerY):
1600
+ """
1601
+ Converts the input values into logical x, y coordinates.
1602
+
1603
+ :param `radius`: the :class:`SpeedMeter` radius;
1604
+ :param `angle`: the angular position of the mouse;
1605
+ :param `centerX`: the `x` position of the :class:`SpeedMeter` center;
1606
+ :param `centerX`: the `y` position of the :class:`SpeedMeter` center.
1607
+ """
1608
+
1609
+ x = radius*cos(angle) + centerX
1610
+ y = radius*sin(angle) + centerY
1611
+
1612
+ return int(x), int(y)
1613
+
1614
+
1615
+ def GetIntersection(self, current, intervals):
1616
+ """ Used internally. """
1617
+
1618
+ if self.GetDirection() == "Reverse":
1619
+ interval = intervals[:]
1620
+ interval.reverse()
1621
+ else:
1622
+ interval = intervals
1623
+
1624
+ indexes = list(range(len(intervals)))
1625
+ try:
1626
+ intersection = [ind for ind in indexes if interval[ind] <= current <= interval[ind+1]]
1627
+ except:
1628
+ if self.GetDirection() == "Reverse":
1629
+ intersection = [len(intervals) - 1]
1630
+ else:
1631
+ intersection = [0]
1632
+
1633
+ return intersection[0]
1634
+
1635
+
1636
+ def SetFirstGradientColour(self, colour=None):
1637
+ """
1638
+ Sets the first gradient colour (near the ticks).
1639
+
1640
+ :param `colour`: a valid :class:`wx.Colour` object.
1641
+ """
1642
+
1643
+ if colour is None:
1644
+ colour = wx.Colour(145, 220, 200)
1645
+
1646
+ self._firstgradientcolour = colour
1647
+
1648
+
1649
+ def GetFirstGradientColour(self):
1650
+ """ Returns the first gradient colour (near the ticks). """
1651
+
1652
+ return self._firstgradientcolour
1653
+
1654
+
1655
+ def SetSecondGradientColour(self, colour=None):
1656
+ """
1657
+ Sets the second gradient colour (near the center).
1658
+
1659
+ :param `colour`: a valid :class:`wx.Colour` object.
1660
+ """
1661
+
1662
+ if colour is None:
1663
+ colour = wx.WHITE
1664
+
1665
+ self._secondgradientcolour = colour
1666
+
1667
+
1668
+ def GetSecondGradientColour(self):
1669
+ """ Returns the first gradient colour (near the center). """
1670
+
1671
+ return self._secondgradientcolour
1672
+
1673
+
1674
+ def SetHandStyle(self, style=None):
1675
+ """
1676
+ Sets the style for the hand (arrow indicator).
1677
+
1678
+ :param `style`: by specifying "Hand", :class:`SpeedMeter` will draw a polygon
1679
+ that simulates the car speed control indicator. Using "Arrow" will force
1680
+ :class:`SpeedMeter` to draw a simple arrow. If defaulted to ``None``, "Hand" will
1681
+ be used.
1682
+ """
1683
+
1684
+ if style is None:
1685
+ style = "Hand"
1686
+
1687
+ if style not in ["Hand", "Arrow"]:
1688
+ raise Exception('\nERROR: Hand Style Parameter Should Be One Of "Hand" Or "Arrow".')
1689
+ return
1690
+
1691
+ self._handstyle = style
1692
+
1693
+
1694
+ def GetHandStyle(self):
1695
+ """ Returns the style for the hand (arrow indicator)."""
1696
+
1697
+ return self._handstyle
1698
+
1699
+
1700
+ def DrawExternalArc(self, draw=True):
1701
+ """
1702
+ Specify whether or not you wish to draw the external (thicker) arc.
1703
+
1704
+ :param `draw`: ``True`` to draw the external arc, ``False`` otherwise.
1705
+ """
1706
+
1707
+ self._drawarc = draw
1708
+
1709
+
1710
+ def OnMouseMotion(self, event):
1711
+ """
1712
+ Handles the ``wx.EVT_MOUSE_EVENTS`` event for :class:`SpeedMeter`.
1713
+
1714
+ :param `event`: a :class:`MouseEvent` event to be processed.
1715
+
1716
+ :note: Here only left clicks/drags are involved. Should :class:`SpeedMeter`
1717
+ have something more?
1718
+ """
1719
+
1720
+ mousex = event.GetX()
1721
+ mousey = event.GetY()
1722
+
1723
+ if event.Leaving():
1724
+ return
1725
+
1726
+ pos = self.GetClientSize()
1727
+ size = self.GetPosition()
1728
+ centerX = self.CenterX
1729
+ centerY = self.CenterY
1730
+
1731
+ direction = self.GetDirection()
1732
+
1733
+ if event.LeftIsDown():
1734
+
1735
+ angle = atan2(float(mousey) - centerY, centerX - float(mousex)) + pi - self.EndAngle
1736
+ if angle >= 2*pi:
1737
+ angle = angle - 2*pi
1738
+
1739
+ if direction == "Advance":
1740
+ currentvalue = (self.StartAngle - self.EndAngle - angle)*float(self.Span)/(self.StartAngle - self.EndAngle) + self.StartValue
1741
+ else:
1742
+ currentvalue = (angle)*float(self.Span)/(self.StartAngle - self.EndAngle) + self.StartValue
1743
+
1744
+ if currentvalue >= self.StartValue and currentvalue <= self.EndValue:
1745
+ self.SetSpeedValue(currentvalue)
1746
+
1747
+ event.Skip()
1748
+
1749
+
1750
+ def GetSpeedStyle(self):
1751
+ """ Returns a list of strings and a list of integers containing the styles. """
1752
+
1753
+ stringstyle = []
1754
+ integerstyle = []
1755
+
1756
+ if self._agwStyle & SM_ROTATE_TEXT:
1757
+ stringstyle.append("SM_ROTATE_TEXT")
1758
+ integerstyle.append(SM_ROTATE_TEXT)
1759
+
1760
+ if self._agwStyle & SM_DRAW_SECTORS:
1761
+ stringstyle.append("SM_DRAW_SECTORS")
1762
+ integerstyle.append(SM_DRAW_SECTORS)
1763
+
1764
+ if self._agwStyle & SM_DRAW_PARTIAL_SECTORS:
1765
+ stringstyle.append("SM_DRAW_PARTIAL_SECTORS")
1766
+ integerstyle.append(SM_DRAW_PARTIAL_SECTORS)
1767
+
1768
+ if self._agwStyle & SM_DRAW_HAND:
1769
+ stringstyle.append("SM_DRAW_HAND")
1770
+ integerstyle.append(SM_DRAW_HAND)
1771
+
1772
+ if self._agwStyle & SM_DRAW_SHADOW:
1773
+ stringstyle.append("SM_DRAW_SHADOW")
1774
+ integerstyle.append(SM_DRAW_SHADOW)
1775
+
1776
+ if self._agwStyle & SM_DRAW_PARTIAL_FILLER:
1777
+ stringstyle.append("SM_DRAW_PARTIAL_FILLER")
1778
+ integerstyle.append(SM_DRAW_PARTIAL_FILLER)
1779
+
1780
+ if self._agwStyle & SM_DRAW_SECONDARY_TICKS:
1781
+ stringstyle.append("SM_DRAW_SECONDARY_TICKS")
1782
+ integerstyle.append(SM_DRAW_SECONDARY_TICKS)
1783
+
1784
+ if self._agwStyle & SM_DRAW_MIDDLE_TEXT:
1785
+ stringstyle.append("SM_DRAW_MIDDLE_TEXT")
1786
+ integerstyle.append(SM_DRAW_MIDDLE_TEXT)
1787
+
1788
+ if self._agwStyle & SM_DRAW_MIDDLE_ICON:
1789
+ stringstyle.append("SM_DRAW_MIDDLE_ICON")
1790
+ integerstyle.append(SM_DRAW_MIDDLE_ICON)
1791
+
1792
+ if self._agwStyle & SM_DRAW_GRADIENT:
1793
+ stringstyle.append("SM_DRAW_GRADIENT")
1794
+ integerstyle.append(SM_DRAW_GRADIENT)
1795
+
1796
+ if self._agwStyle & SM_DRAW_FANCY_TICKS:
1797
+ stringstyle.append("SM_DRAW_FANCY_TICKS")
1798
+ integerstyle.append(SM_DRAW_FANCY_TICKS)
1799
+
1800
+ return stringstyle, integerstyle