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 125 126 127 128 129 130 131 132
| import sys, os
import sqlite3
from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox, QDateTimeEdit,
QDial, QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
QProgressBar, QPushButton, QRadioButton, QScrollBar, QSizePolicy, QTableWidgetItem,
QSlider, QSpinBox, QStyleFactory, QTableWidget, QTabWidget, QTextEdit,
QVBoxLayout, QWidget, QMainWindow, QFrame, QFormLayout, QMessageBox)
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtCore import pyqtSlot, QSettings, QDateTime, Qt, QTimer, QDateTime
from PyQt5 import QtCore, QtGui, QtWidgets, QtSql
from PyQt5 import QtWidgets, QtGui
from PyQt5.QtSql import QSqlDatabase
import logging
from logging.handlers import RotatingFileHandler
class App(QMainWindow):
#===============================================================================================
def __init__(self, parent=None):
super(App, self).__init__(parent)
#--- Application datas ---------------------------------------------------------------------
settings=QSettings('ini/application.ini',QSettings.IniFormat);
global APPLICATION_NAME
APPLICATION_NAME="DEBUG_MODE"
self.setFont(QtGui.QFont('Courier new', 10))
#self.setWindowIcon(QIcon('ini/graph.ico'))
self.setWindowTitle(APPLICATION_NAME+ " - Design By.")
self.initUI()
#===============================================================================================
def initUI(self):
#--- User Interface ------------------------------------------------------------------------
#--- Header --------------------------------------------------------------------------------
#Headband = QPixmap('ini/bandeau.jpg')
#self.bandeau = QLabel(self)
#self.bandeau.setFixedHeight(15)
#self.bandeau.setScaledContents(True)
#self.bandeau.setPixmap(Headband)
#--- QTabWidget creation with x tabwidget --------------------------------------------------
self.tabwidget = QTabWidget(self)
self.tabwidget.addTab(self.tab1(), "Tabwidget 1")
self.tabwidget.addTab(self.tab2(), "Tabwidget 2")
self.tabwidget.addTab(self.tab3(), "Tabwidget 3")
self.tabwidget.addTab(self.tab4(), "Tabwidget 4")
self.tabwidget.currentChanged.connect(self.onChange)
self.setCentralWidget(QFrame())
layout = QGridLayout()
#layout.addWidget(self.bandeau, 0, 0)
layout.addWidget(self.CreateToolInformationFormGroup(), 1, 0)
layout.addWidget(self.tabwidget, 2, 0)
#self.tabwidget.setDisabled(True)
self.centralWidget().setLayout(layout)
#--- Affichage d'un message sur la barre de status -----------------------------------------
self.statusBar().showMessage(os.getlogin()+' is currently connected.')
def onChange(self):
print(' select self.tab1('+str(self.tabwidget.currentIndex())+')')
def CreateToolInformationFormGroup(self):
#--- QGroupBox below header ----------------------------------------------------------------
groupBox = QGroupBox("--- QGroupBox ---")
self.label_1 = QLabel()
self.label_1.setText("label_1.setText")
self.toolQRcode = QLineEdit(self)
self.toolQRcode.textChanged.connect(self.to_upper)
self.toolQRcode.setFixedWidth(200)
self.toolQRcode.setMaxLength(8)
self.toolQRcode.returnPressed.connect(self.onPressed)
self.label_ToolInformations = QLabel()
self.label_ToolInformations.setText("")
vbox = QVBoxLayout()
vbox.addWidget(self.label_1)
vbox.addWidget(self.toolQRcode)
vbox.addWidget(self.label_ToolInformations)
#vbox.addStretch(1)
groupBox.setLayout(vbox)
return groupBox
#--- QLineEdit in Uppercase --------------------------------------------------------------------
def to_upper(self, txt):
self.toolQRcode.setText(txt.upper())
#--- Function after onPressed QLineEdit --------------------------------------------------------
def onPressed(self):
self.label_ToolInformations.setText(self.toolQRcode.text())
#--- This line will be improved later with the query result ---/!\---/!\---/!\---/!\---/!\--
#--- Tabwidget 1 -------------------------------------------------------------------------------
def tab1(self):
groupBoxTab1 = QGroupBox("--- Tabwidget 1 ---")
layout = QFormLayout()
self.toolText = QLineEdit(self)
layout.addRow(self.toolText)
self.toolText.setText(self.toolQRcode.text())
self.toolText.setEnabled(False)
groupBoxTab1.setLayout(layout)
return groupBoxTab1
#--- Tabwidget 2 -------------------------------------------------------------------------------
def tab2(self):
groupBoxTab2 = QGroupBox("--- Tabwidget 2 ---")
return groupBoxTab2
#--- Tabwidget 3 -------------------------------------------------------------------------------
def tab3(self):
groupBoxTab3 = QGroupBox("--- Tabwidget 3 ---")
return groupBoxTab3
#--- Tabwidget 4 -------------------------------------------------------------------------------
def tab4(self):
groupBoxTab4 = QGroupBox("--- Tabwidget 4 ---")
return groupBoxTab4
#--- /!\ --- DO NOT DELETE BELOW --- /!\ -----------------------------------------------------------
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setStyle('Fusion')
ex = App()
ex.showMaximized()
sys.exit(app.exec_()) |
Partager