meerk40t 0.9.3001__py2.py3-none-any.whl → 0.9.7020__py2.py3-none-any.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 (446) hide show
  1. meerk40t/__init__.py +1 -1
  2. meerk40t/balormk/balor_params.py +167 -167
  3. meerk40t/balormk/clone_loader.py +457 -457
  4. meerk40t/balormk/controller.py +1566 -1512
  5. meerk40t/balormk/cylindermod.py +64 -0
  6. meerk40t/balormk/device.py +966 -1959
  7. meerk40t/balormk/driver.py +778 -591
  8. meerk40t/balormk/galvo_commands.py +1194 -0
  9. meerk40t/balormk/gui/balorconfig.py +237 -111
  10. meerk40t/balormk/gui/balorcontroller.py +191 -184
  11. meerk40t/balormk/gui/baloroperationproperties.py +116 -115
  12. meerk40t/balormk/gui/corscene.py +845 -0
  13. meerk40t/balormk/gui/gui.py +179 -147
  14. meerk40t/balormk/livelightjob.py +466 -382
  15. meerk40t/balormk/mock_connection.py +131 -109
  16. meerk40t/balormk/plugin.py +133 -135
  17. meerk40t/balormk/usb_connection.py +306 -301
  18. meerk40t/camera/__init__.py +1 -1
  19. meerk40t/camera/camera.py +514 -397
  20. meerk40t/camera/gui/camerapanel.py +1241 -1095
  21. meerk40t/camera/gui/gui.py +58 -58
  22. meerk40t/camera/plugin.py +441 -399
  23. meerk40t/ch341/__init__.py +27 -27
  24. meerk40t/ch341/ch341device.py +628 -628
  25. meerk40t/ch341/libusb.py +595 -589
  26. meerk40t/ch341/mock.py +171 -171
  27. meerk40t/ch341/windriver.py +157 -157
  28. meerk40t/constants.py +13 -0
  29. meerk40t/core/__init__.py +1 -1
  30. meerk40t/core/bindalias.py +550 -539
  31. meerk40t/core/core.py +47 -47
  32. meerk40t/core/cutcode/cubiccut.py +73 -73
  33. meerk40t/core/cutcode/cutcode.py +315 -312
  34. meerk40t/core/cutcode/cutgroup.py +141 -137
  35. meerk40t/core/cutcode/cutobject.py +192 -185
  36. meerk40t/core/cutcode/dwellcut.py +37 -37
  37. meerk40t/core/cutcode/gotocut.py +29 -29
  38. meerk40t/core/cutcode/homecut.py +29 -29
  39. meerk40t/core/cutcode/inputcut.py +34 -34
  40. meerk40t/core/cutcode/linecut.py +33 -33
  41. meerk40t/core/cutcode/outputcut.py +34 -34
  42. meerk40t/core/cutcode/plotcut.py +335 -335
  43. meerk40t/core/cutcode/quadcut.py +61 -61
  44. meerk40t/core/cutcode/rastercut.py +168 -148
  45. meerk40t/core/cutcode/waitcut.py +34 -34
  46. meerk40t/core/cutplan.py +1843 -1316
  47. meerk40t/core/drivers.py +330 -329
  48. meerk40t/core/elements/align.py +801 -669
  49. meerk40t/core/elements/branches.py +1858 -1507
  50. meerk40t/core/elements/clipboard.py +229 -219
  51. meerk40t/core/elements/element_treeops.py +4595 -2837
  52. meerk40t/core/elements/element_types.py +125 -105
  53. meerk40t/core/elements/elements.py +4315 -3617
  54. meerk40t/core/elements/files.py +117 -64
  55. meerk40t/core/elements/geometry.py +473 -224
  56. meerk40t/core/elements/grid.py +467 -316
  57. meerk40t/core/elements/materials.py +158 -94
  58. meerk40t/core/elements/notes.py +50 -38
  59. meerk40t/core/elements/offset_clpr.py +934 -912
  60. meerk40t/core/elements/offset_mk.py +963 -955
  61. meerk40t/core/elements/penbox.py +339 -267
  62. meerk40t/core/elements/placements.py +300 -83
  63. meerk40t/core/elements/render.py +785 -687
  64. meerk40t/core/elements/shapes.py +2618 -2092
  65. meerk40t/core/elements/testcases.py +105 -0
  66. meerk40t/core/elements/trace.py +651 -563
  67. meerk40t/core/elements/tree_commands.py +415 -409
  68. meerk40t/core/elements/undo_redo.py +116 -58
  69. meerk40t/core/elements/wordlist.py +319 -200
  70. meerk40t/core/exceptions.py +9 -9
  71. meerk40t/core/laserjob.py +220 -220
  72. meerk40t/core/logging.py +63 -63
  73. meerk40t/core/node/blobnode.py +83 -86
  74. meerk40t/core/node/bootstrap.py +105 -103
  75. meerk40t/core/node/branch_elems.py +40 -31
  76. meerk40t/core/node/branch_ops.py +45 -38
  77. meerk40t/core/node/branch_regmark.py +48 -41
  78. meerk40t/core/node/cutnode.py +29 -32
  79. meerk40t/core/node/effect_hatch.py +375 -257
  80. meerk40t/core/node/effect_warp.py +398 -0
  81. meerk40t/core/node/effect_wobble.py +441 -309
  82. meerk40t/core/node/elem_ellipse.py +404 -309
  83. meerk40t/core/node/elem_image.py +1082 -801
  84. meerk40t/core/node/elem_line.py +358 -292
  85. meerk40t/core/node/elem_path.py +259 -201
  86. meerk40t/core/node/elem_point.py +129 -102
  87. meerk40t/core/node/elem_polyline.py +310 -246
  88. meerk40t/core/node/elem_rect.py +376 -286
  89. meerk40t/core/node/elem_text.py +445 -418
  90. meerk40t/core/node/filenode.py +59 -40
  91. meerk40t/core/node/groupnode.py +138 -74
  92. meerk40t/core/node/image_processed.py +777 -766
  93. meerk40t/core/node/image_raster.py +156 -113
  94. meerk40t/core/node/layernode.py +31 -31
  95. meerk40t/core/node/mixins.py +135 -107
  96. meerk40t/core/node/node.py +1427 -1304
  97. meerk40t/core/node/nutils.py +117 -114
  98. meerk40t/core/node/op_cut.py +463 -335
  99. meerk40t/core/node/op_dots.py +296 -251
  100. meerk40t/core/node/op_engrave.py +414 -311
  101. meerk40t/core/node/op_image.py +755 -369
  102. meerk40t/core/node/op_raster.py +787 -522
  103. meerk40t/core/node/place_current.py +37 -40
  104. meerk40t/core/node/place_point.py +329 -126
  105. meerk40t/core/node/refnode.py +58 -47
  106. meerk40t/core/node/rootnode.py +225 -219
  107. meerk40t/core/node/util_console.py +48 -48
  108. meerk40t/core/node/util_goto.py +84 -65
  109. meerk40t/core/node/util_home.py +61 -61
  110. meerk40t/core/node/util_input.py +102 -102
  111. meerk40t/core/node/util_output.py +102 -102
  112. meerk40t/core/node/util_wait.py +65 -65
  113. meerk40t/core/parameters.py +709 -707
  114. meerk40t/core/planner.py +875 -785
  115. meerk40t/core/plotplanner.py +656 -652
  116. meerk40t/core/space.py +120 -113
  117. meerk40t/core/spoolers.py +706 -705
  118. meerk40t/core/svg_io.py +1836 -1549
  119. meerk40t/core/treeop.py +534 -445
  120. meerk40t/core/undos.py +278 -124
  121. meerk40t/core/units.py +784 -680
  122. meerk40t/core/view.py +393 -322
  123. meerk40t/core/webhelp.py +62 -62
  124. meerk40t/core/wordlist.py +513 -504
  125. meerk40t/cylinder/cylinder.py +247 -0
  126. meerk40t/cylinder/gui/cylindersettings.py +41 -0
  127. meerk40t/cylinder/gui/gui.py +24 -0
  128. meerk40t/device/__init__.py +1 -1
  129. meerk40t/device/basedevice.py +322 -123
  130. meerk40t/device/devicechoices.py +50 -0
  131. meerk40t/device/dummydevice.py +163 -128
  132. meerk40t/device/gui/defaultactions.py +618 -602
  133. meerk40t/device/gui/effectspanel.py +114 -0
  134. meerk40t/device/gui/formatterpanel.py +253 -290
  135. meerk40t/device/gui/warningpanel.py +337 -260
  136. meerk40t/device/mixins.py +13 -13
  137. meerk40t/dxf/__init__.py +1 -1
  138. meerk40t/dxf/dxf_io.py +766 -554
  139. meerk40t/dxf/plugin.py +47 -35
  140. meerk40t/external_plugins.py +79 -79
  141. meerk40t/external_plugins_build.py +28 -28
  142. meerk40t/extra/cag.py +112 -116
  143. meerk40t/extra/coolant.py +403 -0
  144. meerk40t/extra/encode_detect.py +204 -0
  145. meerk40t/extra/ezd.py +1165 -1165
  146. meerk40t/extra/hershey.py +834 -340
  147. meerk40t/extra/imageactions.py +322 -316
  148. meerk40t/extra/inkscape.py +628 -622
  149. meerk40t/extra/lbrn.py +424 -424
  150. meerk40t/extra/outerworld.py +283 -0
  151. meerk40t/extra/param_functions.py +1542 -1556
  152. meerk40t/extra/potrace.py +257 -253
  153. meerk40t/extra/serial_exchange.py +118 -0
  154. meerk40t/extra/updater.py +602 -453
  155. meerk40t/extra/vectrace.py +147 -146
  156. meerk40t/extra/winsleep.py +83 -83
  157. meerk40t/extra/xcs_reader.py +597 -0
  158. meerk40t/fill/fills.py +781 -335
  159. meerk40t/fill/patternfill.py +1061 -1061
  160. meerk40t/fill/patterns.py +614 -567
  161. meerk40t/grbl/control.py +87 -87
  162. meerk40t/grbl/controller.py +990 -903
  163. meerk40t/grbl/device.py +1084 -768
  164. meerk40t/grbl/driver.py +989 -771
  165. meerk40t/grbl/emulator.py +532 -497
  166. meerk40t/grbl/gcodejob.py +783 -767
  167. meerk40t/grbl/gui/grblconfiguration.py +373 -298
  168. meerk40t/grbl/gui/grblcontroller.py +485 -271
  169. meerk40t/grbl/gui/grblhardwareconfig.py +269 -153
  170. meerk40t/grbl/gui/grbloperationconfig.py +105 -0
  171. meerk40t/grbl/gui/gui.py +147 -116
  172. meerk40t/grbl/interpreter.py +44 -44
  173. meerk40t/grbl/loader.py +22 -22
  174. meerk40t/grbl/mock_connection.py +56 -56
  175. meerk40t/grbl/plugin.py +294 -264
  176. meerk40t/grbl/serial_connection.py +93 -88
  177. meerk40t/grbl/tcp_connection.py +81 -79
  178. meerk40t/grbl/ws_connection.py +112 -0
  179. meerk40t/gui/__init__.py +1 -1
  180. meerk40t/gui/about.py +2042 -296
  181. meerk40t/gui/alignment.py +1644 -1608
  182. meerk40t/gui/autoexec.py +199 -0
  183. meerk40t/gui/basicops.py +791 -670
  184. meerk40t/gui/bufferview.py +77 -71
  185. meerk40t/gui/busy.py +232 -133
  186. meerk40t/gui/choicepropertypanel.py +1662 -1469
  187. meerk40t/gui/consolepanel.py +706 -542
  188. meerk40t/gui/devicepanel.py +687 -581
  189. meerk40t/gui/dialogoptions.py +110 -107
  190. meerk40t/gui/executejob.py +316 -306
  191. meerk40t/gui/fonts.py +90 -90
  192. meerk40t/gui/functionwrapper.py +252 -0
  193. meerk40t/gui/gui_mixins.py +729 -0
  194. meerk40t/gui/guicolors.py +205 -182
  195. meerk40t/gui/help_assets/help_assets.py +218 -201
  196. meerk40t/gui/helper.py +154 -0
  197. meerk40t/gui/hersheymanager.py +1440 -846
  198. meerk40t/gui/icons.py +3422 -2747
  199. meerk40t/gui/imagesplitter.py +555 -508
  200. meerk40t/gui/keymap.py +354 -344
  201. meerk40t/gui/laserpanel.py +897 -806
  202. meerk40t/gui/laserrender.py +1470 -1232
  203. meerk40t/gui/lasertoolpanel.py +805 -793
  204. meerk40t/gui/magnetoptions.py +436 -0
  205. meerk40t/gui/materialmanager.py +2944 -0
  206. meerk40t/gui/materialtest.py +1722 -1694
  207. meerk40t/gui/mkdebug.py +646 -359
  208. meerk40t/gui/mwindow.py +163 -140
  209. meerk40t/gui/navigationpanels.py +2605 -2467
  210. meerk40t/gui/notes.py +143 -142
  211. meerk40t/gui/opassignment.py +414 -410
  212. meerk40t/gui/operation_info.py +310 -299
  213. meerk40t/gui/plugin.py +500 -328
  214. meerk40t/gui/position.py +714 -669
  215. meerk40t/gui/preferences.py +901 -650
  216. meerk40t/gui/propertypanels/attributes.py +1461 -1131
  217. meerk40t/gui/propertypanels/blobproperty.py +117 -114
  218. meerk40t/gui/propertypanels/consoleproperty.py +83 -80
  219. meerk40t/gui/propertypanels/gotoproperty.py +77 -0
  220. meerk40t/gui/propertypanels/groupproperties.py +223 -217
  221. meerk40t/gui/propertypanels/hatchproperty.py +489 -469
  222. meerk40t/gui/propertypanels/imageproperty.py +2244 -1384
  223. meerk40t/gui/propertypanels/inputproperty.py +59 -58
  224. meerk40t/gui/propertypanels/opbranchproperties.py +82 -80
  225. meerk40t/gui/propertypanels/operationpropertymain.py +1890 -1638
  226. meerk40t/gui/propertypanels/outputproperty.py +59 -58
  227. meerk40t/gui/propertypanels/pathproperty.py +389 -380
  228. meerk40t/gui/propertypanels/placementproperty.py +1214 -383
  229. meerk40t/gui/propertypanels/pointproperty.py +140 -136
  230. meerk40t/gui/propertypanels/propertywindow.py +313 -181
  231. meerk40t/gui/propertypanels/rasterwizardpanels.py +996 -912
  232. meerk40t/gui/propertypanels/regbranchproperties.py +76 -0
  233. meerk40t/gui/propertypanels/textproperty.py +770 -755
  234. meerk40t/gui/propertypanels/waitproperty.py +56 -55
  235. meerk40t/gui/propertypanels/warpproperty.py +121 -0
  236. meerk40t/gui/propertypanels/wobbleproperty.py +255 -204
  237. meerk40t/gui/ribbon.py +2471 -2210
  238. meerk40t/gui/scene/scene.py +1100 -1051
  239. meerk40t/gui/scene/sceneconst.py +22 -22
  240. meerk40t/gui/scene/scenepanel.py +439 -349
  241. meerk40t/gui/scene/scenespacewidget.py +365 -365
  242. meerk40t/gui/scene/widget.py +518 -505
  243. meerk40t/gui/scenewidgets/affinemover.py +215 -215
  244. meerk40t/gui/scenewidgets/attractionwidget.py +315 -309
  245. meerk40t/gui/scenewidgets/bedwidget.py +120 -97
  246. meerk40t/gui/scenewidgets/elementswidget.py +137 -107
  247. meerk40t/gui/scenewidgets/gridwidget.py +785 -745
  248. meerk40t/gui/scenewidgets/guidewidget.py +765 -765
  249. meerk40t/gui/scenewidgets/laserpathwidget.py +66 -66
  250. meerk40t/gui/scenewidgets/machineoriginwidget.py +86 -86
  251. meerk40t/gui/scenewidgets/nodeselector.py +28 -28
  252. meerk40t/gui/scenewidgets/rectselectwidget.py +592 -346
  253. meerk40t/gui/scenewidgets/relocatewidget.py +33 -33
  254. meerk40t/gui/scenewidgets/reticlewidget.py +83 -83
  255. meerk40t/gui/scenewidgets/selectionwidget.py +2958 -2756
  256. meerk40t/gui/simpleui.py +362 -333
  257. meerk40t/gui/simulation.py +2451 -2094
  258. meerk40t/gui/snapoptions.py +208 -203
  259. meerk40t/gui/spoolerpanel.py +1227 -1180
  260. meerk40t/gui/statusbarwidgets/defaultoperations.py +480 -353
  261. meerk40t/gui/statusbarwidgets/infowidget.py +520 -483
  262. meerk40t/gui/statusbarwidgets/opassignwidget.py +356 -355
  263. meerk40t/gui/statusbarwidgets/selectionwidget.py +172 -171
  264. meerk40t/gui/statusbarwidgets/shapepropwidget.py +754 -236
  265. meerk40t/gui/statusbarwidgets/statusbar.py +272 -260
  266. meerk40t/gui/statusbarwidgets/statusbarwidget.py +268 -270
  267. meerk40t/gui/statusbarwidgets/strokewidget.py +267 -251
  268. meerk40t/gui/themes.py +200 -78
  269. meerk40t/gui/tips.py +590 -0
  270. meerk40t/gui/toolwidgets/circlebrush.py +35 -35
  271. meerk40t/gui/toolwidgets/toolcircle.py +248 -242
  272. meerk40t/gui/toolwidgets/toolcontainer.py +82 -77
  273. meerk40t/gui/toolwidgets/tooldraw.py +97 -90
  274. meerk40t/gui/toolwidgets/toolellipse.py +219 -212
  275. meerk40t/gui/toolwidgets/toolimagecut.py +25 -132
  276. meerk40t/gui/toolwidgets/toolline.py +39 -144
  277. meerk40t/gui/toolwidgets/toollinetext.py +79 -236
  278. meerk40t/gui/toolwidgets/toollinetext_inline.py +296 -0
  279. meerk40t/gui/toolwidgets/toolmeasure.py +163 -216
  280. meerk40t/gui/toolwidgets/toolnodeedit.py +2088 -2074
  281. meerk40t/gui/toolwidgets/toolnodemove.py +92 -94
  282. meerk40t/gui/toolwidgets/toolparameter.py +754 -668
  283. meerk40t/gui/toolwidgets/toolplacement.py +108 -108
  284. meerk40t/gui/toolwidgets/toolpoint.py +68 -59
  285. meerk40t/gui/toolwidgets/toolpointlistbuilder.py +294 -0
  286. meerk40t/gui/toolwidgets/toolpointmove.py +183 -0
  287. meerk40t/gui/toolwidgets/toolpolygon.py +288 -403
  288. meerk40t/gui/toolwidgets/toolpolyline.py +38 -196
  289. meerk40t/gui/toolwidgets/toolrect.py +211 -207
  290. meerk40t/gui/toolwidgets/toolrelocate.py +72 -72
  291. meerk40t/gui/toolwidgets/toolribbon.py +598 -113
  292. meerk40t/gui/toolwidgets/tooltabedit.py +546 -0
  293. meerk40t/gui/toolwidgets/tooltext.py +98 -89
  294. meerk40t/gui/toolwidgets/toolvector.py +213 -204
  295. meerk40t/gui/toolwidgets/toolwidget.py +39 -39
  296. meerk40t/gui/usbconnect.py +98 -91
  297. meerk40t/gui/utilitywidgets/buttonwidget.py +18 -18
  298. meerk40t/gui/utilitywidgets/checkboxwidget.py +90 -90
  299. meerk40t/gui/utilitywidgets/controlwidget.py +14 -14
  300. meerk40t/gui/utilitywidgets/cyclocycloidwidget.py +343 -340
  301. meerk40t/gui/utilitywidgets/debugwidgets.py +148 -0
  302. meerk40t/gui/utilitywidgets/handlewidget.py +27 -27
  303. meerk40t/gui/utilitywidgets/harmonograph.py +450 -447
  304. meerk40t/gui/utilitywidgets/openclosewidget.py +40 -40
  305. meerk40t/gui/utilitywidgets/rotationwidget.py +54 -54
  306. meerk40t/gui/utilitywidgets/scalewidget.py +75 -75
  307. meerk40t/gui/utilitywidgets/seekbarwidget.py +183 -183
  308. meerk40t/gui/utilitywidgets/togglewidget.py +142 -142
  309. meerk40t/gui/utilitywidgets/toolbarwidget.py +8 -8
  310. meerk40t/gui/wordlisteditor.py +985 -931
  311. meerk40t/gui/wxmeerk40t.py +1447 -1169
  312. meerk40t/gui/wxmmain.py +5644 -4112
  313. meerk40t/gui/wxmribbon.py +1591 -1076
  314. meerk40t/gui/wxmscene.py +1631 -1453
  315. meerk40t/gui/wxmtree.py +2416 -2089
  316. meerk40t/gui/wxutils.py +1769 -1099
  317. meerk40t/gui/zmatrix.py +102 -102
  318. meerk40t/image/__init__.py +1 -1
  319. meerk40t/image/dither.py +429 -0
  320. meerk40t/image/imagetools.py +2793 -2269
  321. meerk40t/internal_plugins.py +150 -130
  322. meerk40t/kernel/__init__.py +63 -12
  323. meerk40t/kernel/channel.py +259 -212
  324. meerk40t/kernel/context.py +538 -538
  325. meerk40t/kernel/exceptions.py +41 -41
  326. meerk40t/kernel/functions.py +463 -414
  327. meerk40t/kernel/jobs.py +100 -100
  328. meerk40t/kernel/kernel.py +3828 -3571
  329. meerk40t/kernel/lifecycles.py +71 -71
  330. meerk40t/kernel/module.py +49 -49
  331. meerk40t/kernel/service.py +147 -147
  332. meerk40t/kernel/settings.py +383 -343
  333. meerk40t/lihuiyu/controller.py +883 -876
  334. meerk40t/lihuiyu/device.py +1181 -1069
  335. meerk40t/lihuiyu/driver.py +1466 -1372
  336. meerk40t/lihuiyu/gui/gui.py +127 -106
  337. meerk40t/lihuiyu/gui/lhyaccelgui.py +377 -363
  338. meerk40t/lihuiyu/gui/lhycontrollergui.py +741 -651
  339. meerk40t/lihuiyu/gui/lhydrivergui.py +470 -446
  340. meerk40t/lihuiyu/gui/lhyoperationproperties.py +238 -237
  341. meerk40t/lihuiyu/gui/tcpcontroller.py +226 -190
  342. meerk40t/lihuiyu/interpreter.py +53 -53
  343. meerk40t/lihuiyu/laserspeed.py +450 -450
  344. meerk40t/lihuiyu/loader.py +90 -90
  345. meerk40t/lihuiyu/parser.py +404 -404
  346. meerk40t/lihuiyu/plugin.py +101 -102
  347. meerk40t/lihuiyu/tcp_connection.py +111 -109
  348. meerk40t/main.py +231 -165
  349. meerk40t/moshi/builder.py +788 -781
  350. meerk40t/moshi/controller.py +505 -499
  351. meerk40t/moshi/device.py +495 -442
  352. meerk40t/moshi/driver.py +862 -696
  353. meerk40t/moshi/gui/gui.py +78 -76
  354. meerk40t/moshi/gui/moshicontrollergui.py +538 -522
  355. meerk40t/moshi/gui/moshidrivergui.py +87 -75
  356. meerk40t/moshi/plugin.py +43 -43
  357. meerk40t/network/console_server.py +140 -57
  358. meerk40t/network/kernelserver.py +10 -9
  359. meerk40t/network/tcp_server.py +142 -140
  360. meerk40t/network/udp_server.py +103 -77
  361. meerk40t/network/web_server.py +404 -0
  362. meerk40t/newly/controller.py +1158 -1144
  363. meerk40t/newly/device.py +874 -732
  364. meerk40t/newly/driver.py +540 -412
  365. meerk40t/newly/gui/gui.py +219 -188
  366. meerk40t/newly/gui/newlyconfig.py +116 -101
  367. meerk40t/newly/gui/newlycontroller.py +193 -186
  368. meerk40t/newly/gui/operationproperties.py +51 -51
  369. meerk40t/newly/mock_connection.py +82 -82
  370. meerk40t/newly/newly_params.py +56 -56
  371. meerk40t/newly/plugin.py +1214 -1246
  372. meerk40t/newly/usb_connection.py +322 -322
  373. meerk40t/rotary/gui/gui.py +52 -46
  374. meerk40t/rotary/gui/rotarysettings.py +240 -232
  375. meerk40t/rotary/rotary.py +202 -98
  376. meerk40t/ruida/control.py +291 -91
  377. meerk40t/ruida/controller.py +138 -1088
  378. meerk40t/ruida/device.py +676 -231
  379. meerk40t/ruida/driver.py +534 -472
  380. meerk40t/ruida/emulator.py +1494 -1491
  381. meerk40t/ruida/exceptions.py +4 -4
  382. meerk40t/ruida/gui/gui.py +71 -76
  383. meerk40t/ruida/gui/ruidaconfig.py +239 -72
  384. meerk40t/ruida/gui/ruidacontroller.py +187 -184
  385. meerk40t/ruida/gui/ruidaoperationproperties.py +48 -47
  386. meerk40t/ruida/loader.py +54 -52
  387. meerk40t/ruida/mock_connection.py +57 -109
  388. meerk40t/ruida/plugin.py +124 -87
  389. meerk40t/ruida/rdjob.py +2084 -945
  390. meerk40t/ruida/serial_connection.py +116 -0
  391. meerk40t/ruida/tcp_connection.py +146 -0
  392. meerk40t/ruida/udp_connection.py +73 -0
  393. meerk40t/svgelements.py +9671 -9669
  394. meerk40t/tools/driver_to_path.py +584 -579
  395. meerk40t/tools/geomstr.py +5583 -4680
  396. meerk40t/tools/jhfparser.py +357 -292
  397. meerk40t/tools/kerftest.py +904 -890
  398. meerk40t/tools/livinghinges.py +1168 -1033
  399. meerk40t/tools/pathtools.py +987 -949
  400. meerk40t/tools/pmatrix.py +234 -0
  401. meerk40t/tools/pointfinder.py +942 -942
  402. meerk40t/tools/polybool.py +941 -940
  403. meerk40t/tools/rasterplotter.py +1660 -547
  404. meerk40t/tools/shxparser.py +1047 -901
  405. meerk40t/tools/ttfparser.py +726 -446
  406. meerk40t/tools/zinglplotter.py +595 -593
  407. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/LICENSE +21 -21
  408. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/METADATA +150 -139
  409. meerk40t-0.9.7020.dist-info/RECORD +446 -0
  410. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/WHEEL +1 -1
  411. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/top_level.txt +0 -1
  412. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/zip-safe +1 -1
  413. meerk40t/balormk/elementlightjob.py +0 -159
  414. meerk40t-0.9.3001.dist-info/RECORD +0 -437
  415. test/bootstrap.py +0 -63
  416. test/test_cli.py +0 -12
  417. test/test_core_cutcode.py +0 -418
  418. test/test_core_elements.py +0 -144
  419. test/test_core_plotplanner.py +0 -397
  420. test/test_core_viewports.py +0 -312
  421. test/test_drivers_grbl.py +0 -108
  422. test/test_drivers_lihuiyu.py +0 -443
  423. test/test_drivers_newly.py +0 -113
  424. test/test_element_degenerate_points.py +0 -43
  425. test/test_elements_classify.py +0 -97
  426. test/test_elements_penbox.py +0 -22
  427. test/test_file_svg.py +0 -176
  428. test/test_fill.py +0 -155
  429. test/test_geomstr.py +0 -1523
  430. test/test_geomstr_nodes.py +0 -18
  431. test/test_imagetools_actualize.py +0 -306
  432. test/test_imagetools_wizard.py +0 -258
  433. test/test_kernel.py +0 -200
  434. test/test_laser_speeds.py +0 -3303
  435. test/test_length.py +0 -57
  436. test/test_lifecycle.py +0 -66
  437. test/test_operations.py +0 -251
  438. test/test_operations_hatch.py +0 -57
  439. test/test_ruida.py +0 -19
  440. test/test_spooler.py +0 -22
  441. test/test_tools_rasterplotter.py +0 -29
  442. test/test_wobble.py +0 -133
  443. test/test_zingl.py +0 -124
  444. {test → meerk40t/cylinder}/__init__.py +0 -0
  445. /meerk40t/{core/element_commands.py → cylinder/gui/__init__.py} +0 -0
  446. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/entry_points.txt +0 -0
