pilas.lanzador

Package pilas :: Module lanzador |
[hide private]
[frames] | no frames]

# Source Code for Module pilas.lanzador

     1  # -*- coding: utf-8 -*-
     2  from PyQt4 import QtCore, QtGui
     3  import sys
     4  from lanzador_base import Ui_Dialog
     5  import utils
     6
     7 -class Ventana(Ui_Dialog):
     8
     9 -    def setupUi(self, Dialog):
    10          Ui_Dialog.setupUi(self, Dialog)
    11          self.ha_aceptado = False
    12          self._quitar_barras_scroll()
    13          QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
    14          QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.acepta)
    15          QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject)
    16          QtCore.QMetaObject.connectSlotsByName(Dialog)
    17
    18 -    def acepta(self):
    19          self.ha_aceptado = True
    20
    21 -    def obtener_seleccion(self):
    22          motor = ['qtgl', 'qt']
    23          modo = [False, True]
    24          audio = ['gst', 'phonon', 'deshabilitado']
    25
    26          i = self.comboBox.currentIndex()
    27          j = self.comboBox_2.currentIndex()
    28          k = self.comboBox_3.currentIndex()
    29
    30          return (motor[i], modo[j], audio[k])
    31
    32 -    def _quitar_barras_scroll(self):
    33          self.graphicsView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
    34          self.graphicsView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
    35
    36 -    def mostrar_imagen(self, ruta):
    37          escena = QtGui.QGraphicsScene()
    38          self.graphicsView.setScene(escena)
    39          pixmap = QtGui.QGraphicsPixmapItem(QtGui.QPixmap(ruta))
    40
    41          # Define el size para la imagen
    42          width = pixmap.boundingRect().width()
    43          height = pixmap.boundingRect().height()
    44          self.graphicsView.setFixedSize(width, height)
    45
    46          escena.addItem(pixmap)
    47
    48
    49  app = None
    50
    51
    52 -def ejecutar(imagen, titulo):
    53      global app
    54
    55      app = QtGui.QApplication(sys.argv)
    56      Dialog = QtGui.QDialog()
    57      Dialog.setWindowTitle(titulo)
    58      ui = Ventana()
    59      ui.setupUi(Dialog)
    60
    61      if imagen:
    62          ruta_a_imagen = utils.obtener_ruta_al_recurso(imagen)
    63          ui.mostrar_imagen(ruta_a_imagen)
    64
    65      Dialog.show()
    66      Dialog.raise_()
    67      app.exec_()
    68
    69      if not ui.ha_aceptado:
    70          sys.exit(0)
    71
    72      return ui.obtener_seleccion()
    73