diff --git a/FlatCAMApp.py b/FlatCAMApp.py
index 3d94a04f..e3604d28 100644
--- a/FlatCAMApp.py
+++ b/FlatCAMApp.py
@@ -4418,7 +4418,7 @@ class App(QtCore.QObject):
self.ui.removeToolBar(self.ui.grb_edit_toolbar)
self.ui.removeToolBar(self.ui.snap_toolbar)
self.ui.removeToolBar(self.ui.toolbarshell)
- except:
+ except Exception as e:
pass
if current_layout == 'standard':
diff --git a/FlatCAMObj.py b/FlatCAMObj.py
index b4489171..7e50685c 100644
--- a/FlatCAMObj.py
+++ b/FlatCAMObj.py
@@ -181,7 +181,7 @@ class FlatCAMObj(QtCore.QObject):
# self.app.ui.selected_layout.addWidget(self.ui)
try:
self.app.ui.selected_scroll_area.takeWidget()
- except:
+ except Exception as e:
self.app.log.debug("Nothing to remove")
self.app.ui.selected_scroll_area.setWidget(self.ui)
@@ -198,7 +198,7 @@ class FlatCAMObj(QtCore.QObject):
self.app.myKeywords.append(new_name)
self.app.shell._edit.set_model_data(self.app.myKeywords)
self.app.ui.code_editor.set_model_data(self.app.myKeywords)
- except:
+ except Exception as e:
log.debug("on_name_activate() --> Could not remove the old object name from auto-completer model list")
self.options["name"] = self.ui.name_entry.get_value()
@@ -242,7 +242,7 @@ class FlatCAMObj(QtCore.QObject):
for option in self.options:
try:
self.set_form_item(option)
- except:
+ except Exception as e:
self.app.log.warning("Unexpected error:", sys.exc_info())
def read_form(self):
@@ -256,7 +256,7 @@ class FlatCAMObj(QtCore.QObject):
for option in self.options:
try:
self.read_form_item(option)
- except:
+ except Exception as e:
self.app.log.warning("Unexpected error:", sys.exc_info())
def set_form_item(self, option):
@@ -581,7 +581,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.ui.apertures_table.itemChanged.disconnect()
- except Exception as e:
+ except TypeError:
pass
self.apertures_row = 0
@@ -725,12 +725,12 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
for row in range(self.ui.apertures_table.rowCount()):
try:
self.ui.apertures_table.cellWidget(row, 5).clicked.disconnect()
- except:
+ except TypeError:
pass
try:
self.ui.mark_all_cb.clicked.disconnect(self.on_mark_all_click)
- except:
+ except TypeError:
pass
def on_generatenoncopper_button_click(self, *args):
@@ -767,7 +767,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
def on_ext_iso_button_click(self, *args):
- if self.ui.follow_cb.get_value() == True:
+ if self.ui.follow_cb.get_value() is True:
obj = self.app.collection.get_active()
obj.follow()
# in the end toggle the visibility of the origin object so we can see the generated Geometry
@@ -1278,7 +1278,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
:return: Gerber_code
"""
- def tz_format(x, y ,fac):
+ def tz_format(x, y, fac):
x_c = x * fac
y_c = y * fac
@@ -1501,7 +1501,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
else:
x_formatted, y_formatted = lz_format(coord[0], coord[1], factor)
gerber_code += "X{xform}Y{yform}D01*\n".format(xform=x_formatted,
- yform=y_formatted)
+ yform=y_formatted)
prev_coord = coord
# gerber_code += "D02*\n"
@@ -1585,7 +1585,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
self.tool_cbs = {}
# dict to hold the tool number as key and tool offset as value
- self.tool_offset ={}
+ self.tool_offset = {}
# variable to store the total amount of drills per job
self.tot_drill_cnt = 0
@@ -1790,7 +1790,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.ui.tools_table.itemChanged.disconnect()
- except Exception as e:
+ except TypeError:
pass
n = len(self.tools)
@@ -1857,7 +1857,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
else:
t_offset = self.tool_offset[float('%.4f' % float(self.tools[tool_no]['C']))]
except KeyError:
- t_offset = self.app.defaults['excellon_offset']
+ t_offset = self.app.defaults['excellon_offset']
+
tool_offset_item = QtWidgets.QTableWidgetItem('%s' % str(t_offset))
plot_item = FCCheckBox()
@@ -2075,12 +2076,12 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
for row in range(self.ui.tools_table.rowCount()):
try:
self.ui.tools_table.cellWidget(row, 5).clicked.disconnect()
- except Exception as e:
+ except TypeError:
pass
try:
self.ui.plot_cb.stateChanged.disconnect()
- except Exception as e:
+ except TypeError:
pass
def on_tool_offset_edit(self):
@@ -2854,7 +2855,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
if option is not 'name':
try:
geo_final.options[option] = geo.options[option]
- except:
+ except Exception as e:
log.warning("Failed to copy option.", option)
# Expand lists
@@ -2879,6 +2880,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
geo_final_uid_list = []
for key in geo_final.tools:
geo_final_uid_list.append(int(key))
+
try:
max_uid = max(geo_final_uid_list, key=int)
except ValueError:
@@ -3022,7 +3024,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.ser_attrs += ['options', 'kind', 'tools', 'multigeo']
def build_ui(self):
-
self.ui_disconnect()
FlatCAMObj.build_ui(self)
@@ -3089,7 +3090,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
try:
self.ui.tool_offset_entry.set_value(tooluid_value['offset_value'])
- except:
+ except Exception as e:
log.debug("build_ui() --> Could not set the 'offset_value' key in self.tools")
# make the diameter column editable
@@ -3384,23 +3385,31 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
return
def ui_connect(self):
-
# on any change to the widgets that matter it will be called self.gui_form_to_storage which will save the
# changes in geometry UI
for i in range(self.ui.grid3.count()):
- try:
- # works for CheckBoxes
- self.ui.grid3.itemAt(i).widget().stateChanged.connect(self.gui_form_to_storage)
- except Exception as e:
- # works for ComboBoxes
- try:
- self.ui.grid3.itemAt(i).widget().currentIndexChanged.connect(self.gui_form_to_storage)
- except Exception as e2:
- # works for Entry
- try:
- self.ui.grid3.itemAt(i).widget().editingFinished.connect(self.gui_form_to_storage)
- except Exception as e3:
- pass
+ # try:
+ # # works for CheckBoxes
+ # self.ui.grid3.itemAt(i).widget().stateChanged.connect(self.gui_form_to_storage)
+ # except Exception as e:
+ # # works for ComboBoxes
+ # try:
+ # self.ui.grid3.itemAt(i).widget().currentIndexChanged.connect(self.gui_form_to_storage)
+ # except Exception as e2:
+ # # works for Entry
+ # try:
+ # self.ui.grid3.itemAt(i).widget().editingFinished.connect(self.gui_form_to_storage)
+ # except Exception as e3:
+ # pass
+
+ current_widget = self.ui.grid3.itemAt(i).widget()
+ if isinstance(current_widget, FCCheckBox):
+ current_widget.stateChanged.connect(self.gui_form_to_storage)
+ elif isinstance(current_widget, FCComboBox):
+ current_widget.currentIndexChanged.connect(self.gui_form_to_storage)
+ elif isinstance(current_widget, FloatEntry) or isinstance(current_widget, LengthEntry) or \
+ isinstance(current_widget, FCEntry) or isinstance(current_widget, IntEntry):
+ current_widget.editingFinished.connect(self.gui_form_to_storage)
for row in range(self.ui.geo_tools_table.rowCount()):
for col in [2, 3, 4]:
@@ -3423,70 +3432,87 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
def ui_disconnect(self):
- try:
- # on any change to the widgets that matter it will be called self.gui_form_to_storage which will save the
- # changes in geometry UI
- for i in range(self.ui.grid3.count()):
- if isinstance(self.ui.grid3.itemAt(i).widget(), FCCheckBox):
- self.ui.grid3.itemAt(i).widget().stateChanged.disconnect()
+ # on any change to the widgets that matter it will be called self.gui_form_to_storage which will save the
+ # changes in geometry UI
+ for i in range(self.ui.grid3.count()):
+ # try:
+ # # works for CheckBoxes
+ # self.ui.grid3.itemAt(i).widget().stateChanged.disconnect(self.gui_form_to_storage)
+ # except Exception as e:
+ # # works for ComboBoxes
+ # try:
+ # self.ui.grid3.itemAt(i).widget().currentIndexChanged.disconnect(self.gui_form_to_storage)
+ # except Exception as e2:
+ # # works for Entry
+ # try:
+ # self.ui.grid3.itemAt(i).widget().editingFinished.disconnect(self.gui_form_to_storage)
+ # except Exception as e3:
+ # pass
- if isinstance(self.ui.grid3.itemAt(i).widget(), FCComboBox):
- self.ui.grid3.itemAt(i).widget().currentIndexChanged.disconnect()
+ current_widget = self.ui.grid3.itemAt(i).widget()
+ if isinstance(current_widget, FCCheckBox):
+ try:
+ self.ui.grid3.itemAt(i).widget().stateChanged.disconnect(self.gui_form_to_storage)
+ except TypeError:
+ pass
+ elif isinstance(current_widget, FCComboBox):
+ try:
+ self.ui.grid3.itemAt(i).widget().currentIndexChanged.disconnect(self.gui_form_to_storage)
+ except TypeError:
+ pass
+ elif isinstance(current_widget, LengthEntry) or isinstance(current_widget, IntEntry) or \
+ isinstance(current_widget, FCEntry) or isinstance(current_widget, FloatEntry):
+ try:
+ self.ui.grid3.itemAt(i).widget().editingFinished.disconnect(self.gui_form_to_storage)
+ except TypeError:
+ pass
- if isinstance(self.ui.grid3.itemAt(i).widget(), LengthEntry) or \
- isinstance(self.ui.grid3.itemAt(i).widget(), IntEntry) or \
- isinstance(self.ui.grid3.itemAt(i).widget(), FCEntry):
- self.ui.grid3.itemAt(i).widget().editingFinished.disconnect()
- except Exception as e:
- pass
-
- try:
- for row in range(self.ui.geo_tools_table.rowCount()):
- for col in [2, 3, 4]:
+ for row in range(self.ui.geo_tools_table.rowCount()):
+ for col in [2, 3, 4]:
+ try:
self.ui.geo_tools_table.cellWidget(row, col).currentIndexChanged.disconnect()
- except Exception as e:
- pass
+ except TypeError:
+ pass
- # I use lambda's because the connected functions have parameters that could be used in certain scenarios
try:
self.ui.addtool_btn.clicked.disconnect()
- except Exception as e:
+ except TypeError:
pass
try:
self.ui.copytool_btn.clicked.disconnect()
- except Exception as e:
+ except TypeError:
pass
try:
self.ui.deltool_btn.clicked.disconnect()
- except Exception as e:
+ except TypeError:
pass
try:
self.ui.geo_tools_table.currentItemChanged.disconnect()
- except Exception as e:
+ except TypeError:
pass
try:
self.ui.geo_tools_table.itemChanged.disconnect()
- except Exception as e:
+ except TypeError:
pass
try:
self.ui.tool_offset_entry.editingFinished.disconnect()
- except Exception as e:
+ except TypeError:
pass
for row in range(self.ui.geo_tools_table.rowCount()):
try:
self.ui.geo_tools_table.cellWidget(row, 6).clicked.disconnect()
- except Exception as e:
+ except TypeError:
pass
try:
self.ui.plot_cb.stateChanged.disconnect()
- except Exception as e:
+ except TypeError:
pass
def on_tool_add(self, dia=None):
@@ -3581,7 +3607,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
# we do this HACK to make sure the tools attribute to be serialized is updated in the self.ser_attrs list
try:
self.ser_attrs.remove('tools')
- except Exception as e:
+ except TypeError:
pass
self.ser_attrs.append('tools')
@@ -3655,7 +3681,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
# we do this HACK to make sure the tools attribute to be serialized is updated in the self.ser_attrs list
try:
self.ser_attrs.remove('tools')
- except:
+ except Exception as e:
pass
self.ser_attrs.append('tools')
@@ -3690,7 +3716,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
try:
self.ser_attrs.remove('tools')
self.ser_attrs.append('tools')
- except Exception as e:
+ except TypeError:
pass
self.app.inform.emit(_(
@@ -3749,7 +3775,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
# we do this HACK to make sure the tools attribute to be serialized is updated in the self.ser_attrs list
try:
self.ser_attrs.remove('tools')
- except Exception as e:
+ except TypeError:
pass
self.ser_attrs.append('tools')
@@ -3838,7 +3864,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.update_cutz()
except Exception as e:
log.debug("FlatCAMObj ---> update_ui() " + str(e))
-
self.ui_connect()
def ui_update_v_shape(self, tool_type_txt):
@@ -3951,7 +3976,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.ui.ois_tcz_geo.on_cb_change()
def gui_form_to_storage(self):
-
self.ui_disconnect()
widget_changed = self.sender()
try:
@@ -4345,7 +4369,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
if diadict_key == 'data':
for data_key, data_value in diadict_value.items():
- if data_key == "multidepth":
+ if data_key == "multidepth":
multidepth = data_value
if data_key == "depthperpass":
depthpercut = data_value
@@ -5459,7 +5483,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
try:
self.ui.annotation_cb.stateChanged.disconnect(self.on_annotation_change)
- except:
+ except TypeError:
pass
self.ui.annotation_cb.stateChanged.connect(self.on_annotation_change)
@@ -5503,7 +5527,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
self.ui.cnc_tools_table.cellWidget(row, 6).clicked.disconnect(self.on_plot_cb_click_table)
try:
self.ui.plot_cb.stateChanged.disconnect(self.on_plot_cb_click)
- except Exception as e:
+ except TypeError:
pass
def on_updateplot_button_click(self, *args):
diff --git a/README.md b/README.md
index f891f967..b2e7fe8a 100644
--- a/README.md
+++ b/README.md
@@ -9,9 +9,15 @@ CAD program, and create G-Code for Isolation routing.
=================================================
+19.07.2019
+
+- fixed bug in FlatCAMObj.FlatCAMGeometry.ui_disconnect(); the widgets signals were not disconnected from handlers when required therefore the signals were connected in an exponential way
+- some changes in the widgets used in the Selected tab for Geometry object
+- some PEP8 cleanup in FlatCAMObj.py
+
17.07.2019
-- added some more strings to the translateable ones, especially the radio button labels
+- added some more strings to the translatable ones, especially the radio button labels
- updated the .POT file and the available translations
- 51% progress in Spanish Google translation
- version date change
diff --git a/camlib.py b/camlib.py
index 8a9b04be..f5f72740 100644
--- a/camlib.py
+++ b/camlib.py
@@ -710,12 +710,12 @@ class Geometry(object):
try:
green = src.read(2)
- except:
+ except Exception as e:
pass
try:
blue = src.read(3)
- except:
+ except Exception as e:
pass
if mode == 'black':
@@ -2713,7 +2713,7 @@ class Gerber (Geometry):
if 'geometry' not in self.apertures[current_aperture]:
self.apertures[current_aperture]['geometry'] = []
self.apertures[current_aperture]['geometry'].append(deepcopy(geo_dict))
- except:
+ except Exception as e:
pass
last_path_aperture = current_aperture
# we do this for the case that a region is done without having defined any aperture
@@ -4086,7 +4086,7 @@ class Excellon(Geometry):
slot_dia = 0.05
try:
slot_dia = float(self.tools[current_tool]['C'])
- except:
+ except Exception as e:
pass
log.debug(
'Milling/Drilling slot with tool %s, diam=%f' % (
@@ -4155,7 +4155,7 @@ class Excellon(Geometry):
slot_dia = 0.05
try:
slot_dia = float(self.tools[current_tool]['C'])
- except:
+ except Exception as e:
pass
log.debug(
'Milling/Drilling slot with tool %s, diam=%f' % (
diff --git a/flatcamEditors/FlatCAMExcEditor.py b/flatcamEditors/FlatCAMExcEditor.py
index 70dea694..ea071f3c 100644
--- a/flatcamEditors/FlatCAMExcEditor.py
+++ b/flatcamEditors/FlatCAMExcEditor.py
@@ -49,7 +49,7 @@ class FCDrillAdd(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_drill.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -91,7 +91,7 @@ class FCDrillAdd(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
# add the point to drills if the diameter is a key in the dict, if not, create it add the drill location
@@ -152,8 +152,9 @@ class FCDrillArray(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
+
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_drill_array.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -274,7 +275,7 @@ class FCDrillArray(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
# add the point to drills if the diameter is a key in the dict, if not, create it add the drill location
@@ -599,7 +600,7 @@ class FCDrillSelect(DrawTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.exc_editor_app = exc_editor_app
@@ -668,7 +669,7 @@ class FCDrillSelect(DrawTool):
# select the diameter of the selected shape in the tool table
try:
self.draw_app.tools_table_exc.cellPressed.disconnect()
- except:
+ except TypeError:
pass
sel_tools = set()
@@ -1257,12 +1258,12 @@ class FlatCAMExcEditor(QtCore.QObject):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.tools_table_exc.itemChanged.disconnect()
- except:
+ except TypeError:
pass
try:
self.tools_table_exc.cellPressed.disconnect()
- except:
+ except TypeError:
pass
# updated units
@@ -1704,7 +1705,7 @@ class FlatCAMExcEditor(QtCore.QObject):
def deactivate(self):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
# adjust the status of the menu entries related to the editor
@@ -2311,7 +2312,7 @@ class FlatCAMExcEditor(QtCore.QObject):
if self.app.ui.popMenu.mouse_is_panning is False:
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
if self.active_tool.complete is False and not isinstance(self.active_tool, FCDrillSelect):
self.active_tool.complete = True
@@ -2380,7 +2381,7 @@ class FlatCAMExcEditor(QtCore.QObject):
try:
self.tools_table_exc.cellPressed.disconnect()
- except:
+ except Exception as e:
pass
# select the diameter of the selected shape in the tool table
self.tools_table_exc.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
diff --git a/flatcamEditors/FlatCAMGeoEditor.py b/flatcamEditors/FlatCAMGeoEditor.py
index 4672b0ae..07e92f37 100644
--- a/flatcamEditors/FlatCAMGeoEditor.py
+++ b/flatcamEditors/FlatCAMGeoEditor.py
@@ -1921,7 +1921,7 @@ class FCCircle(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_circle_geo.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -1954,7 +1954,7 @@ class FCCircle(FCShapeTool):
def make(self):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
p1 = self.points[0]
@@ -1972,7 +1972,7 @@ class FCArc(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_arc.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -2190,7 +2190,7 @@ class FCRectangle(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -2221,7 +2221,7 @@ class FCRectangle(FCShapeTool):
def make(self):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
p1 = self.points[0]
@@ -2243,7 +2243,7 @@ class FCPolygon(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -2276,7 +2276,7 @@ class FCPolygon(FCShapeTool):
def make(self):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
# self.geometry = LinearRing(self.points)
@@ -2305,7 +2305,7 @@ class FCPath(FCPolygon):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_path5.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -2316,7 +2316,7 @@ class FCPath(FCPolygon):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.draw_app.in_action = False
@@ -2349,7 +2349,7 @@ class FCSelect(DrawTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.storage = self.draw_app.storage
@@ -2433,7 +2433,7 @@ class FCMove(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.storage = self.draw_app.storage
@@ -2613,7 +2613,7 @@ class FCText(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_text.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -3173,7 +3173,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
def deactivate(self):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
# adjust the status of the menu entries related to the editor
@@ -3638,7 +3638,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
if self.in_action is False:
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
if self.active_tool.complete is False and not isinstance(self.active_tool, FCSelect):
diff --git a/flatcamEditors/FlatCAMGrbEditor.py b/flatcamEditors/FlatCAMGrbEditor.py
index 31fe7b9b..11a6de72 100644
--- a/flatcamEditors/FlatCAMGrbEditor.py
+++ b/flatcamEditors/FlatCAMGrbEditor.py
@@ -188,7 +188,7 @@ class FCPad(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_circle.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -403,7 +403,7 @@ class FCPadArray(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_array.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -1341,7 +1341,7 @@ class FCDisc(FCShapeTool):
try:
QtGui.QGuiApplication.restoreOverrideCursor()
- except:
+ except Exception as e:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_disc.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -2934,12 +2934,12 @@ class FlatCAMGrbEditor(QtCore.QObject):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.apertures_table.itemChanged.disconnect()
- except Exception as e:
+ except TypeError:
pass
try:
self.apertures_table.cellPressed.disconnect()
- except Exception as e:
+ except TypeError:
pass
# updated units
diff --git a/flatcamGUI/FlatCAMGUI.py b/flatcamGUI/FlatCAMGUI.py
index b3752812..6de34c82 100644
--- a/flatcamGUI/FlatCAMGUI.py
+++ b/flatcamGUI/FlatCAMGUI.py
@@ -2266,7 +2266,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# try to disconnect the slot from Set Origin
try:
self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_set_zero_click)
- except:
+ except TypeError:
pass
self.app.inform.emit("")
diff --git a/flatcamGUI/GUIElements.py b/flatcamGUI/GUIElements.py
index 812d8fa6..548792c5 100644
--- a/flatcamGUI/GUIElements.py
+++ b/flatcamGUI/GUIElements.py
@@ -220,7 +220,7 @@ class FloatEntry(QtWidgets.QLineEdit):
def mousePressEvent(self, e, Parent=None):
super(FloatEntry, self).mousePressEvent(e) # required to deselect on 2e click
- if self.readyToEdit:
+ if self.readyToEdit == True:
self.selectAll()
self.readyToEdit = False
@@ -238,20 +238,18 @@ class FloatEntry(QtWidgets.QLineEdit):
def get_value(self):
raw = str(self.text()).strip(' ')
- evaled = 0.0
try:
evaled = eval(raw)
+ return float(evaled)
except Exception as e:
if raw is not '':
log.error("Could not evaluate val: %s, error: %s" % (str(raw), str(e)))
return None
- return float(evaled)
-
def set_value(self, val):
if val is not None:
- self.setText("%.4f" % val)
+ self.setText("%.4f" % float(val))
else:
self.setText("")
@@ -282,16 +280,15 @@ class FloatEntry2(QtWidgets.QLineEdit):
def get_value(self):
raw = str(self.text()).strip(' ')
- evaled = 0.0
+
try:
evaled = eval(raw)
+ return float(evaled)
except Exception as e:
if raw is not '':
log.error("Could not evaluate val: %s, error: %s" % (str(raw), str(e)))
return None
- return float(evaled)
-
def set_value(self, val):
self.setText("%.4f" % val)
diff --git a/flatcamGUI/ObjectUI.py b/flatcamGUI/ObjectUI.py
index 759d75cc..5c056063 100644
--- a/flatcamGUI/ObjectUI.py
+++ b/flatcamGUI/ObjectUI.py
@@ -1,15 +1,15 @@
-# ########################################################## ##
+# ##########################################################
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# Author: Juan Pablo Caram (c) #
# Date: 2/5/2014 #
# MIT Licence #
-# ########################################################## ##
+# ##########################################################
-# ########################################################## ##
+# ##########################################################
# File Modified (major mod): Marius Adrian Stanciu #
# Date: 3/10/2019 #
-# ########################################################## ##
+# ##########################################################
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt5.QtCore import Qt
@@ -17,9 +17,9 @@ from flatcamGUI.GUIElements import *
import gettext
import FlatCAMTranslation as fcTranslate
+import builtins
fcTranslate.apply_language('strings')
-import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -71,11 +71,11 @@ class ObjectUI(QtWidgets.QWidget):
self.custom_box = QtWidgets.QVBoxLayout()
layout.addLayout(self.custom_box)
- ######################### ##
- # ## Common to all objects # ##
- ######################### ##
+ # ###########################
+ # ## Common to all objects ##
+ # ###########################
- #### Scale ## ##
+ # ### Scale ####
self.scale_label = QtWidgets.QLabel(_('Scale:'))
self.scale_label.setToolTip(
_("Change the size of the object.")
@@ -89,7 +89,7 @@ class ObjectUI(QtWidgets.QWidget):
faclabel = QtWidgets.QLabel(_('Factor:'))
faclabel.setToolTip(
_("Factor by which to multiply\n"
- "geometric features of this object.")
+ "geometric features of this object.")
)
self.scale_grid.addWidget(faclabel, 0, 0)
self.scale_entry = FloatEntry2()
@@ -104,7 +104,7 @@ class ObjectUI(QtWidgets.QWidget):
self.scale_button.setFixedWidth(70)
self.scale_grid.addWidget(self.scale_button, 0, 2)
- #### Offset ## ##
+ # ### Offset ####
self.offset_label = QtWidgets.QLabel(_('Offset:'))
self.offset_label.setToolTip(
_("Change the position of this object.")
@@ -117,7 +117,7 @@ class ObjectUI(QtWidgets.QWidget):
self.offset_vectorlabel = QtWidgets.QLabel(_('Vector:'))
self.offset_vectorlabel.setToolTip(
_("Amount by which to move the object\n"
- "in the x and y axes in (x, y) format.")
+ "in the x and y axes in (x, y) format.")
)
self.offset_grid.addWidget(self.offset_vectorlabel, 0, 0)
self.offsetvector_entry = EvalEntry2()
@@ -188,7 +188,7 @@ class GerberObjectUI(ObjectUI):
hlay_plot = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(hlay_plot)
- #### Gerber Apertures ## ##
+ # ### Gerber Apertures ####
self.apertures_table_label = QtWidgets.QLabel(_('Apertures:'))
self.apertures_table_label.setToolTip(
_("Apertures Table for the Gerber Object.")
@@ -201,9 +201,8 @@ class GerberObjectUI(ObjectUI):
self.aperture_table_visibility_cb = FCCheckBox()
self.aperture_table_visibility_cb.setToolTip(
_("Toggle the display of the Gerber Apertures Table.\n"
- "When unchecked, it will delete all mark shapes\n"
- "that are drawn on canvas.")
-
+ "When unchecked, it will delete all mark shapes\n"
+ "that are drawn on canvas.")
)
# self.aperture_table_visibility_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
hlay_plot.addWidget(self.aperture_table_visibility_cb)
@@ -214,8 +213,8 @@ class GerberObjectUI(ObjectUI):
self.mark_all_cb = FCCheckBox(_('Mark All'))
self.mark_all_cb.setToolTip(
_("When checked it will display all the apertures.\n"
- "When unchecked, it will delete all mark shapes\n"
- "that are drawn on canvas.")
+ "When unchecked, it will delete all mark shapes\n"
+ "that are drawn on canvas.")
)
self.mark_all_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
@@ -238,8 +237,8 @@ class GerberObjectUI(ObjectUI):
_("Aperture Size:"))
self.apertures_table.horizontalHeaderItem(4).setToolTip(
_("Aperture Dimensions:\n"
- " - (width, height) for R, O type.\n"
- " - (dia, nVertices) for P type"))
+ " - (width, height) for R, O type.\n"
+ " - (dia, nVertices) for P type"))
self.apertures_table.horizontalHeaderItem(5).setToolTip(
_("Mark the aperture instances on canvas."))
# self.apertures_table.setColumnHidden(5, True)
@@ -251,7 +250,7 @@ class GerberObjectUI(ObjectUI):
self.isolation_routing_label = QtWidgets.QLabel(_("Isolation Routing:"))
self.isolation_routing_label.setToolTip(
_("Create a Geometry object with\n"
- "toolpaths to cut outside polygons.")
+ "toolpaths to cut outside polygons.")
)
self.custom_box.addWidget(self.isolation_routing_label)
@@ -260,10 +259,10 @@ class GerberObjectUI(ObjectUI):
tdlabel = QtWidgets.QLabel(_('Tool dia:'))
tdlabel.setToolTip(
_("Diameter of the cutting tool.\n"
- "If you want to have an isolation path\n"
- "inside the actual shape of the Gerber\n"
- "feature, use a negative value for\n"
- "this parameter.")
+ "If you want to have an isolation path\n"
+ "inside the actual shape of the Gerber\n"
+ "feature, use a negative value for\n"
+ "this parameter.")
)
tdlabel.setFixedWidth(90)
grid1.addWidget(tdlabel, 0, 0)
@@ -273,7 +272,7 @@ class GerberObjectUI(ObjectUI):
passlabel = QtWidgets.QLabel(_('Passes:'))
passlabel.setToolTip(
_("Width of the isolation gap in\n"
- "number (integer) of tool widths.")
+ "number (integer) of tool widths.")
)
passlabel.setFixedWidth(90)
grid1.addWidget(passlabel, 1, 0)
@@ -283,8 +282,8 @@ class GerberObjectUI(ObjectUI):
overlabel = QtWidgets.QLabel(_('Pass overlap:'))
overlabel.setToolTip(
_("How much (fraction) of the tool width to overlap each tool pass.\n"
- "Example:\n"
- "A value here of 0.25 means an overlap of 25% from the tool diameter found above.")
+ "Example:\n"
+ "A value here of 0.25 means an overlap of 25% from the tool diameter found above.")
)
overlabel.setFixedWidth(90)
grid1.addWidget(overlabel, 2, 0)
@@ -295,8 +294,8 @@ class GerberObjectUI(ObjectUI):
self.milling_type_label = QtWidgets.QLabel(_('Milling Type:'))
self.milling_type_label.setToolTip(
_("Milling type:\n"
- "- climb / best for precision milling and to reduce tool usage\n"
- "- conventional / useful when there is no backlash compensation")
+ "- climb / best for precision milling and to reduce tool usage\n"
+ "- conventional / useful when there is no backlash compensation")
)
grid1.addWidget(self.milling_type_label, 3, 0)
self.milling_type_radio = RadioSet([{'label': _('Climb'), 'value': 'cl'},
@@ -313,9 +312,9 @@ class GerberObjectUI(ObjectUI):
# generate follow
self.follow_cb = FCCheckBox(label=_('"Follow"'))
self.follow_cb.setToolTip(
- _( "Generate a 'Follow' geometry.\n"
- "This means that it will cut through\n"
- "the middle of the trace.")
+ _("Generate a 'Follow' geometry.\n"
+ "This means that it will cut through\n"
+ "the middle of the trace.")
)
grid1.addWidget(self.follow_cb, 4, 1)
@@ -323,14 +322,14 @@ class GerberObjectUI(ObjectUI):
self.gen_iso_label = QtWidgets.QLabel(_("Generate Isolation Geometry:"))
self.gen_iso_label.setToolTip(
_("Create a Geometry object with toolpaths to cut \n"
- "isolation outside, inside or on both sides of the\n"
- "object. For a Gerber object outside means outside\n"
- "of the Gerber feature and inside means inside of\n"
- "the Gerber feature, if possible at all. This means\n"
- "that only if the Gerber feature has openings inside, they\n"
- "will be isolated. If what is wanted is to cut isolation\n"
- "inside the actual Gerber feature, use a negative tool\n"
- "diameter above.")
+ "isolation outside, inside or on both sides of the\n"
+ "object. For a Gerber object outside means outside\n"
+ "of the Gerber feature and inside means inside of\n"
+ "the Gerber feature, if possible at all. This means\n"
+ "that only if the Gerber feature has openings inside, they\n"
+ "will be isolated. If what is wanted is to cut isolation\n"
+ "inside the actual Gerber feature, use a negative tool\n"
+ "diameter above.")
)
self.custom_box.addWidget(self.gen_iso_label)
@@ -344,8 +343,8 @@ class GerberObjectUI(ObjectUI):
self.generate_iso_button = QtWidgets.QPushButton(_('FULL Geo'))
self.generate_iso_button.setToolTip(
_("Create the Geometry Object\n"
- "for isolation routing. It contains both\n"
- "the interiors and exteriors geometry.")
+ "for isolation routing. It contains both\n"
+ "the interiors and exteriors geometry.")
)
self.generate_iso_button.setFixedWidth(90)
hlay_1.addWidget(self.generate_iso_button, alignment=Qt.AlignLeft)
@@ -355,8 +354,8 @@ class GerberObjectUI(ObjectUI):
self.generate_ext_iso_button = QtWidgets.QPushButton(_('Ext Geo'))
self.generate_ext_iso_button.setToolTip(
_("Create the Geometry Object\n"
- "for isolation routing containing\n"
- "only the exteriors geometry.")
+ "for isolation routing containing\n"
+ "only the exteriors geometry.")
)
# self.generate_ext_iso_button.setFixedWidth(100)
hlay_1.addWidget(self.generate_ext_iso_button)
@@ -364,8 +363,8 @@ class GerberObjectUI(ObjectUI):
self.generate_int_iso_button = QtWidgets.QPushButton(_('Int Geo'))
self.generate_int_iso_button.setToolTip(
_("Create the Geometry Object\n"
- "for isolation routing containing\n"
- "only the interiors geometry.")
+ "for isolation routing containing\n"
+ "only the interiors geometry.")
)
# self.generate_ext_iso_button.setFixedWidth(90)
hlay_1.addWidget(self.generate_int_iso_button)
@@ -375,8 +374,6 @@ class GerberObjectUI(ObjectUI):
self.ois_iso = OptionalInputSection(self.follow_cb,
[self.generate_int_iso_button, self.generate_ext_iso_button], logic=False)
-
-
grid2 = QtWidgets.QGridLayout()
self.custom_box.addLayout(grid2)
@@ -384,7 +381,7 @@ class GerberObjectUI(ObjectUI):
self.clearcopper_label = QtWidgets.QLabel(_("Clear N-copper:"))
self.clearcopper_label.setToolTip(
_("Create a Geometry object with\n"
- "toolpaths to cut all non-copper regions.")
+ "toolpaths to cut all non-copper regions.")
)
self.clearcopper_label.setFixedWidth(90)
grid2.addWidget(self.clearcopper_label, 0, 0)
@@ -392,7 +389,7 @@ class GerberObjectUI(ObjectUI):
self.generate_ncc_button = QtWidgets.QPushButton(_('NCC Tool'))
self.generate_ncc_button.setToolTip(
_("Create the Geometry Object\n"
- "for non-copper routing.")
+ "for non-copper routing.")
)
grid2.addWidget(self.generate_ncc_button, 0, 1)
@@ -400,15 +397,15 @@ class GerberObjectUI(ObjectUI):
self.board_cutout_label = QtWidgets.QLabel(_("Board cutout:"))
self.board_cutout_label.setToolTip(
_("Create toolpaths to cut around\n"
- "the PCB and separate it from\n"
- "the original board.")
+ "the PCB and separate it from\n"
+ "the original board.")
)
grid2.addWidget(self.board_cutout_label, 1, 0)
self.generate_cutout_button = QtWidgets.QPushButton(_('Cutout Tool'))
self.generate_cutout_button.setToolTip(
_("Generate the geometry for\n"
- "the board cutout.")
+ "the board cutout.")
)
grid2.addWidget(self.generate_cutout_button, 1, 1)
@@ -416,10 +413,10 @@ class GerberObjectUI(ObjectUI):
self.noncopper_label = QtWidgets.QLabel(_("Non-copper regions:"))
self.noncopper_label.setToolTip(
_("Create polygons covering the\n"
- "areas without copper on the PCB.\n"
- "Equivalent to the inverse of this\n"
- "object. Can be used to remove all\n"
- "copper from a specified region.")
+ "areas without copper on the PCB.\n"
+ "Equivalent to the inverse of this\n"
+ "object. Can be used to remove all\n"
+ "copper from a specified region.")
)
self.custom_box.addWidget(self.noncopper_label)
@@ -430,9 +427,9 @@ class GerberObjectUI(ObjectUI):
bmlabel = QtWidgets.QLabel(_('Boundary Margin:'))
bmlabel.setToolTip(
_("Specify the edge of the PCB\n"
- "by drawing a box around all\n"
- "objects with this minimum\n"
- "distance.")
+ "by drawing a box around all\n"
+ "objects with this minimum\n"
+ "distance.")
)
bmlabel.setFixedWidth(90)
grid4.addWidget(bmlabel, 0, 0)
@@ -454,7 +451,7 @@ class GerberObjectUI(ObjectUI):
self.boundingbox_label = QtWidgets.QLabel(_('Bounding Box:'))
self.boundingbox_label.setToolTip(
_("Create a geometry surrounding the Gerber object.\n"
- "Square shape.")
+ "Square shape.")
)
self.custom_box.addWidget(self.boundingbox_label)
@@ -464,7 +461,7 @@ class GerberObjectUI(ObjectUI):
bbmargin = QtWidgets.QLabel(_('Boundary Margin:'))
bbmargin.setToolTip(
_("Distance of the edges of the box\n"
- "to the nearest polygon.")
+ "to the nearest polygon.")
)
bbmargin.setFixedWidth(90)
grid5.addWidget(bbmargin, 0, 0)
@@ -474,9 +471,9 @@ class GerberObjectUI(ObjectUI):
self.bbrounded_cb = FCCheckBox(label=_("Rounded Geo"))
self.bbrounded_cb.setToolTip(
_("If the bounding box is \n"
- "to have rounded corners\n"
- "their radius is equal to\n"
- "the margin.")
+ "to have rounded corners\n"
+ "their radius is equal to\n"
+ "the margin.")
)
self.bbrounded_cb.setFixedWidth(90)
grid5.addWidget(self.bbrounded_cb, 1, 0)
@@ -498,7 +495,7 @@ class ExcellonObjectUI(ObjectUI):
icon_file='share/drill32.png',
parent=parent)
- #### Plot options ## ##
+ # ### Plot options ####
hlay_plot = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(hlay_plot)
@@ -532,11 +529,11 @@ class ExcellonObjectUI(ObjectUI):
hlay_plot = QtWidgets.QHBoxLayout()
self.tools_box.addLayout(hlay_plot)
- #### Tools Drills ## ##
+ # ### Tools Drills ####
self.tools_table_label = QtWidgets.QLabel(_('Tools Table'))
self.tools_table_label.setToolTip(
_("Tools in this Excellon object\n"
- "when are used for drilling.")
+ "when are used for drilling.")
)
hlay_plot.addWidget(self.tools_table_label)
@@ -559,32 +556,32 @@ class ExcellonObjectUI(ObjectUI):
self.tools_table.horizontalHeaderItem(0).setToolTip(
_("This is the Tool Number.\n"
- "When ToolChange is checked, on toolchange event this value\n"
- "will be showed as a T1, T2 ... Tn in the Machine Code."))
+ "When ToolChange is checked, on toolchange event this value\n"
+ "will be showed as a T1, T2 ... Tn in the Machine Code."))
self.tools_table.horizontalHeaderItem(1).setToolTip(
_("Tool Diameter. It's value (in current FlatCAM units) \n"
- "is the cut width into the material."))
+ "is the cut width into the material."))
self.tools_table.horizontalHeaderItem(2).setToolTip(
_("The number of Drill holes. Holes that are drilled with\n"
- "a drill bit."))
+ "a drill bit."))
self.tools_table.horizontalHeaderItem(3).setToolTip(
_("The number of Slot holes. Holes that are created by\n"
- "milling them with an endmill bit."))
+ "milling them with an endmill bit."))
self.tools_table.horizontalHeaderItem(4).setToolTip(
_("Some drill bits (the larger ones) need to drill deeper\n"
- "to create the desired exit hole diameter due of the tip shape.\n"
- "The value here can compensate the Cut Z parameter."))
+ "to create the desired exit hole diameter due of the tip shape.\n"
+ "The value here can compensate the Cut Z parameter."))
self.tools_table.horizontalHeaderItem(5).setToolTip(
_("Toggle display of the drills for the current tool."))
self.empty_label = QtWidgets.QLabel('')
self.tools_box.addWidget(self.empty_label)
- #### Create CNC Job ## ##
+ # ### Create CNC Job ####
self.cncjob_label = QtWidgets.QLabel(_('Create CNC Job'))
self.cncjob_label.setToolTip(
_("Create a CNC Job object\n"
- "for this drill object.")
+ "for this drill object.")
)
self.tools_box.addWidget(self.cncjob_label)
@@ -595,7 +592,7 @@ class ExcellonObjectUI(ObjectUI):
cutzlabel = QtWidgets.QLabel(_('Cut Z:'))
cutzlabel.setToolTip(
_("Drill depth (negative)\n"
- "below the copper surface.")
+ "below the copper surface.")
)
grid1.addWidget(cutzlabel, 0, 0)
self.cutz_entry = LengthEntry()
@@ -605,7 +602,7 @@ class ExcellonObjectUI(ObjectUI):
travelzlabel = QtWidgets.QLabel(_('Travel Z:'))
travelzlabel.setToolTip(
_("Tool height when travelling\n"
- "across the XY plane.")
+ "across the XY plane.")
)
grid1.addWidget(travelzlabel, 1, 0)
self.travelz_entry = LengthEntry()
@@ -615,7 +612,7 @@ class ExcellonObjectUI(ObjectUI):
self.toolchange_cb = FCCheckBox(_("Tool change"))
self.toolchange_cb.setToolTip(
_("Include tool-change sequence\n"
- "in G-Code (Pause for tool change).")
+ "in G-Code (Pause for tool change).")
)
grid1.addWidget(self.toolchange_cb, 2, 0)
@@ -623,7 +620,7 @@ class ExcellonObjectUI(ObjectUI):
toolchzlabel = QtWidgets.QLabel(_("Tool change Z:"))
toolchzlabel.setToolTip(
_("Z-axis position (height) for\n"
- "tool change.")
+ "tool change.")
)
grid1.addWidget(toolchzlabel, 3, 0)
self.toolchangez_entry = LengthEntry()
@@ -634,7 +631,7 @@ class ExcellonObjectUI(ObjectUI):
self.estartz_label = QtWidgets.QLabel(_("Start move Z:"))
self.estartz_label.setToolTip(
_("Tool height just before starting the work.\n"
- "Delete the value if you don't need this feature.")
+ "Delete the value if you don't need this feature.")
)
grid1.addWidget(self.estartz_label, 4, 0)
self.estartz_entry = FloatEntry()
@@ -644,7 +641,7 @@ class ExcellonObjectUI(ObjectUI):
self.eendz_label = QtWidgets.QLabel(_("End move Z:"))
self.eendz_label.setToolTip(
_("Z-axis position (height) for\n"
- "the last move.")
+ "the last move.")
)
grid1.addWidget(self.eendz_label, 5, 0)
self.eendz_entry = LengthEntry()
@@ -654,8 +651,8 @@ class ExcellonObjectUI(ObjectUI):
frlabel = QtWidgets.QLabel(_('Feedrate (Plunge):'))
frlabel.setToolTip(
_("Tool speed while drilling\n"
- "(in units per minute).\n"
- "This is for linear move G01.")
+ "(in units per minute).\n"
+ "This is for linear move G01.")
)
grid1.addWidget(frlabel, 6, 0)
self.feedrate_entry = LengthEntry()
@@ -682,7 +679,7 @@ class ExcellonObjectUI(ObjectUI):
spdlabel = QtWidgets.QLabel(_('Spindle speed:'))
spdlabel.setToolTip(
_("Speed of the spindle\n"
- "in RPM (optional)")
+ "in RPM (optional)")
)
grid1.addWidget(spdlabel, 8, 0)
self.spindlespeed_entry = IntEntry(allow_empty=True)
@@ -692,7 +689,7 @@ class ExcellonObjectUI(ObjectUI):
self.dwell_cb = FCCheckBox(_('Dwell:'))
self.dwell_cb.setToolTip(
_("Pause to allow the spindle to reach its\n"
- "speed before cutting.")
+ "speed before cutting.")
)
self.dwelltime_entry = FCEntry()
self.dwelltime_entry.setToolTip(
@@ -707,7 +704,7 @@ class ExcellonObjectUI(ObjectUI):
pp_excellon_label = QtWidgets.QLabel(_("Postprocessor:"))
pp_excellon_label.setToolTip(
_("The json file that dictates\n"
- "gcode output.")
+ "gcode output.")
)
self.pp_excellon_name_cb = FCComboBox()
self.pp_excellon_name_cb.setFocusPolicy(QtCore.Qt.StrongFocus)
@@ -718,7 +715,7 @@ class ExcellonObjectUI(ObjectUI):
self.pdepth_label = QtWidgets.QLabel(_("Probe Z depth:"))
self.pdepth_label.setToolTip(
_("The maximum depth that the probe is allowed\n"
- "to probe. Negative value, in current units.")
+ "to probe. Negative value, in current units.")
)
grid1.addWidget(self.pdepth_label, 11, 0)
self.pdepth_entry = FCEntry()
@@ -739,18 +736,18 @@ class ExcellonObjectUI(ObjectUI):
choose_tools_label = QtWidgets.QLabel(
_("Select from the Tools Table above\n"
- "the tools you want to include.")
+ "the tools you want to include.")
)
self.tools_box.addWidget(choose_tools_label)
- #### Choose what to use for Gcode creation: Drills, Slots or Both
+ # ### Choose what to use for Gcode creation: Drills, Slots or Both
gcode_box = QtWidgets.QFormLayout()
gcode_type_label = QtWidgets.QLabel(_('Type: '))
gcode_type_label.setToolTip(
_("Choose what to use for GCode generation:\n"
- "'Drills', 'Slots' or 'Both'.\n"
- "When choosing 'Slots' or 'Both', slots will be\n"
- "converted to a series of drills.")
+ "'Drills', 'Slots' or 'Both'.\n"
+ "When choosing 'Slots' or 'Both', slots will be\n"
+ "converted to a series of drills.")
)
self.excellon_gcode_type_radio = RadioSet([{'label': 'Drills', 'value': 'drills'},
{'label': 'Slots', 'value': 'slots'},
@@ -768,7 +765,7 @@ class ExcellonObjectUI(ObjectUI):
)
self.tools_box.addWidget(self.generate_cnc_button)
- #### Milling Holes Drills## ##
+ # ### Milling Holes Drills ####
self.mill_hole_label = QtWidgets.QLabel(_('Mill Holes'))
self.mill_hole_label.setToolTip(
_("Create Geometry for milling holes.")
@@ -777,7 +774,7 @@ class ExcellonObjectUI(ObjectUI):
self.choose_tools_label2 = QtWidgets.QLabel(
_("Select from the Tools Table above\n"
- " the hole dias that are to be milled.")
+ " the hole dias that are to be milled.")
)
self.tools_box.addWidget(self.choose_tools_label2)
@@ -793,7 +790,7 @@ class ExcellonObjectUI(ObjectUI):
self.generate_milling_button = QtWidgets.QPushButton(_('Mill Drills Geo'))
self.generate_milling_button.setToolTip(
_("Create the Geometry Object\n"
- "for milling DRILLS toolpaths.")
+ "for milling DRILLS toolpaths.")
)
grid2.addWidget(self.generate_milling_button, 0, 2)
@@ -809,7 +806,7 @@ class ExcellonObjectUI(ObjectUI):
self.generate_milling_slots_button = QtWidgets.QPushButton(_('Mill Slots Geo'))
self.generate_milling_slots_button.setToolTip(
_("Create the Geometry Object\n"
- "for milling SLOTS toolpaths.")
+ "for milling SLOTS toolpaths.")
)
grid3.addWidget(self.generate_milling_slots_button, 0, 2)
@@ -854,21 +851,21 @@ class GeometryObjectUI(ObjectUI):
hlay_plot = QtWidgets.QHBoxLayout()
self.geo_tools_box.addLayout(hlay_plot)
- #### Tools ## ##
+ # ### Tools ####
self.tools_table_label = QtWidgets.QLabel(_('Tools Table'))
self.tools_table_label.setToolTip(
_("Tools in this Geometry object used for cutting.\n"
- "The 'Offset' entry will set an offset for the cut.\n"
- "'Offset' can be inside, outside, on path (none) and custom.\n"
- "'Type' entry is only informative and it allow to know the \n"
- "intent of using the current tool. \n"
- "It can be Rough(ing), Finish(ing) or Iso(lation).\n"
- "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n"
- "ball(B), or V-Shaped(V). \n"
- "When V-shaped is selected the 'Type' entry is automatically \n"
- "set to Isolation, the CutZ parameter in the UI form is\n"
- "grayed out and Cut Z is automatically calculated from the newly \n"
- "showed UI form entries named V-Tip Dia and V-Tip Angle.")
+ "The 'Offset' entry will set an offset for the cut.\n"
+ "'Offset' can be inside, outside, on path (none) and custom.\n"
+ "'Type' entry is only informative and it allow to know the \n"
+ "intent of using the current tool. \n"
+ "It can be Rough(ing), Finish(ing) or Iso(lation).\n"
+ "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n"
+ "ball(B), or V-Shaped(V). \n"
+ "When V-shaped is selected the 'Type' entry is automatically \n"
+ "set to Isolation, the CutZ parameter in the UI form is\n"
+ "grayed out and Cut Z is automatically calculated from the newly \n"
+ "showed UI form entries named V-Tip Dia and V-Tip Angle.")
)
hlay_plot.addWidget(self.tools_table_label)
@@ -928,7 +925,8 @@ class GeometryObjectUI(ObjectUI):
"- Ball -> informative only and make reference to the Ball type endmill.\n"
"- V-Shape -> it will disable de Z-Cut parameter in the UI form and enable two additional UI form\n"
"fields: V-Tip Dia and V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such\n"
- "as the cut width into material will be equal with the value in the Tool Diameter column of this table.\n"
+ "as the cut width into material will be equal with the value in the Tool "
+ "Diameter column of this table.\n"
"Choosing the V-Shape Tool Type automatically will select the Operation Type as Isolation."
))
self.geo_tools_table.horizontalHeaderItem(6).setToolTip(
@@ -964,7 +962,7 @@ class GeometryObjectUI(ObjectUI):
self.grid1.addWidget(self.tool_offset_entry, 0, 1)
self.grid1.addWidget(spacer_lbl, 0, 2)
- #### Add a new Tool ## ##
+ # ### Add a new Tool ####
hlay = QtWidgets.QHBoxLayout()
self.geo_tools_box.addLayout(hlay)
@@ -1014,15 +1012,15 @@ class GeometryObjectUI(ObjectUI):
grid2.addWidget(self.addtool_btn, 0, 0)
grid2.addWidget(self.copytool_btn, 0, 1)
- grid2.addWidget(self.deltool_btn, 0,2)
+ grid2.addWidget(self.deltool_btn, 0, 2)
self.empty_label = QtWidgets.QLabel('')
self.geo_tools_box.addWidget(self.empty_label)
- #-----------------------------------
- # Create CNC Job
- #-----------------------------------
- #### Tools Data ## ##
+ # ##################
+ # Create CNC Job ###
+ # ##################
+ # ### Tools Data ## ##
self.tool_data_label = QtWidgets.QLabel(_('Tool Data'))
self.tool_data_label.setToolTip(
_(
@@ -1067,7 +1065,7 @@ class GeometryObjectUI(ObjectUI):
)
)
self.grid3.addWidget(cutzlabel, 3, 0)
- self.cutz_entry = LengthEntry()
+ self.cutz_entry = FloatEntry()
self.grid3.addWidget(self.cutz_entry, 3, 1)
# Multi-pass
@@ -1084,7 +1082,7 @@ class GeometryObjectUI(ObjectUI):
)
self.grid3.addWidget(self.mpass_cb, 4, 0)
- self.maxdepth_entry = LengthEntry()
+ self.maxdepth_entry = FloatEntry()
self.maxdepth_entry.setToolTip(
_(
"Depth of each pass (positive)."
@@ -1103,7 +1101,7 @@ class GeometryObjectUI(ObjectUI):
)
)
self.grid3.addWidget(travelzlabel, 5, 0)
- self.travelz_entry = LengthEntry()
+ self.travelz_entry = FloatEntry()
self.grid3.addWidget(self.travelz_entry, 5, 1)
# Tool change:
@@ -1122,7 +1120,7 @@ class GeometryObjectUI(ObjectUI):
"in the Machine Code (Pause for tool change)."
)
)
- self.toolchangez_entry = LengthEntry()
+ self.toolchangez_entry = FloatEntry()
self.grid3.addWidget(self.toolchangeg_cb, 6, 0)
self.grid3.addWidget(self.toolchzlabel, 7, 0)
@@ -1149,7 +1147,7 @@ class GeometryObjectUI(ObjectUI):
)
)
self.grid3.addWidget(self.endzlabel, 9, 0)
- self.gendz_entry = LengthEntry()
+ self.gendz_entry = FloatEntry()
self.grid3.addWidget(self.gendz_entry, 9, 1)
# Feedrate X-Y
@@ -1161,7 +1159,7 @@ class GeometryObjectUI(ObjectUI):
)
)
self.grid3.addWidget(frlabel, 10, 0)
- self.cncfeedrate_entry = LengthEntry()
+ self.cncfeedrate_entry = FloatEntry()
self.grid3.addWidget(self.cncfeedrate_entry, 10, 1)
# Feedrate Z (Plunge)
@@ -1173,7 +1171,7 @@ class GeometryObjectUI(ObjectUI):
)
)
self.grid3.addWidget(frzlabel, 11, 0)
- self.cncplunge_entry = LengthEntry()
+ self.cncplunge_entry = FloatEntry()
self.grid3.addWidget(self.cncplunge_entry, 11, 1)
# Feedrate rapids
@@ -1189,7 +1187,7 @@ class GeometryObjectUI(ObjectUI):
)
)
self.grid3.addWidget(self.fr_rapidlabel, 12, 0)
- self.cncfeedrate_rapid_entry = LengthEntry()
+ self.cncfeedrate_rapid_entry = FloatEntry()
self.grid3.addWidget(self.cncfeedrate_rapid_entry, 12, 1)
# default values is to hide
self.fr_rapidlabel.hide()
@@ -1228,7 +1226,7 @@ class GeometryObjectUI(ObjectUI):
"speed before cutting."
)
)
- self.dwelltime_entry = FCEntry()
+ self.dwelltime_entry = FloatEntry()
self.dwelltime_entry.setToolTip(
_(
"Number of milliseconds for spindle to dwell."
@@ -1296,9 +1294,9 @@ class GeometryObjectUI(ObjectUI):
)
self.geo_tools_box.addWidget(self.generate_cnc_button)
- #------------------------------
- # Paint area
- #------------------------------
+ # ##############
+ # Paint area ##
+ # ##############
self.paint_label = QtWidgets.QLabel(_('Paint Area:'))
self.paint_label.setToolTip(
_(
@@ -1340,7 +1338,6 @@ class CNCObjectUI(ObjectUI):
self.scale_label.hide()
self.scale_button.hide()
-
for i in range(0, self.offset_grid.count()):
self.offset_grid.itemAt(i).widget().hide()
self.offset_label.hide()
@@ -1475,9 +1472,9 @@ class CNCObjectUI(ObjectUI):
)
self.custom_box.addWidget(self.updateplot_button)
- ################ ##
- # ## Export G-Code
- ################ ##
+ # ####################
+ # ## Export G-Code ##
+ # ####################
self.export_gcode_label = QtWidgets.QLabel(_("Export CNC Code:"))
self.export_gcode_label.setToolTip(
_("Export and save G-Code to\n"
@@ -1575,7 +1572,8 @@ class CNCObjectUI(ObjectUI):
self.tc_variable_combo.setItemData(8, _("z_move = height where to travel"), Qt.ToolTipRole)
self.tc_variable_combo.setItemData(9, _("z_depthpercut = the step value for multidepth cut"), Qt.ToolTipRole)
self.tc_variable_combo.setItemData(10, _("spindlesspeed = the value for the spindle speed"), Qt.ToolTipRole)
- self.tc_variable_combo.setItemData(11, _("dwelltime = time to dwell to allow the spindle to reach it's set RPM"),
+ self.tc_variable_combo.setItemData(11, _("dwelltime = time to dwell to allow the "
+ "spindle to reach it's set RPM"),
Qt.ToolTipRole)
cnclay.addWidget(self.toolchange_cb)
diff --git a/flatcamGUI/PlotCanvas.py b/flatcamGUI/PlotCanvas.py
index 915f9ba4..f914be7b 100644
--- a/flatcamGUI/PlotCanvas.py
+++ b/flatcamGUI/PlotCanvas.py
@@ -132,7 +132,7 @@ class PlotCanvas(QtCore.QObject):
self.r_line.parent = None
self.t_line.parent = None
self.l_line.parent = None
- except:
+ except Exception as e:
pass
# redraw the workspace lines on the plot by readding them to the parent view.scene
@@ -142,7 +142,7 @@ class PlotCanvas(QtCore.QObject):
self.r_line.parent = self.vispy_canvas.view.scene
self.t_line.parent = self.vispy_canvas.view.scene
self.l_line.parent = self.vispy_canvas.view.scene
- except:
+ except Exception as e:
pass
def vis_connect(self, event_name, callback):
diff --git a/flatcamParsers/ParseFont.py b/flatcamParsers/ParseFont.py
index f7b0034e..d280d77e 100644
--- a/flatcamParsers/ParseFont.py
+++ b/flatcamParsers/ParseFont.py
@@ -270,7 +270,7 @@ class ParseFont():
else:
try:
name = name.replace(" Regular", '')
- except:
+ except Exception as e:
pass
self.regular_f.update({name: font})
log.debug("Font parsing is finished.")
@@ -313,7 +313,7 @@ class ParseFont():
if previous > 0 and glyph_index > 0:
delta = face.get_kerning(previous, glyph_index)
pen_x += delta.x
- except:
+ except Exception as e:
pass
face.load_glyph(glyph_index)
diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNonCopperClear.py
index 8d6a3e9e..614241c4 100644
--- a/flatcamTools/ToolNonCopperClear.py
+++ b/flatcamTools/ToolNonCopperClear.py
@@ -461,7 +461,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.tools_table.itemChanged.disconnect(self.on_tool_edit)
- except:
+ except TypeError:
pass
def on_tool_add(self, dia=None, muted=None):
@@ -861,7 +861,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
for poly in cleared_by_last_tool:
try:
area = area.difference(poly)
- except:
+ except Exception as e:
pass
cleared_by_last_tool[:] = []
diff --git a/flatcamTools/ToolPDF.py b/flatcamTools/ToolPDF.py
index 8b4cb1bf..718a856d 100644
--- a/flatcamTools/ToolPDF.py
+++ b/flatcamTools/ToolPDF.py
@@ -360,13 +360,13 @@ class ToolPDF(FlatCAMTool):
try:
self.check_thread.stop()
- except Exception as e:
+ except TypeError:
pass
self.check_thread.setInterval(check_period)
try:
self.check_thread.timeout.disconnect(self.periodic_check_handler)
- except:
+ except TypeError:
pass
self.check_thread.timeout.connect(self.periodic_check_handler)
diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py
index cb14b027..c54a65b8 100644
--- a/flatcamTools/ToolPaint.py
+++ b/flatcamTools/ToolPaint.py
@@ -437,7 +437,7 @@ class ToolPaint(FlatCAMTool, Gerber):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.tools_table.itemChanged.disconnect()
- except:
+ except TypeError:
pass
# updated units
diff --git a/flatcamTools/ToolSolderPaste.py b/flatcamTools/ToolSolderPaste.py
index aede24d8..5ca85d1a 100644
--- a/flatcamTools/ToolSolderPaste.py
+++ b/flatcamTools/ToolSolderPaste.py
@@ -642,22 +642,26 @@ class SolderPaste(FlatCAMTool):
def ui_disconnect(self):
# if connected, disconnect the signal from the slot on item_changed as it creates issues
- try:
- for i in range(self.gcode_form_layout.count()):
- if isinstance(self.gcode_form_layout.itemAt(i).widget(), FCComboBox):
+ for i in range(self.gcode_form_layout.count()):
+ if isinstance(self.gcode_form_layout.itemAt(i).widget(), FCComboBox):
+ try:
self.gcode_form_layout.itemAt(i).widget().currentIndexChanged.disconnect()
- if isinstance(self.gcode_form_layout.itemAt(i).widget(), FCEntry):
+ except TypeError:
+ pass
+ if isinstance(self.gcode_form_layout.itemAt(i).widget(), FCEntry):
+ try:
self.gcode_form_layout.itemAt(i).widget().editingFinished.disconnect()
- except:
- pass
+ except TypeError:
+ pass
+
try:
self.tools_table.itemChanged.disconnect(self.on_tool_edit)
- except:
+ except TypeError:
pass
try:
self.tools_table.currentItemChanged.disconnect(self.on_row_selection_change)
- except:
+ except TypeError:
pass
def update_comboboxes(self, obj, status):
diff --git a/flatcamTools/ToolSub.py b/flatcamTools/ToolSub.py
index c05d8f1e..eb943fb5 100644
--- a/flatcamTools/ToolSub.py
+++ b/flatcamTools/ToolSub.py
@@ -569,14 +569,14 @@ class ToolSub(FlatCAMTool):
try:
self.check_thread.stop()
- except Exception as e:
+ except TypeError:
pass
if reset:
self.check_thread.setInterval(check_period)
try:
self.check_thread.timeout.disconnect(self.periodic_check_handler)
- except Exception as e:
+ except TypeError:
pass
self.check_thread.timeout.connect(self.periodic_check_handler)