@@ -1,542 +1,706 @@
1
- import os
2
- import threading
3
-
4
- import wx
5
- from wx import aui
6
-
7
- from meerk40t.gui.icons import STD_ICON_SIZE, icons8_console
8
- from meerk40t.gui.mwindow import MWindow
9
- from meerk40t.kernel import get_safe_path, signal_listener
10
-
11
- try:
12
- from wx import richtext
13
- except ImportError:
14
- print("import of wx.richtext for console failed, using default console window")
15
-
16
-
17
- _ = wx.GetTranslation
18
-
19
-
20
- def background_color(colour):
21
- def style_color(style):
22
- style.SetBackgroundColour(wx.Colour(colour))
23
- return style
24
-
25
- return style_color
26
-
27
-
28
- def foreground_color(colour):
29
- def style_color(style):
30
- style.SetTextColour(wx.Colour(colour))
31
- return style
32
-
33
- return style_color
34
-
35
-
36
- def style_bold(style):
37
- style.SetFontWeight(wx.FONTWEIGHT_BOLD)
38
- return style
39
-
40
-
41
- def style_unbold(style):
42
- style.SetFontWeight(wx.FONTWEIGHT_NORMAL)
43
- return style
44
-
45
-
46
- def style_italic(style):
47
- style.SetFontStyle(wx.FONTSTYLE_ITALIC)
48
- return style
49
-
50
-
51
- def style_unitalic(style):
52
- style.SetFontStyle(wx.FONTSTYLE_NORMAL)
53
- return style
54
-
55
-
56
- def style_underline(style):
57
- style.SetFontUnderlined(True)
58
- return style
59
-
60
-
61
- def style_ununderline(style):
62
- style.SetFontUnderlined(False)
63
- return style
64
-
65
-
66
- def style_negate(style):
67
- bg_colour = style.BackgroundColour
68
- fg_colour = style.TextColour
69
- style.SetBackgroundColour(fg_colour)
70
- style.SetTextColour(bg_colour)
71
- return style
72
-
73
-
74
- def register_panel_console(window, context):
75
- panel = ConsolePanel(window, wx.ID_ANY, context=context)
76
- pane = (
77
- aui.AuiPaneInfo()
78
- .Bottom()
79
- .Layer(2)
80
- .MinSize(600, 100)
81
- .FloatingSize(600, 230)
82
- .Caption(_("Console"))
83
- .Name("console")
84
- .CaptionVisible(not context.pane_lock)
85
- .Hide()
86
- )
87
- pane.dock_proportion = 600
88
- pane.control = panel
89
-
90
- window.on_pane_create(pane)
91
- context.register("pane/console", pane)
92
-
93
- @context.console_command(
94
- ("cls", "clear"),
95
- help=_("Clear console screen"),
96
- )
97
- def clear_console(channel, _, *args, **kwargs):
98
- if "window/Console" in context.opened:
99
- w = context.opened["window/Console"]
100
- w.panel.clear()
101
- if "pane/console" in context.opened:
102
- w = context.opened["pane/console"]
103
- w.control.clear()
104
-
105
-
106
- class ConsolePanel(wx.ScrolledWindow):
107
- def __init__(self, *args, context=None, **kwargs):
108
- # begin wxGlade: ConsolePanel.__init__
109
- kwargs["style"] = kwargs.get("style", 0) | wx.TAB_TRAVERSAL
110
- wx.ScrolledWindow.__init__(self, *args, **kwargs)
111
- self.context = context
112
-
113
- font = wx.Font(
114
- 10,
115
- wx.FONTFAMILY_TELETYPE,
116
- wx.FONTSTYLE_NORMAL,
117
- wx.FONTWEIGHT_NORMAL,
118
- )
119
- self.text_entry = wx.TextCtrl(
120
- self, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB
121
- )
122
-
123
- try:
124
- self.text_main = richtext.RichTextCtrl(
125
- self,
126
- wx.ID_ANY,
127
- "",
128
- style=wx.richtext.RE_MULTILINE
129
- | wx.richtext.RE_READONLY
130
- | wx.BG_STYLE_SYSTEM
131
- | wx.VSCROLL
132
- | wx.ALWAYS_SHOW_SB,
133
- )
134
- self.text_main.SetEditable(False)
135
- self.text_main.BeginSuppressUndo()
136
- style = wx.TextAttr()
137
-
138
- style.SetFont(font)
139
- style.SetLineSpacing(0)
140
- style.SetParagraphSpacingBefore(0)
141
- style.SetParagraphSpacingAfter(0)
142
- bg = self.background_color()
143
- if self.is_dark:
144
- fg = wx.Colour("white")
145
- else:
146
- fg = wx.Colour("black")
147
- style.SetTextColour(fg)
148
- style.SetBackgroundColour(bg)
149
-
150
- self.text_main.SetForegroundColour(fg)
151
- self.text_main.SetBackgroundColour(bg)
152
- self.text_entry.SetForegroundColour(fg)
153
- self.text_entry.SetBackgroundColour(bg)
154
- self.text_entry.SetDefaultStyle(style)
155
-
156
- style = richtext.RichTextAttr(style)
157
- style.SetLeftIndent(0, 320)
158
- self.text_main.SetBasicStyle(style)
159
- self.text_main.SetDefaultStyle(style)
160
- self.style = style
161
- self.text_main.Update() # Apply style to just opened window
162
- self._update_text = self.update_text_rich
163
-
164
- except NameError:
165
- self.text_main = wx.TextCtrl(
166
- self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY
167
- )
168
- self.text_main.SetFont(font)
169
- self._update_text = self.update_text_text
170
-
171
- self.__set_properties()
172
- self.__do_layout()
173
-
174
- self.Bind(wx.EVT_CHAR_HOOK, self.on_key_down, self.text_entry)
175
- self.Bind(wx.EVT_TEXT_ENTER, self.on_enter, self.text_entry)
176
- self.Bind(wx.EVT_CHAR_HOOK, self.on_key_down_main, self.text_main)
177
- self.Bind(wx.EVT_TEXT_URL, self.on_text_uri)
178
- # end wxGlade
179
- self.command_log = []
180
- self.command_position = 0
181
- self.load_log()
182
-
183
- self.ansi_styles = {
184
- "\033[30m": foreground_color("black"), # "black"
185
- "\033[31m": foreground_color("red"), # "red"
186
- "\033[32m": foreground_color("green"), # "green"
187
- "\033[33m": foreground_color("yellow"), # "yellow"
188
- "\033[34m": foreground_color("blue"), # "blue"
189
- "\033[35m": foreground_color("magenta"), # "magenta"
190
- "\033[36m": foreground_color("cyan"), # "cyan"
191
- "\033[37m": foreground_color("white"), # "white"
192
- "\033[40m": background_color("black"), # "bg-black"
193
- "\033[41m": background_color("red"), # "bg-red"
194
- "\033[42m": background_color("green"), # "bg-green"
195
- "\033[43m": background_color("yellow"), # "bg-yellow"
196
- "\033[44m": background_color("blue"), # "bg-blue"
197
- "\033[45m": background_color("magenta"), # "bg-magenta"
198
- "\033[46m": background_color("cyan"), # "bg-cyan"
199
- "\033[47m": background_color("white"), # "bg-white"
200
- "\033[1m": style_bold, # "bold"
201
- "\033[22m": style_unbold, # "/bold"
202
- "\033[3m": style_italic, # "italic"
203
- # "\033[3m": style_unitalic, # "/italic"
204
- "\033[4m": style_underline, # "underline"
205
- "\033[24m": style_ununderline, # "/underline"
206
- "\033[7m": None, # "negative"
207
- "\033[27m": None, # "positive"
208
- "\033[0m": self.style_normal, # "normal"
209
- }
210
- self._buffer = ""
211
- self._buffer_lock = threading.Lock()
212
-
213
- def style_normal(self, style):
214
- return self.style
215
-
216
- def background_color(self):
217
- return wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOW)
218
-
219
- @property
220
- def is_dark(self):
221
- # try:
222
- # res = wx.SystemSettings().GetAppearance().IsDark()
223
- # except AttributeError:
224
- # res = wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOW)[0] < 127
225
- return self.context.themes.dark
226
-
227
- def __set_properties(self):
228
- # begin wxGlade: ConsolePanel.__set_properties
229
- self.text_entry.SetFocus()
230
- # end wxGlade
231
-
232
- def __do_layout(self):
233
- # begin wxGlade: ConsolePanel.__do_layout
234
- sizer_2 = wx.BoxSizer(wx.VERTICAL)
235
- sizer_2.Add(self.text_main, 1, wx.EXPAND, 0)
236
- sizer_2.Add(self.text_entry, 0, wx.EXPAND, 0)
237
- self.SetSizer(sizer_2)
238
- sizer_2.FitInside(self)
239
- self.Layout()
240
- # end wxGlade
241
-
242
- def pane_show(self, *args):
243
- self.context.channel("console").watch(self.update_text)
244
-
245
- def pane_hide(self, *args):
246
- self.context.channel("console").unwatch(self.update_text)
247
-
248
- def clear(self):
249
- self.text_main.Clear()
250
-
251
- def update_text(self, text):
252
- with self._buffer_lock:
253
- self._buffer += f"{text}\n"
254
- if len(self._buffer) > 50000:
255
- self._buffer = self._buffer[-50000:]
256
- self.context.signal("console_update")
257
-
258
- @signal_listener("console_update")
259
- def update_console_main(self, origin, *args):
260
- with self._buffer_lock:
261
- buffer = self._buffer
262
- self._buffer = ""
263
- # Update text depends on rich/normal text_field
264
- self._update_text(buffer)
265
-
266
- def update_text_text(self, text):
267
- # If normal called by self._update_text
268
- self.process_text_text_line(str(text))
269
-
270
- def update_text_rich(self, text):
271
- # If rich called by self._update_text
272
- self.process_text_rich_line(str(text))
273
-
274
- def process_text_text_line(self, lines):
275
- text = ""
276
- ansi_text = ""
277
- ansi = False
278
- try:
279
- if not self.text_main.IsEmpty():
280
- self.text_main.AppendText("\n")
281
- except RuntimeError:
282
- return
283
- for c in lines:
284
- b = ord(c)
285
- if c == "\n":
286
- if text:
287
- self.text_main.AppendText(text)
288
- text = ""
289
- if b == 27:
290
- ansi = True
291
- if ansi:
292
- ansi_text += c
293
- if c == "m":
294
- if text:
295
- self.text_main.AppendText(text)
296
- text = ""
297
- ansi = False
298
- ansi_text = ""
299
- continue
300
- text += c
301
- if text:
302
- self.text_main.AppendText(text)
303
-
304
- def process_text_rich_line(self, lines):
305
- """
306
- Update rich text code line. This only works if text_main is a RichText box.
307
-
308
- @param lines:
309
- @return:
310
- """
311
- try:
312
- self.text_main.SetInsertionPointEnd()
313
- except RuntimeError:
314
- # Console is shutdown.
315
- return
316
- ansi = False
317
- ansi_text = ""
318
- text = ""
319
- open_style = False
320
- for c in lines:
321
- b = ord(c)
322
- if c == "\n":
323
- if text:
324
- self.text_main.WriteText(text)
325
- text = ""
326
- self.text_main.Newline()
327
- self.text_main.BeginStyle(self.style)
328
- open_style = True
329
- continue # New Line is already processed.
330
- if b == 27:
331
- ansi = True
332
- if ansi:
333
- ansi_text += c
334
- if c == "m":
335
- if text:
336
- self.text_main.WriteText(text)
337
- text = ""
338
- style_function = self.ansi_styles.get(ansi_text)
339
- if style_function is not None:
340
- new_style = style_function(self.text_main.GetDefaultStyleEx())
341
- if open_style:
342
- self.text_main.EndStyle()
343
- open_style = False
344
- if new_style is not None:
345
- self.text_main.BeginStyle(new_style)
346
- open_style = True
347
- ansi = False
348
- ansi_text = ""
349
- continue
350
- text += c
351
- if text:
352
- self.text_main.WriteText(text)
353
- if open_style:
354
- self.text_main.EndStyle()
355
-
356
- self.text_main.ScrollIntoView(self.text_main.GetLastPosition(), wx.WXK_END)
357
- self.text_main.Update()
358
-
359
- def on_text_uri(self, event):
360
- mouse_event = event.GetMouseEvent()
361
- if mouse_event.LeftDClick():
362
- url_start = event.GetURLStart()
363
- url_end = event.GetURLEnd()
364
- url = self.text_main.GetRange(url_start, url_end)
365
- import webbrowser
366
-
367
- webbrowser.open_new_tab(url)
368
-
369
- def on_key_down_main(self, event):
370
- def isrealchar(keycode):
371
- if keycode in (wx.WXK_LEFT, wx.WXK_RIGHT):
372
- # There are much more, but I am lazy...
373
- return False
374
- else:
375
- return chr(keycode).isprintable
376
-
377
- def refocus():
378
- self.text_entry.SetInsertionPointEnd()
379
- self.text_entry.SetFocus()
380
-
381
- key = event.GetKeyCode()
382
- if key != wx.WXK_CONTROL and (key != ord("C")) and not event.ControlDown():
383
- if self.FindFocus() is not self.text_entry:
384
- try:
385
- if key == wx.WXK_DOWN:
386
- self.text_entry.SetValue(
387
- self.command_log[self.command_position + 1]
388
- )
389
- if not wx.IsMainThread():
390
- wx.CallAfter(refocus)
391
- else:
392
- refocus()
393
- self.command_position += 1
394
- elif key == wx.WXK_UP:
395
- self.text_entry.SetValue(
396
- self.command_log[self.command_position - 1]
397
- )
398
- if not wx.IsMainThread():
399
- wx.CallAfter(refocus)
400
- else:
401
- refocus()
402
- self.command_position -= 1
403
- elif isrealchar(key):
404
- self.text_entry.SetFocus()
405
- self.text_entry.AppendText(str(chr(key)).lower())
406
- else:
407
- self.text_entry.SetFocus()
408
- # event.Skip()
409
- except IndexError:
410
- self.command_position = 0
411
- self.text_entry.SetValue("")
412
- else:
413
- event.Skip()
414
-
415
- def on_key_down(self, event):
416
- key = event.GetKeyCode()
417
- try:
418
- if key == wx.WXK_DOWN:
419
- self.text_entry.SetValue(self.command_log[self.command_position + 1])
420
- if not wx.IsMainThread():
421
- wx.CallAfter(self.text_entry.SetInsertionPointEnd)
422
- else:
423
- self.text_entry.SetInsertionPointEnd()
424
- self.command_position += 1
425
- elif key == wx.WXK_UP:
426
- self.text_entry.SetValue(self.command_log[self.command_position - 1])
427
- if not wx.IsMainThread():
428
- wx.CallAfter(self.text_entry.SetInsertionPointEnd)
429
- else:
430
- self.text_entry.SetInsertionPointEnd()
431
- self.command_position -= 1
432
- else:
433
- event.Skip()
434
- except IndexError:
435
- self.command_position = 0
436
- self.text_entry.SetValue("")
437
-
438
- def on_enter(self, event): # wxGlade: Terminal.<event_handler>
439
- command = self.text_entry.GetValue()
440
- self.command_log.append(command)
441
- self.save_log(command)
442
- self.command_position = 0
443
- self.context(command + "\n")
444
- self.text_entry.SetValue("")
445
- event.Skip(False)
446
-
447
- def history_filename(self):
448
- safe_dir = os.path.realpath(get_safe_path(self.context.kernel.name))
449
- fname = os.path.join(safe_dir, "cmdhistory.log")
450
- is_there = os.path.exists(fname)
451
- return fname, is_there
452
-
453
- def save_log(self, last_command):
454
- fname, fexists = self.history_filename()
455
- try:
456
- history_file = open(fname, "a", encoding="utf-8") # Append mode
457
- history_file.write(last_command + "\n")
458
- history_file.close()
459
- except (PermissionError, OSError):
460
- # Could not save
461
- pass
462
-
463
- def load_log(self):
464
- def tail(f, window=1):
465
- """
466
- Returns the last `window` lines of file `f` as a list of bytes.
467
- """
468
- if window == 0:
469
- return b""
470
- BUFSIZE = 1024
471
- f.seek(0, 2)
472
- end = f.tell()
473
- nlines = window + 1
474
- data = []
475
- while nlines > 0 and end > 0:
476
- i = max(0, end - BUFSIZE)
477
- nread = min(end, BUFSIZE)
478
-
479
- f.seek(i)
480
- chunk = f.read(nread)
481
- data.append(chunk)
482
- nlines -= chunk.count(b"\n")
483
- end -= nread
484
- return b"\n".join(b"".join(reversed(data)).splitlines()[-window:])
485
-
486
- # Restores the last 50 commands from disk
487
-
488
- self.context.setting(int, "history_limit", 50)
489
- limit = int(self.context.history_limit)
490
- # print (f"Limit = {limit}")
491
- self.command_log = [""]
492
- fname, fexists = self.history_filename()
493
- if fexists:
494
- result = []
495
- if fexists:
496
- result = []
497
- try:
498
- with open(fname, "rb") as f:
499
- result = tail(f, 3 * limit).decode("utf-8").splitlines()
500
- except (PermissionError, OSError):
501
- # Could not load
502
- pass
503
- for entry in result:
504
- if len(self.command_log) and entry == self.command_log[-1]:
505
- # print (f"ignored duplicate {entry}")
506
- continue
507
- self.command_log.append(entry)
508
- if len(self.command_log) > limit:
509
- self.command_log = self.command_log[-limit:]
510
-
511
-
512
- class Console(MWindow):
513
- def __init__(self, *args, **kwds):
514
- super().__init__(581, 410, *args, **kwds)
515
- self.panel = ConsolePanel(self, wx.ID_ANY, context=self.context)
516
- self.add_module_delegate(self.panel)
517
- _icon = wx.NullIcon
518
- _icon.CopyFromBitmap(icons8_console.GetBitmap())
519
- self.SetIcon(_icon)
520
- self.SetTitle(_("Console"))
521
- self.Layout()
522
-
523
- @staticmethod
524
- def sub_register(kernel):
525
- kernel.register("wxpane/Console", register_panel_console)
526
- kernel.register(
527
- "button/preparation/Console",
528
- {
529
- "label": _("Console"),
530
- "icon": icons8_console,
531
- "tip": _("Open Console Window"),
532
- "action": lambda v: kernel.console("window toggle Console\n"),
533
- "size": STD_ICON_SIZE,
534
- "priority": 4,
535
- },
536
- )
537
-
538
- def window_open(self):
539
- self.panel.pane_show()
540
-
541
- def window_close(self):
542
- self.panel.pane_hide()
1
+ import os
2
+ import threading
3
+
4
+ import wx
5
+ from wx import aui
6
+
7
+ from meerk40t.gui.icons import STD_ICON_SIZE, icons8_console
8
+ from meerk40t.gui.mwindow import MWindow
9
+ from meerk40t.kernel import signal_listener
10
+ from meerk40t.gui.wxutils import TextCtrl
11
+
12
+ try:
13
+ from wx import richtext
14
+ except ImportError:
15
+ print("import of wx.richtext for console failed, using default console window")
16
+
17
+
18
+ _ = wx.GetTranslation
19
+
20
+
21
+ def background_color(colour):
22
+ def style_color(style):
23
+ style.SetBackgroundColour(wx.Colour(colour))
24
+ return style
25
+
26
+ return style_color
27
+
28
+
29
+ def foreground_color(colour):
30
+ def style_color(style):
31
+ style.SetTextColour(wx.Colour(colour))
32
+ return style
33
+
34
+ return style_color
35
+
36
+
37
+ def style_bold(style):
38
+ style.SetFontWeight(wx.FONTWEIGHT_BOLD)
39
+ return style
40
+
41
+
42
+ def style_unbold(style):
43
+ style.SetFontWeight(wx.FONTWEIGHT_NORMAL)
44
+ return style
45
+
46
+
47
+ def style_italic(style):
48
+ style.SetFontStyle(wx.FONTSTYLE_ITALIC)
49
+ return style
50
+
51
+
52
+ def style_unitalic(style):
53
+ style.SetFontStyle(wx.FONTSTYLE_NORMAL)
54
+ return style
55
+
56
+
57
+ def style_underline(style):
58
+ style.SetFontUnderlined(True)
59
+ return style
60
+
61
+
62
+ def style_ununderline(style):
63
+ style.SetFontUnderlined(False)
64
+ return style
65
+
66
+
67
+ def style_negate(style):
68
+ bg_colour = style.BackgroundColour
69
+ fg_colour = style.TextColour
70
+ style.SetBackgroundColour(fg_colour)
71
+ style.SetTextColour(bg_colour)
72
+ return style
73
+
74
+
75
+ def register_panel_console(window, context):
76
+ panel = ConsolePanel(window, wx.ID_ANY, context=context)
77
+ pane = (
78
+ aui.AuiPaneInfo()
79
+ .Bottom()
80
+ .Layer(2)
81
+ .MinSize(100, 100)
82
+ .FloatingSize(600, 230)
83
+ .Caption(_("Console"))
84
+ .Name("console")
85
+ .CaptionVisible(not context.pane_lock)
86
+ .Hide()
87
+ )
88
+ pane.dock_proportion = 600
89
+ pane.control = panel
90
+ pane.helptext = _("Open command interface")
91
+
92
+ window.on_pane_create(pane)
93
+ context.register("pane/console", pane)
94
+
95
+ @context.console_command(
96
+ ("cls", "clear"),
97
+ help=_("Clear console screen"),
98
+ )
99
+ def clear_console(channel, _, *args, **kwargs):
100
+ if "window/Console" in context.opened:
101
+ w = context.opened["window/Console"]
102
+ w.panel.clear()
103
+ if "pane/console" in context.opened:
104
+ w = context.opened["pane/console"]
105
+ w.control.clear()
106
+
107
+ @context.console_option("reset", "r", type=bool, action="store_true")
108
+ @context.console_command(
109
+ ("console_font"),
110
+ help=_("Sets the console font"),
111
+ )
112
+ def set_console_font(channel, _, reset=False, *args, **kwargs):
113
+ def getfont(initial):
114
+ result = ""
115
+ data = wx.FontData()
116
+ data.EnableEffects(True)
117
+ cur_font = None
118
+ if initial:
119
+ try:
120
+ cur_font = wx.Font()
121
+ success = cur_font.SetNativeFontInfo(initial)
122
+ if not success:
123
+ cur_font = None
124
+ except Exception:
125
+ pass
126
+ if cur_font is None:
127
+ cur_font = wx.Font(
128
+ 10,
129
+ wx.FONTFAMILY_TELETYPE,
130
+ wx.FONTSTYLE_NORMAL,
131
+ wx.FONTWEIGHT_NORMAL,
132
+ )
133
+ data.SetInitialFont(cur_font)
134
+
135
+ dlg = wx.FontDialog(window, data)
136
+
137
+ if dlg.ShowModal() == wx.ID_OK:
138
+ data = dlg.GetFontData()
139
+ font = data.GetChosenFont()
140
+ result = font.GetNativeFontInfoDesc()
141
+
142
+ # Don't destroy the dialog until you get everything you need from the
143
+ # dialog!
144
+ dlg.Destroy()
145
+ return result
146
+
147
+ current = context.setting(str, "console_font", "")
148
+ if reset:
149
+ context.console_font = ""
150
+ else:
151
+ # Show Fontdialog
152
+ result = getfont(current)
153
+ context.console_font = result
154
+ if "window/Console" in context.opened:
155
+ w = context.opened["window/Console"]
156
+ w.panel.reset_font()
157
+ if "pane/console" in context.opened:
158
+ w = context.opened["pane/console"]
159
+ w.control.reset_font()
160
+ channel(_("Font has been changed"))
161
+
162
+
163
+ class ConsolePanel(wx.ScrolledWindow):
164
+ def __init__(self, *args, context=None, **kwargs):
165
+ # begin wxGlade: ConsolePanel.__init__
166
+ kwargs["style"] = kwargs.get("style", 0) | wx.TAB_TRAVERSAL
167
+ wx.ScrolledWindow.__init__(self, *args, **kwargs)
168
+ self.context = context
169
+ self.context.themes.set_window_colors(self)
170
+ self.SetHelpText("notes")
171
+ font = self.get_font()
172
+ self.text_entry = TextCtrl(
173
+ self, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB
174
+ )
175
+ self.richtext = False
176
+
177
+ try:
178
+ self.text_main = richtext.RichTextCtrl(
179
+ self,
180
+ wx.ID_ANY,
181
+ "",
182
+ style=wx.richtext.RE_MULTILINE
183
+ | wx.richtext.RE_READONLY
184
+ | wx.BG_STYLE_SYSTEM
185
+ | wx.VSCROLL
186
+ | wx.ALWAYS_SHOW_SB,
187
+ )
188
+ self.text_main.SetEditable(False)
189
+ self.text_main.BeginSuppressUndo()
190
+ style = wx.TextAttr()
191
+
192
+ style.SetFont(font)
193
+ style.SetLineSpacing(0)
194
+ style.SetParagraphSpacingBefore(0)
195
+ style.SetParagraphSpacingAfter(0)
196
+ bg = self.background_color()
197
+ if self.is_dark:
198
+ fg = wx.Colour("white")
199
+ else:
200
+ fg = wx.Colour("black")
201
+ style.SetTextColour(fg)
202
+ style.SetBackgroundColour(bg)
203
+
204
+ self.text_main.SetForegroundColour(fg)
205
+ self.text_main.SetBackgroundColour(bg)
206
+ self.text_entry.SetForegroundColour(fg)
207
+ self.text_entry.SetBackgroundColour(bg)
208
+ self.text_entry.SetDefaultStyle(style)
209
+
210
+ style = richtext.RichTextAttr(style)
211
+ style.SetLeftIndent(0, 320)
212
+ self.text_main.SetBasicStyle(style)
213
+ self.text_main.SetDefaultStyle(style)
214
+ self.style = style
215
+ self.text_main.Update() # Apply style to just opened window
216
+ self._update_text = self.update_text_rich
217
+ self.richtext = True
218
+
219
+ except NameError:
220
+ self.text_main = TextCtrl(
221
+ self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY
222
+ )
223
+ self.text_main.SetFont(font)
224
+ self._update_text = self.update_text_text
225
+
226
+ self.__set_properties()
227
+ self.__do_layout()
228
+
229
+ self.Bind(wx.EVT_CHAR_HOOK, self.on_key_down, self.text_entry)
230
+ self.Bind(wx.EVT_TEXT_ENTER, self.on_enter, self.text_entry)
231
+ self.Bind(wx.EVT_CHAR_HOOK, self.on_key_down_main, self.text_main)
232
+ self.Bind(wx.EVT_TEXT_URL, self.on_text_uri)
233
+ # end wxGlade
234
+ self.command_log = []
235
+ self.command_position = 0
236
+ self.load_log()
237
+
238
+ self.ansi_styles = {
239
+ "\033[30m": foreground_color("black"), # "black"
240
+ "\033[31m": foreground_color("red"), # "red"
241
+ "\033[32m": foreground_color("green"), # "green"
242
+ "\033[33m": foreground_color("yellow"), # "yellow"
243
+ "\033[34m": foreground_color("blue"), # "blue"
244
+ "\033[35m": foreground_color("magenta"), # "magenta"
245
+ "\033[36m": foreground_color("cyan"), # "cyan"
246
+ "\033[37m": foreground_color("white"), # "white"
247
+ "\033[40m": background_color("black"), # "bg-black"
248
+ "\033[41m": background_color("red"), # "bg-red"
249
+ "\033[42m": background_color("green"), # "bg-green"
250
+ "\033[43m": background_color("yellow"), # "bg-yellow"
251
+ "\033[44m": background_color("blue"), # "bg-blue"
252
+ "\033[45m": background_color("magenta"), # "bg-magenta"
253
+ "\033[46m": background_color("cyan"), # "bg-cyan"
254
+ "\033[47m": background_color("white"), # "bg-white"
255
+ "\033[1m": style_bold, # "bold"
256
+ "\033[22m": style_unbold, # "/bold"
257
+ "\033[3m": style_italic, # "italic"
258
+ # "\033[3m": style_unitalic, # "/italic"
259
+ "\033[4m": style_underline, # "underline"
260
+ "\033[24m": style_ununderline, # "/underline"
261
+ "\033[7m": None, # "negative"
262
+ "\033[27m": None, # "positive"
263
+ "\033[0m": self.style_normal, # "normal"
264
+ }
265
+ self._buffer = ""
266
+ self._buffer_lock = threading.Lock()
267
+ self.command_list = list(self.context.kernel.match("command/.*/.*"))
268
+ self.command_list.sort()
269
+ self.command_context = list()
270
+ for command_name in self.command_list:
271
+ parts = command_name.split("/")
272
+ context_item = parts[1]
273
+ if context_item != "None" and context_item not in self.command_context:
274
+ self.command_context.append(context_item)
275
+
276
+ def get_font(self):
277
+ font = None
278
+ fontdesc = self.context.setting(str, "console_font", "")
279
+ if fontdesc:
280
+ # print (f"Try fontdesc: {fontdesc}")
281
+ try:
282
+ font = wx.Font(fontdesc)
283
+ except Exception as e:
284
+ # print (e)
285
+ font = None
286
+ if font is None:
287
+ font = wx.Font(
288
+ 10,
289
+ wx.FONTFAMILY_TELETYPE,
290
+ wx.FONTSTYLE_NORMAL,
291
+ wx.FONTWEIGHT_NORMAL,
292
+ )
293
+ return font
294
+
295
+ def reset_font(self):
296
+ font = self.get_font()
297
+ if self.richtext:
298
+ self.style.SetFont(font)
299
+ self.text_main.SetBasicStyle(self.style)
300
+ self.text_main.SetDefaultStyle(self.style)
301
+ self.text_main.Update()
302
+ else:
303
+ self.text_main.SetFont(font)
304
+ self.Refresh()
305
+
306
+ def style_normal(self, style):
307
+ return self.style
308
+
309
+ def background_color(self):
310
+ return self.context.themes.get("win_bg")
311
+ # return wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOW)
312
+
313
+ @property
314
+ def is_dark(self):
315
+ # try:
316
+ # res = wx.SystemSettings().GetAppearance().IsDark()
317
+ # except AttributeError:
318
+ # res = wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOW)[0] < 127
319
+ return self.context.themes.dark
320
+
321
+ def __set_properties(self):
322
+ # begin wxGlade: ConsolePanel.__set_properties
323
+ self.text_entry.SetFocus()
324
+ # end wxGlade
325
+
326
+ def __do_layout(self):
327
+ # begin wxGlade: ConsolePanel.__do_layout
328
+ sizer_2 = wx.BoxSizer(wx.VERTICAL)
329
+ sizer_2.Add(self.text_main, 1, wx.EXPAND, 0)
330
+ sizer_2.Add(self.text_entry, 0, wx.EXPAND, 0)
331
+ self.SetSizer(sizer_2)
332
+ sizer_2.FitInside(self)
333
+ self.Layout()
334
+ # end wxGlade
335
+
336
+ def pane_show(self, *args):
337
+ self.context.channel("console").watch(self.update_text)
338
+
339
+ def pane_hide(self, *args):
340
+ self.context.channel("console").unwatch(self.update_text)
341
+
342
+ def clear(self):
343
+ self.text_main.SetValue("")
344
+ self.text_main.Clear()
345
+
346
+ def update_text(self, text):
347
+ with self._buffer_lock:
348
+ self._buffer += f"{text}\n"
349
+ if len(self._buffer) > 50000:
350
+ self._buffer = self._buffer[-50000:]
351
+ if getattr(self.context, "process_console_in_realtime", False):
352
+ self.update_console_main("internal")
353
+ else:
354
+ self.context.signal("console_update")
355
+
356
+ @signal_listener("console_update")
357
+ def update_console_main(self, origin, *args):
358
+ with self._buffer_lock:
359
+ buffer = self._buffer
360
+ self._buffer = ""
361
+ # Update text depends on rich/normal text_field
362
+ self._update_text(buffer)
363
+
364
+ def update_text_text(self, text):
365
+ # If normal called by self._update_text
366
+ self.process_text_text_line(str(text))
367
+
368
+ def update_text_rich(self, text):
369
+ # If rich called by self._update_text
370
+ self.process_text_rich_line(str(text))
371
+
372
+ def process_text_text_line(self, lines):
373
+ text = ""
374
+ ansi_text = ""
375
+ ansi = False
376
+ try:
377
+ if not self.text_main.IsEmpty():
378
+ self.text_main.AppendText("\n")
379
+ except RuntimeError:
380
+ return
381
+ for c in lines:
382
+ b = ord(c)
383
+ if c == "\n":
384
+ if text:
385
+ self.text_main.AppendText(text)
386
+ text = ""
387
+ if b == 27:
388
+ ansi = True
389
+ if ansi:
390
+ ansi_text += c
391
+ if c == "m":
392
+ if text:
393
+ self.text_main.AppendText(text)
394
+ text = ""
395
+ ansi = False
396
+ ansi_text = ""
397
+ continue
398
+ text += c
399
+ if text:
400
+ self.text_main.AppendText(text)
401
+
402
+ def process_text_rich_line(self, lines):
403
+ """
404
+ Update rich text code line. This only works if text_main is a RichText box.
405
+
406
+ @param lines:
407
+ @return:
408
+ """
409
+ try:
410
+ self.text_main.SetInsertionPointEnd()
411
+ except RuntimeError:
412
+ # Console is shutdown.
413
+ return
414
+ ansi = False
415
+ ansi_text = ""
416
+ text = ""
417
+ open_style = False
418
+ for c in lines:
419
+ b = ord(c)
420
+ if c == "\n":
421
+ if text:
422
+ self.text_main.WriteText(text)
423
+ text = ""
424
+ self.text_main.Newline()
425
+ self.text_main.BeginStyle(self.style)
426
+ open_style = True
427
+ continue # New Line is already processed.
428
+ if b == 27:
429
+ ansi = True
430
+ if ansi:
431
+ ansi_text += c
432
+ if c == "m":
433
+ if text:
434
+ self.text_main.WriteText(text)
435
+ text = ""
436
+ style_function = self.ansi_styles.get(ansi_text)
437
+ if style_function is not None:
438
+ new_style = style_function(self.text_main.GetDefaultStyleEx())
439
+ if open_style:
440
+ self.text_main.EndStyle()
441
+ open_style = False
442
+ if new_style is not None:
443
+ self.text_main.BeginStyle(new_style)
444
+ open_style = True
445
+ ansi = False
446
+ ansi_text = ""
447
+ continue
448
+ text += c
449
+ if text:
450
+ self.text_main.WriteText(text)
451
+ if open_style:
452
+ self.text_main.EndStyle()
453
+
454
+ self.text_main.ScrollIntoView(self.text_main.GetLastPosition(), wx.WXK_END)
455
+ self.text_main.Update()
456
+
457
+ def on_text_uri(self, event):
458
+ mouse_event = event.GetMouseEvent()
459
+ if mouse_event.LeftDClick():
460
+ url_start = event.GetURLStart()
461
+ url_end = event.GetURLEnd()
462
+ url = self.text_main.GetRange(url_start, url_end)
463
+ import webbrowser
464
+
465
+ webbrowser.open_new_tab(url)
466
+
467
+ def on_key_down_main(self, event):
468
+ def isrealchar(keycode):
469
+ if keycode in (wx.WXK_LEFT, wx.WXK_RIGHT):
470
+ # There are much more, but I am lazy...
471
+ return False
472
+ else:
473
+ return chr(keycode).isprintable
474
+
475
+ def refocus():
476
+ self.text_entry.SetInsertionPointEnd()
477
+ self.text_entry.SetFocus()
478
+
479
+ key = event.GetKeyCode()
480
+ if key != wx.WXK_CONTROL and (key != ord("C")) and not event.ControlDown():
481
+ if self.FindFocus() is not self.text_entry:
482
+ try:
483
+ if key == wx.WXK_DOWN:
484
+ self.text_entry.SetValue(
485
+ self.command_log[self.command_position + 1]
486
+ )
487
+ if not wx.IsMainThread():
488
+ wx.CallAfter(refocus)
489
+ else:
490
+ refocus()
491
+ self.command_position += 1
492
+ elif key == wx.WXK_UP:
493
+ self.text_entry.SetValue(
494
+ self.command_log[self.command_position - 1]
495
+ )
496
+ if not wx.IsMainThread():
497
+ wx.CallAfter(refocus)
498
+ else:
499
+ refocus()
500
+ self.command_position -= 1
501
+ elif isrealchar(key):
502
+ self.text_entry.SetFocus()
503
+ self.text_entry.AppendText(str(chr(key)).lower())
504
+ else:
505
+ self.text_entry.SetFocus()
506
+ # event.Skip()
507
+ except IndexError:
508
+ self.command_position = 0
509
+ self.text_entry.SetValue("")
510
+ else:
511
+ event.Skip()
512
+
513
+ def on_key_down(self, event):
514
+ key = event.GetKeyCode()
515
+ try:
516
+ if key == wx.WXK_DOWN:
517
+ self.text_entry.SetValue(self.command_log[self.command_position + 1])
518
+ if not wx.IsMainThread():
519
+ wx.CallAfter(self.text_entry.SetInsertionPointEnd)
520
+ else:
521
+ self.text_entry.SetInsertionPointEnd()
522
+ self.command_position += 1
523
+ elif key == wx.WXK_UP:
524
+ self.text_entry.SetValue(self.command_log[self.command_position - 1])
525
+ if not wx.IsMainThread():
526
+ wx.CallAfter(self.text_entry.SetInsertionPointEnd)
527
+ else:
528
+ self.text_entry.SetInsertionPointEnd()
529
+ self.command_position -= 1
530
+ elif key == wx.WXK_TAB:
531
+ # Let's try some autocompletion or at least show possible candidates
532
+ content = self.text_entry.GetValue()
533
+ words = content.split(" ")
534
+ if len(words):
535
+ short_check = words[0]
536
+ context_str = ""
537
+ if len(short_check):
538
+ if len(words) > 1 and short_check in self.command_context:
539
+ context_str = short_check + " "
540
+ short_check = words[1]
541
+ long_check = context_str + short_check
542
+ full_match = False
543
+ found = 0
544
+ candidate = ""
545
+ for command_name in self.command_list:
546
+ parts = command_name.split("/")
547
+ command_item = parts[2]
548
+ full_item = command_item
549
+ if parts[1] != "None":
550
+ full_item = parts[1] + " " + full_item
551
+ # print (f"Compare {s} to {command_item}")
552
+ if context_str == "":
553
+ if command_item == short_check:
554
+ candidate = command_item
555
+ full_match = True
556
+ elif short_check in command_item:
557
+ candidate = command_item
558
+ found += 1
559
+ else:
560
+ if full_item == long_check:
561
+ candidate = command_item
562
+ full_match = True
563
+ elif long_check in full_item:
564
+ candidate = command_item
565
+ found += 1
566
+ self.context(f"?? {long_check}\n")
567
+ if full_match or found == 1:
568
+ self.context(f"help {candidate}\n")
569
+ if found == 0 and context_str == "":
570
+ context_candidate = ""
571
+ for context_name in self.command_context:
572
+ if context_name.startswith(short_check):
573
+ found += 1
574
+ context_candidate = context_name
575
+ # Only set if we did not provide parameters already
576
+ if found == 1 and len(words) == 1:
577
+ self.text_entry.SetValue(f"{context_candidate} ")
578
+ self.text_entry.SetInsertionPointEnd()
579
+ elif found == 1:
580
+ # Only set if we did not provide parameters already
581
+ if len(words) == 1 or (
582
+ len(words) == 2 and context_str != ""
583
+ ):
584
+ self.text_entry.SetValue(f"{context_str}{candidate}")
585
+ self.text_entry.SetInsertionPointEnd()
586
+ # We are consuming the key...
587
+ else:
588
+ event.Skip()
589
+ except IndexError:
590
+ self.command_position = 0
591
+ self.text_entry.SetValue("")
592
+
593
+ def on_enter(self, event): # wxGlade: Terminal.<event_handler>
594
+ command = self.text_entry.GetValue()
595
+ self.command_log.append(command)
596
+ self.save_log(command)
597
+ self.command_position = 0
598
+ self.context(command + "\n")
599
+ self.text_entry.SetValue("")
600
+ event.Skip(False)
601
+
602
+ def history_filename(self):
603
+ safe_dir = self.context.kernel.os_information["WORKDIR"]
604
+ fname = os.path.join(safe_dir, "cmdhistory.log")
605
+ is_there = os.path.exists(fname)
606
+ return fname, is_there
607
+
608
+ def save_log(self, last_command):
609
+ fname, fexists = self.history_filename()
610
+ try:
611
+ history_file = open(fname, "a", encoding="utf-8") # Append mode
612
+ history_file.write(last_command + "\n")
613
+ history_file.close()
614
+ except (PermissionError, OSError):
615
+ # Could not save
616
+ pass
617
+
618
+ def load_log(self):
619
+ def tail(fs, window=1):
620
+ """
621
+ Returns the last `window` lines of file `f` as a list of bytes.
622
+ """
623
+ if window == 0:
624
+ return b""
625
+ BUFSIZE = 1024
626
+ fs.seek(0, 2)
627
+ end = fs.tell()
628
+ nlines = window + 1
629
+ data = []
630
+ while nlines > 0 and end > 0:
631
+ i = max(0, end - BUFSIZE)
632
+ nread = min(end, BUFSIZE)
633
+
634
+ fs.seek(i)
635
+ chunk = fs.read(nread)
636
+ data.append(chunk)
637
+ nlines -= chunk.count(b"\n")
638
+ end -= nread
639
+ return b"\n".join(b"".join(reversed(data)).splitlines()[-window:])
640
+
641
+ # Restores the last 50 commands from disk
642
+
643
+ self.context.setting(int, "history_limit", 50)
644
+ limit = int(self.context.history_limit)
645
+ # print (f"Limit = {limit}")
646
+ self.command_log = [""]
647
+ fname, fexists = self.history_filename()
648
+ if fexists:
649
+ result = []
650
+ if fexists:
651
+ result = []
652
+ try:
653
+ with open(fname, "rb") as f:
654
+ result = (
655
+ tail(f, 3 * limit).decode("utf-8", errors="ignore").splitlines()
656
+ )
657
+ except (PermissionError, OSError):
658
+ # Could not load
659
+ pass
660
+ for entry in result:
661
+ if len(self.command_log) and entry == self.command_log[-1]:
662
+ # print (f"ignored duplicate {entry}")
663
+ continue
664
+ self.command_log.append(entry)
665
+ if len(self.command_log) > limit:
666
+ self.command_log = self.command_log[-limit:]
667
+
668
+
669
+ class Console(MWindow):
670
+ def __init__(self, *args, **kwds):
671
+ super().__init__(550, 450, *args, **kwds)
672
+ self.panel = ConsolePanel(self, wx.ID_ANY, context=self.context)
673
+ self.sizer.Add(self.panel, 1, wx.EXPAND, 0)
674
+ self.add_module_delegate(self.panel)
675
+ _icon = wx.NullIcon
676
+ _icon.CopyFromBitmap(icons8_console.GetBitmap())
677
+ self.SetIcon(_icon)
678
+ self.SetTitle(_("Console"))
679
+ self.Layout()
680
+ self.restore_aspect(honor_initial_values=True)
681
+
682
+ @staticmethod
683
+ def sub_register(kernel):
684
+ kernel.register("wxpane/Console", register_panel_console)
685
+ kernel.register(
686
+ "button/preparation/Console",
687
+ {
688
+ "label": _("Console"),
689
+ "icon": icons8_console,
690
+ "tip": _("Open Console Window"),
691
+ "help": "console",
692
+ "action": lambda v: kernel.console("window toggle Console\n"),
693
+ "size": STD_ICON_SIZE,
694
+ "priority": 4,
695
+ },
696
+ )
697
+
698
+ def window_open(self):
699
+ self.panel.pane_show()
700
+
701
+ def window_close(self):
702
+ self.panel.pane_hide()
703
+
704
+ @staticmethod
705
+ def helptext():
706
+ return _("Open command interface")