framePj.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. for i in range(0, 6):
  27. bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
  28. self.connect(bouton, SIGNAL("clicked()"), self.afficherFiche)
  29. def signalerModif(self):
  30. """on signale a la fenetre principale que le personnage a ete modifie"""
  31. self.emit(SIGNAL("pjModifie()"), self.idPj)
  32. def pj(self):
  33. """retourne le pj represente"""
  34. return self._pj
  35. def chargerPj(self, pj = None):
  36. """met a jour le contenu avec les donnees du pj en param"""
  37. if pj != None:
  38. self.ui.pj_image.chargerImage(pj.logo)
  39. self.ui.pj_nom.majTexte(pj.nom)
  40. for i in range(0, 6):
  41. bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
  42. bouton.setEnabled(True)
  43. self._pj = pj
  44. def reinitialiser(self):
  45. self.ui.pj_image.majImage("")
  46. self.ui.pj_nom.majTexte("(Nouveau personnage...)")
  47. for i in range(0, 6):
  48. bouton = self.findChild(QPushButton, "pj_afficher_{}".format(i))
  49. bouton.setEnabled(False)
  50. def afficherFiche(self):
  51. """affiche la fiche de perso a la page demandee"""
  52. emetteur = self.sender().objectName()
  53. page = int(str(emetteur)[-1:])
  54. self.editionPj = EcranEditionCombattant(self._pj, page)
  55. self.editionPj.setAttribute(Qt.WA_DeleteOnClose)
  56. r = self.editionPj.exec_()
  57. self._pj = self.editionPj.combattant
  58. self.ui.pj_image.chargerImage(self._pj.logo)
  59. self.ui.pj_nom.majTexte(self._pj.nom)
  60. self.signalerModif()
  61. if __name__ == "__main__":
  62. app = QApplication(sys.argv)
  63. ecran = FramePj(0)
  64. ecran.show()
  65. r = app.exec_()
  66. exit(r)