def __init__(self, parent=None): super(MainDialog, self).__init__(parent) self.setupUi(self) self.setWindowIcon(QIcon(resource_path('assets/weather.ico'))) icon = QIcon() icon.addPixmap(QPixmap(resource_path("assets/search.png")), QIcon.Normal, QIcon.Off) self.pushButton.setIcon(icon) self.pushButton.setIconSize(QtCore.QSize(30, 30)) self.pushButton.setAutoRepeatDelay(200) self.flag = 0 self.pushButton.clicked.connect(self.push_info)
def closeEvent(self, event): """ Forward the close event to every tabs contained by the windows """ if self.tab_widget.count() == 0: # no tabs, just close event.accept() return # Do Not loop on the widget count as it change while closing title = self.window().windowTitle() cancel = QtGui.QMessageBox.Cancel okay = QtGui.QMessageBox.Ok accept_role = QtGui.QMessageBox.AcceptRole if self.confirm_exit: if self.tab_widget.count() > 1: msg = "Close all tabs, stop all kernels, and Quit?" else: msg = "Close console, stop kernel, and Quit?" info = "Kernels not started here (e.g. notebooks) will be left alone." closeall = QtGui.QPushButton("&Quit", self) closeall.setShortcut('Q') box = QtGui.QMessageBox(QtGui.QMessageBox.Question, title, msg) box.setInformativeText(info) box.addButton(cancel) box.addButton(closeall, QtGui.QMessageBox.YesRole) box.setDefaultButton(closeall) box.setEscapeButton(cancel) pixmap = QtGui.QPixmap(self._app.icon.pixmap(QtCore.QSize(64,64))) box.setIconPixmap(pixmap) reply = box.exec_() else: reply = okay if reply == cancel: event.ignore() return if reply == okay or reply == accept_role: while self.tab_widget.count() >= 1: # prevent further confirmations: widget = self.active_frontend widget._confirm_exit = False self.close_tab(widget) event.accept()
def sizeHint(self): return QtCore.QSize(600, 200)
def sizeHint(self): return QtCore.QSize(350, 500)
def initUI(self): #Création des labels titre = QLabel("Consultation et Modification d'un Équipement") titre.setFont((QFont('SansSerif', 24))) identifiant = QLabel('ID') categorie = QLabel('Catégorie') marque = QLabel('Marque') modele = QLabel('Modèle') numeroDeSerie = QLabel('No. de série') salle = QLabel('Salle') centreDeService = QLabel('Centre de service') dateDacquisititon = QLabel("Date d'acquisition") dateDuDernierEntretien = QLabel('Date du dernier entretien') provenance = QLabel('Provenance') etatDeService = QLabel('État de service') listeDesBonsDeTravail = QLabel('Liste des bons de travail') etatDeConservation = QLabel('État de conservation') commentaires = QLabel('Commentaires') #Création des champs d'entrée de texte identifiantEdit = QLineEdit() categorieEdit = QLineEdit() marqueEdit = QLineEdit() modeleEdit = QLineEdit() numeroDeSerieEdit = QLineEdit() salleEdit = QLineEdit() centreDeServiceEdit = QLineEdit() dateDacquisititonEdit = QLineEdit() dateDuDernierEntretienEdit = QLineEdit() provenanceEdit = QLineEdit() etatDeServiceEdit = QLineEdit() listeDesBonsDeTravailEdit = QLineEdit() etatDeConservationEdit = QLineEdit() #Création d'un champ d'entrée multiligne commentairesEdit = QTextEdit() #Création des boutons self.nouveauBonDeTravailButton = QPushButton("Nouveau bon de travail") self.nouveauBonDeTravailButton.setIcon(QtGui.QIcon("Add-icon.png")) self.nouveauBonDeTravailButton.setIconSize(QtCore.QSize(50, 50)) self.modifierEquipementButton = QPushButton("Modifier l'équipement") self.modifierEquipementButton.setIcon(QtGui.QIcon("Modify-icon.png")) self.modifierEquipementButton.setIconSize(QtCore.QSize(50, 50)) self.afficherBonDeTravailButton = QPushButton("Afficher le bon de travail sélectionné") self.afficherBonDeTravailButton.setIcon(QtGui.QIcon("view-icon2.png")) self.afficherBonDeTravailButton.setIconSize(QtCore.QSize(50, 50)) #Création d'un layout horizontal hbox = QHBoxLayout() #hbox.addStretch(1) # Création d'un second layout horizontal pour le titre hbox2 = QHBoxLayout() #hbox2.addStretch(1) hbox2.setAlignment(Qt.AlignCenter) #Ajout des widget dans le layout principal hbox.addWidget(self.nouveauBonDeTravailButton) hbox.addWidget(self.modifierEquipementButton) hbox.addWidget(self.afficherBonDeTravailButton) # Ajout du label du titre dans le layout horizontal 2 hbox2.addWidget(titre) #Création d'un layout vertical vbox = QVBoxLayout() vbox.addStretch(1) #Création d'une grid layout grid = QGridLayout() grid.setSpacing(10) #Postionnement des differents elements dans le grid layout grid.addWidget(identifiant, 1, 0) grid.addWidget(identifiantEdit, 1, 1) grid.addWidget(categorie, 2, 0) grid.addWidget(categorieEdit, 2, 1) grid.addWidget(marque, 3, 0) grid.addWidget(marqueEdit, 3, 1) grid.addWidget(modele, 4, 0) grid.addWidget(modeleEdit, 4, 1) grid.addWidget(numeroDeSerie, 5, 0) grid.addWidget(numeroDeSerieEdit, 5, 1) grid.addWidget(salle, 6, 0) grid.addWidget(salleEdit, 6, 1) grid.addWidget(centreDeService, 7, 0) grid.addWidget(centreDeServiceEdit, 7, 1) grid.addWidget(dateDacquisititon, 8, 0) grid.addWidget(dateDacquisititonEdit, 8, 1) grid.addWidget(dateDuDernierEntretien, 9, 0) grid.addWidget(dateDuDernierEntretienEdit, 9, 1) grid.addWidget(provenance, 10, 0) grid.addWidget(provenanceEdit, 10, 1) grid.addWidget(etatDeService, 11, 0) grid.addWidget(etatDeServiceEdit, 11, 1) grid.addWidget(listeDesBonsDeTravail, 12, 0) grid.addWidget(listeDesBonsDeTravailEdit, 12, 1) grid.addWidget(etatDeConservation, 13, 0) grid.addWidget(etatDeConservationEdit, 13, 1) grid.addWidget(commentaires, 14, 0) grid.addWidget(commentairesEdit, 14, 1, 5, 1) # Mise en place de la forme de la fenetre self.setGeometry(200, 100, 200, 1000) self.resize(1000, 1000) self.setWindowTitle("SIMM 2.0") self.setWindowIcon(QIcon('PC2.png')) # Connection des differents actions au click d'un bouton self.nouveauBonDeTravailButton.clicked.connect(self.NouveauBonDeTravail) #On ajoute la grid layout et le layout horizontal dans le layout vertical vbox.addLayout(hbox2) vbox.addLayout(hbox) vbox.addLayout(grid) #On met en place le layout self.setLayout(vbox) #Mise a jour des fenetres self.setGeometry(300, 300, 350, 300) self.setWindowTitle('PC2') self.show()
def close_tab(self, current_tab): """ Called when you need to try to close a tab. It takes the number of the tab to be closed as argument, or a reference to the widget inside this tab """ # let's be sure "tab" and "closing widget" are respectively the index # of the tab to close and a reference to the frontend to close if type(current_tab) is not int: current_tab = self.tab_widget.indexOf(current_tab) closing_widget = self.tab_widget.widget(current_tab) # when trying to be closed, widget might re-send a request to be # closed again, but will be deleted when event will be processed. So # need to check that widget still exists and skip if not. One example # of this is when 'exit' is sent in a slave tab. 'exit' will be # re-sent by this function on the master widget, which ask all slave # widgets to exit if closing_widget is None: return #get a list of all slave widgets on the same kernel. slave_tabs = self.find_slave_widgets(closing_widget) keepkernel = None #Use the prompt by default if hasattr(closing_widget, '_keep_kernel_on_exit'): #set by exit magic keepkernel = closing_widget._keep_kernel_on_exit # If signal sent by exit magic (_keep_kernel_on_exit, exist and not None) # we set local slave tabs._hidden to True to avoid prompting for kernel # restart when they get the signal. and then "forward" the 'exit' # to the main window if keepkernel is not None: for tab in slave_tabs: tab._hidden = True if closing_widget in slave_tabs: try: self.find_master_tab(closing_widget).execute('exit') except AttributeError: self.log.info( "Master already closed or not local, closing only current tab" ) self.tab_widget.removeTab(current_tab) self.update_tab_bar_visibility() return kernel_client = closing_widget.kernel_client kernel_manager = closing_widget.kernel_manager if keepkernel is None and not closing_widget._confirm_exit: # don't prompt, just terminate the kernel if we own it # or leave it alone if we don't keepkernel = closing_widget._existing if keepkernel is None: #show prompt if kernel_client and kernel_client.channels_running: title = self.window().windowTitle() cancel = QtGui.QMessageBox.Cancel okay = QtGui.QMessageBox.Ok if closing_widget._may_close: msg = "You are closing the tab : " + '"' + self.tab_widget.tabText( current_tab) + '"' info = "Would you like to quit the Kernel and close all attached Consoles as well?" justthis = QtGui.QPushButton("&No, just this Tab", self) justthis.setShortcut('N') closeall = QtGui.QPushButton("&Yes, close all", self) closeall.setShortcut('Y') # allow ctrl-d ctrl-d exit, like in terminal closeall.setShortcut('Ctrl+D') box = QtGui.QMessageBox(QtGui.QMessageBox.Question, title, msg) box.setInformativeText(info) box.addButton(cancel) box.addButton(justthis, QtGui.QMessageBox.NoRole) box.addButton(closeall, QtGui.QMessageBox.YesRole) box.setDefaultButton(closeall) box.setEscapeButton(cancel) pixmap = QtGui.QPixmap( self._app.icon.pixmap(QtCore.QSize(64, 64))) box.setIconPixmap(pixmap) reply = box.exec_() if reply == 1: # close All for slave in slave_tabs: background(slave.kernel_client.stop_channels) self.tab_widget.removeTab( self.tab_widget.indexOf(slave)) kernel_manager.shutdown_kernel() self.tab_widget.removeTab(current_tab) background(kernel_client.stop_channels) elif reply == 0: # close Console if not closing_widget._existing: # Have kernel: don't quit, just close the tab closing_widget.execute("exit True") self.tab_widget.removeTab(current_tab) background(kernel_client.stop_channels) else: reply = QtGui.QMessageBox.question( self, title, "Are you sure you want to close this Console?" + "\nThe Kernel and other Consoles will remain active.", okay | cancel, defaultButton=okay) if reply == okay: self.tab_widget.removeTab(current_tab) elif keepkernel: #close console but leave kernel running (no prompt) self.tab_widget.removeTab(current_tab) background(kernel_client.stop_channels) else: #close console and kernel (no prompt) self.tab_widget.removeTab(current_tab) if kernel_client and kernel_client.channels_running: for slave in slave_tabs: background(slave.kernel_client.stop_channels) self.tab_widget.removeTab(self.tab_widget.indexOf(slave)) if kernel_manager: kernel_manager.shutdown_kernel() background(kernel_client.stop_channels) self.update_tab_bar_visibility()
def initUI(self): # Label self.Titre = QLabel('Bon de travail- maintenance et réparation') self.Titre.setFont((QFont('SansSerif', 24))) ID = QLabel('ID') CategorieEquip = QLabel('Catégorie d' 'équipement') Marque = QLabel('Marque') Modele = QLabel('Modèle') Salle = QLabel('Salle') CentreService = QLabel('Centre de service') Bdt = QLabel('#Bon de travail') Date = QLabel('Date') Temps = QLabel('Temps estimé (h:m)') DescSit = QLabel('Description de la situation') DescInv = QLabel('Description de l' 'intervention') # Edit (ligne pour écrire) self.idEdit = QLineEdit() self.categorieEdit = QLabel("ici categorie") self.markEdit = QLabel("ici marque") self.modelEdit = QLabel("ici modele") self.salleEdit = QLabel("ici salle") self.centreEdit = QLabel("ici centre") self.bdtEdit = QLineEdit() self.tempsEdit = QLineEdit() self.descsitEdit = QTextEdit() self.descinvEdit = QTextEdit() self.okButton = QPushButton("OK") self.quitButton = QPushButton("Quitter") hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.okButton) hbox.addWidget(self.quitButton) self.quitButton.clicked.connect(self.quitter) vbox = QVBoxLayout() vbox.addStretch(1) # Partie du haut widget grid = QGridLayout() grid.setSpacing(10) grid.addWidget(self.Titre, 1, 0) grid.addWidget(ID, 2, 0) grid.addWidget(self.idEdit, 3, 0) grid.addWidget(CategorieEquip, 2, 1) grid.addWidget(self.categorieEdit, 3, 1) grid.addWidget(Marque, 4, 0) grid.addWidget(self.markEdit, 5, 0) grid.addWidget(Modele, 4, 1) grid.addWidget(self.modelEdit, 5, 1) grid.addWidget(Salle, 6, 0) grid.addWidget(self.salleEdit, 7, 0) grid.addWidget(CentreService, 6, 1) grid.addWidget(self.centreEdit, 7, 1) # Partie du bas widget grid2 = QGridLayout() grid2.setSpacing(10) grid2.addWidget(Bdt, 1, 0) grid2.addWidget(self.bdtEdit, 2, 0) grid2.addWidget(Date, 3, 0) # self.dateEdit est plus bas grid2.addWidget(Temps, 5, 0) grid2.addWidget(self.tempsEdit, 6, 0) grid2.addWidget(DescSit, 1, 3) grid2.addWidget(self.descsitEdit, 2, 3) grid2.addWidget(DescInv, 6, 3) grid2.addWidget(self.descinvEdit, 7, 3) # Ouvert ou fermé self.combo = QComboBox(self) self.combo.addItem("Ouvert") self.combo.addItem("Fermé") grid2.addWidget(self.combo, 8, 3) self.label = QLabel("Ouvert", self) grid2.addWidget(self.label, 9, 3) self.combo.activated[str].connect(self.onActivated) vbox.addLayout(grid) vbox.addLayout(grid2) vbox.addLayout(hbox) self.setLayout(vbox) # Fenêtre self.setGeometry(300, 300, 700, 600) self.setWindowTitle('PC2') self.setWindowIcon(QIcon('Images/PC2_logo.png')) self.show() # Bouton self.ajoutBdT = QPushButton('') self.ajoutBdT.setIcon(QtGui.QIcon("Images/Bouton_Sauvegarde.gif")) self.ajoutBdT.setIconSize(QtCore.QSize(50, 50)) self.ajoutBdT.clicked.connect(self.enregistrer) grid.addWidget(self.ajoutBdT, 9, 2) btnGG = QPushButton('<<', self) btnGG.resize(btnGG.sizeHint()) grid.addWidget(btnGG, 9, 3) btnG = QPushButton('<', self) btnG.resize(btnG.sizeHint()) grid.addWidget(btnG, 9, 4) btnD = QPushButton('>', self) btnD.resize(btnD.sizeHint()) grid.addWidget(btnD, 9, 5) btnDD = QPushButton('>>', self) btnDD.resize(btnDD.sizeHint()) grid.addWidget(btnDD, 9, 6) # Ecriture de la date sur la ligne self.dateEdit = QDateEdit() grid2.addWidget(self.dateEdit, 4, 0) self.dateEdit.setDate(QDate.currentDate())
def sizeHint(self): s = QtCore.QSize() s.setHeight(super(MinListWidget, self).sizeHint().height()) s.setWidth(self.sizeHintForColumn(0)) return s
def initUI(self): #les boutons AddEq_Btn= QPushButton('Ajouter un \néquipement', self) AddEq_Btn.setFont(QFont( 'SansSerif', 8, QFont.Bold )) AddEq_Btn.move(75,150) AddEq_Btn.resize(150,100) AddEq_Btn.setIcon(QIcon('PdC-Bouton_Ajouter.png')) AddEq_Btn.setIconSize(QtCore.QSize(40, 40)) AddEq_Btn.clicked.connect(self.AddEqForm) AddBTD_Btn = QPushButton('Ajouter un \nbon de travail', self) AddBTD_Btn.setFont(QFont( 'SansSerif', 8, QFont.Bold )) AddBTD_Btn.move(250,150) AddBTD_Btn.resize(150, 100) AddBTD_Btn.setIcon(QIcon('PdC_Bouton_BdT2.png')) AddBTD_Btn.setIconSize(QtCore.QSize(40, 40)) ConsulterEq_Btn = QPushButton('Consulter ou \nmodifier \nun équipement', self) ConsulterEq_Btn.setFont(QFont( 'SansSerif', 8, QFont.Bold )) ConsulterEq_Btn.move(75, 300) ConsulterEq_Btn.resize(150,100) ConsulterEq_Btn.setIcon(QIcon('PdC-crayon.png')) ConsulterEq_Btn.setIconSize(QtCore.QSize(40, 40)) SeachEq_Btn = QPushButton('Rechercher un \néquipement', self) SeachEq_Btn.setFont(QFont( 'SansSerif', 8, QFont.Bold )) SeachEq_Btn.move(250, 300) SeachEq_Btn.resize(150,100) SeachEq_Btn.setIcon(QIcon('PdC_Bouton_Rechercher2.png')) SeachEq_Btn.setIconSize(QtCore.QSize(40,40)) SeachBDT_Btn = QPushButton('Rechercher un\nbon de travail', self) SeachBDT_Btn.setFont(QFont( 'SansSerif', 8, QFont.Bold )) SeachBDT_Btn.move(75, 450) SeachBDT_Btn.resize(150, 100) SeachBDT_Btn.setIcon(QIcon('Bouton_Recherche_BdT.png')) SeachBDT_Btn.setIconSize(QtCore.QSize(40,40)) Stats_Btn = QPushButton('Voir les \nstatistiques', self) Stats_Btn.setFont(QFont('SansSerif', 8, QFont.Bold)) Stats_Btn.move(250, 450) Stats_Btn.resize(150, 100) Stats_Btn.setIcon(QIcon('PdC-Bouton-stats.png')) Stats_Btn.setIconSize(QtCore.QSize(40,40)) SupportPC2_Btn = QPushButton('Support \n technique', self) SupportPC2_Btn.setFont(QFont( 'SansSerif', 8, QFont.Bold )) SupportPC2_Btn.move(480,390) SupportPC2_Btn.resize(150, 100) SupportPC2_Btn.setIcon(QIcon('PC2.png')) SupportPC2_Btn.setIconSize(QtCore.QSize(40,40)) PrintInventaire_Btn = QPushButton('Imprimer l"inventaire', self) PrintInventaire_Btn.setFont(QFont( 'SansSerif', 8, QFont.Bold )) PrintInventaire_Btn.move(450, 150) PrintInventaire_Btn.resize(210, 70) #initialisation fenetre du panneau de controle #Les déclaration des écritures dans la fenetre self.textTitre = 'S.I.M.M. 2.0 \n Hôpital Saint-Michel \n ' self.textRemarque = ' S.I.M.M : Système d"Iventorisation du Matériel Médical ' #Size of the window self.setGeometry(400, 175, 720, 700) self.setWindowTitle('SIMM 2.0 : Panneau de controle') self.setWindowIcon(QIcon('PC2.png')) #Définir la couleur de l'arriere plan de la fenêtre principale backG = self.palette() backG.setColor(self.backgroundRole(), Qt.darkBlue) self.setPalette(backG) self.show()