Beispiel #1
0
class ChooseDocumentWidget(QtGui.QWidget):
    
    def __init__(self, parent=None):
        super(ChooseDocumentWidget, self).__init__(parent)
        self.ui = Ui_ChooseDocumentWidget()
        self.home_directory =  os.getenv('USERPROFILE') or os.getenv('HOME')
        
        self.ui.setupUi(self)
        self.ui.btn_choose_file.clicked.connect(self.choose_document)
        self.ui.btn_start.clicked.connect(self.start_presentation)
        self.ui.btn_start.setEnabled(False)
        self.show()
        
    
    @QtCore.Slot()
    def choose_document(self):
        filepath = QtGui.QFileDialog.getOpenFileName(self, 
                                                    u'Selecione o Documento NCL',
                                                    self.home_directory,
                                                    'Documento NCL (*.ncl)')
        print filepath
        
        if not filepath:
            self.ui.btn_start.setEnabled(False)
            self.ui.txt_document_name.setText('')
        else:
            self.directory, self.filename = os.path.split(str(filepath))
            self.ui.txt_document_name.setText(filepath)
            self.ui.btn_start.setEnabled(True)
        
    
    @QtCore.Slot()
    def start_presentation(self):
        size_str = self.ui.cmb_size.currentText()
        width, height = 0, 0
        try:
            width, height = size_str.split('x')
            width = int(width)
            height = int(height)
        except:
            QtGui.QMessageBox.warning(self, u'Informações Inválidas',
                                      u'O tamanho especificado é invalido.',
                                      QtGui.QMessageBox.Ok)
            self.ui.cmb_size.setCurrentIndex(0)
            return
        
        use_control = self.ui.ckb_remote_control.checkState() == QtCore.Qt.Checked
        
        self.playback = PlaybackWidget(width, height, self.directory, self.filename)
        #self.playback.activateWindow()
        
        if use_control:
            self.remote_control = RemoteControlWidget()
            self.remote_control.button_pressed.connect(self.playback.key_event)
            #create and initialize control
            
        self.setVisible(False)
Beispiel #2
0
 def __init__(self, parent=None):
     super(ChooseDocumentWidget, self).__init__(parent)
     self.ui = Ui_ChooseDocumentWidget()
     self.home_directory =  os.getenv('USERPROFILE') or os.getenv('HOME')
     
     self.ui.setupUi(self)
     self.ui.btn_choose_file.clicked.connect(self.choose_document)
     self.ui.btn_start.clicked.connect(self.start_presentation)
     self.ui.btn_start.setEnabled(False)
     self.show()