def create_boards(self): '''Creates the layout for boards preferences''' w = QtWidgets.QWidget() vbox = QtWidgets.QVBoxLayout() us = self.units.units_string(withParens=True) self.le_board_width_label = QtWidgets.QLabel( self.transl.tr('Initial Board Width{}:').format(us)) self.le_board_width = QtWidgets.QLineEdit(w) self.le_board_width.setFixedWidth(self.line_edit_width) self.le_board_width.editingFinished.connect(self._on_board_width) tt = self.transl.tr('The initial board width when pyRouterJig starts.') grid = form_line(self.le_board_width_label, self.le_board_width, tt) vbox.addLayout(grid) self.le_db_thick_label = QtWidgets.QLabel( self.transl.tr('Initial Double Board Thickness{}:').format(us)) self.le_db_thick = QtWidgets.QLineEdit(w) self.le_db_thick.setFixedWidth(self.line_edit_width) self.le_db_thick.editingFinished.connect(self._on_db_thick) tt = self.transl.tr( 'The initial double-board thickness when pyRouterJig starts.') grid = form_line(self.le_db_thick_label, self.le_db_thick, tt) vbox.addLayout(grid) (woods, patterns) = qt_utils.create_wood_dict(self.config.wood_images, self.transl) woodnames = list(woods.keys()) woodnames.extend(patterns.keys()) self.cb_wood_label = QtWidgets.QLabel( self.transl.tr('Default Wood Fill:')) self.cb_wood = QtWidgets.QComboBox(self) self.set_wood_combobox() self.cb_wood.activated.connect(self._on_wood) tt = self.transl.tr('The default wood fill for each board.') grid = form_line(self.cb_wood_label, self.cb_wood, tt) vbox.addLayout(grid) self.le_wood_images_label = QtWidgets.QLabel( self.transl.tr('Wood Images Folder:')) self.le_wood_images = QtWidgets.QLineEdit(w) self.le_wood_images.editingFinished.connect(self._on_wood_images) tt = self.transl.tr('Location of wood images.') self.le_wood_images.setToolTip(tt) grid = QtWidgets.QGridLayout() grid.addWidget(qt_utils.create_vline(), 0, 0, 4, 1) grid.addWidget(qt_utils.create_vline(), 0, 3, 4, 1) grid.addWidget(qt_utils.create_hline(), 0, 0, 1, 4) grid.addWidget(self.le_wood_images_label, 1, 1) grid.addWidget(self.le_wood_images, 2, 1) grid.addWidget(qt_utils.create_hline(), 3, 0, 1, 4) vbox.addLayout(grid) vbox.addWidget(self.le_wood_images) vbox.addStretch(1) w.setLayout(vbox) return w
def create_boards(self): '''Creates the layout for boards preferences''' w = QtGui.QWidget() vbox = QtGui.QVBoxLayout() us = self.units.units_string(withParens=True) self.le_board_width_label = QtGui.QLabel('Initial Board Width{}:'.format(us)) self.le_board_width = QtGui.QLineEdit(w) self.le_board_width.setFixedWidth(self.line_edit_width) self.le_board_width.editingFinished.connect(self._on_board_width) tt = 'The initial board width when pyRouterJig starts.' grid = form_line(self.le_board_width_label, self.le_board_width, tt) vbox.addLayout(grid) self.le_db_thick_label = QtGui.QLabel('Initial Double Board Thickness{}:'.format(us)) self.le_db_thick = QtGui.QLineEdit(w) self.le_db_thick.setFixedWidth(self.line_edit_width) self.le_db_thick.editingFinished.connect(self._on_db_thick) tt = 'The initial double-board thickness when pyRouterJig starts.' grid = form_line(self.le_db_thick_label, self.le_db_thick, tt) vbox.addLayout(grid) (woods, patterns) = qt_utils.create_wood_dict(self.config.wood_images) woodnames = woods.keys() woodnames.extend(patterns.keys()) self.cb_wood_label = QtGui.QLabel('Default Wood Fill:') self.cb_wood = QtGui.QComboBox(self) self.set_wood_combobox() self.cb_wood.activated.connect(self._on_wood) tt = 'The default wood fill for each board.' grid = form_line(self.cb_wood_label, self.cb_wood, tt) vbox.addLayout(grid) self.le_wood_images_label = QtGui.QLabel('Wood Images Folder:') self.le_wood_images = QtGui.QLineEdit(w) self.le_wood_images.editingFinished.connect(self._on_wood_images) tt = 'Location of wood images.' self.le_wood_images.setToolTip(tt) grid = QtGui.QGridLayout() grid.addWidget(qt_utils.create_vline(), 0, 0, 4, 1) grid.addWidget(qt_utils.create_vline(), 0, 3, 4, 1) grid.addWidget(qt_utils.create_hline(), 0, 0, 1, 4) grid.addWidget(self.le_wood_images_label, 1, 1) grid.addWidget(self.le_wood_images, 2, 1) grid.addWidget(qt_utils.create_hline(), 3, 0, 1, 4) vbox.addLayout(grid) vbox.addWidget(self.le_wood_images) vbox.addStretch(1) w.setLayout(vbox) return w
def form_line(label, widget=None, tooltip=None): ''' Formats a line as label --------------- widget and returns the QLayout ''' grid = QtWidgets.QGridLayout() line = qt_utils.create_hline() line.setMinimumWidth(20) if tooltip is not None: label.setToolTip(tooltip) if widget is not None: widget.setToolTip(tooltip) line.setToolTip(tooltip) grid.addWidget(label, 0, 0) grid.addWidget(line, 0, 1) if widget is not None: grid.addWidget(widget, 0, 2) grid.setColumnStretch(1, 5) return grid
def form_line(label, widget=None, tooltip=None): ''' Formats a line as label --------------- widget and returns the QLayout ''' grid = QtGui.QGridLayout() line = qt_utils.create_hline() line.setMinimumWidth(20) if tooltip is not None: label.setToolTip(tooltip) if widget is not None: widget.setToolTip(tooltip) line.setToolTip(tooltip) grid.addWidget(label, 0, 0) grid.addWidget(line, 0, 1) if widget is not None: grid.addWidget(widget, 0, 2) grid.setColumnStretch(1, 5) return grid