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 36 37 38 39 40 41 42 43 44 45 46
|
import sys
from PyQt4 import QtCore, QtGui
from UI_MyList import Ui_dialog
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_dialog()
self.ui.setupUi(self)
self.ui.spinBox.setEnabled(False)
lst_IntervalleCouleur=[["intervalle1","#8B8989"],["intervalle2","5A6351"],["intervalle3","#7A8B8B"]]
for index, intervalle in enumerate(lst_IntervalleCouleur):
a = QtGui.QTreeWidgetItem(self.ui.treeWidget)
a.setText(0, lst_IntervalleCouleur[index][0])
a.setText(1, lst_IntervalleCouleur[index][1])
QtCore.QObject.connect(self.ui.bt_ChooseColor,QtCore.SIGNAL("clicked()"), self.color_dialog)
QtCore.QObject.connect(self.ui.comboBox,QtCore.SIGNAL("currentIndexChanged(int)"), self.enable_spinBox)
QtCore.QObject.connect(self.ui.treeWidget,QtCore.SIGNAL("itemClicked(QTreeWidgetItem*,int)"), self.selectionListe)
def color_dialog(self):
couleur = QtGui.QColorDialog.getColor()
palette=QtGui.QPalette()
palette.setColor(QtGui.QPalette.Button, couleur)
self.ui.bt_applycolor.setPalette(palette)
self.ui.txt_color.setText(couleur.name())
def enable_spinBox(self):
valeur2=self.ui.comboBox.currentIndex()
if valeur2==0:
self.ui.spinBox.setEnabled(False)
else:
self.ui.spinBox.setEnabled(True)
def selectionListe(self,item):
self.ui.txt_color.setText(item.text(1))
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = MyForm()
myapp.show()
sys.exit(app.exec_()) |
Partager