diff --git a/CHANGELOG.md b/CHANGELOG.md index 21ff6475..0729ff66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ CHANGELOG for FlatCAM beta - updated the language strings - on Coppper Thieving Plugin some UI updates - updated the GCGridLayout GUi element to automatically stretch the first column but offered also configuration; updated the use throughout the app +- in Copper Thieving Plugin more UI changes +- in GUI Elements the FCGridLayout has now a class method that allow adjusting column size in multiple grid layouts to the highest on that column; still work to d oto take care of the situation when widgets are spanning multiple cells 8.09.2021 diff --git a/appGUI/GUIElements.py b/appGUI/GUIElements.py index 9e1968f8..c84c0112 100644 --- a/appGUI/GUIElements.py +++ b/appGUI/GUIElements.py @@ -10,6 +10,7 @@ # File Modified (major mod): Marius Adrian Stanciu # # Date: 3/10/2019 # # ########################################################## +import typing from PyQt6 import QtGui, QtCore, QtWidgets from PyQt6.QtCore import Qt, pyqtSlot, pyqtSignal @@ -979,7 +980,8 @@ class FCSpinner(QtWidgets.QSpinBox): self.menu = None if policy: - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Ignored, QtWidgets.QSizePolicy.Policy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Ignored, + QtWidgets.QSizePolicy.Policy.Preferred) self.setSizePolicy(sizePolicy) def eventFilter(self, object, event): @@ -1244,7 +1246,8 @@ class FCSliderWithDoubleSpinner(QtWidgets.QFrame): self.spinner.set_step(step) self.spinner.setMinimumWidth(70) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, + QtWidgets.QSizePolicy.Policy.Preferred) self.spinner.setSizePolicy(sizePolicy) self.layout = QtWidgets.QHBoxLayout() @@ -1309,7 +1312,8 @@ class FCButtonWithDoubleSpinner(QtWidgets.QFrame): self.spinner.set_precision(decimals) self.spinner.setMinimumWidth(70) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, + QtWidgets.QSizePolicy.Policy.Preferred) self.spinner.setSizePolicy(sizePolicy) self.layout = QtWidgets.QHBoxLayout() @@ -4899,7 +4903,7 @@ class FCZeroAxes(QtWidgets.QFrame): self.setLineWidth(1) # Zero the axes - grbl_zero_grid = FCGridLayout(v_spacing=5, h_spacing=3, c_stretch=[0,0]) + grbl_zero_grid = FCGridLayout(v_spacing=5, h_spacing=3, c_stretch=[0, 0]) grbl_zero_grid.setContentsMargins(2, 4, 2, 4) # grbl_zero_grid.setRowStretch(4, 1) self.setLayout(grbl_zero_grid) @@ -5268,9 +5272,6 @@ class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon): class FCGridLayout(QtWidgets.QGridLayout): - """ - This class create the Sys Tray icon for the app - """ def __init__(self, *args, v_spacing=None, h_spacing=None, c_stretch=None, margins=None, parent=None): """ @@ -5308,6 +5309,46 @@ class FCGridLayout(QtWidgets.QGridLayout): self.blockSignals(False) + @classmethod + def set_common_column_size(cls, grid_layout_list, column, only_wdg=None): + """ + + :param grid_layout_list: list of FCGridLayout + :type grid_layout_list list + :param column: the column for which to make the size the same in all grid_grid_layout_list; int + :param only_wdg: use only Widgets of this kind + :type only_wdg: + :return: + """ + + def get_max_cell_width(layout, column_no, only_this_widget=None): + width_list = [] + for row in range(layout.rowCount()): + item = layout.itemAtPosition(row, column_no) + if item: + item_width = item.sizeHint().width() + + if not only_this_widget: + width_list.append(item_width) + elif isinstance(item.widget(), only_this_widget): + width_list.append(item_width) + + return max(width_list) if width_list else None + + # find the maximum width for all grid layouts on the specified column + all_col_size_list = [] + for grid_lay in grid_layout_list: + lay_m_size = get_max_cell_width(grid_lay, column_no=column, only_this_widget=only_wdg) + if lay_m_size: + all_col_size_list.append(lay_m_size) + + max_size = max(all_col_size_list) + + if max_size: + # now set the found maximum size to all grid layouts on the specified column + for grid_lay in grid_layout_list: + grid_lay.setColumnMinimumWidth(column, max_size) + def message_dialog(title, message, kind="info", parent=None): """ diff --git a/appPlugins/ToolAlignObjects.py b/appPlugins/ToolAlignObjects.py index b4ce889d..73d7c1fe 100644 --- a/appPlugins/ToolAlignObjects.py +++ b/appPlugins/ToolAlignObjects.py @@ -531,6 +531,8 @@ class AlignUI: grid2.addWidget(self.a_type_lbl, 0, 0, 1, 2) grid2.addWidget(self.a_type_radio, 2, 0, 1, 2) + # FCGridLayout.set_common_column_size([grid0, grid1, grid2], 0, FCLabel) + # Buttons self.align_object_button = FCButton(_("Align Object")) self.align_object_button.setIcon(QtGui.QIcon(self.app.resource_location + '/align16.png')) diff --git a/appPlugins/ToolCopperThieving.py b/appPlugins/ToolCopperThieving.py index acb38a03..a159cbbe 100644 --- a/appPlugins/ToolCopperThieving.py +++ b/appPlugins/ToolCopperThieving.py @@ -519,7 +519,7 @@ class ToolCopperThieving(AppTool): # "%.4f    " % (self.app.dx, self.app.dy)) self.app.ui.update_location_labels(self.app.dx, self.app.dy, curr_pos[0], curr_pos[1]) - units = self.app.defaults["units"].lower() + # units = self.app.defaults["units"].lower() # self.app.plotcanvas.text_hud.text = \ # 'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX: \t{:<.4f} [{:s}]\nY: \t{:<.4f} [{:s}]'.format( # self.app.dx, units, self.app.dy, units, curr_pos[0], units, curr_pos[1], units) @@ -756,7 +756,7 @@ class ToolCopperThieving(AppTool): # ######################################################################################################### tool_obj.app.proc_container.update_view_text(' %s' % _("Create geometry")) - if fill_type == 1 or fill_type == 2: # 'dot' or 'square' + if fill_type == 1 or fill_type == 2: # 'dot' or 'square' # build the MultiPolygon of dots/squares that will fill the entire bounding box thieving_list = [] @@ -1368,7 +1368,8 @@ class ThievingUI: self.area_entry.set_range(0.0, 10000.0000) self.area_entry.set_precision(self.decimals) self.area_entry.setSingleStep(0.1) - self.area_entry.setSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Preferred) + self.area_entry.setSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, + QtWidgets.QSizePolicy.Policy.Preferred) if self.units.upper() == 'MM': units_area_label = FCLabel('%s2' % _("mm")) @@ -1766,10 +1767,13 @@ class ThievingUI: # {"label": _("None"), "value": "n"} # ], orientation='vertical', stretch=False) self.ppm_choice_combo = FCComboBox2() - self.ppm_choice_combo.addItems([_("Both"),_('Thieving'), _("Robber bar"), _("None")]) + self.ppm_choice_combo.addItems([_("Both"), _('Thieving'), _("Robber bar"), _("None")]) grid_lay_2.addWidget(self.ppm_choice_label, 6, 0) grid_lay_2.addWidget(self.ppm_choice_combo, 6, 1, 1, 2) + # FCGridLayout.set_common_column_size( + # [i_grid_lay, grid_lay, grid_lay_1, grid_lay_2, dots_grid, squares_grid, lines_grid], 0, FCLabel) + # ############################################################################################################# # ## Pattern Plating Mask Button # ############################################################################################################# diff --git a/appPlugins/ToolPanelize.py b/appPlugins/ToolPanelize.py index be2afc3b..3b1a1748 100644 --- a/appPlugins/ToolPanelize.py +++ b/appPlugins/ToolPanelize.py @@ -1369,6 +1369,8 @@ class PanelizeUI: self.separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) grid3.addWidget(self.separator_line, 10, 0, 1, 2) + # FCGridLayout.set_common_column_size([grid0, grid1, grid2, grid3], 0, FCLabel) + # ############################################################################################################# # Generate Panel Button # #############################################################################################################