diff --git a/README.md b/README.md
index 784c6c6f..892a62ea 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
=================================================
+16.07.2019
+
+- PEP8 correction in flatcamTools
+- merged the Brazilian-portuguese language from a pull request made by Carlos Stein
+
15.07.2019
- some PEP8 corrections
diff --git a/flatcamTools/ToolPDF.py b/flatcamTools/ToolPDF.py
index decef799..8b4cb1bf 100644
--- a/flatcamTools/ToolPDF.py
+++ b/flatcamTools/ToolPDF.py
@@ -207,8 +207,8 @@ class ToolPDF(FlatCAMTool):
while True:
self.parsing_promises.remove(short_name)
time.sleep(0.1)
- except:
- pass
+ except Exception as e:
+ log.debug("ToolPDF.open_pdf() --> %s" % str(e))
self.app.inform.emit(_("[success] Opened: %s") % filename)
def layer_rendering_as_excellon(self, filename, ap_dict, layer_nr):
@@ -264,8 +264,8 @@ class ToolPDF(FlatCAMTool):
with self.app.proc_container.new(_("Rendering PDF layer #%d ...") % int(layer_nr)):
- ret = self.app.new_object("excellon", outname, obj_init, autoselected=False)
- if ret == 'fail':
+ ret_val = self.app.new_object("excellon", outname, obj_init, autoselected=False)
+ if ret_val == 'fail':
self.app.inform.emit(_('[ERROR_NOTCL] Open PDF file failed.'))
return
# Register recent file
@@ -300,7 +300,7 @@ class ToolPDF(FlatCAMTool):
global_clear_geo.append(geo_el['clear'])
if global_clear_geo:
- solid= []
+ solid = []
for apid in grb_obj.apertures:
if 'geometry' in grb_obj.apertures[apid]:
for elem in grb_obj.apertures[apid]['geometry']:
@@ -360,7 +360,7 @@ class ToolPDF(FlatCAMTool):
try:
self.check_thread.stop()
- except:
+ except Exception as e:
pass
self.check_thread.setInterval(check_period)
@@ -458,7 +458,7 @@ class ToolPDF(FlatCAMTool):
# on stroke color change we create a new apertures dictionary and store the old one in a storage from where
# it will be transformed into Gerber object
- old_color = [None, None ,None]
+ old_color = [None, None, None]
# signal that we have clear geometry and the geometry will be added to a special layer_nr = 0
flag_clear_geo = False
@@ -681,10 +681,8 @@ class ToolPDF(FlatCAMTool):
current_subpath = 'rectangle'
x = (float(match.group(1)) + offset_geo[0]) * self.point_to_unit_factor * scale_geo[0]
y = (float(match.group(2)) + offset_geo[1]) * self.point_to_unit_factor * scale_geo[1]
- width = (float(match.group(3)) + offset_geo[0]) * \
- self.point_to_unit_factor * scale_geo[0]
- height = (float(match.group(4)) + offset_geo[1]) * \
- self.point_to_unit_factor * scale_geo[1]
+ width = (float(match.group(3)) + offset_geo[0]) * self.point_to_unit_factor * scale_geo[0]
+ height = (float(match.group(4)) + offset_geo[1]) * self.point_to_unit_factor * scale_geo[1]
pt1 = (x, y)
pt2 = (x+width, y)
pt3 = (x+width, y+height)
@@ -758,7 +756,8 @@ class ToolPDF(FlatCAMTool):
for subp in path['lines']:
geo = copy(subp)
try:
- geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
+ geo = LineString(geo).buffer((float(applied_size) / 2),
+ resolution=self.step_per_circles)
path_geo.append(geo)
except ValueError:
pass
diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py
index f2009c88..0d1f5ad3 100644
--- a/flatcamTools/ToolPaint.py
+++ b/flatcamTools/ToolPaint.py
@@ -7,14 +7,14 @@
# ########################################################## ##
from FlatCAMTool import FlatCAMTool
-from copy import copy,deepcopy
+from copy import copy, deepcopy
from ObjectCollection import *
import gettext
import FlatCAMTranslation as fcTranslate
+import builtins
fcTranslate.apply_language('strings')
-import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -65,11 +65,11 @@ class ToolPaint(FlatCAMTool, Gerber):
form_layout.addRow(self.object_label, self.object_combo)
form_layout.addRow(e_lab_0)
- #### Tools ## ##
+ # ### Tools ## ##
self.tools_table_label = QtWidgets.QLabel('%s' % _('Tools Table'))
self.tools_table_label.setToolTip(
_("Tools pool from which the algorithm\n"
- "will pick the ones used for painting.")
+ "will pick the ones used for painting.")
)
self.tools_box.addWidget(self.tools_table_label)
@@ -84,33 +84,33 @@ class ToolPaint(FlatCAMTool, Gerber):
self.tools_table.horizontalHeaderItem(0).setToolTip(
_("This is the Tool Number.\n"
- "Painting will start with the tool with the biggest diameter,\n"
- "continuing until there are no more tools.\n"
- "Only tools that create painting geometry will still be present\n"
- "in the resulting geometry. This is because with some tools\n"
- "this function will not be able to create painting geometry.")
+ "Painting will start with the tool with the biggest diameter,\n"
+ "continuing until there are no more tools.\n"
+ "Only tools that create painting geometry will still be present\n"
+ "in the resulting geometry. This is because with some tools\n"
+ "this function will not be able to create painting geometry.")
)
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 Tool Type (TT) can be:
"
- "- Circular with 1 ... 4 teeth -> it is informative only. Being circular,
"
- "the cut width in material is exactly the tool diameter.
"
- "- Ball -> informative only and make reference to the Ball type endmill.
"
- "- V-Shape -> it will disable de Z-Cut parameter in the resulting geometry UI form "
- "and enable two additional UI form fields in the resulting geometry: V-Tip Dia and "
- "V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such "
- "as the cut width into material will be equal with the value in the Tool Diameter "
- "column of this table.
"
- "Choosing the V-Shape Tool Type automatically will select the Operation Type "
- "in the resulting geometry as Isolation."))
+ "- Circular with 1 ... 4 teeth -> it is informative only. Being circular,
"
+ "the cut width in material is exactly the tool diameter.
"
+ "- Ball -> informative only and make reference to the Ball type endmill.
"
+ "- V-Shape -> it will disable de Z-Cut parameter in the resulting geometry UI form "
+ "and enable two additional UI form fields in the resulting geometry: V-Tip Dia and "
+ "V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such "
+ "as the cut width into material will be equal with the value in the Tool Diameter "
+ "column of this table.
"
+ "Choosing the V-Shape Tool Type automatically will select the Operation Type "
+ "in the resulting geometry as Isolation."))
self.empty_label = QtWidgets.QLabel('')
self.tools_box.addWidget(self.empty_label)
- #### Add a new Tool ## ##
+ # ### Add a new Tool ## ##
hlay = QtWidgets.QHBoxLayout()
self.tools_box.addLayout(hlay)
@@ -131,7 +131,7 @@ class ToolPaint(FlatCAMTool, Gerber):
self.addtool_btn = QtWidgets.QPushButton(_('Add'))
self.addtool_btn.setToolTip(
_("Add a new tool to the Tool Table\n"
- "with the diameter specified above.")
+ "with the diameter specified above.")
)
# self.copytool_btn = QtWidgets.QPushButton('Copy')
@@ -143,12 +143,12 @@ class ToolPaint(FlatCAMTool, Gerber):
self.deltool_btn = QtWidgets.QPushButton(_('Delete'))
self.deltool_btn.setToolTip(
_("Delete a selection of tools in the Tool Table\n"
- "by first selecting a row(s) in the Tool Table.")
+ "by first selecting a row(s) in the Tool Table.")
)
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_0 = QtWidgets.QLabel('')
self.tools_box.addWidget(self.empty_label_0)
@@ -177,8 +177,8 @@ class ToolPaint(FlatCAMTool, Gerber):
marginlabel = QtWidgets.QLabel(_('Margin:'))
marginlabel.setToolTip(
_("Distance by which to avoid\n"
- "the edges of the polygon to\n"
- "be painted.")
+ "the edges of the polygon to\n"
+ "be painted.")
)
grid3.addWidget(marginlabel, 2, 0)
self.paintmargin_entry = FCEntry()
@@ -188,9 +188,9 @@ class ToolPaint(FlatCAMTool, Gerber):
methodlabel = QtWidgets.QLabel(_('Method:'))
methodlabel.setToolTip(
_("Algorithm for non-copper clearing:
"
- "Standard: Fixed step inwards.
"
- "Seed-based: Outwards from seed.
"
- "Line-based: Parallel lines.")
+ "Standard: Fixed step inwards.
"
+ "Seed-based: Outwards from seed.
"
+ "Line-based: Parallel lines.")
)
grid3.addWidget(methodlabel, 3, 0)
self.paintmethod_combo = RadioSet([
@@ -204,7 +204,7 @@ class ToolPaint(FlatCAMTool, Gerber):
pathconnectlabel = QtWidgets.QLabel(_("Connect:"))
pathconnectlabel.setToolTip(
_("Draw lines between resulting\n"
- "segments to minimize tool lifts.")
+ "segments to minimize tool lifts.")
)
grid3.addWidget(pathconnectlabel, 4, 0)
self.pathconnect_cb = FCCheckBox()
@@ -213,7 +213,7 @@ class ToolPaint(FlatCAMTool, Gerber):
contourlabel = QtWidgets.QLabel(_("Contour:"))
contourlabel.setToolTip(
_("Cut around the perimeter of the polygon\n"
- "to trim rough edges.")
+ "to trim rough edges.")
)
grid3.addWidget(contourlabel, 5, 0)
self.paintcontour_cb = FCCheckBox()
@@ -222,12 +222,12 @@ class ToolPaint(FlatCAMTool, Gerber):
restlabel = QtWidgets.QLabel(_("Rest M.:"))
restlabel.setToolTip(
_("If checked, use 'rest machining'.\n"
- "Basically it will clear copper outside PCB features,\n"
- "using the biggest tool and continue with the next tools,\n"
- "from bigger to smaller, to clear areas of copper that\n"
- "could not be cleared by previous tool, until there is\n"
- "no more copper to clear or there are no more tools.\n\n"
- "If not checked, use the standard algorithm.")
+ "Basically it will clear copper outside PCB features,\n"
+ "using the biggest tool and continue with the next tools,\n"
+ "from bigger to smaller, to clear areas of copper that\n"
+ "could not be cleared by previous tool, until there is\n"
+ "no more copper to clear or there are no more tools.\n\n"
+ "If not checked, use the standard algorithm.")
)
grid3.addWidget(restlabel, 6, 0)
self.rest_cb = FCCheckBox()
@@ -237,9 +237,9 @@ class ToolPaint(FlatCAMTool, Gerber):
selectlabel = QtWidgets.QLabel(_('Selection:'))
selectlabel.setToolTip(
_("How to select the polygons to paint.
"
- "Options:
"
- "- Single: left mouse click on the polygon to be painted.
"
- "- All: paint all polygons.")
+ "Options:
"
+ "- Single: left mouse click on the polygon to be painted.
"
+ "- All: paint all polygons.")
)
grid3.addWidget(selectlabel, 7, 0)
# grid3 = QtWidgets.QGridLayout()
@@ -254,10 +254,10 @@ class ToolPaint(FlatCAMTool, Gerber):
self.generate_paint_button = QtWidgets.QPushButton(_('Create Paint Geometry'))
self.generate_paint_button.setToolTip(
_("After clicking here, click inside
"
- "the polygon you wish to be painted if Single is selected.
"
- "If All is selected then the Paint will start after click.
"
- "A new Geometry object with the tool
"
- "paths will be created.")
+ "the polygon you wish to be painted if Single is selected.
"
+ "If All is selected then the Paint will start after click.
"
+ "A new Geometry object with the tool
"
+ "paths will be created.")
)
self.tools_box.addWidget(self.generate_paint_button)
@@ -314,7 +314,6 @@ class ToolPaint(FlatCAMTool, Gerber):
self.generate_paint_button.clicked.connect(self.on_paint_button_click)
self.selectmethod_combo.activated_custom.connect(self.on_radio_selection)
-
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+P', **kwargs)
@@ -430,7 +429,7 @@ class ToolPaint(FlatCAMTool, Gerber):
self.on_tool_add(self.app.defaults["tools_painttooldia"], muted=True)
# if the Paint Method is "Single" disable the tool table context menu
- if self.default_data["selectmethod"] == "single":
+ if self.default_data["selectmethod"] == "single":
self.tools_table.setContextMenuPolicy(Qt.NoContextMenu)
def build_ui(self):
@@ -522,8 +521,8 @@ class ToolPaint(FlatCAMTool, Gerber):
try:
self.tools_table.itemChanged.disconnect()
- except:
- pass
+ except Exception as e:
+ log.debug("ToolPaint.on_tool_add() --> %s" % str(e))
if dia:
tool_dia = dia
@@ -586,10 +585,12 @@ class ToolPaint(FlatCAMTool, Gerber):
self.build_ui()
def on_tool_edit(self):
+ old_tool_dia = ''
+
try:
self.tools_table.itemChanged.disconnect()
- except:
- pass
+ except Exception as e:
+ log.debug("ToolPaint.on_tool_edit() --> %s" % str(e))
tool_dias = []
for k, v in self.paint_tools.items():
@@ -624,7 +625,8 @@ class ToolPaint(FlatCAMTool, Gerber):
break
restore_dia_item = self.tools_table.item(row, 1)
restore_dia_item.setText(str(old_tool_dia))
- self.app.inform.emit(_("[WARNING_NOTCL] Edit cancelled. New diameter value is already in the Tool Table."))
+ self.app.inform.emit(_("[WARNING_NOTCL] Edit cancelled. "
+ "New diameter value is already in the Tool Table."))
self.build_ui()
# def on_tool_copy(self, all=None):
@@ -685,7 +687,8 @@ class ToolPaint(FlatCAMTool, Gerber):
def on_tool_delete(self, rows_to_delete=None, all=None):
try:
self.tools_table.itemChanged.disconnect()
- except:
+ except Exception as e:
+ log.debug("ToolPaint.on_tool_delete() --> %s" % str(e))
pass
deleted_tools_list = []
@@ -741,12 +744,12 @@ class ToolPaint(FlatCAMTool, Gerber):
overlap = float(self.paintoverlap_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
- "use a number."))
+ "use a number."))
return
if overlap >= 1 or overlap < 0:
self.app.inform.emit(_("[ERROR_NOTCL] Overlap value must be between "
- "0 (inclusive) and 1 (exclusive), "))
+ "0 (inclusive) and 1 (exclusive), "))
return
self.app.inform.emit(_("[WARNING_NOTCL] Click inside the desired polygon."))
@@ -760,7 +763,8 @@ class ToolPaint(FlatCAMTool, Gerber):
# Get source object.
try:
self.paint_obj = self.app.collection.get_by_name(str(self.obj_name))
- except:
+ except Exception as e:
+ log.debug("ToolPaint.on_paint_button_click() --> %s" % str(e))
self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % self.obj_name)
return
@@ -774,7 +778,7 @@ class ToolPaint(FlatCAMTool, Gerber):
self.app.inform.emit(_("[ERROR_NOTCL] Can't do Paint on MultiGeo geometries ..."))
return 'Fail'
- o_name = '%s_multitool_paint' % (self.obj_name)
+ o_name = '%s_multitool_paint' % self.obj_name
if select_method == "all":
self.paint_poly_all(self.paint_obj,
@@ -811,15 +815,13 @@ class ToolPaint(FlatCAMTool, Gerber):
self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.vis_connect('mouse_press', doit)
- def paint_poly(self, obj, inside_pt, tooldia, overlap,
- outname=None, connect=True,
- contour=True):
+ def paint_poly(self, obj, inside_pt, tooldia, overlap, outname=None, connect=True, contour=True):
"""
Paints a polygon selected by clicking on its interior.
Note:
* The margin is taken directly from the form.
-
+ :param obj: painted object
:param inside_pt: [x, y]
:param tooldia: Diameter of the painting tool
:param overlap: Overlap of the tool between passes.
@@ -864,34 +866,34 @@ class ToolPaint(FlatCAMTool, Gerber):
def paint_p(polyg):
if paint_method == "seed":
# Type(cp) == FlatCAMRTreeStorage | None
- cp = self.clear_polygon2(polyg,
- tooldia=tooldia,
- steps_per_circle=self.app.defaults["geometry_circle_steps"],
- overlap=overlap,
- contour=contour,
- connect=connect)
+ cpoly = self.clear_polygon2(polyg,
+ tooldia=tooldia,
+ steps_per_circle=self.app.defaults["geometry_circle_steps"],
+ overlap=overlap,
+ contour=contour,
+ connect=connect)
elif paint_method == "lines":
# Type(cp) == FlatCAMRTreeStorage | None
- cp = self.clear_polygon3(polyg,
- tooldia=tooldia,
- steps_per_circle=self.app.defaults["geometry_circle_steps"],
- overlap=overlap,
- contour=contour,
- connect=connect)
+ cpoly = self.clear_polygon3(polyg,
+ tooldia=tooldia,
+ steps_per_circle=self.app.defaults["geometry_circle_steps"],
+ overlap=overlap,
+ contour=contour,
+ connect=connect)
else:
# Type(cp) == FlatCAMRTreeStorage | None
- cp = self.clear_polygon(polyg,
- tooldia=tooldia,
- steps_per_circle=self.app.defaults["geometry_circle_steps"],
- overlap=overlap,
- contour=contour,
- connect=connect)
+ cpoly = self.clear_polygon(polyg,
+ tooldia=tooldia,
+ steps_per_circle=self.app.defaults["geometry_circle_steps"],
+ overlap=overlap,
+ contour=contour,
+ connect=connect)
- if cp is not None:
- geo_obj.solid_geometry += list(cp.get_objects())
- return cp
+ if cpoly is not None:
+ geo_obj.solid_geometry += list(cpoly.get_objects())
+ return cpoly
else:
self.app.inform.emit(_('[ERROR_NOTCL] Geometry could not be painted completely'))
return None
@@ -975,12 +977,11 @@ class ToolPaint(FlatCAMTool, Gerber):
# Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
- def paint_poly_all(self, obj, overlap, outname=None,
- connect=True, contour=True):
+ def paint_poly_all(self, obj, overlap, outname=None, connect=True, contour=True):
"""
Paints all polygons in this object.
- :param tooldia:
+ :param obj: painted object
:param overlap:
:param outname:
:param connect: Connect lines to avoid tool lifts.
@@ -1055,6 +1056,7 @@ class ToolPaint(FlatCAMTool, Gerber):
def gen_paintarea(geo_obj, app_obj):
assert isinstance(geo_obj, FlatCAMGeometry), \
"Initializer expected a FlatCAMGeometry, got %s" % type(geo_obj)
+ tool_dia = None
sorted_tools = []
for row in range(self.tools_table.rowCount()):
@@ -1083,7 +1085,7 @@ class ToolPaint(FlatCAMTool, Gerber):
for geo in recurse(obj.solid_geometry):
try:
- #Polygons are the only really paintable geometries, lines in theory have no area to be painted
+ # Polygons are the only really paintable geometries, lines in theory have no area to be painted
if not isinstance(geo, Polygon):
continue
poly_buf = geo.buffer(-paint_margin)
@@ -1109,11 +1111,11 @@ class ToolPaint(FlatCAMTool, Gerber):
else:
# Type(cp) == FlatCAMRTreeStorage | None
cp = self.clear_polygon(poly_buf,
- tooldia=tool_dia,
- steps_per_circle=self.app.defaults["geometry_circle_steps"],
- overlap=over,
- contour=cont,
- connect=conn)
+ tooldia=tool_dia,
+ steps_per_circle=self.app.defaults["geometry_circle_steps"],
+ overlap=over,
+ contour=cont,
+ connect=conn)
if cp is not None:
total_geometry += list(cp.get_objects())
@@ -1121,7 +1123,7 @@ class ToolPaint(FlatCAMTool, Gerber):
log.debug("Could not Paint the polygons. %s" % str(e))
self.app.inform.emit(
_("[ERROR] Could not do Paint All. Try a different combination of parameters. "
- "Or a different Method of paint\n%s") % str(e))
+ "Or a different Method of paint\n%s") % str(e))
return
# add the solid_geometry to the current too in self.paint_tools dictionary and then reset the
@@ -1160,6 +1162,7 @@ class ToolPaint(FlatCAMTool, Gerber):
assert isinstance(geo_obj, FlatCAMGeometry), \
"Initializer expected a FlatCAMGeometry, got %s" % type(geo_obj)
+ tool_dia = None
sorted_tools = []
for row in range(self.tools_table.rowCount()):
sorted_tools.append(float(self.tools_table.item(row, 1).text()))
@@ -1184,12 +1187,13 @@ class ToolPaint(FlatCAMTool, Gerber):
try:
geo = Polygon(geo) if not isinstance(geo, Polygon) else geo
poly_buf = geo.buffer(-paint_margin)
+ cp = None
if paint_method == "standard":
# Type(cp) == FlatCAMRTreeStorage | None
cp = self.clear_polygon(poly_buf, tooldia=tool_dia,
- steps_per_circle=self.app.defaults["geometry_circle_steps"],
- overlap=over, contour=cont, connect=conn)
+ steps_per_circle=self.app.defaults["geometry_circle_steps"],
+ overlap=over, contour=cont, connect=conn)
elif paint_method == "seed":
# Type(cp) == FlatCAMRTreeStorage | None
@@ -1200,8 +1204,8 @@ class ToolPaint(FlatCAMTool, Gerber):
elif paint_method == "lines":
# Type(cp) == FlatCAMRTreeStorage | None
cp = self.clear_polygon3(poly_buf, tooldia=tool_dia,
- steps_per_circle=self.app.defaults["geometry_circle_steps"],
- overlap=over, contour=cont, connect=conn)
+ steps_per_circle=self.app.defaults["geometry_circle_steps"],
+ overlap=over, contour=cont, connect=conn)
if cp is not None:
cleared_geo += list(cp.get_objects())
@@ -1210,7 +1214,7 @@ class ToolPaint(FlatCAMTool, Gerber):
log.debug("Could not Paint the polygons. %s" % str(e))
self.app.inform.emit(
_("[ERROR] Could not do Paint All. Try a different combination of parameters. "
- "Or a different Method of paint\n%s") % str(e))
+ "Or a different Method of paint\n%s") % str(e))
return
# find the tooluid associated with the current tool_dia so we know where to add the tool solid_geometry
@@ -1240,8 +1244,8 @@ class ToolPaint(FlatCAMTool, Gerber):
has_solid_geo += 1
if has_solid_geo == 0:
self.app.inform.emit(_("[ERROR_NOTCL] There is no Painting Geometry in the file.\n"
- "Usually it means that the tool diameter is too big for the painted geometry.\n"
- "Change the painting parameters and try again."))
+ "Usually it means that the tool diameter is too big for the painted geometry.\n"
+ "Change the painting parameters and try again."))
return
# Experimental...
diff --git a/flatcamTools/ToolPcbWizard.py b/flatcamTools/ToolPcbWizard.py
index e1eccdb7..db142d4d 100644
--- a/flatcamTools/ToolPcbWizard.py
+++ b/flatcamTools/ToolPcbWizard.py
@@ -18,9 +18,9 @@ from io import StringIO
import gettext
import FlatCAMTranslation as fcTranslate
+import builtins
fcTranslate.apply_language('strings')
-import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -56,9 +56,8 @@ class PcbWizard(FlatCAMTool):
self.excellon_label = QtWidgets.QLabel(_("Excellon file:"))
self.excellon_label.setToolTip(
- _( "Load the Excellon file.\n"
- "Usually it has a .DRL extension")
-
+ _("Load the Excellon file.\n"
+ "Usually it has a .DRL extension")
)
self.excellon_brn = FCButton(_("Open"))
form_layout.addRow(self.excellon_label, self.excellon_brn)
@@ -66,7 +65,6 @@ class PcbWizard(FlatCAMTool):
self.inf_label = QtWidgets.QLabel(_("INF file:"))
self.inf_label.setToolTip(
_("Load the INF file.")
-
)
self.inf_btn = FCButton(_("Open"))
form_layout.addRow(self.inf_label, self.inf_btn)
@@ -96,7 +94,7 @@ class PcbWizard(FlatCAMTool):
self.int_entry.set_range(1, 10)
self.int_label = QtWidgets.QLabel(_("Int. digits:"))
self.int_label.setToolTip(
- _( "The number of digits for the integral part of the coordinates.")
+ _("The number of digits for the integral part of the coordinates.")
)
form_layout1.addRow(self.int_label, self.int_entry)
@@ -283,18 +281,17 @@ class PcbWizard(FlatCAMTool):
"""
self.app.log.debug("on_load_excellon_click()")
- filter = "Excellon Files(*.DRL *.DRD *.TXT);;All Files (*.*)"
+ _filter = "Excellon Files(*.DRL *.DRD *.TXT);;All Files (*.*)"
try:
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Load PcbWizard Excellon file"),
directory=self.app.get_last_folder(),
- filter=filter)
+ filter=_filter)
except TypeError:
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Load PcbWizard Excellon file"),
- filter=filter)
+ filter=_filter)
filename = str(filename)
-
if filename == "":
self.app.inform.emit(_("Open cancelled."))
else:
@@ -307,14 +304,14 @@ class PcbWizard(FlatCAMTool):
"""
self.app.log.debug("on_load_inf_click()")
- filter = "INF Files(*.INF);;All Files (*.*)"
+ _filter = "INF Files(*.INF);;All Files (*.*)"
try:
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Load PcbWizard INF file"),
directory=self.app.get_last_folder(),
- filter=filter)
+ filter=_filter)
except TypeError:
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Load PcbWizard INF file"),
- filter=filter)
+ filter=_filter)
filename = str(filename)
@@ -338,7 +335,7 @@ class PcbWizard(FlatCAMTool):
match = tool_re.search(eline)
if match:
- tool =int( match.group(1))
+ tool = int(match.group(1))
dia = float(match.group(2))
# if dia < 0.1:
# # most likely the file is in INCH
@@ -396,7 +393,7 @@ class PcbWizard(FlatCAMTool):
(str(self.app.version), str(self.app.version_date))
header += ';Created on : %s' % time_str + '\n'
header += ';FILE_FORMAT={integral}:{fractional}\n'.format(integral=self.integral,
- fractional=self.fractional)
+ fractional=self.fractional)
header += '{units},{zeros}\n'.format(units=self.units, zeros=self.zeros)
for k, v in self.tools_from_inf.items():
header += 'T{tool}C{dia}\n'.format(tool=int(k), dia=float(v))
@@ -425,7 +422,8 @@ class PcbWizard(FlatCAMTool):
app_obj.log.debug("Could not import Excellon object.")
app_obj.progress.emit(0)
return "fail"
- except:
+ except Exception as e:
+ app_obj.log.debug("PcbWizard.on_import_excellon().obj_init() %s" % str(e))
msg = _("[ERROR_NOTCL] An internal error has occurred. See shell.\n")
msg += app_obj.traceback.format_exc()
app_obj.inform.emit(msg)
@@ -449,8 +447,8 @@ class PcbWizard(FlatCAMTool):
# Object name
name = self.outname
- ret = self.app.new_object("excellon", name, obj_init, autoselected=False)
- if ret == 'fail':
+ ret_val = self.app.new_object("excellon", name, obj_init, autoselected=False)
+ if ret_val == 'fail':
self.app.inform.emit(_('[ERROR_NOTCL] Import Excellon file failed.'))
return
diff --git a/flatcamTools/ToolProperties.py b/flatcamTools/ToolProperties.py
index 175d9097..cf6c6db2 100644
--- a/flatcamTools/ToolProperties.py
+++ b/flatcamTools/ToolProperties.py
@@ -13,9 +13,9 @@ from FlatCAMObj import *
import gettext
import FlatCAMTranslation as fcTranslate
+import builtins
fcTranslate.apply_language('strings')
-import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -49,7 +49,7 @@ class Properties(FlatCAMTool):
self.properties_box.addWidget(title_label)
# self.layout.setMargin(0) # PyQt4
- self.properties_box.setContentsMargins(0, 0, 0, 0) # PyQt5
+ self.properties_box.setContentsMargins(0, 0, 0, 0) # PyQt5
self.vlay = QtWidgets.QVBoxLayout()
@@ -62,7 +62,7 @@ class Properties(FlatCAMTool):
self.treeWidget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Expanding)
self.vlay.addWidget(self.treeWidget)
- self.vlay.setStretch(0,0)
+ self.vlay.setStretch(0, 0)
def run(self, toggle=True):
self.app.report_usage("ToolProperties()")
@@ -130,9 +130,14 @@ class Properties(FlatCAMTool):
self.addChild(obj_type, ['Object Type:', ('%s' % (obj.kind.capitalize()))], True)
try:
- self.addChild(obj_type, ['Geo Type:', ('%s' % ({False: "Single-Geo", True: "Multi-Geo"}[obj.multigeo]))], True)
+ self.addChild(obj_type,
+ ['Geo Type:',
+ ('%s' % ({False: "Single-Geo", True: "Multi-Geo"}[obj.multigeo]))
+ ],
+ True
+ )
except Exception as e:
- pass
+ log.debug("Properties.addItems() --> %s" % str(e))
self.addChild(obj_name, [obj.options['name']])
@@ -163,7 +168,10 @@ class Properties(FlatCAMTool):
'in': 'Inch',
'mm': 'Metric'
}
- [str(self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower())]], True)
+ [str(self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower())]
+ ],
+ True
+ )
for option in obj.options:
if option is 'name':
diff --git a/flatcamTools/ToolShell.py b/flatcamTools/ToolShell.py
index ac5ed996..f0e41e5b 100644
--- a/flatcamTools/ToolShell.py
+++ b/flatcamTools/ToolShell.py
@@ -15,9 +15,9 @@ import html
import gettext
import FlatCAMTranslation as fcTranslate
+import builtins
fcTranslate.apply_language('strings')
-import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
diff --git a/flatcamTools/ToolSolderPaste.py b/flatcamTools/ToolSolderPaste.py
index 7f4b5e3e..aede24d8 100644
--- a/flatcamTools/ToolSolderPaste.py
+++ b/flatcamTools/ToolSolderPaste.py
@@ -26,9 +26,9 @@ from io import StringIO
import gettext
import FlatCAMTranslation as fcTranslate
+import builtins
fcTranslate.apply_language('strings')
-import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -66,11 +66,11 @@ class SolderPaste(FlatCAMTool):
)
obj_form_layout.addRow(self.object_label, self.obj_combo)
- #### Tools ## ##
+ # ### Tools ## ##
self.tools_table_label = QtWidgets.QLabel('%s' % _('Tools Table'))
self.tools_table_label.setToolTip(
_("Tools pool from which the algorithm\n"
- "will pick the ones used for dispensing solder paste.")
+ "will pick the ones used for dispensing solder paste.")
)
self.layout.addWidget(self.tools_table_label)
@@ -85,16 +85,16 @@ class SolderPaste(FlatCAMTool):
self.tools_table.horizontalHeaderItem(0).setToolTip(
_("This is the Tool Number.\n"
- "The solder dispensing will start with the tool with the biggest \n"
- "diameter, continuing until there are no more Nozzle tools.\n"
- "If there are no longer tools but there are still pads not covered\n "
- "with solder paste, the app will issue a warning message box.")
+ "The solder dispensing will start with the tool with the biggest \n"
+ "diameter, continuing until there are no more Nozzle tools.\n"
+ "If there are no longer tools but there are still pads not covered\n "
+ "with solder paste, the app will issue a warning message box.")
)
self.tools_table.horizontalHeaderItem(1).setToolTip(
- _( "Nozzle tool Diameter. It's value (in current FlatCAM units)\n"
- "is the width of the solder paste dispensed."))
+ _("Nozzle tool Diameter. It's value (in current FlatCAM units)\n"
+ "is the width of the solder paste dispensed."))
- #### Add a new Tool ## ##
+ # ### Add a new Tool ## ##
hlay_tools = QtWidgets.QHBoxLayout()
self.layout.addLayout(hlay_tools)
@@ -115,13 +115,13 @@ class SolderPaste(FlatCAMTool):
self.addtool_btn = QtWidgets.QPushButton(_('Add'))
self.addtool_btn.setToolTip(
_("Add a new nozzle tool to the Tool Table\n"
- "with the diameter specified above.")
+ "with the diameter specified above.")
)
self.deltool_btn = QtWidgets.QPushButton(_('Delete'))
self.deltool_btn.setToolTip(
- _( "Delete a selection of tools in the Tool Table\n"
- "by first selecting a row(s) in the Tool Table.")
+ _("Delete a selection of tools in the Tool Table\n"
+ "by first selecting a row(s) in the Tool Table.")
)
self.soldergeo_btn = QtWidgets.QPushButton(_("Generate Geo"))
@@ -142,10 +142,10 @@ class SolderPaste(FlatCAMTool):
step1_lbl = QtWidgets.QLabel("%s:" % _('STEP 1:'))
step1_lbl.setToolTip(
_("First step is to select a number of nozzle tools for usage\n"
- "and then optionally modify the GCode parameters bellow.")
+ "and then optionally modify the GCode parameters bellow.")
)
step1_description_lbl = QtWidgets.QLabel(_("Select tools.\n"
- "Modify parameters."))
+ "Modify parameters."))
grid0_1.addWidget(step1_lbl, 0, 0, alignment=Qt.AlignTop)
grid0_1.addWidget(step1_description_lbl, 0, 2, alignment=Qt.AlignBottom)
@@ -174,7 +174,6 @@ class SolderPaste(FlatCAMTool):
self.z_dispense_label = QtWidgets.QLabel(_("Z Dispense:"))
self.z_dispense_label.setToolTip(
_("The height (Z) when doing solder paste dispensing.")
-
)
self.gcode_form_layout.addRow(self.z_dispense_label, self.z_dispense_entry)
@@ -190,8 +189,8 @@ class SolderPaste(FlatCAMTool):
self.z_travel_entry = FCEntry()
self.z_travel_label = QtWidgets.QLabel(_("Z Travel:"))
self.z_travel_label.setToolTip(
- _( "The height (Z) for travel between pads\n"
- "(without dispensing solder paste).")
+ _("The height (Z) for travel between pads\n"
+ "(without dispensing solder paste).")
)
self.gcode_form_layout.addRow(self.z_travel_label, self.z_travel_entry)
@@ -199,7 +198,7 @@ class SolderPaste(FlatCAMTool):
self.z_toolchange_entry = FCEntry()
self.z_toolchange_label = QtWidgets.QLabel(_("Z Toolchange:"))
self.z_toolchange_label.setToolTip(
- _( "The height (Z) for tool (nozzle) change.")
+ _("The height (Z) for tool (nozzle) change.")
)
self.gcode_form_layout.addRow(self.z_toolchange_label, self.z_toolchange_entry)
@@ -208,7 +207,7 @@ class SolderPaste(FlatCAMTool):
self.xy_toolchange_label = QtWidgets.QLabel(_("XY Toolchange:"))
self.xy_toolchange_label.setToolTip(
_("The X,Y location for tool (nozzle) change.\n"
- "The format is (x, y) where x and y are real numbers.")
+ "The format is (x, y) where x and y are real numbers.")
)
self.gcode_form_layout.addRow(self.xy_toolchange_label, self.xy_toolchange_entry)
@@ -216,7 +215,7 @@ class SolderPaste(FlatCAMTool):
self.frxy_entry = FCEntry()
self.frxy_label = QtWidgets.QLabel(_("Feedrate X-Y:"))
self.frxy_label.setToolTip(
- _( "Feedrate (speed) while moving on the X-Y plane.")
+ _("Feedrate (speed) while moving on the X-Y plane.")
)
self.gcode_form_layout.addRow(self.frxy_label, self.frxy_entry)
@@ -225,7 +224,7 @@ class SolderPaste(FlatCAMTool):
self.frz_label = QtWidgets.QLabel(_("Feedrate Z:"))
self.frz_label.setToolTip(
_("Feedrate (speed) while moving vertically\n"
- "(on Z plane).")
+ "(on Z plane).")
)
self.gcode_form_layout.addRow(self.frz_label, self.frz_entry)
@@ -233,8 +232,8 @@ class SolderPaste(FlatCAMTool):
self.frz_dispense_entry = FCEntry()
self.frz_dispense_label = QtWidgets.QLabel(_("Feedrate Z Dispense:"))
self.frz_dispense_label.setToolTip(
- _( "Feedrate (speed) while moving up vertically\n"
- " to Dispense position (on Z plane).")
+ _("Feedrate (speed) while moving up vertically\n"
+ " to Dispense position (on Z plane).")
)
self.gcode_form_layout.addRow(self.frz_dispense_label, self.frz_dispense_entry)
@@ -242,8 +241,8 @@ class SolderPaste(FlatCAMTool):
self.speedfwd_entry = FCEntry()
self.speedfwd_label = QtWidgets.QLabel(_("Spindle Speed FWD:"))
self.speedfwd_label.setToolTip(
- _( "The dispenser speed while pushing solder paste\n"
- "through the dispenser nozzle.")
+ _("The dispenser speed while pushing solder paste\n"
+ "through the dispenser nozzle.")
)
self.gcode_form_layout.addRow(self.speedfwd_label, self.speedfwd_entry)
@@ -259,8 +258,8 @@ class SolderPaste(FlatCAMTool):
self.speedrev_entry = FCEntry()
self.speedrev_label = QtWidgets.QLabel(_("Spindle Speed REV:"))
self.speedrev_label.setToolTip(
- _( "The dispenser speed while retracting solder paste\n"
- "through the dispenser nozzle.")
+ _("The dispenser speed while retracting solder paste\n"
+ "through the dispenser nozzle.")
)
self.gcode_form_layout.addRow(self.speedrev_label, self.speedrev_entry)
@@ -269,7 +268,7 @@ class SolderPaste(FlatCAMTool):
self.dwellrev_label = QtWidgets.QLabel(_("Dwell REV:"))
self.dwellrev_label.setToolTip(
_("Pause after solder paste dispenser retracted,\n"
- "to allow pressure equilibrium.")
+ "to allow pressure equilibrium.")
)
self.gcode_form_layout.addRow(self.dwellrev_label, self.dwellrev_entry)
@@ -289,8 +288,8 @@ class SolderPaste(FlatCAMTool):
self.solder_gcode_btn = QtWidgets.QPushButton(_("Generate GCode"))
self.solder_gcode_btn.setToolTip(
- _( "Generate GCode for Solder Paste dispensing\n"
- "on PCB pads.")
+ _("Generate GCode for Solder Paste dispensing\n"
+ "on PCB pads.")
)
self.generation_frame = QtWidgets.QFrame()
@@ -300,7 +299,6 @@ class SolderPaste(FlatCAMTool):
self.generation_box.setContentsMargins(0, 0, 0, 0)
self.generation_frame.setLayout(self.generation_box)
-
# ## Buttons
grid2 = QtWidgets.QGridLayout()
self.generation_box.addLayout(grid2)
@@ -308,7 +306,7 @@ class SolderPaste(FlatCAMTool):
step2_lbl = QtWidgets.QLabel("%s" % _('STEP 2:'))
step2_lbl.setToolTip(
_("Second step is to create a solder paste dispensing\n"
- "geometry out of an Solder Paste Mask Gerber file.")
+ "geometry out of an Solder Paste Mask Gerber file.")
)
grid2.addWidget(step2_lbl, 0, 0)
grid2.addWidget(self.soldergeo_btn, 0, 2)
@@ -325,9 +323,9 @@ class SolderPaste(FlatCAMTool):
self.geo_object_label = QtWidgets.QLabel(_("Geo Result:"))
self.geo_object_label.setToolTip(
- _( "Geometry Solder Paste object.\n"
- "The name of the object has to end in:\n"
- "'_solderpaste' as a protection.")
+ _("Geometry Solder Paste object.\n"
+ "The name of the object has to end in:\n"
+ "'_solderpaste' as a protection.")
)
geo_form_layout.addRow(self.geo_object_label, self.geo_obj_combo)
@@ -336,11 +334,11 @@ class SolderPaste(FlatCAMTool):
step3_lbl = QtWidgets.QLabel("%s" % _('STEP 3:'))
step3_lbl.setToolTip(
- _( "Third step is to select a solder paste dispensing geometry,\n"
- "and then generate a CNCJob object.\n\n"
- "REMEMBER: if you want to create a CNCJob with new parameters,\n"
- "first you need to generate a geometry with those new params,\n"
- "and only after that you can generate an updated CNCJob.")
+ _("Third step is to select a solder paste dispensing geometry,\n"
+ "and then generate a CNCJob object.\n\n"
+ "REMEMBER: if you want to create a CNCJob with new parameters,\n"
+ "first you need to generate a geometry with those new params,\n"
+ "and only after that you can generate an updated CNCJob.")
)
grid3.addWidget(step3_lbl, 0, 0)
@@ -358,10 +356,10 @@ class SolderPaste(FlatCAMTool):
self.cnc_object_label = QtWidgets.QLabel(_("CNC Result:"))
self.cnc_object_label.setToolTip(
- _( "CNCJob Solder paste object.\n"
- "In order to enable the GCode save section,\n"
- "the name of the object has to end in:\n"
- "'_solderpaste' as a protection.")
+ _("CNCJob Solder paste object.\n"
+ "In order to enable the GCode save section,\n"
+ "the name of the object has to end in:\n"
+ "'_solderpaste' as a protection.")
)
cnc_form_layout.addRow(self.cnc_object_label, self.cnc_obj_combo)
@@ -371,19 +369,19 @@ class SolderPaste(FlatCAMTool):
self.solder_gcode_view_btn = QtWidgets.QPushButton(_("View GCode"))
self.solder_gcode_view_btn.setToolTip(
_("View the generated GCode for Solder Paste dispensing\n"
- "on PCB pads.")
+ "on PCB pads.")
)
self.solder_gcode_save_btn = QtWidgets.QPushButton(_("Save GCode"))
self.solder_gcode_save_btn.setToolTip(
- _( "Save the generated GCode for Solder Paste dispensing\n"
- "on PCB pads, to a file.")
+ _("Save the generated GCode for Solder Paste dispensing\n"
+ "on PCB pads, to a file.")
)
step4_lbl = QtWidgets.QLabel("%s" % _('STEP 4:'))
step4_lbl.setToolTip(
- _( "Fourth step (and last) is to select a CNCJob made from \n"
- "a solder paste dispensing geometry, and then view/save it's GCode.")
+ _("Fourth step (and last) is to select a CNCJob made from \n"
+ "a solder paste dispensing geometry, and then view/save it's GCode.")
)
grid4.addWidget(step4_lbl, 0, 0)
@@ -402,6 +400,7 @@ class SolderPaste(FlatCAMTool):
self.form_fields = {}
self.units = ''
+ self.name = ""
# this will be used in the combobox context menu, for delete entry
self.obj_to_be_deleted_name = ''
@@ -607,7 +606,6 @@ class SolderPaste(FlatCAMTool):
if current_row < 0:
current_row = 0
-
# populate the form with the data from the tool associated with the row parameter
try:
tooluid = int(self.tools_table.item(current_row, 2).text())
@@ -754,7 +752,7 @@ class SolderPaste(FlatCAMTool):
tool_dia = float(self.addtool_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
- "use a number."))
+ "use a number."))
return
if tool_dia is None:
self.build_ui()
@@ -762,7 +760,8 @@ class SolderPaste(FlatCAMTool):
return
if tool_dia == 0:
- self.app.inform.emit(_("[WARNING_NOTCL] Please enter a tool diameter with non-zero value, in Float format."))
+ self.app.inform.emit(_("[WARNING_NOTCL] Please enter a tool diameter with non-zero value, "
+ "in Float format."))
return
# construct a list of all 'tooluid' in the self.tooltable_tools
@@ -825,7 +824,7 @@ class SolderPaste(FlatCAMTool):
new_tool_dia = float(self.tools_table.item(row, 1).text().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
- "use a number."))
+ "use a number."))
return
tooluid = int(self.tools_table.item(row, 2).text())
@@ -844,7 +843,8 @@ class SolderPaste(FlatCAMTool):
break
restore_dia_item = self.tools_table.item(row, 1)
restore_dia_item.setText(str(old_tool_dia))
- self.app.inform.emit(_("[WARNING_NOTCL] Edit cancelled. New diameter value is already in the Tool Table."))
+ self.app.inform.emit(_("[WARNING_NOTCL] Edit cancelled. "
+ "New diameter value is already in the Tool Table."))
self.build_ui()
def on_tool_delete(self, rows_to_delete=None, all=None):
@@ -964,6 +964,7 @@ class SolderPaste(FlatCAMTool):
:param name: the outname for the resulting geometry object
:param work_object: the source Gerber object from which the geometry is created
+ :param use_thread: use thread, True or False
:return: a Geometry type object
"""
proc = self.app.proc_container.new(_("Creating Solder Paste dispensing geometry."))
@@ -1030,8 +1031,8 @@ class SolderPaste(FlatCAMTool):
for tool in sorted_tools:
offset = tool / 2
- for uid, v in self.tooltable_tools.items():
- if float('%.4f' % float(v['tooldia'])) == tool:
+ for uid, vl in self.tooltable_tools.items():
+ if float('%.4f' % float(vl['tooldia'])) == tool:
tooluid = int(uid)
break
@@ -1064,19 +1065,19 @@ class SolderPaste(FlatCAMTool):
round_diag_2 = round(diag_2_intersect.length, 2)
if round_diag_1 == round_diag_2:
- l = distance((x_min, y_min), (x_max, y_min))
+ length = distance((x_min, y_min), (x_max, y_min))
h = distance((x_min, y_min), (x_min, y_max))
- if offset >= l / 2 or offset >= h / 2:
+ if offset >= length / 2 or offset >= h / 2:
pass
else:
- if l > h:
+ if length > h:
h_half = h / 2
start = [x_min, (y_min + h_half)]
- stop = [(x_min + l), (y_min + h_half)]
+ stop = [(x_min + length), (y_min + h_half)]
geo = LineString([start, stop])
else:
- l_half = l / 2
+ l_half = length / 2
start = [(x_min + l_half), y_min]
stop = [(x_min + l_half), (y_min + h)]
geo = LineString([start, stop])
@@ -1151,7 +1152,8 @@ class SolderPaste(FlatCAMTool):
return 'fail'
if obj.special_group != 'solder_paste_tool':
- self.app.inform.emit(_("[WARNING_NOTCL] This Geometry can't be processed. NOT a solder_paste_tool geometry."))
+ self.app.inform.emit(_("[WARNING_NOTCL] This Geometry can't be processed. "
+ "NOT a solder_paste_tool geometry."))
return 'fail'
a = 0
@@ -1314,7 +1316,8 @@ class SolderPaste(FlatCAMTool):
# then append the text from GCode to the text editor
try:
lines = StringIO(gcode)
- except:
+ except Exception as e:
+ log.debug("ToolSolderpaste.on_view_gcode() --> %s" % str(e))
self.app.inform.emit(_("[ERROR_NOTCL] No Gcode in the object..."))
return
diff --git a/flatcamTools/ToolSub.py b/flatcamTools/ToolSub.py
index aa5159b2..c05d8f1e 100644
--- a/flatcamTools/ToolSub.py
+++ b/flatcamTools/ToolSub.py
@@ -155,7 +155,6 @@ class ToolSub(FlatCAMTool):
self.sub_follow_union = None
self.sub_clear_union = None
-
self.sub_grb_obj = None
self.sub_grb_obj_name = None
self.target_grb_obj = None
@@ -172,16 +171,18 @@ class ToolSub(FlatCAMTool):
# store here the options from target_obj
self.target_options = {}
+ self.sub_union = []
+
try:
self.intersect_btn.clicked.disconnect(self.on_grb_intersection_click)
- except:
- pass
+ except Exception as e:
+ log.debug("ToolSub.__init__() --> %s" % str(e))
self.intersect_btn.clicked.connect(self.on_grb_intersection_click)
try:
self.intersect_geo_btn.clicked.disconnect()
- except:
- pass
+ except Exception as e:
+ log.debug("ToolSub.__init__() --> %s" % str(e))
self.intersect_geo_btn.clicked.connect(self.on_geo_intersection_click)
def install(self, icon=None, separator=None, **kwargs):
@@ -233,7 +234,8 @@ class ToolSub(FlatCAMTool):
# Get source object.
try:
self.target_grb_obj = self.app.collection.get_by_name(self.target_grb_obj_name)
- except:
+ except Exception as e:
+ log.debug("ToolSub.on_grb_intersection_click() --> %s" % str(e))
self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % self.obj_name)
return "Could not retrieve object: %s" % self.target_grb_obj_name
@@ -245,7 +247,8 @@ class ToolSub(FlatCAMTool):
# Get source object.
try:
self.sub_grb_obj = self.app.collection.get_by_name(self.sub_grb_obj_name)
- except:
+ except Exception as e:
+ log.debug("ToolSub.on_grb_intersection_click() --> %s" % str(e))
self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % self.obj_name)
return "Could not retrieve object: %s" % self.sub_grb_obj_name
@@ -424,7 +427,8 @@ class ToolSub(FlatCAMTool):
# Get source object.
try:
self.target_geo_obj = self.app.collection.get_by_name(self.target_geo_obj_name)
- except:
+ except Exception as e:
+ log.debug("ToolSub.on_geo_intersection_click() --> %s" % str(e))
self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % self.target_geo_obj_name)
return "Could not retrieve object: %s" % self.target_grb_obj_name
@@ -436,7 +440,8 @@ class ToolSub(FlatCAMTool):
# Get source object.
try:
self.sub_geo_obj = self.app.collection.get_by_name(self.sub_geo_obj_name)
- except:
+ except Exception as e:
+ log.debug("ToolSub.on_geo_intersection_click() --> %s" % str(e))
self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % self.sub_geo_obj_name)
return "Could not retrieve object: %s" % self.sub_geo_obj_name
@@ -533,8 +538,8 @@ class ToolSub(FlatCAMTool):
geo_obj.tools = deepcopy(self.new_tools)
for tool in geo_obj.tools:
geo_obj.tools[tool]['solid_geometry'] = deepcopy(self.new_solid_geometry)
- except:
- pass
+ except Exception as e:
+ log.debug("ToolSub.new_geo_object() --> %s" % str(e))
with self.app.proc_container.new(_("Generating new object ...")):
ret = self.app.new_object('geometry', outname, obj_init, autoselected=False)
@@ -584,7 +589,6 @@ class ToolSub(FlatCAMTool):
"""
# log.debug("checking parsing --> %s" % str(self.parsing_promises))
-
try:
if not self.promises:
self.check_thread.stop()
@@ -614,4 +618,6 @@ class ToolSub(FlatCAMTool):
self.sub_gerber_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.target_geo_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))
- self.sub_geo_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))
\ No newline at end of file
+ self.sub_geo_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))
+
+# end of file
diff --git a/flatcamTools/ToolTransform.py b/flatcamTools/ToolTransform.py
index 0e9a9b8b..4d77323a 100644
--- a/flatcamTools/ToolTransform.py
+++ b/flatcamTools/ToolTransform.py
@@ -11,9 +11,9 @@ from FlatCAMObj import *
import gettext
import FlatCAMTranslation as fcTranslate
+import builtins
fcTranslate.apply_language('strings')
-import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -68,9 +68,9 @@ class ToolTransform(FlatCAMTool):
self.rotate_label = QtWidgets.QLabel(_("Angle:"))
self.rotate_label.setToolTip(
_("Angle for Rotation action, in degrees.\n"
- "Float number between -360 and 359.\n"
- "Positive numbers for CW motion.\n"
- "Negative numbers for CCW motion.")
+ "Float number between -360 and 359.\n"
+ "Positive numbers for CW motion.\n"
+ "Negative numbers for CCW motion.")
)
self.rotate_label.setFixedWidth(70)
@@ -82,8 +82,8 @@ class ToolTransform(FlatCAMTool):
self.rotate_button.set_value(_("Rotate"))
self.rotate_button.setToolTip(
_("Rotate the selected object(s).\n"
- "The point of reference is the middle of\n"
- "the bounding box for all selected objects.")
+ "The point of reference is the middle of\n"
+ "the bounding box for all selected objects.")
)
self.rotate_button.setFixedWidth(90)
@@ -107,7 +107,7 @@ class ToolTransform(FlatCAMTool):
self.skewx_label = QtWidgets.QLabel(_("Angle X:"))
self.skewx_label.setToolTip(
_("Angle for Skew action, in degrees.\n"
- "Float number between -360 and 359.")
+ "Float number between -360 and 359.")
)
self.skewx_label.setFixedWidth(70)
self.skewx_entry = FCEntry()
@@ -118,14 +118,14 @@ class ToolTransform(FlatCAMTool):
self.skewx_button.set_value(_("Skew X"))
self.skewx_button.setToolTip(
_("Skew/shear the selected object(s).\n"
- "The point of reference is the middle of\n"
- "the bounding box for all selected objects."))
+ "The point of reference is the middle of\n"
+ "the bounding box for all selected objects."))
self.skewx_button.setFixedWidth(90)
self.skewy_label = QtWidgets.QLabel(_("Angle Y:"))
self.skewy_label.setToolTip(
_("Angle for Skew action, in degrees.\n"
- "Float number between -360 and 359.")
+ "Float number between -360 and 359.")
)
self.skewy_label.setFixedWidth(70)
self.skewy_entry = FCEntry()
@@ -136,8 +136,8 @@ class ToolTransform(FlatCAMTool):
self.skewy_button.set_value(_("Skew Y"))
self.skewy_button.setToolTip(
_("Skew/shear the selected object(s).\n"
- "The point of reference is the middle of\n"
- "the bounding box for all selected objects."))
+ "The point of reference is the middle of\n"
+ "the bounding box for all selected objects."))
self.skewy_button.setFixedWidth(90)
form1_child_1.addWidget(self.skewx_entry)
@@ -174,8 +174,8 @@ class ToolTransform(FlatCAMTool):
self.scalex_button.set_value(_("Scale X"))
self.scalex_button.setToolTip(
_("Scale the selected object(s).\n"
- "The point of reference depends on \n"
- "the Scale reference checkbox state."))
+ "The point of reference depends on \n"
+ "the Scale reference checkbox state."))
self.scalex_button.setFixedWidth(90)
self.scaley_label = QtWidgets.QLabel(_("Factor Y:"))
@@ -191,8 +191,8 @@ class ToolTransform(FlatCAMTool):
self.scaley_button.set_value(_("Scale Y"))
self.scaley_button.setToolTip(
_("Scale the selected object(s).\n"
- "The point of reference depends on \n"
- "the Scale reference checkbox state."))
+ "The point of reference depends on \n"
+ "the Scale reference checkbox state."))
self.scaley_button.setFixedWidth(90)
self.scale_link_cb = FCCheckBox()
@@ -200,7 +200,7 @@ class ToolTransform(FlatCAMTool):
self.scale_link_cb.setText(_("Link"))
self.scale_link_cb.setToolTip(
_("Scale the selected object(s)\n"
- "using the Scale Factor X for both axis."))
+ "using the Scale Factor X for both axis."))
self.scale_link_cb.setFixedWidth(70)
self.scale_zero_ref_cb = FCCheckBox()
@@ -208,9 +208,9 @@ class ToolTransform(FlatCAMTool):
self.scale_zero_ref_cb.setText(_("Scale Reference"))
self.scale_zero_ref_cb.setToolTip(
_("Scale the selected object(s)\n"
- "using the origin reference when checked,\n"
- "and the center of the biggest bounding box\n"
- "of the selected objects when unchecked."))
+ "using the origin reference when checked,\n"
+ "and the center of the biggest bounding box\n"
+ "of the selected objects when unchecked."))
form2_child_1.addWidget(self.scalex_entry)
form2_child_1.addWidget(self.scalex_button)
@@ -248,8 +248,8 @@ class ToolTransform(FlatCAMTool):
self.offx_button.set_value(_("Offset X"))
self.offx_button.setToolTip(
_("Offset the selected object(s).\n"
- "The point of reference is the middle of\n"
- "the bounding box for all selected objects.\n"))
+ "The point of reference is the middle of\n"
+ "the bounding box for all selected objects.\n"))
self.offx_button.setFixedWidth(90)
self.offy_label = QtWidgets.QLabel(_("Value Y:"))
@@ -265,8 +265,8 @@ class ToolTransform(FlatCAMTool):
self.offy_button.set_value(_("Offset Y"))
self.offy_button.setToolTip(
_("Offset the selected object(s).\n"
- "The point of reference is the middle of\n"
- "the bounding box for all selected objects.\n"))
+ "The point of reference is the middle of\n"
+ "the bounding box for all selected objects.\n"))
self.offy_button.setFixedWidth(90)
form3_child_1.addWidget(self.offx_entry)
@@ -295,7 +295,7 @@ class ToolTransform(FlatCAMTool):
self.flipx_button.set_value(_("Flip on X"))
self.flipx_button.setToolTip(
_("Flip the selected object(s) over the X axis.\n"
- "Does not create a new object.\n ")
+ "Does not create a new object.\n ")
)
self.flipx_button.setFixedWidth(100)
@@ -303,7 +303,7 @@ class ToolTransform(FlatCAMTool):
self.flipy_button.set_value(_("Flip on Y"))
self.flipy_button.setToolTip(
_("Flip the selected object(s) over the X axis.\n"
- "Does not create a new object.\n ")
+ "Does not create a new object.\n ")
)
self.flipy_button.setFixedWidth(90)
@@ -312,21 +312,21 @@ class ToolTransform(FlatCAMTool):
self.flip_ref_cb.setText(_("Ref Pt"))
self.flip_ref_cb.setToolTip(
_("Flip the selected object(s)\n"
- "around the point in Point Entry Field.\n"
- "\n"
- "The point coordinates can be captured by\n"
- "left click on canvas together with pressing\n"
- "SHIFT key. \n"
- "Then click Add button to insert coordinates.\n"
- "Or enter the coords in format (x, y) in the\n"
- "Point Entry field and click Flip on X(Y)"))
+ "around the point in Point Entry Field.\n"
+ "\n"
+ "The point coordinates can be captured by\n"
+ "left click on canvas together with pressing\n"
+ "SHIFT key. \n"
+ "Then click Add button to insert coordinates.\n"
+ "Or enter the coords in format (x, y) in the\n"
+ "Point Entry field and click Flip on X(Y)"))
self.flip_ref_cb.setFixedWidth(70)
self.flip_ref_label = QtWidgets.QLabel(_("Point:"))
self.flip_ref_label.setToolTip(
_("Coordinates in format (x, y) used as reference for mirroring.\n"
- "The 'x' in (x, y) will be used when using Flip on X and\n"
- "the 'y' in (x, y) will be used when using Flip on Y and")
+ "The 'x' in (x, y) will be used when using Flip on X and\n"
+ "the 'y' in (x, y) will be used when using Flip on Y and")
)
self.flip_ref_label.setFixedWidth(70)
self.flip_ref_entry = EvalEntry2("(0, 0)")
@@ -337,8 +337,8 @@ class ToolTransform(FlatCAMTool):
self.flip_ref_button.set_value(_("Add"))
self.flip_ref_button.setToolTip(
_("The point coordinates can be captured by\n"
- "left click on canvas together with pressing\n"
- "SHIFT key. Then click Add button to insert."))
+ "left click on canvas together with pressing\n"
+ "SHIFT key. Then click Add button to insert."))
self.flip_ref_button.setFixedWidth(90)
form4_child_hlay.addStretch()
@@ -350,8 +350,7 @@ class ToolTransform(FlatCAMTool):
form4_layout.addRow(self.flip_ref_cb)
form4_layout.addRow(self.flip_ref_label, form4_child_1)
- self.ois_flip = OptionalInputSection(self.flip_ref_cb,
- [self.flip_ref_entry, self.flip_ref_button], logic=True)
+ self.ois_flip = OptionalInputSection(self.flip_ref_cb, [self.flip_ref_entry, self.flip_ref_button], logic=True)
self.transform_lay.addStretch()
@@ -455,7 +454,7 @@ class ToolTransform(FlatCAMTool):
if self.app.defaults["tools_transform_mirror_point"]:
self.flip_ref_entry.set_value(self.app.defaults["tools_transform_mirror_point"])
else:
- self.flip_ref_entry.set_value((0,0))
+ self.flip_ref_entry.set_value((0, 0))
def on_rotate(self):
try:
@@ -466,10 +465,10 @@ class ToolTransform(FlatCAMTool):
value = float(self.rotate_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered for Rotate, "
- "use a number."))
+ "use a number."))
return
self.app.worker_task.emit({'fcn': self.on_rotate_action,
- 'params': [value]})
+ 'params': [value]})
# self.on_rotate_action(value)
return
@@ -500,7 +499,7 @@ class ToolTransform(FlatCAMTool):
value = float(self.skewx_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered for Skew X, "
- "use a number."))
+ "use a number."))
return
# self.on_skew("X", value)
@@ -518,7 +517,7 @@ class ToolTransform(FlatCAMTool):
value = float(self.skewy_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered for Skew Y, "
- "use a number."))
+ "use a number."))
return
# self.on_skew("Y", value)
@@ -536,7 +535,7 @@ class ToolTransform(FlatCAMTool):
xvalue = float(self.scalex_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered for Scale X, "
- "use a number."))
+ "use a number."))
return
# scaling to zero has no sense so we remove it, because scaling with 1 does nothing
@@ -570,7 +569,7 @@ class ToolTransform(FlatCAMTool):
yvalue = float(self.scaley_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered for Scale Y, "
- "use a number."))
+ "use a number."))
return
# scaling to zero has no sense so we remove it, because scaling with 1 does nothing
@@ -599,7 +598,7 @@ class ToolTransform(FlatCAMTool):
value = float(self.offx_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered for Offset X, "
- "use a number."))
+ "use a number."))
return
# self.on_offset("X", value)
@@ -617,7 +616,7 @@ class ToolTransform(FlatCAMTool):
value = float(self.offy_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered for Offset Y, "
- "use a number."))
+ "use a number."))
return
# self.on_offset("Y", value)