#!/usr/bin/python -d
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtCore, QtGui
from table8 import Ui_Form
# Lars set this path to where you have my scripts!
sys.path += ['/jobs/generic/shots/lightDome/qtDesigner']
def __init__(self, parent=None):
QtGui.
QWidget.__init__
(self, parent
) self.ui = Ui_Form()
self.ui.setupUi(self)
QtCore.
QObject.
connect(self.
ui.
spinBox, QtCore.
SIGNAL("valueChanged(int)"), self.
createMyRow) def createMyRow(self, rows):
howManyRows = self.ui.tableWidget.rowCount()
diff = rows - howManyRows
if diff > 0:
start = howManyRows
while rows > start:
print(start)
self.ui.tableWidget.insertRow(start)
self.
comboBoxNew.
setGeometry(QtCore.
QRect(30,
480,
61,
21)) self.comboBoxNew.setMaxVisibleItems(2)
self.comboBoxNew.setMaxCount(2)
self.comboBoxNew.setObjectName("comboBox")
self.comboBoxNew.addItem("")
self.comboBoxNew.addItem("")
self.ui.tableWidget.setCellWidget(start,1,self.comboBoxNew)
start = start +1
if __name__ == "__main__":
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())
#!/usr/bin/python -d
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtCore, QtGui
from table8 import Ui_Form
# Lars set this path to where you have my scripts!
sys.path += ['/jobs/generic/shots/lightDome/qtDesigner']
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Form()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.spinBox, QtCore.SIGNAL("valueChanged(int)"), self.createMyRow)
def createMyRow(self, rows):
howManyRows = self.ui.tableWidget.rowCount()
diff = rows - howManyRows
if diff > 0:
start = howManyRows
while rows > start:
print(start)
self.ui.tableWidget.insertRow(start)
self.comboBoxNew = QtGui.QComboBox()
self.comboBoxNew.setGeometry(QtCore.QRect(30, 480, 61, 21))
self.comboBoxNew.setMaxVisibleItems(2)
self.comboBoxNew.setMaxCount(2)
self.comboBoxNew.setObjectName("comboBox")
self.comboBoxNew.addItem("")
self.comboBoxNew.addItem("")
self.comboBoxNew.setItemText(0, QtGui.QApplication.translate("Form", "color", None, QtGui.QApplication.UnicodeUTF8))
self.comboBoxNew.setItemText(1, QtGui.QApplication.translate("Form", "bw", None, QtGui.QApplication.UnicodeUTF8))
self.ui.tableWidget.setCellWidget(start,1,self.comboBoxNew)
start = start +1
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks