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
|
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
from PyQt5.QtGui import QIcon
#from ImageViewerUI import Ui_MainWindow
from VisuCli import Ui_Form_visucli
import sys
class Main(QMainWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.initUI()
def initUI(self):
self.setGeometry(0, 0, 500, 500)
ouvrirAction = QAction('&Ouvrir Visu Artistes', self)
ouvrirAction.setShortcut('Ctrl+O')
ouvrirAction.setStatusTip('Ouvrir Visu Artistes')
ouvrirAction.triggered.connect(self.on_open)
fermerAction = QAction('&Fermer Visu Artistes', self)
fermerAction.setShortcut('Ctrl+F')
fermerAction.setStatusTip('Fermer Visu Artistes')
fermerAction.triggered.connect(self.on_close)
self.statusBar()
# QMainWindow.menuBar()
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(ouvrirAction)
fileMenu.addAction(fermerAction)
self.setWindowTitle('PyQt5 Fenêtre principale')
# self.show() #Affiche la fenêtre Main
self.init_dialog()
Main.show(self) #Affiche la fenêtre Main (en fait la classe Main
def init_dialog(self):
self.form = QtWidgets.QDialog()
self.ui = Ui_Form_visucli()
self.ui.setupUi(self.form)
#self.ui.LineEd_nom.setText('coucou')
#self.ui.label_nom.setText('Nom')
self.form.setWindowModality(QtCore.Qt.ApplicationModal)
# self.form.finished.connect(self.on_close) #Se déclenche lorsque la fenêtre VisuCli se ferme
self.form.open.connect(self.Remplir_ComboBox)
def on_open(self):
print ("Ouverture de VisuArtiste")
self.form.open()
def Remplir_ComboBox():
print ("Remplissage")
def on_close(self):
print ("Fermeture du programme")
quit()
# ----------------------------------------------------------------------------------------------------------------------
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Main()
ret = app.exec_()
sys.exit(ret) |
Partager