From a9c777030b6c7757ec1cb7443c35145e042bedf4 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 18 May 2020 06:48:30 +0300 Subject: [PATCH] - modified the GUI for Film and Panelize Tools --- CHANGELOG.md | 2 + flatcamTools/ToolFilm.py | 75 +++++++++++++++--------------------- flatcamTools/ToolPanelize.py | 20 +++++++--- 3 files changed, 47 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b97cbb87..748a1376 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ CHANGELOG for FlatCAM beta - moved all the parsing out of the PDF Tool to a new file ParsePDF in the flatcamParsers folder - trying to fix the pixmap load crash when running a FlatCAMScript - made the workspace label in the status bar clickable and also added a status bar message on status toggle for workspace +- modified the GUI for Film and Panelize Tools + 17.05.2020 diff --git a/flatcamTools/ToolFilm.py b/flatcamTools/ToolFilm.py index f386f0e8..0cceb34e 100644 --- a/flatcamTools/ToolFilm.py +++ b/flatcamTools/ToolFilm.py @@ -65,13 +65,8 @@ class Film(FlatCAMTool): grid0.setColumnStretch(1, 1) # Type of object for which to create the film - self.tf_type_obj_combo = FCComboBox() - self.tf_type_obj_combo.addItems([_("Gerber"), _("Geometry")]) - - # we get rid of item1 ("Excellon") as it is not suitable for creating film - # self.tf_type_obj_combo.view().setRowHidden(1, True) - self.tf_type_obj_combo.setItemIcon(0, QtGui.QIcon(self.app.resource_location + "/flatcam_icon16.png")) - self.tf_type_obj_combo.setItemIcon(1, QtGui.QIcon(self.app.resource_location + "/geometry16.png")) + self.tf_type_obj_combo = RadioSet([{'label': _('Gerber'), 'value': 'grb'}, + {'label': _('Geometry'), 'value': 'geo'}]) self.tf_type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Object Type")) self.tf_type_obj_combo_label.setToolTip( @@ -89,26 +84,12 @@ class Film(FlatCAMTool): self.tf_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.tf_object_combo.is_last = True - self.tf_object_label = QtWidgets.QLabel('%s:' % _("Film Object")) - self.tf_object_label.setToolTip( - _("Object for which to create the film.") - ) - grid0.addWidget(self.tf_object_label, 1, 0) - grid0.addWidget(self.tf_object_combo, 1, 1) + grid0.addWidget(self.tf_object_combo, 1, 0, 1, 2) # Type of Box Object to be used as an envelope for film creation # Within this we can create negative - self.tf_type_box_combo = FCComboBox() - self.tf_type_box_combo.addItems([_("Gerber"), _("Geometry")]) - - # self.tf_type_box_combo.addItem("Gerber") - # self.tf_type_box_combo.addItem("Excellon") - # self.tf_type_box_combo.addItem("Geometry") - - # we get rid of item1 ("Excellon") as it is not suitable for box when creating film - # self.tf_type_box_combo.view().setRowHidden(1, True) - self.tf_type_box_combo.setItemIcon(0, QtGui.QIcon(self.app.resource_location + "/flatcam_icon16.png")) - self.tf_type_box_combo.setItemIcon(1, QtGui.QIcon(self.app.resource_location + "/geometry16.png")) + self.tf_type_box_combo = RadioSet([{'label': _('Gerber'), 'value': 'grb'}, + {'label': _('Geometry'), 'value': 'geo'}]) self.tf_type_box_combo_label = QtWidgets.QLabel(_("Box Type:")) self.tf_type_box_combo_label.setToolTip( @@ -126,17 +107,19 @@ class Film(FlatCAMTool): self.tf_box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.tf_box_combo.is_last = True - self.tf_box_combo_label = QtWidgets.QLabel('%s:' % _("Box Object")) - self.tf_box_combo_label.setToolTip( - _("The actual object that is used as container for the\n " - "selected object for which we create the film.\n" - "Usually it is the PCB outline but it can be also the\n" - "same object for which the film is created.") - ) - grid0.addWidget(self.tf_box_combo_label, 3, 0) - grid0.addWidget(self.tf_box_combo, 3, 1) + # self.tf_box_combo_label = QtWidgets.QLabel('%s:' % _("Box Object")) + # self.tf_box_combo_label.setToolTip( + # _("The actual object that is used as container for the\n " + # "selected object for which we create the film.\n" + # "Usually it is the PCB outline but it can be also the\n" + # "same object for which the film is created.") + # ) + grid0.addWidget(self.tf_box_combo, 3, 0, 1, 2) - grid0.addWidget(QtWidgets.QLabel(''), 4, 0) + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + grid0.addWidget(separator_line, 4, 0, 1, 2) self.film_adj_label = QtWidgets.QLabel('%s' % _("Film Adjustments")) self.film_adj_label.setToolTip( @@ -533,28 +516,28 @@ class Film(FlatCAMTool): # ## Signals self.film_object_button.clicked.connect(self.on_film_creation) - self.tf_type_obj_combo.currentIndexChanged.connect(self.on_type_obj_index_changed) - self.tf_type_box_combo.currentIndexChanged.connect(self.on_type_box_index_changed) + self.tf_type_obj_combo.activated_custom.connect(self.on_type_obj_index_changed) + self.tf_type_box_combo.activated_custom.connect(self.on_type_box_index_changed) self.film_type.activated_custom.connect(self.on_film_type) self.source_punch.activated_custom.connect(self.on_punch_source) self.file_type_radio.activated_custom.connect(self.on_file_type) self.reset_button.clicked.connect(self.set_tool_ui) - def on_type_obj_index_changed(self): - obj_type = self.tf_type_obj_combo.currentIndex() + def on_type_obj_index_changed(self, val): + obj_type = 2 if val == 'geo' else 0 self.tf_object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) self.tf_object_combo.setCurrentIndex(0) self.tf_object_combo.obj_type = { - _("Gerber"): "Gerber", _("Geometry"): "Geometry" + "grb": "gerber", "geo": "geometry" }[self.tf_type_obj_combo.get_value()] - def on_type_box_index_changed(self): - obj_type = self.tf_type_box_combo.currentIndex() + def on_type_box_index_changed(self, val): + obj_type = 2 if val == 'geo' else 0 self.tf_box_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) self.tf_box_combo.setCurrentIndex(0) self.tf_box_combo.obj_type = { - _("Gerber"): "Gerber", _("Geometry"): "Geometry" + "grb": "gerber", "geo": "geometry" }[self.tf_type_obj_combo.get_value()] def run(self, toggle=True): @@ -618,9 +601,11 @@ class Film(FlatCAMTool): self.orientation_radio.set_value(self.app.defaults["tools_film_orientation"]) self.pagesize_combo.set_value(self.app.defaults["tools_film_pagesize"]) + self.tf_type_obj_combo.set_value('grb') + self.tf_type_box_combo.set_value('grb') # run once to update the obj_type attribute in the FCCombobox so the last object is showed in cb - self.on_type_obj_index_changed() - self.on_type_box_index_changed() + self.on_type_obj_index_changed(val='grb') + self.on_type_box_index_changed(val='grb') def on_film_type(self, val): type_of_film = val @@ -659,7 +644,7 @@ class Film(FlatCAMTool): self.exc_label.show() self.exc_combo.show() - if val == 'pad' and self.tf_type_obj_combo.currentText() == 'Geometry': + if val == 'pad' and self.tf_type_obj_combo.get_value() == 'geo': self.source_punch.set_value('exc') self.app.inform.emit('[WARNING_NOTCL] %s' % _("Using the Pad center does not work on Geometry objects. " "Only a Gerber object has pads.")) diff --git a/flatcamTools/ToolPanelize.py b/flatcamTools/ToolPanelize.py index 8995da05..ed9ded7a 100644 --- a/flatcamTools/ToolPanelize.py +++ b/flatcamTools/ToolPanelize.py @@ -49,8 +49,6 @@ class Panelize(FlatCAMTool): """) self.layout.addWidget(title_label) - self.layout.addWidget(QtWidgets.QLabel('')) - self.object_label = QtWidgets.QLabel('%s:' % _("Source Object")) self.object_label.setToolTip( _("Specify the type of object to be panelized\n" @@ -90,7 +88,6 @@ class Panelize(FlatCAMTool): "be duplicated in an array of rows and columns.") ) form_layout_0.addRow(self.object_combo) - form_layout_0.addRow(QtWidgets.QLabel("")) # Form Layout form_layout = QtWidgets.QFormLayout() @@ -142,7 +139,11 @@ class Panelize(FlatCAMTool): "selected object that is to be panelized.") ) form_layout.addRow(self.box_combo) - form_layout.addRow(QtWidgets.QLabel("")) + + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + form_layout.addRow(separator_line) panel_data_label = QtWidgets.QLabel("%s:" % _("Panel Data")) panel_data_label.setToolTip( @@ -198,7 +199,11 @@ class Panelize(FlatCAMTool): _("Number of rows of the desired panel") ) form_layout.addRow(self.rows_label, self.rows) - form_layout.addRow(QtWidgets.QLabel("")) + + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + form_layout.addRow(separator_line) # Type of resulting Panel object self.panel_type_radio = RadioSet([{'label': _('Gerber'), 'value': 'gerber'}, @@ -248,6 +253,11 @@ class Panelize(FlatCAMTool): self.constrain_sel = OptionalInputSection( self.constrain_cb, [self.x_width_lbl, self.x_width_entry, self.y_height_lbl, self.y_height_entry]) + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + form_layout.addRow(separator_line) + # Buttons self.panelize_object_button = QtWidgets.QPushButton(_("Panelize Object")) self.panelize_object_button.setToolTip(