| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #from __future__ import unicode_literals
- # -*- coding: utf-8 -*-
- """Panneau d'affichage des PJ dans l'onglet groupe
- """
- import sys
- from PyQt4.QtCore import *
- from PyQt4.QtGui import *
- from ui.ecran_panneauPj import Ui_pj_panneau
- from ui.dm import *
- from EcranEditionCombattant import EcranEditionCombattant
- class FramePj(QFrame):
- """Panneau d'affichage du Pj
- a inserer dans le layout de l'onglet groupe
- de l'ecran principal"""
- def __init__(self, idPj, parent=None):
- super (FramePj, self).__init__(parent)
- self.idPj = idPj
- self._pj = None
- self.enCreation = False
- self.createWidgets()
- def createWidgets(self):
- """construction de l'interface"""
- self.ui = Ui_pj_panneau()
- self.ui.setupUi(self)
- self.setEnabled(False)
- self.setMouseTracking(True)
- for i in range(0, 6):
- bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
- self.connect(bouton, SIGNAL("clicked()"), self.afficherFiche)
- def signalerModif(self):
- """on signale a la fenetre principale que le personnage a ete modifie"""
- self.emit(SIGNAL("pjModifie()"), self.idPj)
- def pj(self):
- """retourne le pj represente"""
- return self._pj
- def chargerPj(self, pj = None):
- """met a jour le contenu avec les donnees du pj en param"""
- if pj != None:
- self.ui.pj_image.chargerImage(pj.logo)
- self.ui.pj_nom.majTexte(pj.nom)
- for i in range(0, 6):
- bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
- bouton.setEnabled(True)
- self._pj = pj
- self.majApparence()
- def reinitialiser(self):
- self.ui.pj_image.majImage("")
- self.ui.pj_nom.majTexte("(Nouveau personnage...)")
- for i in range(0, 6):
- bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
- bouton.setEnabled(False)
- def afficherFiche(self):
- """affiche la fiche de perso a la page demandee"""
- emetteur = self.sender().objectName()
- page = int(str(emetteur)[-1:])
- self.editionPj = EcranEditionCombattant(self._pj, page)
- self.editionPj.setAttribute(Qt.WA_DeleteOnClose)
- self.editionPj.exec_()
- self._pj = self.editionPj.combattant
- self.ui.pj_image.chargerImage(self._pj.logo)
- self.ui.pj_nom.majTexte(self._pj.nom)
- self.signalerModif()
- def majApparence(self):
- """affiche le fond de la couleur du pion, et epaissit la bordure au survol"""
- # "QFrame {background-color: " + self._pj.couleur.lighter(150).name() + ";" \
- self.setStyleSheet("QFrame {background-color: rgb(249,249,249);" \
- "border: 2px solid " + self._pj.couleur.lighter(110).name() + ";" \
- "border-radius: 5px;}" \
- "QLabel {border-width: 0px;}")
- def enterEvent(self, event):
- self.setEnabled(True)
- def leaveEvent(self, event):
- self.setEnabled(False)
- if __name__ == "__main__":
- app = QApplication(sys.argv)
- ecran = FramePj(0)
- ecran.show()
- r = app.exec_()
- exit(r)
|