1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
# -*- coding: utf-8 -*-
from PyQt4 import QtGui, QtCore
from functools import partial
class TestTable(QtGui.QTableWidget):
def __init__(self,parent=None):
super(TestTable,self).__init__(parent)
self.setRowCount(2)
self.setColumnCount(2)
combo1 = QtGui.QComboBox()
combo1.addItems(['pomme','banane'])
combo2 = QtGui.QComboBox()
combo2.addItems(['brocoli','haricot'])
combo1.row = 0
combo2.row = 1
self.setCellWidget(0,1,combo1)
self.setCellWidget(1,1,combo2)
combo1.focusInEvent = partial(self.changeFocus, combo1)
combo2.focusInEvent = partial(self.changeFocus, combo2)
def changeFocus(self, comboBox, e):
self.setCurrentCell(comboBox.row, 0)
return QtGui.QComboBox.focusInEvent(comboBox,e)
if __name__=='__main__':
import sys
app=QtGui.QApplication(sys.argv)
fen = TestTable()
fen.show()
sys.exit(app.exec_()) |
Partager