def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.addUnitWidget = Ui_addGoods() self.addUnitWidget.setupUi(self) QtCore.QObject.connect(self.addUnitWidget.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.save_unit) self.addUnitWidget.NdsEdit.setText(str(NDS))
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.editUnitWidget = Ui_addGoods() self.editUnitWidget.setupUi(self) QtCore.QObject.connect(self.editUnitWidget.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.save_unit) #self.editUnitWidget.addGoods.setWindowTitle(QtGui.QApplication.translate("addGoods", "Изменение позиции", None, QtGui.QApplication.UnicodeUTF8)) self.units = myapp.ui.tableWidget.selectedItems() self.row = myapp.ui.tableWidget.row(self.units[0]) self.name = myapp.ui.tableWidget.item( myapp.ui.tableWidget.row(self.units[0]), 1).text() #print (self.name) conn = sqlite3.connect(str(db_filename)) cur = conn.cursor() row = cur.execute('select * from goodscatalog where name=?', (self.name, )) keyss = tuple([d[0] for d in cur.description]) # Получаем имена полей conn.commit() # Создаём словарь из строки базы >> for field in row: #print (field) row1 = field #print ('Ключи ', keyss) #print('ROW1 = ', row1) self.dictionary = dict(zip(keyss, row1)) #print (self.dictionary) # << Создаём словарь из строки базы # Вывод данных и словаря в форму >> self.editUnitWidget.ArticleEdit.setText(str( self.dictionary['article'])) self.editUnitWidget.NameEdit.setText(str(self.dictionary['name'])) self.editUnitWidget.PriceEdit.setText(str(self.dictionary['price'])) self.editUnitWidget.BrendEdit.setText(str(self.dictionary['brand'])) self.editUnitWidget.CountryEdit.setText(str( self.dictionary['country'])) self.editUnitWidget.NdsEdit.setText(str(self.dictionary['nds']))