def set_wood_combobox(self): ''' Sets the entries for the wood combox box, and resets the default wood. The wood names can be translated so we have use the value ''' (woods, patterns) = qt_utils.create_wood_dict(self.new_config['wood_images'], self.transl) #woodnames = list(woods.keys()) #woodnames.extend(patterns.keys()) self.cb_wood.clear() #combo boxes now store values as well as keys skeys = sorted(woods.keys()) for k in skeys: self.cb_wood.addItem(k, woods.get(k)) # Next add patterns if skeys: self.cb_wood.insertSeparator(len(skeys)) skeys = sorted(patterns.keys()) for k in skeys: self.cb_wood.addItem(k, patterns.get(k)) #i = self.cb_wood.findText(self.new_config['default_wood']) i = self.cb_wood.findData(self.new_config['default_wood']) if i < 0: self.cb_wood.setCurrentIndex(0) self.new_config['default_wood'] = self.cb_wood.currentData() # self.new_config['default_wood'] = str(self.cb_wood.currentText()) else: self.cb_wood.setCurrentIndex(i)
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 set_wood_combobox(self): ''' Sets the entries for the wood combox box, and resets the default wood. ''' (woods, patterns) = qt_utils.create_wood_dict(self.new_config['wood_images']) woodnames = woods.keys() woodnames.extend(patterns.keys()) self.cb_wood.clear() self.cb_wood.addItems(woodnames) i = self.cb_wood.findText(self.new_config['default_wood']) if i < 0: self.cb_wood.setCurrentIndex(0) self.new_config['default_wood'] = str(self.cb_wood.currentText()) else: self.cb_wood.setCurrentIndex(i)