diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd915fa4..dd9b88e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,12 @@ CHANGELOG for FlatCAM Evo beta
=================================================
+25.11.2023
+
+- some names are updated
+- made sure that when a new project is created that the levelling grid shapes are deleted
+- some code optimization and code refactoring
+
14.11.2023
- trying to solve an idiosyncrasy of MacOS which do not allow modifying the main menu in a non-main thread which is done after editing an object
diff --git a/appGUI/GUIElements.py b/appGUI/GUIElements.py
index 58712ab5..b051f97f 100644
--- a/appGUI/GUIElements.py
+++ b/appGUI/GUIElements.py
@@ -6101,10 +6101,10 @@ class AppSystemTray(QtWidgets.QSystemTrayIcon):
self.menu_open.addSeparator()
- menu_openproject.triggered.connect(lambda: self.app.f_handlers.on_file_openproject())
- menu_opengerber.triggered.connect(lambda: self.app.f_handlers.on_fileopengerber())
- menu_openexcellon.triggered.connect(lambda: self.app.f_handlers.on_fileopenexcellon())
- menu_opengcode.triggered.connect(lambda: self.app.f_handlers.on_fileopengcode())
+ menu_openproject.triggered.connect(lambda: self.app.f_handlers.on_file_open_project())
+ menu_opengerber.triggered.connect(lambda: self.app.f_handlers.on_file_open_gerber())
+ menu_openexcellon.triggered.connect(lambda: self.app.f_handlers.on_file_open_excellon())
+ menu_opengcode.triggered.connect(lambda: self.app.f_handlers.on_file_open_gcode())
exitAction = menu.addAction(_("Exit"))
exitAction.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png'))
@@ -6112,7 +6112,7 @@ class AppSystemTray(QtWidgets.QSystemTrayIcon):
menu_toggle_gui.triggered.connect(self.app.ui.on_toggle_gui)
- menu_runscript.triggered.connect(lambda: self.app.on_filerunscript(
+ menu_runscript.triggered.connect(lambda: self.app.on_file_run_cript(
silent=True if self.app.cmd_line_headless == 1 else False))
exitAction.triggered.connect(self.app.final_save)
diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py
index fd1a4e33..0ea7adb8 100644
--- a/appGUI/MainGUI.py
+++ b/appGUI/MainGUI.py
@@ -2950,7 +2950,7 @@ class MainGUI(QtWidgets.QMainWindow):
# CTRL + SHIFT
if modifiers == QtCore.Qt.KeyboardModifier.ControlModifier | QtCore.Qt.KeyboardModifier.ShiftModifier:
if key == QtCore.Qt.Key.Key_S:
- self.app.f_handlers.on_file_saveprojectas()
+ self.app.f_handlers.on_file_save_project_as()
return
# CTRL
elif modifiers == QtCore.Qt.KeyboardModifier.ControlModifier:
@@ -2975,7 +2975,7 @@ class MainGUI(QtWidgets.QMainWindow):
# Open Excellon file
if key == QtCore.Qt.Key.Key_E:
- self.app.f_handlers.on_fileopenexcellon()
+ self.app.f_handlers.on_file_open_excellon()
# Open Gerber file
if key == QtCore.Qt.Key.Key_G:
@@ -2983,7 +2983,7 @@ class MainGUI(QtWidgets.QMainWindow):
if 'editor' in widget_name.lower():
self.app.goto_text_line()
else:
- self.app.f_handlers.on_fileopengerber()
+ self.app.f_handlers.on_file_open_gerber()
# Distance Tool
if key == QtCore.Qt.Key.Key_M:
@@ -2995,7 +2995,7 @@ class MainGUI(QtWidgets.QMainWindow):
# Open Project
if key == QtCore.Qt.Key.Key_O:
- self.app.f_handlers.on_file_openproject()
+ self.app.f_handlers.on_file_open_project()
# Open Project
if key == QtCore.Qt.Key.Key_P:
@@ -3019,7 +3019,7 @@ class MainGUI(QtWidgets.QMainWindow):
self.app.tools_db_tab.on_save_tools_db()
return
- self.app.f_handlers.on_file_saveproject()
+ self.app.f_handlers.on_file_save_project()
# Toggle Plot Area
if key == QtCore.Qt.Key.Key_F10 or key == 'F10':
@@ -3070,7 +3070,7 @@ class MainGUI(QtWidgets.QMainWindow):
# Run a Script
if key == QtCore.Qt.Key.Key_S:
- self.app.f_handlers.on_filerunscript()
+ self.app.f_handlers.on_file_run_cript()
return
# Toggle Workspace
diff --git a/appHandlers/AppIO.py b/appHandlers/AppIO.py
index 29ad05bb..53fb8fbf 100644
--- a/appHandlers/AppIO.py
+++ b/appHandlers/AppIO.py
@@ -73,7 +73,7 @@ class AppIO(QtCore.QObject):
self.app.new_project_signal.connect(self.on_new_project_house_keeping)
- def on_fileopengerber(self, name=None):
+ def on_file_open_gerber(self, name=None):
"""
File menu callback for opening a Gerber.
@@ -81,7 +81,7 @@ class AppIO(QtCore.QObject):
:return: None
"""
- self.log.debug("on_fileopengerber()")
+ self.log.debug("on_file_open_gerber()")
_filter_ = "Gerber Files (*.gbr *.ger *.gtl *.gbl *.gts *.gbs *.gtp *.gbp *.gto *.gbo *.gm1 *.gml *.gm3 " \
"*.gko *.cmp *.sol *.stc *.sts *.plc *.pls *.crc *.crs *.tsm *.bsm *.ly2 *.ly15 *.dim *.mil *.grb " \
@@ -122,7 +122,7 @@ class AppIO(QtCore.QObject):
if filename != '':
self.worker_task.emit({'fcn': self.open_gerber, 'params': [filename]})
- def on_fileopenexcellon(self, name=None):
+ def on_file_open_excellon(self, name=None):
"""
File menu callback for opening an Excellon file.
@@ -130,7 +130,7 @@ class AppIO(QtCore.QObject):
:return: None
"""
- self.log.debug("on_fileopenexcellon()")
+ self.log.debug("on_file_open_excellon()")
_filter_ = "Excellon Files (*.drl *.txt *.xln *.drd *.tap *.exc *.ncd);;" \
"All Files (*.*)"
@@ -160,7 +160,7 @@ class AppIO(QtCore.QObject):
if filename != '':
self.worker_task.emit({'fcn': self.open_excellon, 'params': [filename]})
- def on_fileopengcode(self, name=None):
+ def on_file_open_gcode(self, name=None):
"""
File menu call back for opening gcode.
@@ -169,7 +169,7 @@ class AppIO(QtCore.QObject):
:return:
"""
- self.log.debug("on_fileopengcode()")
+ self.log.debug("on_file_open_gcode()")
# https://bobcadsupport.com/helpdesk/index.php?/Knowledgebase/Article/View/13/5/known-g-code-file-extensions
_filter_ = "G-Code Files (*.txt *.nc *.ncc *.tap *.gcode *.cnc *.ecs *.fnc *.dnc *.ncg *.gc *.fan *.fgc" \
@@ -203,14 +203,14 @@ class AppIO(QtCore.QObject):
if filename != '':
self.worker_task.emit({'fcn': self.open_gcode, 'params': [filename, None, True]})
- def on_file_openproject(self):
+ def on_file_open_project(self):
"""
File menu callback for opening a project.
:return: None
"""
- self.log.debug("on_file_openproject()")
+ self.log.debug("on_file_open_project()")
_filter_ = "FlatCAM Project (*.FlatPrj);;All Files (*.*)"
try:
@@ -230,14 +230,14 @@ class AppIO(QtCore.QObject):
# thread safe. The new_project()
self.open_project(filename)
- def on_fileopenhpgl2(self, name=None):
+ def on_file_open_hpgl2(self, name=None):
"""
File menu callback for opening a HPGL2.
:param name:
:return: None
"""
- self.log.debug("on_fileopenhpgl2()")
+ self.log.debug("on_file_open_hpgl2()")
_filter_ = "HPGL2 Files (*.plt);;" \
"All Files (*.*)"
@@ -267,14 +267,14 @@ class AppIO(QtCore.QObject):
if filename != '':
self.worker_task.emit({'fcn': self.open_hpgl2, 'params': [filename]})
- def on_file_openconfig(self):
+ def on_file_open_config(self):
"""
File menu callback for opening a config file.
:return: None
"""
- self.log.debug("on_file_openconfig()")
+ self.log.debug("on_file_open_config()")
_filter_ = "FlatCAM Config (*.FlatConfig);;FlatCAM Config (*.json);;All Files (*.*)"
try:
@@ -289,13 +289,13 @@ class AppIO(QtCore.QObject):
else:
self.open_config_file(filename)
- def on_file_exportsvg(self):
+ def on_file_export_svg(self):
"""
Callback for menu item File->Export SVG.
:return: None
"""
- self.log.debug("on_file_exportsvg()")
+ self.log.debug("on_file_export_svg()")
obj = self.app.collection.get_active()
if obj is None:
@@ -344,9 +344,9 @@ class AppIO(QtCore.QObject):
self.app.file_opened.emit("SVG", filename)
self.app.file_saved.emit("SVG", filename)
- def on_file_exportpng(self):
+ def on_file_export_png(self):
- self.log.debug("on_file_exportpng()")
+ self.log.debug("on_file_export_png()")
date = str(datetime.today()).rpartition('.')[0]
date = ''.join(c for c in date if c not in ':-')
@@ -386,13 +386,13 @@ class AppIO(QtCore.QObject):
self.app.file_opened.emit("png", filename)
self.app.file_saved.emit("png", filename)
- def on_file_savegerber(self):
+ def on_file_save_gerber(self):
"""
Callback for menu item in Project context menu.
:return: None
"""
- self.log.debug("on_file_savegerber()")
+ self.log.debug("on_file_save_gerber()")
obj = self.app.collection.get_active()
if obj is None:
@@ -428,13 +428,13 @@ class AppIO(QtCore.QObject):
self.app.file_opened.emit("Gerber", filename)
self.app.file_saved.emit("Gerber", filename)
- def on_file_savescript(self):
+ def on_file_save_script(self):
"""
Callback for menu item in Project context menu.
:return: None
"""
- self.log.debug("on_file_savescript()")
+ self.log.debug("on_file_save_script()")
obj = self.app.collection.get_active()
if obj is None:
@@ -470,13 +470,13 @@ class AppIO(QtCore.QObject):
self.app.file_opened.emit("Script", filename)
self.app.file_saved.emit("Script", filename)
- def on_file_savedocument(self):
+ def on_file_save_document(self):
"""
Callback for menu item in Project context menu.
:return: None
"""
- self.log.debug("on_file_savedocument()")
+ self.log.debug("on_file_save_document()")
obj = self.app.collection.get_active()
if obj is None:
@@ -512,13 +512,13 @@ class AppIO(QtCore.QObject):
self.app.file_opened.emit("Document", filename)
self.app.file_saved.emit("Document", filename)
- def on_file_saveexcellon(self):
+ def on_file_save_excellon(self):
"""
Callback for menu item in project context menu.
:return: None
"""
- self.log.debug("on_file_saveexcellon()")
+ self.log.debug("on_file_save_excellon()")
obj = self.app.collection.get_active()
if obj is None:
@@ -553,13 +553,13 @@ class AppIO(QtCore.QObject):
self.app.file_opened.emit("Excellon", filename)
self.app.file_saved.emit("Excellon", filename)
- def on_file_exportexcellon(self):
+ def on_file_export_excellon(self):
"""
Callback for menu item File->Export->Excellon.
:return: None
"""
- self.log.debug("on_file_exportexcellon()")
+ self.log.debug("on_file_export_excellon()")
obj = self.app.collection.get_active()
if obj is None:
@@ -598,13 +598,13 @@ class AppIO(QtCore.QObject):
self.app.file_opened.emit("Excellon", filename)
self.app.file_saved.emit("Excellon", filename)
- def on_file_exportgerber(self):
+ def on_file_export_gerber(self):
"""
Callback for menu item File->Export->Gerber.
:return: None
"""
- self.log.debug("on_file_exportgerber()")
+ self.log.debug("on_file_export_gerber()")
obj = self.app.collection.get_active()
if obj is None:
@@ -643,13 +643,13 @@ class AppIO(QtCore.QObject):
self.app.file_opened.emit("Gerber", filename)
self.app.file_saved.emit("Gerber", filename)
- def on_file_exportdxf(self):
+ def on_file_export_dxf(self):
"""
Callback for menu item File->Export DXF.
:return: None
"""
- self.log.debug("on_file_exportdxf()")
+ self.log.debug("on_file_export_dxf()")
obj = self.app.collection.get_active()
if obj is None:
@@ -698,14 +698,14 @@ class AppIO(QtCore.QObject):
self.app.file_opened.emit("DXF", filename)
self.app.file_saved.emit("DXF", filename)
- def on_file_importsvg(self, type_of_obj):
+ def on_file_import_svg(self, type_of_obj):
"""
Callback for menu item File->Import SVG.
:param type_of_obj: to import the SVG as Geometry or as Gerber
:type type_of_obj: str
:return: None
"""
- self.log.debug("on_file_importsvg()")
+ self.log.debug("on_file_import_svg()")
_filter_ = "SVG File .svg (*.svg);;All Files (*.*)"
try:
@@ -728,14 +728,14 @@ class AppIO(QtCore.QObject):
if filename != '':
self.worker_task.emit({'fcn': self.import_svg, 'params': [filename, type_of_obj]})
- def on_file_importdxf(self, type_of_obj):
+ def on_file_import_dxf(self, type_of_obj):
"""
Callback for menu item File->Import DXF.
:param type_of_obj: to import the DXF as Geometry or as Gerber
:type type_of_obj: str
:return: None
"""
- self.log.debug("on_file_importdxf()")
+ self.log.debug("on_file_import_dxf()")
_filter_ = "DXF File .dxf (*.DXF);;All Files (*.*)"
try:
@@ -788,15 +788,15 @@ class AppIO(QtCore.QObject):
response = msgbox.clickedButton()
if response == bt_yes:
- self.on_file_saveprojectas(use_thread=True)
+ self.on_file_save_project_as(use_thread=True)
elif response == bt_cancel:
return
elif response == bt_no:
- self.on_file_new_project(use_thread=True, silenced=True)
+ self.on_file_new_project(use_thread=True)
else:
- self.on_file_new_project(use_thread=True, silenced=True)
+ self.on_file_new_project(use_thread=True)
- def on_file_new_project(self, cli=None, reset_tcl=True, use_thread=None, silenced=None, keep_scripts=True):
+ def on_file_new_project(self, cli=None, reset_tcl=True, use_thread=None, keep_scripts=True):
"""
Returns the application to its startup state. This method is thread-safe.
@@ -804,7 +804,6 @@ class AppIO(QtCore.QObject):
:param reset_tcl: Boolean. If False, on new project creation the Tcl instance is not recreated, therefore it
will remember all the previous variables. If True then the Tcl is re-instantiated.
:param use_thread: Bool. If True some part of the initialization are done threaded
- :param silenced: Bool or None. If True then the app will not ask to save the current parameters.
:param keep_scripts: Bool. If True the Script objects are not deleted when creating a new project
:return: None
"""
@@ -841,12 +840,30 @@ class AppIO(QtCore.QObject):
except AttributeError:
pass
+ # clear the possible drawn probing shapes for Levelling Tool
+ try:
+ self.app.levelling_tool.probing_shapes.clear(update=True)
+ except AttributeError:
+ pass
+
+ # clean possible tool shapes for Isolation, NCC, Paint, Punch Gerber Plugins
+ try:
+ self.app.tool_shapes.clear(update=True)
+ except AttributeError:
+ pass
+
# delete the exclusion areas
self.app.exc_areas.clear_shapes()
# delete any selection shape on canvas
self.app.delete_selection_shape()
+ # delete any hover shapes on canvas
+ try:
+ self.app.hover_shapes.clear(update=True)
+ except AttributeError:
+ pass
+
# delete all App objects
if keep_scripts is True:
for prj_obj in self.app.collection.get_list():
@@ -893,7 +910,7 @@ class AppIO(QtCore.QObject):
if cli is None:
# we need to go in reverse because once we remove a tab then the index changes
# meaning that removing the first tab (idx = 0) then the tab at former idx = 1 will assume idx = 0
- # and so on. Therefore the deletion should be done in reverse
+ # and so on. Therefore, the deletion should be done in reverse
wdg_count = self.app.ui.plot_tab_area.tabBar.count() - 1
for index in range(wdg_count, -1, -1):
try:
@@ -931,14 +948,14 @@ class AppIO(QtCore.QObject):
self.app.init_tools(init_tcl=True)
self.log.debug('%s: %s %s.' % ("Initiated the MP pool and plugins in: ", str(time.time() - t0), _("seconds")))
- def on_filenewscript(self, silent=False):
+ def on_file_new_script(self, silent=False):
"""
Will create a new script file and open it in the Code Editor
:param silent: if True will not display status messages
:return: None
"""
- self.log.debug("on_filenewscript()")
+ self.log.debug("on_file_new_script()")
if silent is False:
self.inform.emit('[success] %s' % _("New TCL script file created in Code Editor."))
@@ -949,7 +966,7 @@ class AppIO(QtCore.QObject):
self.app.app_obj.new_script_object()
- def on_fileopenscript(self, name=None, silent=False):
+ def on_file_open_script(self, name=None, silent=False):
"""
Will open a Tcl script file into the Code Editor
@@ -958,7 +975,7 @@ class AppIO(QtCore.QObject):
:return: None
"""
- self.log.debug("on_fileopenscript()")
+ self.log.debug("on_file_open_script()")
_filter_ = "TCL script .FlatScript (*.FlatScript);;TCL script .tcl (*.TCL);;TCL script .txt (*.TXT);;" \
"All Files (*.*)"
@@ -980,7 +997,7 @@ class AppIO(QtCore.QObject):
if filename != '':
self.worker_task.emit({'fcn': self.open_script, 'params': [filename]})
- def on_fileopenscript_example(self, name=None, silent=False):
+ def on_file_open_script_example(self, name=None, silent=False):
"""
Will open a Tcl script file into the Code Editor
@@ -989,7 +1006,7 @@ class AppIO(QtCore.QObject):
:return:
"""
- self.log.debug("on_fileopenscript_example()")
+ self.log.debug("on_file_open_script_example()")
_filter_ = "TCL script .FlatScript (*.FlatScript);;TCL script .tcl (*.TCL);;TCL script .txt (*.TXT);;" \
"All Files (*.*)"
@@ -1017,7 +1034,7 @@ class AppIO(QtCore.QObject):
if filename != '':
self.worker_task.emit({'fcn': self.open_script, 'params': [filename]})
- def on_filerunscript(self, name=None, silent=False):
+ def on_file_run_cript(self, name=None, silent=False):
"""
File menu callback for loading and running a TCL script.
@@ -1062,31 +1079,31 @@ class AppIO(QtCore.QObject):
try:
with open(filename, "r") as tcl_script:
- cmd_line_shellfile_content = tcl_script.read()
+ cmd_line_shell_file_content = tcl_script.read()
if self.app.cmd_line_headless != 1:
- self.app.shell.exec_command(cmd_line_shellfile_content)
+ self.app.shell.exec_command(cmd_line_shell_file_content)
else:
- self.app.shell.exec_command(cmd_line_shellfile_content, no_echo=True)
+ self.app.shell.exec_command(cmd_line_shell_file_content, no_echo=True)
if silent is False:
self.inform.emit('[success] %s' % _("TCL script file opened in Code Editor and executed."))
except Exception as e:
- self.app.error("App.on_filerunscript() -> %s" % str(e))
+ self.app.error("App.on_file_run_cript() -> %s" % str(e))
sys.exit(2)
- def on_file_saveproject(self, silent=False):
+ def on_file_save_project(self, silent=False):
"""
Callback for menu item File->Save Project. Saves the project to
- ``self.project_filename`` or calls ``self.on_file_saveprojectas()``
+ ``self.project_filename`` or calls ``self.on_file_save_project_as()``
if set to None. The project is saved by calling ``self.save_project()``.
:param silent: if True will not display status messages
:return: None
"""
- self.log.debug("on_file_saveproject()")
+ self.log.debug("on_file_save_project()")
if self.app.project_filename is None:
- self.on_file_saveprojectas()
+ self.on_file_save_project_as()
else:
self.worker_task.emit({'fcn': self.save_project, 'params': [self.app.project_filename, silent]})
if self.options["global_open_style"] is False:
@@ -1097,18 +1114,15 @@ class AppIO(QtCore.QObject):
self.app.should_we_save = False
- def on_file_saveprojectas(self, make_copy=False, use_thread=True, quit_action=False):
+ def on_file_save_project_as(self, make_copy=False, use_thread=True, quit_action=False):
"""
- Callback for menu item File->Save Project As... Opens a file
- chooser and saves the project to the given file via
- ``self.save_project()``.
+ Save the project to a given file by opening a file chooser via self.save_project().
- :param make_copy if to be create a copy of the project; boolean
- :param use_thread: if to be run in a separate thread; boolean
- :param quit_action: if to be followed by quiting the application; boolean
- :return: None
- """
- self.log.debug("on_file_saveprojectas()")
+ :param make_copy: boolean, whether to make a copy of the project
+ :param use_thread: boolean, whether to run in a separate thread
+ :param quit_action: boolean, whether to quit the application after
+ :return: None """
+ self.log.debug("on_file_save_project_as()")
date = str(datetime.today()).rpartition('.')[0]
date = ''.join(c for c in date if c not in ':-')
@@ -1264,7 +1278,7 @@ class AppIO(QtCore.QObject):
}
)
- # make sure that the Excellon objeacts are drawn on top of everything
+ # make sure that the Excellon objects are drawn on top of everything
excellon_objs = [obj for obj in obj_selection if obj.kind == 'excellon']
cncjob_objs = [obj for obj in obj_selection if obj.kind == 'cncjob']
# reverse the object order such that the first selected is on top
@@ -1308,11 +1322,11 @@ class AppIO(QtCore.QObject):
for obj in obj_selection:
try:
- gxmin, gymin, gxmax, gymax = obj.bounds()
- xmin = min([xmin, gxmin])
- ymin = min([ymin, gymin])
- xmax = max([xmax, gxmax])
- ymax = max([ymax, gymax])
+ g_xmin, g_ymin, g_xmax, g_ymax = obj.bounds()
+ xmin = min([xmin, g_xmin])
+ ymin = min([ymin, g_ymin])
+ xmax = max([xmax, g_xmax])
+ ymax = max([ymax, g_ymax])
except Exception as e:
self.log.error("Tried to get bounds of empty geometry in App.save_pdf(). %s" % str(e))
@@ -1320,7 +1334,7 @@ class AppIO(QtCore.QObject):
bounds = [xmin, ymin, xmax, ymax]
size = bounds[2] - bounds[0], bounds[3] - bounds[1]
- # This contain the measure units
+ # This contains the measure units
uom = obj_selection[0].units.lower()
# Define a boundary around SVG of about 1.0mm (~39mils)
@@ -1335,7 +1349,7 @@ class AppIO(QtCore.QObject):
minx = str(bounds[0] - boundary)
miny = str(bounds[1] + boundary + size[1])
- # Add a SVG Header and footer to the svg output from shapely
+ # Add an SVG Header and footer to the svg output from shapely
# The transform flips the Y Axis so that everything renders
# properly within svg apps such as inkscape
svg_header = ''
svg_elem = svg_header + exported_svg + svg_footer
# Parse the xml through a xml parser just to add line feeds
# and to make it look more pretty for the output
- svgcode = parse_xml_string(svg_elem)
- svgcode = svgcode.toprettyxml()
+ svg_code = parse_xml_string(svg_elem)
+ svg_code = svg_code.toprettyxml()
try:
with open(filename, 'w') as fp:
- fp.write(svgcode)
+ fp.write(svg_code)
except PermissionError:
self.inform.emit('[WARNING] %s' %
_("Permission denied, saving not possible.\n"
@@ -1526,7 +1540,7 @@ class AppIO(QtCore.QObject):
def export_excellon(self, obj_name, filename, local_use=None, use_thread=True):
"""
- Exports a Excellon Object to an Excellon file.
+ Exports an Excellon Object to an Excellon file.
:param obj_name: the name of the FlatCAM object to be saved as Excellon
:param filename: Path to the Excellon file to save to.
@@ -1561,18 +1575,18 @@ class AppIO(QtCore.QObject):
return
# updated units
- eunits = self.options["excellon_exp_units"]
- ewhole = self.options["excellon_exp_integer"]
- efract = self.options["excellon_exp_decimals"]
- ezeros = self.options["excellon_exp_zeros"]
- eformat = self.options["excellon_exp_format"]
+ e_units = self.options["excellon_exp_units"]
+ e_whole = self.options["excellon_exp_integer"]
+ e_fract = self.options["excellon_exp_decimals"]
+ e_zeros = self.options["excellon_exp_zeros"]
+ e_format = self.options["excellon_exp_format"]
slot_type = self.options["excellon_exp_slot_type"]
fc_units = self.app_units.upper()
if fc_units == 'MM':
- factor = 1 if eunits == 'METRIC' else 0.03937
+ factor = 1 if e_units == 'METRIC' else 0.03937
else:
- factor = 25.4 if eunits == 'METRIC' else 1
+ factor = 25.4 if e_units == 'METRIC' else 1
def make_excellon():
try:
@@ -1585,12 +1599,12 @@ class AppIO(QtCore.QObject):
header += ';Filename: %s' % str(obj_name) + '\n'
header += ';Created on : %s' % time_str + '\n'
- if eformat == 'dec':
- has_slots, excellon_code = obj.export_excellon(ewhole, efract, factor=factor, slot_type=slot_type)
- header += eunits + '\n'
+ if e_format == 'dec':
+ has_slots, excellon_code = obj.export_excellon(e_whole, e_fract, factor=factor, slot_type=slot_type)
+ header += e_units + '\n'
for tool in obj.tools:
- if eunits == 'METRIC':
+ if e_units == 'METRIC':
header += "T{tool}F00S00C{:.{dec}f}\n".format(float(obj.tools[tool]['tooldia']) * factor,
tool=str(tool),
dec=2)
@@ -1599,15 +1613,15 @@ class AppIO(QtCore.QObject):
tool=str(tool),
dec=4)
else:
- if ezeros == 'LZ':
- has_slots, excellon_code = obj.export_excellon(ewhole, efract,
+ if e_zeros == 'LZ':
+ has_slots, excellon_code = obj.export_excellon(e_whole, e_fract,
form='ndec', e_zeros='LZ', factor=factor,
slot_type=slot_type)
- header += '%s,%s\n' % (eunits, 'LZ')
+ header += '%s,%s\n' % (e_units, 'LZ')
header += format_exc
for tool in obj.tools:
- if eunits == 'METRIC':
+ if e_units == 'METRIC':
header += "T{tool}F00S00C{:.{dec}f}\n".format(
float(obj.tools[tool]['tooldia']) * factor,
tool=str(tool),
@@ -1618,14 +1632,14 @@ class AppIO(QtCore.QObject):
tool=str(tool),
dec=4)
else:
- has_slots, excellon_code = obj.export_excellon(ewhole, efract,
+ has_slots, excellon_code = obj.export_excellon(e_whole, e_fract,
form='ndec', e_zeros='TZ', factor=factor,
slot_type=slot_type)
- header += '%s,%s\n' % (eunits, 'TZ')
+ header += '%s,%s\n' % (e_units, 'TZ')
header += format_exc
for tool in obj.tools:
- if eunits == 'METRIC':
+ if e_units == 'METRIC':
header += "T{tool}F00S00C{:.{dec}f}\n".format(
float(obj.tools[tool]['tooldia']) * factor,
tool=str(tool),
@@ -1674,16 +1688,16 @@ class AppIO(QtCore.QObject):
self.worker_task.emit({'fcn': job_thread_exc, 'params': [self]})
else:
- eret = make_excellon()
- if eret == 'fail':
+ ret_val = make_excellon()
+ if ret_val == 'fail':
self.inform.emit('[ERROR_NOTCL] %s' % _('Could not export.'))
return 'fail'
if local_use is not None:
- return eret
+ return ret_val
def export_gerber(self, obj_name, filename, local_use=None, use_thread=True):
"""
- Exports a Gerber Object to an Gerber file.
+ Exports a Gerber Object to a Gerber file.
:param obj_name: the name of the FlatCAM object to be saved as Gerber
:param filename: Path to the Gerber file to save to.
@@ -1708,16 +1722,16 @@ class AppIO(QtCore.QObject):
obj = local_use
# updated units
- gunits = self.options["gerber_exp_units"]
- gwhole = self.options["gerber_exp_integer"]
- gfract = self.options["gerber_exp_decimals"]
- gzeros = self.options["gerber_exp_zeros"]
+ g_units = self.options["gerber_exp_units"]
+ g_whole = self.options["gerber_exp_integer"]
+ g_fract = self.options["gerber_exp_decimals"]
+ g_zeros = self.options["gerber_exp_zeros"]
fc_units = self.app_units.upper()
if fc_units == 'MM':
- factor = 1 if gunits == 'MM' else 0.03937
+ factor = 1 if g_units == 'MM' else 0.03937
else:
- factor = 25.4 if gunits == 'MM' else 1
+ factor = 25.4 if g_units == 'MM' else 1
def make_gerber():
try:
@@ -1729,8 +1743,8 @@ class AppIO(QtCore.QObject):
header += 'G04 Filename: %s*' % str(obj_name) + '\n'
header += 'G04 Created on : %s*' % time_str + '\n'
- header += '%%FS%sAX%s%sY%s%s*%%\n' % (gzeros, gwhole, gfract, gwhole, gfract)
- header += "%MO{units}*%\n".format(units=gunits)
+ header += '%%FS%sAX%s%sY%s%s*%%\n' % (g_zeros, g_whole, g_fract, g_whole, g_fract)
+ header += "%MO{units}*%\n".format(units=g_units)
for apid in obj.tools:
if obj.tools[apid]['type'] == 'C':
@@ -1757,7 +1771,7 @@ class AppIO(QtCore.QObject):
header += '\n'
# obsolete units but some software may need it
- if gunits == 'IN':
+ if g_units == 'IN':
header += 'G70*\n'
else:
header += 'G71*\n'
@@ -1771,7 +1785,7 @@ class AppIO(QtCore.QObject):
footer = 'M02*\n'
- gerber_code = obj.export_gerber(gwhole, gfract, g_zeros=gzeros, factor=factor)
+ gerber_code = obj.export_gerber(g_whole, g_fract, g_zeros=g_zeros, factor=factor)
exported_gerber = header
exported_gerber += gerber_code
@@ -2154,7 +2168,7 @@ class AppIO(QtCore.QObject):
:param filename: G-code file filename
:param outname: Name of the resulting object. None causes the name to be that of the file.
:param force_parsing:
- :param plot: If True plot the object on canvas
+ :param plot: If True, then plot the object on canvas
:param from_tcl: True if run from Tcl Shell
:return: None
"""
@@ -2406,7 +2420,7 @@ class AppIO(QtCore.QObject):
Loads a config file from the specified file.
:param filename: Name of the file from which to load.
- :param run_from_arg: if True the FlatConfig file will be open as an command line argument
+ :param run_from_arg: if True the FlatConfig file will be open as a command line argument
:return: None
"""
self.log.debug("Opening config file: " + filename)
@@ -2460,7 +2474,7 @@ class AppIO(QtCore.QObject):
:param run_from_arg: True if run for arguments
:param plot: If True plot all objects in the project
:param cli: Run from command line
- :param from_tcl: True if run from Tcl Sehll
+ :param from_tcl: True if run from Tcl Shell
:return: None
"""
@@ -2471,7 +2485,7 @@ class AppIO(QtCore.QObject):
self.inform.emit('[ERROR_NOTCL] %s' % _("File no longer available."))
return
- # block autosaving while a project is loaded
+ # block auto-saving while a project is loaded
self.app.block_autosave = True
# for some reason, setting ui_title does not work when this method is called from Tcl Shell
@@ -2616,38 +2630,36 @@ class AppIO(QtCore.QObject):
def worker_task():
with self.app.proc_container.new('%s' % _("Loading...")):
- # Re create objects
+ # Re-create objects
self.log.debug(" **************** Started PROEJCT loading... **************** ")
for obj in proj_dict['objs']:
try:
- msg = "Recreating from opened project an %s object: %s" % \
- (obj['kind'].capitalize(), obj['obj_options']['name'])
+ obj_name = obj['obj_options']['name']
except KeyError:
# allowance for older projects
- msg = "Recreating from opened project an %s object: %s" % \
- (obj['kind'].capitalize(), obj['options']['name'])
- self.app.log.debug(msg)
+ obj_name = obj['options']['name']
+ self.app.log.debug(
+ f"Recreating from opened project an {obj['kind'].capitalize()} object: {obj_name}")
def obj_init(new_obj, app_inst):
try:
new_obj.from_dict(obj)
- except Exception as erro:
- app_inst.log.error('AppIO.open_project() --> ' + str(erro))
+ except Exception as except_error:
+ app_inst.log.error('AppIO.open_project() --> ' + str(except_error))
return 'fail'
# make the 'obj_options' dict a LoudDict
+ new_obj_options = LoudDict()
try:
- new_obj_options = LoudDict()
new_obj_options.update(new_obj.obj_options)
- new_obj.obj_options = new_obj_options
except AttributeError:
- new_obj_options = LoudDict()
new_obj_options.update(new_obj.options)
- new_obj.obj_options = new_obj_options
- except Exception as erro:
- app_inst.log.error('AppIO.open_project() make a LoudDict--> ' + str(erro))
+ except Exception as except_error:
+ app_inst.log.error('AppIO.open_project() make a LoudDict--> ' + str(except_error))
return 'fail'
+ new_obj.obj_options = new_obj_options
+
# #############################################################################################
# for older projects loading try to convert the 'apertures' or 'cnc_tools' or 'exc_cnc_tools'
# attributes, if found, to 'tools'
@@ -2657,10 +2669,6 @@ class AppIO(QtCore.QObject):
new_obj.tools = obj['apertures']
if 'cnc_tools' in obj and obj['cnc_tools']:
new_obj.tools = obj['cnc_tools']
- # new_obj.used_tools = [int(k) for k in new_obj.tools.keys()]
- # first_key = list(obj['cnc_tools'].keys())[0]
- # used_preprocessor = obj['cnc_tools'][first_key]['data']['ppname_g']
- # new_obj.gc_start = new_obj.doformat(self.app.preprocessors[used_preprocessor].start_code)
if 'exc_cnc_tools' in obj and obj['exc_cnc_tools']:
new_obj.tools = obj['exc_cnc_tools']
# add the used_tools (all of them will be used)
@@ -2683,8 +2691,8 @@ class AppIO(QtCore.QObject):
new_obj.tools = {
float(tool): tool_dict for tool, tool_dict in list(new_obj.tools.items())
}
- except Exception as erro:
- app_inst.log.error('AppIO.open_project() keys to int--> ' + str(erro))
+ except Exception as other_error_msg:
+ app_inst.log.error('AppIO.open_project() keys to int--> ' + str(other_error_msg))
return 'fail'
# #############################################################################################
@@ -2697,7 +2705,7 @@ class AppIO(QtCore.QObject):
# #############################################################################################
if new_obj.kind == 'cncjob':
- # some attributes are serialized so we need t otake this into consideration in
+ # some attributes are serialized, so we need to take this into consideration in
# CNCJob.set_ui()
new_obj.is_loaded_from_project = True
@@ -2706,16 +2714,16 @@ class AppIO(QtCore.QObject):
try:
if cli is None:
self.app.ui.set_ui_title(name="{} {}: {}".format(
- _("Loading Project ... restoring"), obj['kind'].upper(), obj['obj_options']['name']))
+ _("Loading Project ... restoring"), obj['kind'].upper(), obj_name))
ret = self.app.app_obj.new_object(obj['kind'], obj['obj_options']['name'], obj_init, plot=plot)
except KeyError:
# allowance for older projects
if cli is None:
self.app.ui.set_ui_title(name="{} {}: {}".format(
- _("Loading Project ... restoring"), obj['kind'].upper(), obj['options']['name']))
+ _("Loading Project ... restoring"), obj['kind'].upper(), obj_name))
try:
- ret = self.app.app_obj.new_object(obj['kind'], obj['options']['name'], obj_init, plot=plot)
+ ret = self.app.app_obj.new_object(obj['kind'], obj_name, obj_init, plot=plot)
except Exception:
continue
if ret == 'fail':
@@ -2726,7 +2734,7 @@ class AppIO(QtCore.QObject):
self.app.should_we_save = False
self.app.file_opened.emit("project", filename)
- # restore autosaving after a project was loaded
+ # restore auto-saving after a project was loaded
self.app.block_autosave = False
# for some reason, setting ui_title does not work when this method is called from Tcl Shell
@@ -2791,8 +2799,8 @@ class AppIO(QtCore.QObject):
out1 = compressor_obj.compress(project_as_json)
out2 = compressor_obj.flush()
project_zipped = b"".join([out1, out2])
- except Exception as errrr:
- self.log.error("Failed to save compressed file: %s because: %s" % (str(filename), str(errrr)))
+ except Exception as error_msg:
+ self.log.error("Failed to save compressed file: %s because: %s" % (str(filename), str(error_msg)))
self.inform.emit('[ERROR_NOTCL] %s' % _("Failed."))
self.app.save_in_progress = False
return
@@ -2877,46 +2885,42 @@ class AppIO(QtCore.QObject):
def save_source_file(self, obj_name, filename):
"""
- Exports a FlatCAM Object to an Gerber/Excellon file.
+ Exports a FlatCAM Object to a Gerber/Excellon file.
- :param obj_name: the name of the FlatCAM object for which to save it's embedded source file
+ :param obj_name: the name of the FlatCAM object for which to save its embedded source file
:param filename: Path to the Gerber file to save to.
:return:
"""
if filename is None:
- filename = self.app.options["global_last_save_folder"] if \
- self.app.options["global_last_save_folder"] is not None else self.app.options["global_last_folder"]
+ filename = self.app.options["global_last_save_folder"] or self.app.options["global_last_folder"]
self.log.debug("save_source_file()")
obj = self.app.collection.get_by_name(obj_name)
- file_string = StringIO(obj.source_file)
- time_string = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
-
- if file_string.getvalue() == '':
+ if not obj.source_file:
msg = _("Save cancelled because source file is empty. Try to export the file.")
self.inform.emit('[ERROR_NOTCL] %s' % msg) # noqa
return 'fail'
+ time_string = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
+
try:
with open(filename, 'w') as file:
- file.writelines('G04*\n')
- file.writelines('G04 %s (RE)GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s*\n' %
- (obj.kind.upper(), str(self.app.version), str(self.app.version_date)))
- file.writelines('G04 Filename: %s*\n' % str(obj_name))
- file.writelines('G04 Created on : %s*\n' % time_string)
-
- for line in file_string:
- file.writelines(line)
+ file.write('G04*\n')
+ file.write('G04 %s (RE)GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s*\n' %
+ (obj.kind.upper(), str(self.app.version), str(self.app.version_date)))
+ file.write('G04 Filename: %s*\n' % str(obj_name))
+ file.write('G04 Created on : %s*\n' % time_string)
+ file.write(obj.source_file)
except PermissionError:
self.inform.emit('[WARNING] %s' %
_("Permission denied, saving not possible.\n"
"Most likely another app is holding the file open and not accessible.")) # noqa
return 'fail'
- def on_file_savedefaults(self):
+ def on_file_save_defaults(self):
"""
Callback for menu item File->Save Defaults. Saves application default options
``self.options`` to current_defaults.FlatConfig.
diff --git a/appMain.py b/appMain.py
index 119ebe83..9f3adcfd 100644
--- a/appMain.py
+++ b/appMain.py
@@ -1480,9 +1480,9 @@ class App(QtCore.QObject):
self.inform.emit(_("Open Script file failed."))
else:
if silent is False:
- self.f_handlers.on_fileopenscript(name=file_name)
+ self.f_handlers.on_file_open_script(name=file_name)
self.ui.plot_tab_area.setCurrentWidget(self.ui.plot_tab)
- self.f_handlers.on_filerunscript(name=file_name)
+ self.f_handlers.on_file_run_cript(name=file_name)
except Exception as e:
self.log.error("Could not open FlatCAM Script file as App parameter due: %s" % str(e))
@@ -1506,7 +1506,7 @@ class App(QtCore.QObject):
if silent is False:
self.inform.emit(_("Open Excellon file failed."))
else:
- self.f_handlers.on_fileopenexcellon(name=file_name)
+ self.f_handlers.on_file_open_excellon(name=file_name)
return
gco_list = self.ui.util_pref_form.fa_gcode_group.gco_list_text.get_value().split(',')
@@ -1519,7 +1519,7 @@ class App(QtCore.QObject):
if silent is False:
self.inform.emit(_("Open GCode file failed."))
else:
- self.f_handlers.on_fileopengcode(name=file_name)
+ self.f_handlers.on_file_open_gcode(name=file_name)
return
grb_list = self.ui.util_pref_form.fa_gerber_group.grb_list_text.get_value().split(',')
@@ -1532,7 +1532,7 @@ class App(QtCore.QObject):
if silent is False:
self.inform.emit(_("Open Gerber file failed."))
else:
- self.f_handlers.on_fileopengerber(name=file_name)
+ self.f_handlers.on_file_open_gerber(name=file_name)
return
# if it reached here without already returning then the app was registered with a file that it does not
@@ -1859,37 +1859,37 @@ class App(QtCore.QObject):
self.ui.menufilenewexc.triggered.connect(lambda: self.app_obj.new_excellon_object())
self.ui.menufilenewdoc.triggered.connect(lambda: self.app_obj.new_document_object())
- self.ui.menufileopengerber.triggered.connect(lambda: self.f_handlers.on_fileopengerber())
- self.ui.menufileopenexcellon.triggered.connect(lambda: self.f_handlers.on_fileopenexcellon())
- self.ui.menufileopengcode.triggered.connect(lambda: self.f_handlers.on_fileopengcode())
- self.ui.menufileopenproject.triggered.connect(lambda: self.f_handlers.on_file_openproject())
- self.ui.menufileopenconfig.triggered.connect(lambda: self.f_handlers.on_file_openconfig())
+ self.ui.menufileopengerber.triggered.connect(lambda: self.f_handlers.on_file_open_gerber())
+ self.ui.menufileopenexcellon.triggered.connect(lambda: self.f_handlers.on_file_open_excellon())
+ self.ui.menufileopengcode.triggered.connect(lambda: self.f_handlers.on_file_open_gcode())
+ self.ui.menufileopenproject.triggered.connect(lambda: self.f_handlers.on_file_open_project())
+ self.ui.menufileopenconfig.triggered.connect(lambda: self.f_handlers.on_file_open_config())
- self.ui.menufilenewscript.triggered.connect(self.f_handlers.on_filenewscript)
- self.ui.menufileopenscript.triggered.connect(self.f_handlers.on_fileopenscript)
- self.ui.menufileopenscriptexample.triggered.connect(self.f_handlers.on_fileopenscript_example)
+ self.ui.menufilenewscript.triggered.connect(self.f_handlers.on_file_new_script)
+ self.ui.menufileopenscript.triggered.connect(self.f_handlers.on_file_open_script)
+ self.ui.menufileopenscriptexample.triggered.connect(self.f_handlers.on_file_open_script_example)
- self.ui.menufilerunscript.triggered.connect(self.f_handlers.on_filerunscript)
+ self.ui.menufilerunscript.triggered.connect(self.f_handlers.on_file_run_cript)
- self.ui.menufileimportsvg.triggered.connect(lambda: self.f_handlers.on_file_importsvg("geometry"))
- self.ui.menufileimportsvg_as_gerber.triggered.connect(lambda: self.f_handlers.on_file_importsvg("gerber"))
+ self.ui.menufileimportsvg.triggered.connect(lambda: self.f_handlers.on_file_import_svg("geometry"))
+ self.ui.menufileimportsvg_as_gerber.triggered.connect(lambda: self.f_handlers.on_file_import_svg("gerber"))
- self.ui.menufileimportdxf.triggered.connect(lambda: self.f_handlers.on_file_importdxf("geometry"))
- self.ui.menufileimportdxf_as_gerber.triggered.connect(lambda: self.f_handlers.on_file_importdxf("gerber"))
- self.ui.menufileimport_hpgl2_as_geo.triggered.connect(lambda: self.f_handlers.on_fileopenhpgl2())
- self.ui.menufileexportsvg.triggered.connect(self.f_handlers.on_file_exportsvg)
- self.ui.menufileexportpng.triggered.connect(self.f_handlers.on_file_exportpng)
- self.ui.menufileexportexcellon.triggered.connect(self.f_handlers.on_file_exportexcellon)
- self.ui.menufileexportgerber.triggered.connect(self.f_handlers.on_file_exportgerber)
+ self.ui.menufileimportdxf.triggered.connect(lambda: self.f_handlers.on_file_import_dxf("geometry"))
+ self.ui.menufileimportdxf_as_gerber.triggered.connect(lambda: self.f_handlers.on_file_import_dxf("gerber"))
+ self.ui.menufileimport_hpgl2_as_geo.triggered.connect(lambda: self.f_handlers.on_file_open_hpgl2())
+ self.ui.menufileexportsvg.triggered.connect(self.f_handlers.on_file_export_svg)
+ self.ui.menufileexportpng.triggered.connect(self.f_handlers.on_file_export_png)
+ self.ui.menufileexportexcellon.triggered.connect(self.f_handlers.on_file_export_excellon)
+ self.ui.menufileexportgerber.triggered.connect(self.f_handlers.on_file_export_gerber)
- self.ui.menufileexportdxf.triggered.connect(self.f_handlers.on_file_exportdxf)
+ self.ui.menufileexportdxf.triggered.connect(self.f_handlers.on_file_export_dxf)
self.ui.menufile_print.triggered.connect(lambda: self.f_handlers.on_file_save_objects_pdf(use_thread=True))
- self.ui.menufilesaveproject.triggered.connect(self.f_handlers.on_file_saveproject)
- self.ui.menufilesaveprojectas.triggered.connect(self.f_handlers.on_file_saveprojectas)
- # self.ui.menufilesaveprojectcopy.triggered.connect(lambda: self.on_file_saveprojectas(make_copy=True))
- self.ui.menufilesavedefaults.triggered.connect(self.f_handlers.on_file_savedefaults)
+ self.ui.menufilesaveproject.triggered.connect(self.f_handlers.on_file_save_project)
+ self.ui.menufilesaveprojectas.triggered.connect(self.f_handlers.on_file_save_project_as)
+ # self.ui.menufilesaveprojectcopy.triggered.connect(lambda: self.on_file_save_project_as(make_copy=True))
+ self.ui.menufilesavedefaults.triggered.connect(self.f_handlers.on_file_save_defaults)
self.ui.menufileexportpref.triggered.connect(self.f_handlers.on_export_preferences)
self.ui.menufileimportpref.triggered.connect(self.f_handlers.on_import_preferences)
@@ -2004,7 +2004,7 @@ class App(QtCore.QObject):
self.ui.popmenu_new_geo.triggered.connect(lambda: self.app_obj.new_geometry_object())
self.ui.popmenu_new_grb.triggered.connect(lambda: self.app_obj.new_gerber_object())
self.ui.popmenu_new_exc.triggered.connect(lambda: self.app_obj.new_excellon_object())
- self.ui.popmenu_new_prj.triggered.connect(lambda: self.f_handlers.on_file_new_project(silenced=True))
+ self.ui.popmenu_new_prj.triggered.connect(lambda: self.f_handlers.on_file_new_project())
# View
self.ui.zoomfit.triggered.connect(self.on_zoom_fit)
@@ -2086,10 +2086,10 @@ class App(QtCore.QObject):
# File Toolbar Signals
# ui.file_new_btn.triggered.connect(self.on_file_new_project)
- self.ui.file_open_btn.triggered.connect(lambda: self.f_handlers.on_file_openproject())
- self.ui.file_save_btn.triggered.connect(lambda: self.f_handlers.on_file_saveproject())
- self.ui.file_open_gerber_btn.triggered.connect(lambda: self.f_handlers.on_fileopengerber())
- self.ui.file_open_excellon_btn.triggered.connect(lambda: self.f_handlers.on_fileopenexcellon())
+ self.ui.file_open_btn.triggered.connect(lambda: self.f_handlers.on_file_open_project())
+ self.ui.file_save_btn.triggered.connect(lambda: self.f_handlers.on_file_save_project())
+ self.ui.file_open_gerber_btn.triggered.connect(lambda: self.f_handlers.on_file_open_gerber())
+ self.ui.file_open_excellon_btn.triggered.connect(lambda: self.f_handlers.on_file_open_excellon())
# View Toolbar Signals
self.ui.clear_plot_btn.triggered.connect(self.clear_plots)
@@ -2115,9 +2115,9 @@ class App(QtCore.QObject):
# Scripting Toolbar Signals
self.ui.shell_btn.triggered.connect(self.ui.toggle_shell_ui)
- self.ui.new_script_btn.triggered.connect(self.f_handlers.on_filenewscript)
- self.ui.open_script_btn.triggered.connect(self.f_handlers.on_fileopenscript)
- self.ui.run_script_btn.triggered.connect(self.f_handlers.on_filerunscript)
+ self.ui.new_script_btn.triggered.connect(self.f_handlers.on_file_new_script)
+ self.ui.open_script_btn.triggered.connect(self.f_handlers.on_file_open_script)
+ self.ui.run_script_btn.triggered.connect(self.f_handlers.on_file_run_cript)
# Tools Toolbar Signals
try:
@@ -3782,7 +3782,7 @@ class App(QtCore.QObject):
self.trayIcon.hide()
except Exception:
pass
- self.f_handlers.on_file_saveprojectas(use_thread=True, quit_action=True)
+ self.f_handlers.on_file_save_project_as(use_thread=True, quit_action=True)
elif response == bt_no:
try:
self.trayIcon.hide()
@@ -7358,17 +7358,17 @@ class App(QtCore.QObject):
obj = self.collection.get_active()
if isinstance(obj, GeometryObject):
- self.f_handlers.on_file_exportdxf()
+ self.f_handlers.on_file_export_dxf()
elif isinstance(obj, ExcellonObject):
- self.f_handlers.on_file_saveexcellon()
+ self.f_handlers.on_file_save_excellon()
elif isinstance(obj, CNCJobObject):
obj.on_exportgcode_button_click()
elif isinstance(obj, GerberObject):
- self.f_handlers.on_file_savegerber()
+ self.f_handlers.on_file_save_gerber()
elif isinstance(obj, ScriptObject):
- self.f_handlers.on_file_savescript()
+ self.f_handlers.on_file_save_script()
elif isinstance(obj, DocumentObject):
- self.f_handlers.on_file_savedocument()
+ self.f_handlers.on_file_save_document()
def obj_move(self):
"""
@@ -8488,7 +8488,7 @@ class App(QtCore.QObject):
"""
if self.block_autosave is False and self.should_we_save is True and self.save_in_progress is False:
- self.f_handlers.on_file_saveproject()
+ self.f_handlers.on_file_save_project()
def save_project_auto_update(self):
"""
diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py
index c9353fc3..265e3083 100644
--- a/appPlugins/ToolDrilling.py
+++ b/appPlugins/ToolDrilling.py
@@ -1,5 +1,5 @@
# ##########################################################
-# FlatCAM: 2D Post-processing for Manufacturing #
+# FlatCAM Evo: 2D Post-processing for Manufacturing #
# File by: Marius Adrian Stanciu (c) #
# Date: 6/15/2020 #
# License: MIT Licence #
diff --git a/appPlugins/ToolFollow.py b/appPlugins/ToolFollow.py
index 292b278c..a6a15378 100644
--- a/appPlugins/ToolFollow.py
+++ b/appPlugins/ToolFollow.py
@@ -1,5 +1,5 @@
# ##########################################################
-# FlatCAM: 2D Post-processing for Manufacturing #
+# FlatCAM Evo: 2D Post-processing for Manufacturing #
# File by: Marius Adrian Stanciu (c) #
# Date: 11/12/2020 #
# License: MIT Licence #
diff --git a/appPlugins/ToolIsolation.py b/appPlugins/ToolIsolation.py
index b5dff911..1652b55c 100644
--- a/appPlugins/ToolIsolation.py
+++ b/appPlugins/ToolIsolation.py
@@ -1,5 +1,5 @@
# ##########################################################
-# FlatCAM: 2D Post-processing for Manufacturing #
+# FlatCAM Evo: 2D Post-processing for Manufacturing #
# File by: Marius Adrian Stanciu (c) #
# Date: 5/25/2020 #
# License: MIT Licence #
diff --git a/appPlugins/ToolLevelling.py b/appPlugins/ToolLevelling.py
index 4e502e93..3431760d 100644
--- a/appPlugins/ToolLevelling.py
+++ b/appPlugins/ToolLevelling.py
@@ -1,5 +1,5 @@
# ##########################################################
-# FlatCAM: 2D Post-processing for Manufacturing #
+# FlatCAM Evo: 2D Post-processing for Manufacturing #
# File by: Marius Adrian Stanciu (c) #
# Date: 11/12/2020 #
# License: MIT Licence #
@@ -75,13 +75,6 @@ class ToolLevelling(AppTool, CNCjob):
AppTool.__init__(self, app)
CNCjob.__init__(self, steps_per_circle=self.app.options["cncjob_steps_per_circle"])
- # #############################################################################
- # ######################### Tool GUI ##########################################
- # #############################################################################
- self.ui = LevelUI(layout=self.layout, app=self.app)
- self.pluginName = self.ui.pluginName
- self.connect_signals_at_init()
-
# updated in the self.set_tool_ui()
self.form_fields = {}
@@ -132,6 +125,14 @@ class ToolLevelling(AppTool, CNCjob):
# store the current selection shape status to be restored after manual adding test points
self.old_selection_state = self.app.options['global_selection_shape']
+ # #############################################################################
+ # ######################### Tool GUI ##########################################
+ # #############################################################################
+ self.ui = LevelUI(layout=self.layout, app=self.app)
+ self.pluginName = self.ui.pluginName
+
+ self.connect_signals_at_init()
+
def install(self, icon=None, separator=None, **kwargs):
AppTool.install(self, icon, separator, shortcut='', **kwargs)
@@ -963,10 +964,10 @@ class ToolLevelling(AppTool, CNCjob):
def on_key_press(self, event):
# events out of the self.app.collection view (it's about Project Tab) are of type int
- if type(event) is int:
+ if isinstance(event, int):
key = event
# events from the GUI are of type QKeyEvent
- elif type(event) == QtGui.QKeyEvent:
+ elif isinstance(event, QtGui.QKeyEvent):
key = event.key()
elif isinstance(event, mpl_key_event): # MatPlotLib key events are trickier to interpret than the rest
key = event.key
@@ -1086,7 +1087,7 @@ class ToolLevelling(AppTool, CNCjob):
self.on_controller_change_alter_ui()
# if the is empty then there is a chance that we've added probe points but the GRBL controller was selected
- # therefore no Probing GCode was genrated (it is different for GRBL on how it gets it's Probing GCode
+ # therefore no Probing GCode was generated (it is different for GRBL on how it gets it's Probing GCode
target_obj = self.app.collection.get_by_name(self.ui.object_combo.get_value())
if (not self.probing_gcode_text or self.probing_gcode_text == '') and target_obj is not None:
# generate Probing GCode
@@ -1168,7 +1169,7 @@ class ToolLevelling(AppTool, CNCjob):
xonxoff=False,
rtscts=False)
- # Toggle DTR to reset the controller loaded with GRBL (Arduino, ESP32, etc)
+ # Toggle DTR to reset the controller loaded with GRBL (Arduino, ESP32, etc.)
try:
self.grbl_ser_port.dtr = False
except IOError:
@@ -1712,7 +1713,7 @@ class ToolLevelling(AppTool, CNCjob):
self.send_grbl_command(command=cmd)
self.app.inform.emit('%s' % _("Finished probing. Doing the autolevelling."))
- # apply autolevel here
+ # apply autolevelling here
self.on_grbl_apply_autolevel()
self.app.inform.emit('%s' % _("Sending probing GCode to the GRBL controller."))
@@ -1830,7 +1831,7 @@ class LevelUI:
self.tools_box.addWidget(self.obj_combo_label)
# #############################################################################################################
- # ################################ The object to be Autolevelled ##############################################
+ # ################################ The object to be Auto-levelled ##############################################
# #############################################################################################################
self.object_combo = FCComboBox()
self.object_combo.setModel(self.app.collection)
@@ -2132,8 +2133,8 @@ class LevelUI:
)
self.baudrates_list_combo = FCComboBox()
- cbmodel = QtCore.QStringListModel()
- self.baudrates_list_combo.setModel(cbmodel)
+ cb_model = QtCore.QStringListModel()
+ self.baudrates_list_combo.setModel(cb_model)
self.baudrates_list_combo.addItems(
['9600', '19200', '38400', '57600', '115200', '230400', '460800', '500000', '576000', '921600', '1000000',
'1152000', '1500000', '2000000'])
@@ -2162,13 +2163,13 @@ class LevelUI:
self.del_bd_button = FCButton(_("Delete selected baudrate"))
grbl_conn_grid.addWidget(self.del_bd_button, 8, 0, 1, 3)
- ctrl_hlay = QtWidgets.QHBoxLayout()
+ ctrl_h_lay = QtWidgets.QHBoxLayout()
self.controller_reset_button = FCButton(_("Reset"))
self.controller_reset_button.setToolTip(
_("Software reset of the controller.")
)
self.controller_reset_button.setDisabled(True)
- ctrl_hlay.addWidget(self.controller_reset_button)
+ ctrl_h_lay.addWidget(self.controller_reset_button)
self.com_connect_button = FCButton()
self.com_connect_button.setText(_("Disconnected"))
@@ -2176,11 +2177,11 @@ class LevelUI:
_("Connect to the selected port with the selected baud rate.")
)
self.com_connect_button.setStyleSheet("QPushButton {background-color: red;}")
- ctrl_hlay.addWidget(self.com_connect_button)
+ ctrl_h_lay.addWidget(self.com_connect_button)
grbl_conn_grid.addWidget(FCLabel(""), 9, 0, 1, 3)
grbl_conn_grid.setRowStretch(9, 1)
- grbl_conn_grid.addLayout(ctrl_hlay, 10, 0, 1, 3)
+ grbl_conn_grid.addLayout(ctrl_h_lay, 10, 0, 1, 3)
# #############################################################################################################
# GRBL CONTROL
@@ -2247,11 +2248,11 @@ class LevelUI:
pause_frame = QtWidgets.QFrame()
pause_frame.setContentsMargins(0, 0, 0, 0)
pause_frame.setSizePolicy(QtWidgets.QSizePolicy.Policy.Ignored, QtWidgets.QSizePolicy.Policy.Expanding)
- pause_hlay = QtWidgets.QHBoxLayout()
- pause_hlay.setContentsMargins(0, 0, 0, 0)
+ pause_h_lay = QtWidgets.QHBoxLayout()
+ pause_h_lay.setContentsMargins(0, 0, 0, 0)
- pause_hlay.addWidget(self.pause_resume_button)
- pause_frame.setLayout(pause_hlay)
+ pause_h_lay.addWidget(self.pause_resume_button)
+ pause_frame.setLayout(pause_h_lay)
grbl_ctrl_grid.addWidget(pause_frame, 2, 1)
# JOG Step
diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py
index b9b7b7b0..0cb14b0a 100644
--- a/appPlugins/ToolMilling.py
+++ b/appPlugins/ToolMilling.py
@@ -1,5 +1,5 @@
# ##########################################################
-# FlatCAM: 2D Post-processing for Manufacturing #
+# FlatCAM Evo: 2D Post-processing for Manufacturing #
# File by: Marius Adrian Stanciu (c) #
# Date: 6/15/2020 #
# License: MIT Licence #
diff --git a/appTranslation.py b/appTranslation.py
index f8643d83..b0e5f39f 100644
--- a/appTranslation.py
+++ b/appTranslation.py
@@ -231,7 +231,7 @@ def restart_program(app, ask=None):
response = msgbox.clickedButton()
if response == bt_yes:
- app.f_handlers.on_file_saveprojectas(use_thread=True, quit_action=True)
+ app.f_handlers.on_file_save_project_as(use_thread=True, quit_action=True)
app.defaults.update(app.options)
app.preferencesUiManager.save_defaults()
diff --git a/doc/source/devman.rst b/doc/source/devman.rst
index 0d8bae39..ca0098dd 100644
--- a/doc/source/devman.rst
+++ b/doc/source/devman.rst
@@ -6,7 +6,7 @@ Options
There are **Application Defaults**, **Project Options** and **Object Options** in FlatCAM.
-**Application Defaults** are stored in ``app.defaults``. This gets populated (updated) from the ``current_defaults.FlatConfig`` file upon startup. These can be edited from the Options tab, where each widget calls ``app.on_options_update()`` if a change is detected. This function iterates over the keys of ``app.defaults`` and reads the GUI elements whose name is ``type + "_app_" key``. Therefore, for an option to be recognized, it must be added to ``defaults.json`` in the first place. When saving, done in ``app.on_file_savedefaults()``, the file is updated, not overwritten.
+**Application Defaults** are stored in ``app.defaults``. This gets populated (updated) from the ``current_defaults.FlatConfig`` file upon startup. These can be edited from the Options tab, where each widget calls ``app.on_options_update()`` if a change is detected. This function iterates over the keys of ``app.defaults`` and reads the GUI elements whose name is ``type + "_app_" key``. Therefore, for an option to be recognized, it must be added to ``defaults.json`` in the first place. When saving, done in ``app.on_file_save_defaults()``, the file is updated, not overwritten.
**Project Options** inherit all options from Application Defaults upon startup. They can be changed thereafter from the UI or by opening a project, which contain previously saved Project Options. These are store in ``app.options`` and can be written and read from the Options tab in the same way as with Application defaults.
diff --git a/locale/de/LC_MESSAGES/strings.po b/locale/de/LC_MESSAGES/strings.po
index fc4e3189..c0a48fd1 100644
--- a/locale/de/LC_MESSAGES/strings.po
+++ b/locale/de/LC_MESSAGES/strings.po
@@ -25887,8 +25887,8 @@ msgstr ""
#~ msgid "ToolSolderPaste.on_view_gcode()"
#~ msgstr "ToolSolderPaste.on_view_gcode()"
-#~ msgid "App.on_fileopenscript() -->"
-#~ msgstr "App.on_fileopenscript() -->"
+#~ msgid "App.on_file_open_script() -->"
+#~ msgstr "App.on_file_open_script() -->"
#, fuzzy
#~| msgid "Basic"
diff --git a/locale/en/LC_MESSAGES/strings.po b/locale/en/LC_MESSAGES/strings.po
index de9c384e..20bef454 100644
--- a/locale/en/LC_MESSAGES/strings.po
+++ b/locale/en/LC_MESSAGES/strings.po
@@ -24690,8 +24690,8 @@ msgstr "No Geometry name in args. Provide a name and try again."
#~ msgid "ToolSolderPaste.on_view_gcode()"
#~ msgstr "ToolSolderPaste.on_view_gcode()"
-#~ msgid "App.on_fileopenscript() -->"
-#~ msgstr "App.on_fileopenscript() -->"
+#~ msgid "App.on_file_open_script() -->"
+#~ msgstr "App.on_file_open_script() -->"
#~ msgid "%s"
#~ msgstr "%s"
diff --git a/locale/es/LC_MESSAGES/strings.po b/locale/es/LC_MESSAGES/strings.po
index bf4b8c67..58c4c38d 100644
--- a/locale/es/LC_MESSAGES/strings.po
+++ b/locale/es/LC_MESSAGES/strings.po
@@ -25280,8 +25280,8 @@ msgstr ""
#~ msgid "ToolSolderPaste.on_view_gcode()"
#~ msgstr "ToolSolderPaste.on_view_gcode()"
-#~ msgid "App.on_fileopenscript() -->"
-#~ msgstr "App.on_fileopenscript() -->"
+#~ msgid "App.on_file_open_script() -->"
+#~ msgstr "App.on_file_open_script() -->"
#~ msgid "%s"
#~ msgstr "%s"
diff --git a/locale/fr/LC_MESSAGES/strings.po b/locale/fr/LC_MESSAGES/strings.po
index 68ceb52c..c525d594 100644
--- a/locale/fr/LC_MESSAGES/strings.po
+++ b/locale/fr/LC_MESSAGES/strings.po
@@ -25818,8 +25818,8 @@ msgstr ""
#~ msgid "FlatCAMObj.GeometryObject.mtool_gen_cncjob() -->"
#~ msgstr "FlatCAMObj.GeometryObject.mtool_gen_cncjob() -->"
-#~ msgid "App.on_fileopenscript() -->"
-#~ msgstr "App.on_fileopenscript() -->"
+#~ msgid "App.on_file_open_script() -->"
+#~ msgstr "App.on_file_open_script() -->"
#~ msgid "%s/Project_%s"
#~ msgstr "%s/Project_%s"
diff --git a/locale/pt_BR/LC_MESSAGES/strings.po b/locale/pt_BR/LC_MESSAGES/strings.po
index 76b46bdc..9211c8b9 100644
--- a/locale/pt_BR/LC_MESSAGES/strings.po
+++ b/locale/pt_BR/LC_MESSAGES/strings.po
@@ -23841,8 +23841,8 @@ msgstr "Nenhum nome de geometria nos argumentos. Altere e tente novamente."
#~ msgid "ToolSolderPaste.on_view_gcode()"
#~ msgstr "ToolSolderPaste.on_view_gcode()"
-#~ msgid "App.on_fileopenscript() -->"
-#~ msgstr "App.on_fileopenscript() -->"
+#~ msgid "App.on_file_open_script() -->"
+#~ msgstr "App.on_file_open_script() -->"
#~ msgid "%s"
#~ msgstr "%s"
diff --git a/locale/ro/LC_MESSAGES/strings.po b/locale/ro/LC_MESSAGES/strings.po
index e6560ef3..2b561cb1 100644
--- a/locale/ro/LC_MESSAGES/strings.po
+++ b/locale/ro/LC_MESSAGES/strings.po
@@ -25135,8 +25135,8 @@ msgstr ""
#~ msgid "ToolSolderPaste.on_view_gcode()"
#~ msgstr "ToolSolderPaste.on_view_gcode()"
-#~ msgid "App.on_fileopenscript() -->"
-#~ msgstr "App.on_fileopenscript() -->"
+#~ msgid "App.on_file_open_script() -->"
+#~ msgstr "App.on_file_open_script() -->"
#~ msgid "%s"
#~ msgstr "%s"
diff --git a/locale/ru/LC_MESSAGES/strings.po b/locale/ru/LC_MESSAGES/strings.po
index 6ab94a37..d48ce854 100644
--- a/locale/ru/LC_MESSAGES/strings.po
+++ b/locale/ru/LC_MESSAGES/strings.po
@@ -25785,8 +25785,8 @@ msgstr "Нет имени геометрии в аргументах. Укажи
#~ msgid "Not available with the current Graphic Engine Legacy(2D)."
#~ msgstr "Недоступно с текущим графическим движком Legacy (2D)."
-#~ msgid "App.on_fileopenscript() -->"
-#~ msgstr "App.on_fileopenscript() -->"
+#~ msgid "App.on_file_open_script() -->"
+#~ msgstr "App.on_file_open_script() -->"
#~ msgid "%s"
#~ msgstr "%s"
diff --git a/locale/tr/LC_MESSAGES/strings.po b/locale/tr/LC_MESSAGES/strings.po
index ffcaf723..0f9d8038 100644
--- a/locale/tr/LC_MESSAGES/strings.po
+++ b/locale/tr/LC_MESSAGES/strings.po
@@ -24698,8 +24698,8 @@ msgstr "Değişkenlerde Şekil ismi yok. Lütfen bir isim girin ve tekrar deneyi
#~ msgid "ToolSolderPaste.on_view_gcode()"
#~ msgstr "ToolSolderPaste.on_view_gcode()"
-#~ msgid "App.on_fileopenscript() -->"
-#~ msgstr "App.on_fileopenscript() -->"
+#~ msgid "App.on_file_open_script() -->"
+#~ msgstr "App.on_file_open_script() -->"
#~ msgid "%s"
#~ msgstr "%s"
diff --git a/tclCommands/TclCommandNew.py b/tclCommands/TclCommandNew.py
index cd3ea200..5fb0047a 100644
--- a/tclCommands/TclCommandNew.py
+++ b/tclCommands/TclCommandNew.py
@@ -65,4 +65,4 @@ class TclCommandNew(TclCommand):
if args['keep_scripts'].lower() == 'true':
keep_scripts = True
- self.app.f_handlers.on_file_new_project(cli=True, reset_tcl=reset_tcl, silenced=True, keep_scripts=keep_scripts)
+ self.app.f_handlers.on_file_new_project(cli=True, reset_tcl=reset_tcl, keep_scripts=keep_scripts)