- some PEP8 changes in FlatCAMApp.py
This commit is contained in:
parent
ee3b38327e
commit
d5f74ae8b4
144
FlatCAMApp.py
144
FlatCAMApp.py
|
@ -6,7 +6,9 @@
|
|||
# MIT Licence #
|
||||
# ###########################################################
|
||||
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import urllib.error
|
||||
import getopt
|
||||
import random
|
||||
import simplejson as json
|
||||
|
@ -19,7 +21,6 @@ import subprocess
|
|||
import tkinter as tk
|
||||
from PyQt5 import QtPrintSupport
|
||||
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
from contextlib import contextmanager
|
||||
import gc
|
||||
|
||||
|
@ -221,7 +222,7 @@ class App(QtCore.QObject):
|
|||
os.makedirs(os.path.join(self.data_path, 'postprocessors'))
|
||||
App.log.debug('Created data postprocessors folder: ' + os.path.join(self.data_path, 'postprocessors'))
|
||||
|
||||
self.postprocessorpaths = os.path.join(self.data_path,'postprocessors')
|
||||
self.postprocessorpaths = os.path.join(self.data_path, 'postprocessors')
|
||||
if not os.path.exists(self.postprocessorpaths):
|
||||
os.makedirs(self.postprocessorpaths)
|
||||
App.log.debug('Created postprocessors folder: ' + self.postprocessorpaths)
|
||||
|
@ -397,10 +398,14 @@ class App(QtCore.QObject):
|
|||
# Excellon General
|
||||
"excellon_plot": self.ui.excellon_defaults_form.excellon_gen_group.plot_cb,
|
||||
"excellon_solid": self.ui.excellon_defaults_form.excellon_gen_group.solid_cb,
|
||||
"excellon_format_upper_in": self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_in_entry,
|
||||
"excellon_format_lower_in": self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_in_entry,
|
||||
"excellon_format_upper_mm": self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_mm_entry,
|
||||
"excellon_format_lower_mm": self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_mm_entry,
|
||||
"excellon_format_upper_in":
|
||||
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_in_entry,
|
||||
"excellon_format_lower_in":
|
||||
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_in_entry,
|
||||
"excellon_format_upper_mm":
|
||||
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_mm_entry,
|
||||
"excellon_format_lower_mm":
|
||||
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_mm_entry,
|
||||
"excellon_zeros": self.ui.excellon_defaults_form.excellon_gen_group.excellon_zeros_radio,
|
||||
"excellon_units": self.ui.excellon_defaults_form.excellon_gen_group.excellon_units_radio,
|
||||
"excellon_optimization_type": self.ui.excellon_defaults_form.excellon_gen_group.excellon_optimization_radio,
|
||||
|
@ -1516,7 +1521,6 @@ class App(QtCore.QObject):
|
|||
self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.connect(
|
||||
lambda: self.on_toggle_units(no_pref=False))
|
||||
|
||||
|
||||
# ##############################
|
||||
# ### GUI PREFERENCES SIGNALS ##
|
||||
# ##############################
|
||||
|
@ -2517,7 +2521,7 @@ class App(QtCore.QObject):
|
|||
:param show: Opens the shell.
|
||||
:param error: Shows the message as an error.
|
||||
:param warning: Shows the message as an warning.
|
||||
:param warning: Shows the message as an success.
|
||||
:param success: Shows the message as an success.
|
||||
:param selected: Indicate that something was selected on canvas
|
||||
:return: None
|
||||
"""
|
||||
|
@ -4153,7 +4157,8 @@ class App(QtCore.QObject):
|
|||
|
||||
# Setting plot colors handlers
|
||||
def on_pf_color_entry(self):
|
||||
self.defaults['global_plot_fill'] = self.ui.general_defaults_form.general_gui_group.pf_color_entry.get_value()[:7] + \
|
||||
self.defaults['global_plot_fill'] = \
|
||||
self.ui.general_defaults_form.general_gui_group.pf_color_entry.get_value()[:7] + \
|
||||
self.defaults['global_plot_fill'][7:9]
|
||||
self.ui.general_defaults_form.general_gui_group.pf_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.defaults['global_plot_fill'])[:7])
|
||||
|
@ -4177,9 +4182,11 @@ class App(QtCore.QObject):
|
|||
def on_pf_color_spinner(self):
|
||||
spinner_value = self.ui.general_defaults_form.general_gui_group.pf_color_alpha_spinner.value()
|
||||
self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.setValue(spinner_value)
|
||||
self.defaults['global_plot_fill'] = self.defaults['global_plot_fill'][:7] + \
|
||||
self.defaults['global_plot_fill'] = \
|
||||
self.defaults['global_plot_fill'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
self.defaults['global_plot_line'] = self.defaults['global_plot_line'][:7] + \
|
||||
self.defaults['global_plot_line'] = \
|
||||
self.defaults['global_plot_line'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
|
||||
def on_pf_color_slider(self):
|
||||
|
@ -4187,7 +4194,8 @@ class App(QtCore.QObject):
|
|||
self.ui.general_defaults_form.general_gui_group.pf_color_alpha_spinner.setValue(slider_value)
|
||||
|
||||
def on_pl_color_entry(self):
|
||||
self.defaults['global_plot_line'] = self.ui.general_defaults_form.general_gui_group.pl_color_entry.get_value()[:7] + \
|
||||
self.defaults['global_plot_line'] = \
|
||||
self.ui.general_defaults_form.general_gui_group.pl_color_entry.get_value()[:7] + \
|
||||
self.defaults['global_plot_line'][7:9]
|
||||
self.ui.general_defaults_form.general_gui_group.pl_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.defaults['global_plot_line'])[:7])
|
||||
|
@ -4211,7 +4219,8 @@ class App(QtCore.QObject):
|
|||
|
||||
# Setting selection colors (left - right) handlers
|
||||
def on_sf_color_entry(self):
|
||||
self.defaults['global_sel_fill'] = self.ui.general_defaults_form.general_gui_group.sf_color_entry.get_value()[:7] + \
|
||||
self.defaults['global_sel_fill'] = \
|
||||
self.ui.general_defaults_form.general_gui_group.sf_color_entry.get_value()[:7] + \
|
||||
self.defaults['global_sel_fill'][7:9]
|
||||
self.ui.general_defaults_form.general_gui_group.sf_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.defaults['global_sel_fill'])[:7])
|
||||
|
@ -4235,9 +4244,11 @@ class App(QtCore.QObject):
|
|||
def on_sf_color_spinner(self):
|
||||
spinner_value = self.ui.general_defaults_form.general_gui_group.sf_color_alpha_spinner.value()
|
||||
self.ui.general_defaults_form.general_gui_group.sf_color_alpha_slider.setValue(spinner_value)
|
||||
self.defaults['global_sel_fill'] = self.defaults['global_sel_fill'][:7] + \
|
||||
self.defaults['global_sel_fill'] = \
|
||||
self.defaults['global_sel_fill'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
self.defaults['global_sel_line'] = self.defaults['global_sel_line'][:7] + \
|
||||
self.defaults['global_sel_line'] = \
|
||||
self.defaults['global_sel_line'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
|
||||
def on_sf_color_slider(self):
|
||||
|
@ -4245,7 +4256,8 @@ class App(QtCore.QObject):
|
|||
self.ui.general_defaults_form.general_gui_group.sf_color_alpha_spinner.setValue(slider_value)
|
||||
|
||||
def on_sl_color_entry(self):
|
||||
self.defaults['global_sel_line'] = self.ui.general_defaults_form.general_gui_group.sl_color_entry.get_value()[:7] + \
|
||||
self.defaults['global_sel_line'] = \
|
||||
self.ui.general_defaults_form.general_gui_group.sl_color_entry.get_value()[:7] + \
|
||||
self.defaults['global_sel_line'][7:9]
|
||||
self.ui.general_defaults_form.general_gui_group.sl_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.defaults['global_sel_line'])[:7])
|
||||
|
@ -4292,9 +4304,11 @@ class App(QtCore.QObject):
|
|||
def on_alt_sf_color_spinner(self):
|
||||
spinner_value = self.ui.general_defaults_form.general_gui_group.alt_sf_color_alpha_spinner.value()
|
||||
self.ui.general_defaults_form.general_gui_group.alt_sf_color_alpha_slider.setValue(spinner_value)
|
||||
self.defaults['global_alt_sel_fill'] = self.defaults['global_alt_sel_fill'][:7] + \
|
||||
self.defaults['global_alt_sel_fill'] = \
|
||||
self.defaults['global_alt_sel_fill'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
self.defaults['global_alt_sel_line'] = self.defaults['global_alt_sel_line'][:7] + \
|
||||
self.defaults['global_alt_sel_line'] = \
|
||||
self.defaults['global_alt_sel_line'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
|
||||
def on_alt_sf_color_slider(self):
|
||||
|
@ -4816,7 +4830,6 @@ class App(QtCore.QObject):
|
|||
self.inform.emit(
|
||||
_("[WARNING_NOTCL] Adding Tool cancelled ..."))
|
||||
|
||||
|
||||
# It's meant to delete tools in tool tables via a 'Delete' shortcut key but only if certain conditions are met
|
||||
# See description bellow.
|
||||
def on_delete_keypress(self):
|
||||
|
@ -4995,9 +5008,9 @@ class App(QtCore.QObject):
|
|||
try:
|
||||
if isinstance(obj, FlatCAMExcellon):
|
||||
self.new_object("excellon", str(obj_name) + "_copy", initialize_excellon)
|
||||
elif isinstance(obj,FlatCAMGerber):
|
||||
elif isinstance(obj, FlatCAMGerber):
|
||||
self.new_object("gerber", str(obj_name) + "_copy", initialize)
|
||||
elif isinstance(obj,FlatCAMGeometry):
|
||||
elif isinstance(obj, FlatCAMGeometry):
|
||||
self.new_object("geometry", str(obj_name) + "_copy", initialize)
|
||||
except Exception as e:
|
||||
return "Operation failed: %s" % str(e)
|
||||
|
@ -5039,9 +5052,9 @@ class App(QtCore.QObject):
|
|||
try:
|
||||
if isinstance(obj, FlatCAMExcellon):
|
||||
self.new_object("excellon", str(obj_name) + custom_name, initialize_excellon)
|
||||
elif isinstance(obj,FlatCAMGerber):
|
||||
elif isinstance(obj, FlatCAMGerber):
|
||||
self.new_object("gerber", str(obj_name) + custom_name, initialize_gerber)
|
||||
elif isinstance(obj,FlatCAMGeometry):
|
||||
elif isinstance(obj, FlatCAMGeometry):
|
||||
self.new_object("geometry", str(obj_name) + custom_name, initialize_geometry)
|
||||
except Exception as e:
|
||||
return "Operation failed: %s" % str(e)
|
||||
|
@ -5176,8 +5189,8 @@ class App(QtCore.QObject):
|
|||
return "Operation failed: %s" % str(e)
|
||||
|
||||
def on_set_zero_click(self, event):
|
||||
#this function will be available only for mouse left click
|
||||
pos =[]
|
||||
# this function will be available only for mouse left click
|
||||
pos = []
|
||||
pos_canvas = self.plotcanvas.vispy_canvas.translate_coords(event.pos)
|
||||
if event.button == 1:
|
||||
if self.grid_status() == True:
|
||||
|
@ -5188,7 +5201,7 @@ class App(QtCore.QObject):
|
|||
x = 0 - pos[0]
|
||||
y = 0 - pos[1]
|
||||
for obj in self.collection.get_list():
|
||||
obj.offset((x,y))
|
||||
obj.offset((x, y))
|
||||
self.object_changed.emit(obj)
|
||||
obj.plot()
|
||||
# Update the object bounding box options
|
||||
|
@ -5974,7 +5987,7 @@ class App(QtCore.QObject):
|
|||
else:
|
||||
# case when there is only an object under the click and we toggle it
|
||||
if len(objects_under_the_click_list) == 1:
|
||||
if self.collection.get_active() is None :
|
||||
if self.collection.get_active() is None:
|
||||
self.collection.set_active(objects_under_the_click_list[0])
|
||||
# create the selection box around the selected object
|
||||
curr_sel_obj = self.collection.get_active()
|
||||
|
@ -6146,8 +6159,12 @@ class App(QtCore.QObject):
|
|||
face = Color(self.defaults['global_sel_fill'], alpha=0.2)
|
||||
outline = Color(self.defaults['global_sel_line'], alpha=0.8)
|
||||
|
||||
self.sel_objects_list.append(self.move_tool.sel_shapes.add(sel_rect, color=outline,
|
||||
face_color=face, update=True, layer=0, tolerance=None))
|
||||
self.sel_objects_list.append(self.move_tool.sel_shapes.add(sel_rect,
|
||||
color=outline,
|
||||
face_color=face,
|
||||
update=True,
|
||||
layer=0,
|
||||
tolerance=None))
|
||||
|
||||
def draw_moving_selection_shape(self, old_coords, coords, **kwargs):
|
||||
"""
|
||||
|
@ -6417,7 +6434,7 @@ class App(QtCore.QObject):
|
|||
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Open Project"),
|
||||
directory=self.get_last_folder(), filter=_filter_)
|
||||
except TypeError:
|
||||
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Open Project"), filter = _filter_)
|
||||
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Open Project"), filter=_filter_)
|
||||
|
||||
# The Qt methods above will return a QString which can cause problems later.
|
||||
# So far json.dump() will fail to serialize it.
|
||||
|
@ -6448,7 +6465,7 @@ class App(QtCore.QObject):
|
|||
directory=self.data_path, filter=_filter_)
|
||||
except TypeError:
|
||||
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Open Configuration File"),
|
||||
filter = _filter_)
|
||||
filter=_filter_)
|
||||
|
||||
if filename == "":
|
||||
self.inform.emit(_("[WARNING_NOTCL] Open Config cancelled."))
|
||||
|
@ -6490,14 +6507,14 @@ class App(QtCore.QObject):
|
|||
|
||||
name = obj.options["name"]
|
||||
|
||||
filter = "SVG File (*.svg);;All Files (*.*)"
|
||||
_filter = "SVG File (*.svg);;All Files (*.*)"
|
||||
try:
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(
|
||||
caption=_("Export SVG"),
|
||||
directory=self.get_last_save_folder() + '/' + str(name),
|
||||
filter=filter)
|
||||
filter=_filter)
|
||||
except TypeError:
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(caption=_("Export SVG"), filter=filter)
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(caption=_("Export SVG"), filter=_filter)
|
||||
|
||||
filename = str(filename)
|
||||
|
||||
|
@ -6565,14 +6582,14 @@ class App(QtCore.QObject):
|
|||
|
||||
name = self.collection.get_active().options["name"]
|
||||
|
||||
filter = "Gerber File (*.GBR);;Gerber File (*.GRB);;All Files (*.*)"
|
||||
_filter = "Gerber File (*.GBR);;Gerber File (*.GRB);;All Files (*.*)"
|
||||
try:
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(
|
||||
caption="Save Gerber source file",
|
||||
directory=self.get_last_save_folder() + '/' + name,
|
||||
filter=filter)
|
||||
filter=_filter)
|
||||
except TypeError:
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(caption=_("Save Gerber source file"), filter=filter)
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(caption=_("Save Gerber source file"), filter=_filter)
|
||||
|
||||
filename = str(filename)
|
||||
|
||||
|
@ -6606,14 +6623,14 @@ class App(QtCore.QObject):
|
|||
|
||||
name = self.collection.get_active().options["name"]
|
||||
|
||||
filter = "Excellon File (*.DRL);;Excellon File (*.TXT);;All Files (*.*)"
|
||||
_filter = "Excellon File (*.DRL);;Excellon File (*.TXT);;All Files (*.*)"
|
||||
try:
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(
|
||||
caption=_("Save Excellon source file"),
|
||||
directory=self.get_last_save_folder() + '/' + name,
|
||||
filter=filter)
|
||||
filter=_filter)
|
||||
except TypeError:
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(caption=_("Save Excellon source file"), filter=filter)
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(caption=_("Save Excellon source file"), filter=_filter)
|
||||
|
||||
filename = str(filename)
|
||||
|
||||
|
@ -6647,14 +6664,14 @@ class App(QtCore.QObject):
|
|||
|
||||
name = self.collection.get_active().options["name"]
|
||||
|
||||
filter = "Excellon File (*.DRL);;Excellon File (*.TXT);;All Files (*.*)"
|
||||
_filter = "Excellon File (*.DRL);;Excellon File (*.TXT);;All Files (*.*)"
|
||||
try:
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(
|
||||
caption=_("Export Excellon"),
|
||||
directory=self.get_last_save_folder() + '/' + name,
|
||||
filter=filter)
|
||||
filter=_filter)
|
||||
except TypeError:
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(caption=_("Export Excellon"), filter=filter)
|
||||
filename, _f = QtWidgets.QFileDialog.getSaveFileName(caption=_("Export Excellon"), filter=_filter)
|
||||
|
||||
filename = str(filename)
|
||||
|
||||
|
@ -6825,9 +6842,9 @@ class App(QtCore.QObject):
|
|||
self.worker_task.emit({'fcn': self.import_dxf,
|
||||
'params': [filename, type_of_obj]})
|
||||
|
||||
# ################################################################################################################ ##
|
||||
# # ## The following section has the functions that are displayed and call the Editor tab CNCJob Tab ############### ##
|
||||
# ################################################################################################################ ##
|
||||
# ###############################################################################################################
|
||||
# ### The following section has the functions that are displayed and call the Editor tab CNCJob Tab #############
|
||||
# ###############################################################################################################
|
||||
|
||||
def init_code_editor(self, name):
|
||||
# Signals section
|
||||
|
@ -7450,7 +7467,7 @@ class App(QtCore.QObject):
|
|||
ewhole = self.defaults["excellon_exp_integer"]
|
||||
efract = self.defaults["excellon_exp_decimals"]
|
||||
ezeros = self.defaults["excellon_exp_zeros"]
|
||||
eformat = self.defaults[ "excellon_exp_format"]
|
||||
eformat = self.defaults["excellon_exp_format"]
|
||||
|
||||
fc_units = self.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
if fc_units == 'MM':
|
||||
|
@ -8629,35 +8646,6 @@ The normal flow when working in FlatCAM is the following:</span></p>
|
|||
|
||||
self.ui.selected_scroll_area.setWidget(sel_title)
|
||||
|
||||
# tool_title = QtWidgets.QTextEdit(
|
||||
# '<b>Shortcut Key List</b>')
|
||||
# tool_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
|
||||
# tool_title.setFrameStyle(QtWidgets.QFrame.NoFrame)
|
||||
# # font = self.sel_title.font()
|
||||
# # font.setPointSize(12)
|
||||
# # self.sel_title.setFont(font)
|
||||
#
|
||||
# tool_text = '''
|
||||
# <p><span style="font-size:14px"><strong>Tool Tab - Choose an Item in Tools Menu</strong></span></p>
|
||||
#
|
||||
# <p><span style="font-size:10px"><strong>Details</strong>:<br />
|
||||
# Some of the functionality of FlatCAM have been implemented as tools (a sort of plugins). </span></p>
|
||||
#
|
||||
# <p><span style="font-size:10px">Most of the tools are accessible through the Tools menu or by using the associated shortcut keys.<br />
|
||||
# Each such a tool, if it needs an object to be used as a source it will provide the way to select this object(s) through a series of comboboxes. The result of using a tool is either a Geometry, an information that can be used in the app or it can be a file that can be saved.</span></p>
|
||||
#
|
||||
# <ol>
|
||||
# </ol>
|
||||
#
|
||||
# <p><span style="font-size:10px">A list of key shortcuts is available through an menu entry in <strong>Help -> Shortcuts List</strong> or through it's own key shortcut: '`' (key left to 1).</span></p>
|
||||
#
|
||||
# '''
|
||||
#
|
||||
# tool_title.setText(tool_text)
|
||||
# tool_title.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
|
||||
#
|
||||
# self.ui.tool_scroll_area.setWidget(tool_title)
|
||||
|
||||
def setup_obj_classes(self):
|
||||
"""
|
||||
Sets up application specifics on the FlatCAMObj class.
|
||||
|
@ -8939,7 +8927,7 @@ The normal flow when working in FlatCAM is the following:</span></p>
|
|||
to_quit = quit
|
||||
self.save_timer = QtCore.QTimer()
|
||||
self.save_timer.setInterval(delay)
|
||||
self.save_timer.timeout.connect(lambda : self.check_project_file_size(filename=filename, quit=to_quit))
|
||||
self.save_timer.timeout.connect(lambda: self.check_project_file_size(filename=filename, quit=to_quit))
|
||||
self.save_timer.start()
|
||||
|
||||
def check_project_file_size(self, filename, quit=None):
|
||||
|
|
|
@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
|
|||
13.08.2019
|
||||
|
||||
- added new option in ToolSub: the ability to close (or not) the resulting paths when using tool on Geometry objects. Added also a new category in the Edit -> Preferences -> Tools, the Substractor Tool Options
|
||||
- some PEP8 changes in FlatCAMApp.py
|
||||
|
||||
12.08.2019
|
||||
|
||||
|
|
Loading…
Reference in New Issue