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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
from PyQt5 import QtGui, QtWidgets
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
class Parameters():
def Scale(self,CoorX,CoorY,Width,Height):
self.CoorX = CoorX
self.CoorY = CoorY
self.Width = Width
self.Height = Height
def Style(self, color, font,fontsize,bold):
self.color = color
self.font = font
self.fontsize = fontsize
self.bold = bold
a=Parameters()
b=Parameters()
c=Parameters()
d=Parameters()
e=Parameters()
GeometryWindow = a.Scale(400,30,1500,1000)
StyleTitrePrincipal = b.Style("color:black","Segoe UI",25,"Bold")
StyleTexte = c.Style("color:black","Calibri",16,"")
StyleInsertTexte = d.Style("color:black","Calibri",12,"")
StyleTable = e.Style("color:black","Calibri",12,"")
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Application")
self.setGeometry(a.CoorX, a.CoorY, a.Width, a.Height)
self.UiComponents()
self.show()
def UiComponents(self):
#label_1 - Essai n°
label_1 = QLabel(self)
label_1.setText("Essai n°")
label_1.move(int(0.03*a.Width),int(0.02*a.Height))
label_1.setFont(QtGui.QFont(c.font,int(c.fontsize/1000*a.Height)))
label_1.setStyleSheet(c.color)
#lineEdit_1
lineEdit_1 = QLineEdit(self)
lineEdit_1.setGeometry(int(0.105*a.Width),int(0.017*a.Height),int(0.06*a.Width),int(0.03*a.Height))
lineEdit_1.setFont(QtGui.QFont(d.font,int(d.fontsize/1000*a.Height)))
lineEdit_1.setStyleSheet(d.color)
lineEdit_1.setStyleSheet("background-color: yellow;")
#Table_1
table_1 = QTableWidget(self)
table_1.setGeometry(int(0.02*a.Width),int(0.07*a.Height),int(0.32*a.Width),int(0.15*a.Height))
table_1.setColumnCount(1)
table_1.setRowCount(3)
table_1.setFont(QtGui.QFont(e.font,int(e.fontsize/1000*a.Height)))
table_1.setStyleSheet(e.color)
horizontal = table_1.horizontalHeader()
horizontal.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
vertical = table_1.verticalHeader()
vertical.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
vertical.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
vertical.setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
name_ligne =("Responsable","Date","Heure",)
table_1.setVerticalHeaderLabels(name_ligne)
table_1.horizontalHeader().hide()
#table_2
self.table_2 = QtWidgets.QTableWidget(self)
self.table_2.setGeometry(int(0.025*a.Width),int(0.30*a.Height),int(0.95*a.Width),int(0.40*a.Height))
self.table_2.setColumnCount(10)
nb_row = 5
self.table_2.setRowCount(nb_row)
self.table_2.setFont(QtGui.QFont(e.font,int(e.fontsize/1000*a.Height)))
self.table_2.setStyleSheet(e.color)
#nom des colonnes
name_colonne =("1","2","3","4","5","6","7","8","9","10")
self.table_2.setHorizontalHeaderLabels(name_colonne)
#ajoute combo_1
combo1 = {}
for i in range(nb_row):
combo1[i] = QComboBox()
combo1[i].addItems(["A","B","C"])
self.table_2.setCellWidget(i, 0, combo1[i])
#Button1
Button_1 = QPushButton("Ajouter une ligne",self)
Button_1.setGeometry(int(0.60*a.Width),int(0.265*a.Height),int(0.1625*a.Width),int(0.03*a.Height))
Button_1.clicked.connect(self._addrow)
#Button_2
Button_2 = QtWidgets.QPushButton("Enregistrer",self)
Button_2.setGeometry(int(0.01*a.Width),int(0.94*a.Height),int(0.25*a.Width),int(0.05*a.Height))
Button_2.clicked.connect(action)
def _addrow(self):
rowcount = self.table_4.rowCount()-1
self.table_4.insertRow(rowcount)
combo2 = QComboBox()
combo2.addItems(["AAA","BBB","CCC"])
self.table_4.setCellWidget(rowcount, 0, combo2)
def result(self):
print("Test3")
numero_essai = Window.UiComponents(self).lineEdit_1.text()
print(numero_essai)
def action(self):
print("Test1")
from LectureSQL import InOutSQL
InOutSQL.Test(self)
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec()) |
Partager