framePj.py 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #from __future__ import unicode_literals
  2. # -*- coding: utf-8 -*-
  3. """Panneau d'affichage des PJ dans l'onglet groupe
  4. """
  5. import sys
  6. from PyQt4.QtCore import *
  7. from PyQt4.QtGui import *
  8. from ui.ecran_panneauPj import Ui_pj_panneau
  9. from ui.dm import *
  10. from EcranEditionCombattant import EcranEditionCombattant
  11. class FramePj(QFrame):
  12. """Panneau d'affichage du Pj
  13. a inserer dans le layout de l'onglet groupe
  14. de l'ecran principal"""
  15. def __init__(self, idPj, parent=None):
  16. super (FramePj, self).__init__(parent)
  17. self.idPj = idPj
  18. self._pj = None
  19. self.enCreation = False
  20. self.createWidgets()
  21. def createWidgets(self):
  22. """construction de l'interface"""
  23. self.ui = Ui_pj_panneau()
  24. self.ui.setupUi(self)
  25. self.setEnabled(False)
  26. self.setMouseTracking(True)
  27. for i in range(0, 6):
  28. bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
  29. self.connect(bouton, SIGNAL("clicked()"), self.afficherFiche)
  30. def signalerModif(self):
  31. """on signale a la fenetre principale que le personnage a ete modifie"""
  32. self.emit(SIGNAL("pjModifie()"), self.idPj)
  33. def pj(self):
  34. """retourne le pj represente"""
  35. return self._pj
  36. def chargerPj(self, pj = None):
  37. """met a jour le contenu avec les donnees du pj en param"""
  38. if pj != None:
  39. self.ui.pj_image.chargerImage(pj.logo)
  40. self.ui.pj_nom.majTexte(pj.nom)
  41. for i in range(0, 6):
  42. bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
  43. bouton.setEnabled(True)
  44. self._pj = pj
  45. self.majApparence()
  46. def reinitialiser(self):
  47. self.ui.pj_image.majImage("")
  48. self.ui.pj_nom.majTexte("(Nouveau personnage...)")
  49. for i in range(0, 6):
  50. bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
  51. bouton.setEnabled(False)
  52. def afficherFiche(self):
  53. """affiche la fiche de perso a la page demandee"""
  54. emetteur = self.sender().objectName()
  55. page = int(str(emetteur)[-1:])
  56. self.editionPj = EcranEditionCombattant(self._pj, page)
  57. self.editionPj.setAttribute(Qt.WA_DeleteOnClose)
  58. self.editionPj.exec_()
  59. self._pj = self.editionPj.combattant
  60. self.ui.pj_image.chargerImage(self._pj.logo)
  61. self.ui.pj_nom.majTexte(self._pj.nom)
  62. self.signalerModif()
  63. def majApparence(self):
  64. """affiche le fond de la couleur du pion, et epaissit la bordure au survol"""
  65. # "QFrame {background-color: " + self._pj.couleur.lighter(150).name() + ";" \
  66. self.setStyleSheet("QFrame {background-color: rgb(249,249,249);" \
  67. "border: 2px solid " + self._pj.couleur.lighter(110).name() + ";" \
  68. "border-radius: 5px;}" \
  69. "QLabel {border-width: 0px;}")
  70. def enterEvent(self, event):
  71. self.setEnabled(True)
  72. def leaveEvent(self, event):
  73. self.setEnabled(False)
  74. if __name__ == "__main__":
  75. app = QApplication(sys.argv)
  76. ecran = FramePj(0)
  77. ecran.show()
  78. r = app.exec_()
  79. exit(r)