framePj.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. import regles
  10. from ui.dm import *
  11. from EcranEditionCombattant import EcranEditionCombattant
  12. class FramePj(QFrame):
  13. """Panneau d'affichage du Pj
  14. a inserer dans le layout de l'onglet groupe
  15. de l'ecran principal"""
  16. def __init__(self, idPj, parent=None):
  17. super (FramePj, self).__init__(parent)
  18. self.idPj = idPj
  19. self._pj = None
  20. self.enCreation = False
  21. self.createWidgets()
  22. def createWidgets(self):
  23. """construction de l'interface"""
  24. self.ui = Ui_pj_panneau()
  25. self.ui.setupUi(self)
  26. ## self.ui.att_voile.setAttribute(Qt.WA_TransparentForMouseEvents)
  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:
  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. def reinitialiser(self):
  46. self.ui.pj_image.majImage("")
  47. self.ui.pj_nom.majTexte("(Nouveau personnage...)")
  48. for i in range(0, 6):
  49. bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
  50. bouton.setEnabled(False)
  51. def afficherFiche(self):
  52. """affiche la fiche de perso a la page demandee"""
  53. emetteur = self.sender().objectName()
  54. page = int(str(emetteur)[-1:])
  55. self.editionPj = EcranEditionCombattant(self._pj, page)
  56. self.editionPj.setAttribute(Qt.WA_DeleteOnClose)
  57. r = self.editionPj.exec_()
  58. self._pj = self.editionPj.combattant
  59. self.signalerModif()
  60. if __name__ == "__main__":
  61. app = QApplication(sys.argv)
  62. ecran = FramePj(0)
  63. ecran.show()
  64. r = app.exec_()
  65. exit(r)