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
| import sys
import sqlite3 as lite
from PyQt5.QtWidgets import (QMainWindow, QApplication, QWidget, QTabWidget, QLabel, QFrame, QGridLayout, QComboBox, QLineEdit, QMenu, QAction)
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtCore import pyqtSlot, QSettings
from PyQt5 import QtWidgets, QtGui
class App(QMainWindow):
def __init__(self):
super().__init__()
self.setFont(QtGui.QFont('Courier new', 10))
settings=QSettings('ini/application.ini',QSettings.IniFormat);
APPLICATION_NAME=settings.value("GLOBAL_PARAMETERS/APPLICATION_NAME")
self.setWindowIcon(QIcon('ini/graph.ico'))
self.setWindowTitle(APPLICATION_NAME)
#Connexion to MySQL database
print('Connexion to data base...')
db_connexion=lite.connect('SQL/GMAO.db')
Cursor=db_connexion.cursor()
Cursor.execute("SELECT * FROM idtools")
idtools_rows=Cursor.fetchall()
#End of connexion
menubar = self.menuBar()
fileMenu = menubar.addMenu('Gestion outillage')
impMenu = QMenu('Outillage', self)
CreationTool = QAction('Création', self)
ModificationTool = QAction('Modification', self)
DeleteTool = QAction('Suppression', self)
impMenu.addAction(CreationTool)
impMenu.addAction(ModificationTool)
impMenu.addAction(DeleteTool)
newAct = QAction('Statistiques', self)
fileMenu.addAction(newAct)
fileMenu.addMenu(impMenu)
BandeauPicture = QPixmap('ini/bandeau.jpg')
self.bandeau = QLabel(self)
#self.bandeau.setFixedHeight(50)
self.bandeau.setScaledContents(True)
self.bandeau.setPixmap(BandeauPicture)
self.LabelCombobox_tool = QLabel(self)
self.LabelCombobox_tool.setText('Select a tool:')
self.combobox_tool=QComboBox(self)
self.combobox_tool.setFixedWidth(250)
for tools in idtools_rows:
self.combobox_tool.addItem(tools[2])
# création d'un QTabWidget avec 2 onglets
self.tabwidget = QTabWidget(self)
self.tab1 = QWidget() # widget de l'onglet tab1
self.tab2 = QWidget() # widget de l'onglet tab2
self.tab3 = QWidget() # widget de l'onglet tab3
self.tab4 = QWidget() # widget de l'onglet tab4
self.tabwidget.addTab(self.tab1,"Saisir panne")
self.tabwidget.addTab(self.tab2,"Saisir réparation")
self.tabwidget.addTab(self.tab3,"Historique")
self.tabwidget.addTab(self.tab4,"Administration")
# Affichage d'un message sur la barre de status
self.statusBar().showMessage("Message de status")
# positionnement des widgets dans la fenêtre QMainWindow
self.setCentralWidget(QFrame())
layout = QGridLayout()
layout.addWidget(self.bandeau, 0, 0) # bandeau en haut
layout.addWidget(self.LabelCombobox_tool, 1, 0) # bandeau en haut
layout.addWidget(self.combobox_tool, 2, 0) # bandeau en haut
layout.addWidget(self.tabwidget, 3, 0) # QTabWidget en bas
self.centralWidget().setLayout(layout)
def toto():
print('toto')
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setStyle('Fusion')
ex = App()
ex.showMaximized()
sys.exit(app.exec_()) |
Partager