def deleteTab(self):
     
     dialog = QDialog( self )
     dialog.setWindowTitle( "Remove Tab" )
     dialog.resize( 300, 50 )
     
     mainLayout = QVBoxLayout(dialog)
     
     description = QLabel( "'%s' ���� �����Ͻð� ���ϱ�?".decode('utf-8') % self.tabText( self.currentIndex() ) )
     layoutButtons = QHBoxLayout()
     buttonDelete = QPushButton( "�����".decode('utf-8') )
     buttonCancel = QPushButton( "���".decode('utf-8') )
     
     layoutButtons.addWidget( buttonDelete )
     layoutButtons.addWidget( buttonCancel )
     
     mainLayout.addWidget( description )
     mainLayout.addLayout( layoutButtons )
     
     dialog.show()
     
     def cmd_delete():
         self.removeTab( self.indexOf( self.currentWidget() ) )
         dialog.close()
     
     def cmd_cancel():
         dialog.close()
         
     QtCore.QObject.connect( buttonDelete, QtCore.SIGNAL('clicked()'), cmd_delete )
     QtCore.QObject.connect( buttonCancel, QtCore.SIGNAL('clicked()'), cmd_cancel )
Exemple #2
0
 def deleteTab(self):
     
     dialog = QDialog( self )
     dialog.setWindowTitle( "Remove Tab" )
     dialog.resize( 300, 50 )
     
     mainLayout = QVBoxLayout(dialog)
     
     description = QLabel( "'%s' ���� �����Ͻð� ���ϱ�?".decode('utf-8') % self.tabText( self.currentIndex() ) )
     layoutButtons = QHBoxLayout()
     buttonDelete = QPushButton( "�����".decode('utf-8') )
     buttonCancel = QPushButton( "���".decode('utf-8') )
     
     layoutButtons.addWidget( buttonDelete )
     layoutButtons.addWidget( buttonCancel )
     
     mainLayout.addWidget( description )
     mainLayout.addLayout( layoutButtons )
     
     dialog.show()
     
     def cmd_delete():
         self.removeTab( self.indexOf( self.currentWidget() ) )
         dialog.deleteLater()
     
     def cmd_cancel():
         dialog.deleteLater()
         
     QtCore.QObject.connect( buttonDelete, QtCore.SIGNAL('clicked()'), cmd_delete )
     QtCore.QObject.connect( buttonCancel, QtCore.SIGNAL('clicked()'), cmd_cancel )
Exemple #3
0
	def settings(self):
		if self.settings_window is None:
			window = QDialog(self)
			self.settings_window = window
		else: window = self.settings_window
		window = self.settings_window
		window.setWindowTitle('Settings')
		
		window.notelabel = QLabel("Currently these settings are only guaranteed to work prior to loading the first MIDI!\nYou'll have to restart ADLMIDI pyGui to change them again if they stop working. \n\nSorry! This will be fixed soon!")
		window.notelabel.setWordWrap(True)
		window.notelabel.setStyleSheet("font-size: 8pt; border-style: dotted; border-width: 1px; padding: 12px;")
		window.banklabel = QLabel("<B>Choose Instrument Bank</B>")
		window.space     = QLabel("")
		window.optlabel  = QLabel("<B>Options</B>")
		
		window.combo = QComboBox()
		window.combo.addItems(self.banks)
		#window.combo.setMaximumWidth(350)
		window.combo.setMaxVisibleItems(12)
		window.combo.setStyleSheet("combobox-popup: 0;")
		window.combo.setCurrentIndex(int(self.progset.value("sound/bank", 1)))
		window.combo.currentIndexChanged.connect(self.saveSettings)
		
		window.perc		= QCheckBox("Adlib Percussion Instrument Mode")
		#window.perc.stateChanged.connect(self.checkOpts)
		window.tremamp  = QCheckBox("Tremolo Amplification Mode")
		#window.tremamp.stateChanged.connect(self.checkOpts)
		window.vibamp   = QCheckBox("Vibrato Amplification Mode")
		#window.vibamp.stateChanged.connect(self.checkOpts)
		window.modscale = QCheckBox("Scaling of Modulator Volume")
		#window.modscale.stateChanged.connect(self.checkOpts)
		
		window.okButton = QPushButton('OK')
		window.okButton.clicked.connect(window.hide)
		
		vbox = QVBoxLayout()
		vbox.addWidget(window.space)
		vbox.addWidget(window.banklabel)
		vbox.addWidget(window.combo)
		vbox.addWidget(window.space)
		vbox.addWidget(window.optlabel)
		vbox.addWidget(window.perc)
		vbox.addWidget(window.tremamp)
		vbox.addWidget(window.vibamp)
		vbox.addWidget(window.modscale)
		vbox.addWidget(window.notelabel)
		
		hbox = QHBoxLayout()
		hbox.addStretch(1)
		hbox.addWidget(window.okButton)
		
		vbox.addLayout(hbox)
		window.setLayout(vbox) 
		
		window.setFixedSize(530, 369)
		window.show()
		window.activateWindow()
		window.raise_()
Exemple #4
0
 def _showpostviewerdialog(self, post):
     d = QDialog(self)
     d.resize(1024, 768)
     l = QVBoxLayout()
     w = PostViewerWidget(post, self._backend, self._masterobserver, self)
     w.nextpostrequested.connect(self._putnextpost)
     w.previouspostrequested.connect(self._putpreviouspost)
     w.closing.connect(d.close)
     l.addWidget(w)
     d.setLayout(l)
     d.setModal(False)
     d.show()
Exemple #5
0
    def addTab(self):
        
        dialog = QDialog( self )
        dialog.setWindowTitle( 'Add Tab' )
        dialog.resize( 300, 50 )
        
        mainLayout = QVBoxLayout( dialog )
        
        tabNameLayout = QHBoxLayout()
        labelTabName = QLabel( 'Tab Name : ' )
        lineEditTabName = QLineEdit()
        tabNameLayout.addWidget( labelTabName )
        tabNameLayout.addWidget( lineEditTabName )
        
        buttonsLayout = QHBoxLayout()
        buttonCreate = QPushButton( "Create" )
        buttonCancel  = QPushButton( "Cancel")
        buttonsLayout.addWidget( buttonCreate )
        buttonsLayout.addWidget( buttonCancel )
        
        mainLayout.addLayout( tabNameLayout )
        mainLayout.addLayout( buttonsLayout )
        
        dialog.show()

        def cmd_create():            
            tabName = lineEditTabName.text()
            if not tabName:
                msgbox = QMessageBox( self )
                msgbox.setText( "�̸��� �������ּ���".decode( 'utf-8' ) )
                msgbox.exec_()
                return

            self.tabWidget.addTab( tabName )
            dialog.deleteLater()
        
        def cmd_cancel():
            dialog.deleteLater()
        
        QtCore.QObject.connect( lineEditTabName, QtCore.SIGNAL( 'returnPressed()' ), cmd_create )
        QtCore.QObject.connect( buttonCreate, QtCore.SIGNAL( 'clicked()' ), cmd_create )
        QtCore.QObject.connect( buttonCancel, QtCore.SIGNAL( 'clicked()' ), cmd_cancel )
    def addTab(self):
        
        dialog = QDialog( self )
        dialog.setWindowTitle( 'Add Tab' )
        dialog.resize( 300, 50 )
        
        mainLayout = QVBoxLayout( dialog )
        
        tabNameLayout = QHBoxLayout()
        labelTabName = QLabel( 'Tab Name : ' )
        lineEditTabName = QLineEdit()
        tabNameLayout.addWidget( labelTabName )
        tabNameLayout.addWidget( lineEditTabName )
        
        buttonsLayout = QHBoxLayout()
        buttonCreate = QPushButton( "Create" )
        buttonCancel  = QPushButton( "Cancel")
        buttonsLayout.addWidget( buttonCreate )
        buttonsLayout.addWidget( buttonCancel )
        
        mainLayout.addLayout( tabNameLayout )
        mainLayout.addLayout( buttonsLayout )
        
        dialog.show()

        def cmd_create():            
            tabName = lineEditTabName.text()
            if not tabName:
                msgbox = QMessageBox( self )
                msgbox.setText( "�̸��� �������ּ���".decode( 'utf-8' ) )
                msgbox.exec_()
                return

            self.tabWidget.addTab( tabName )
            dialog.close()
        
        def cmd_cancel():
            dialog.close()
        
        QtCore.QObject.connect( lineEditTabName, QtCore.SIGNAL( 'returnPressed()' ), cmd_create )
        QtCore.QObject.connect( buttonCreate, QtCore.SIGNAL( 'clicked()' ), cmd_create )
        QtCore.QObject.connect( buttonCancel, QtCore.SIGNAL( 'clicked()' ), cmd_cancel )
Exemple #7
0
class MenuBar(QMenuBar):
    def __init__(self, *args, **kwargs):

        super(MenuBar, self).__init__(*args, **kwargs)
        try:
            menu = self.addMenu("&정보".decode('utf-8'))
            menu.addAction("툴 정보".decode('utf-8'), self.loadToolTip)
        except:
            pass

    def loadToolTip(self):

        try:
            self.dialog.deleteLater()
        except:
            pass

        self.dialog = QDialog(self)
        self.dialog.setWindowTitle("툴 정보".decode('utf-8'))
        dialogLayout = QVBoxLayout(self.dialog)
        lb_description = Label_descriptionImage()
        dialogLayout.addWidget(lb_description)
        self.dialog.show()
Exemple #8
0
class createProject():
    def __init__(self, parent):
        
        self.parent = parent
        
        self.directory = ""      
        
        self.dialog = QDialog(parent.parent)
        
        mainLayout = QVBoxLayout()
        
        aux = QHBoxLayout()
        name = QLabel("Project Name: ")
        self.textBox = QLineEdit()
        
        aux.addWidget(name)
        aux.addWidget(self.textBox)
        aux2 = QWidget()
        aux2.setLayout(aux)
        mainLayout.addWidget(aux2)       
        
                    
        auxBox = QHBoxLayout()
        self.directoryLabel = QLabel("Directory: ")
        button = QPushButton("...")
        button.clicked.connect(self.fileChoosing)
        auxBox.addWidget(self.directoryLabel)
        auxBox.addWidget(button)
        auxWidget = QWidget()
        auxWidget.setLayout(auxBox)
        mainLayout.addWidget(auxWidget) 
        
        buttonOk = QPushButton("Create Project")
        buttonOk.clicked.connect(self.okClicked)
        mainLayout.addWidget(buttonOk)
        
        self.dialog.setLayout(mainLayout)
        self.dialog.show()
        
    def fileChoosing(self):
                
        filePicker = QFileDialog()
        self.directory = filePicker.getExistingDirectory(self.parent, "Get Directory")
        self.directoryLabel.setText("Directory: " + self.directory)            
        filePicker.destroy()
        
    def okClicked(self):
               
        if self.directory != "" and self.textBox.text() != "":
            try:
                if self.parent.parent.platform == "linux2":
                    os.mkdir(self.directory + "/"+ self.textBox.text())
                    self.parent.parent.project = Project(self.directory + "/"+ self.textBox.text(), self.textBox.text(), "linux2")
                                                
                elif self.parent.parent.platform == "win32":
                    os.mkdir(self.directory + "\\"+ self.textBox.text())
                    self.parent.parent.project = Project(self.directory + "\\"+ self.textBox.text(), self.textBox.text(), "win32")
                                                                                                    
                self.parent.parent.project.save()
                self.dialog.setVisible(False)
                
                self.parent.parent.fileMenu.saveProjectAction.setEnabled(True)
                self.parent.parent.signalMenu.addSignalAction.setEnabled(True)
                self.parent.parent.signalMenu.applyOperationAction.setEnabled(True)
                
                msg = QMessageBox(self.parent.parent)
                msg.setText("Project created")
                msg.show()
                                  
                               
            except OSError:
                msg = QErrorMessage(self.parent.parent)            
                msg.showMessage("Project already exists")
Exemple #9
0
class addSignal():
    def __init__(self, parent):
        
        self.parent = parent
        
        self.dialog = QDialog(self.parent.parent)
        
        mainLayout = QVBoxLayout()
        
        aux = QHBoxLayout()
        name = QLabel("Signal Name: ")
        self.nameBox = QLineEdit()
        aux.addWidget(name)
        aux.addWidget(self.nameBox)
        aux2 = QWidget()
        aux2.setLayout(aux)
        mainLayout.addWidget(aux2)   
        
                                       
        auxBox = QHBoxLayout()
        self.fileLabel = QLabel("File: ")
        button = QPushButton("...")
        button.clicked.connect(self.fileChoosing)
        auxBox.addWidget(self.fileLabel)
        auxBox.addWidget(button)
        auxWidget = QWidget()
        auxWidget.setLayout(auxBox)
        mainLayout.addWidget(auxWidget)
        
        
        hBox = QHBoxLayout()
        hBox.addWidget(QLabel("Sample Rate (Hz): "))
        self.sampleRate = QLineEdit()
        self.sampleRate.setText("60")
        hBox.addWidget(self.sampleRate)
        auxW = QWidget()
        auxW.setLayout(hBox)
        mainLayout.addWidget(auxW)      
        
        
        auxBox = QHBoxLayout()
        commentaryLabel = QLabel("Commentary: ")
        self.commentaryBox = QTextEdit()
        auxBox.addWidget(commentaryLabel)
        auxBox.addWidget(self.commentaryBox)
        auxWidget = QWidget()
        auxWidget.setLayout(auxBox)
        mainLayout.addWidget(auxWidget)
        
        
        buttonOk = QPushButton("Add Signal")
        buttonOk.clicked.connect(self.addSignalClicked)
        mainLayout.addWidget(buttonOk)
        
        self.dialog.setLayout(mainLayout)
        self.dialog.show()
        
    def fileChoosing(self):
                        
            filePicker = QFileDialog()
            self.fileName = filePicker.getOpenFileName(self.parent, 'Select File')[0]
            filePicker.destroy() 
            self.fileLabel.setText("File: " + self.fileName)            
            filePicker.destroy()
        
    def addSignalClicked(self):
                
        if self.fileName != "" and self.nameBox.text() != "":
            self.parent.parent.project.addSignal(self.nameBox.text(), self.fileName, self.commentaryBox.toPlainText(), self.sampleRate.text())
            self.dialog.setVisible(False)
            label = self.parent.parent.project.signalList[-1][0].getImage()
            
            if self.parent.parent.table.columnCount() == 0: self.parent.parent.table.setColumnCount(1)
            
            self.parent.parent.table.setRowCount(self.parent.parent.table.rowCount() + 1)
            
            self.parent.parent.table.setCellWidget(len(self.parent.parent.project.signalList)-1,0,label)
            self.parent.parent.table.resizeColumnsToContents()
            self.parent.parent.table.resizeRowsToContents()
            self.parent.parent.setLabels()
                            
            msg = QMessageBox(self.parent.parent)
            msg.setText("Signal added")
            msg.show()       
Exemple #10
0
class Thread(QThread):
    message = Signal(str)

    def __init__(self,
                 parent,
                 func,
                 arg=None,
                 progressText=None,
                 pb_widget=None,
                 redirect_stdout=False,
                 abortButton=False):
        QThread.__init__(self, parent)
        self.func = func
        self.arg = arg
        self.progressText = progressText
        self.pb_widget = pb_widget
        self.redirect_stdout = redirect_stdout
        self.abortButton = abortButton
        self.finished.connect(self.hideProgressbar)
        self.showProgressbar()

    def run(self):
        if self.redirect_stdout:
            sys.stdout = self
        try:
            if self.arg:
                self.data = self.func(self.arg)
            else:
                self.data = self.func()
            self._executed = True
        except Exception as e:
            self._executed = False
            self._executedError = e
            traceback.print_exc()
            exctype, value = sys.exc_info()[:2]
            self._executedErrorInfo = '{} {} {}'.\
                format(exctype, value, traceback.format_exc())
        sys.stdout = sys.__stdout__

    def showProgressbar(self):
        if self.progressText:

            # generate widget if not given in init
            if not self.pb_widget:
                self.pb_widget = QDialog(self.parent())
                self.pb_widget.setWindowFlags(Qt.SplashScreen)
                self.pb_widget.setModal(True)

            # add button
            delete_button = QPushButton('X')
            delete_button.clicked.connect(self.exit)
            hl = QHBoxLayout()
            pb = QProgressBar()
            pb.setRange(0, 0)
            hl.addWidget(pb)
            hl.addWidget(QLabel(self.progressText))
            if self.abortButton:
                hl.addWidget(delete_button)
            self.pb_widget.setLayout(hl)
            self.pb_widget.show()

    def hideProgressbar(self):
        if self.pb_widget:
            self.pb_widget.hide()

    def write(self, text):
        self.message.emit(text)

    def flush(self):
        pass
Exemple #11
0
class MultiThread(QThread):
    finished = Signal(str)
    message = Signal(str)

    def __init__(self,
                 parent,
                 func,
                 args,
                 ncores=1,
                 progressText=None,
                 pb_widget=None,
                 redirect_stdout=False):
        QThread.__init__(self, parent)
        self.func = func
        self.args = args
        self.ncores = ncores
        self.progressText = progressText
        self.pb_widget = pb_widget
        self.redirect_stdout = redirect_stdout
        self.finished.connect(self.hideProgressbar)
        self.showProgressbar()

    def run(self):
        if self.redirect_stdout:
            sys.stdout = self
        try:
            if not self.ncores:
                self.ncores = multiprocessing.cpu_count()
            pool = multiprocessing.Pool(self.ncores)
            self.data = pool.map_async(self.func,
                                       self.args,
                                       callback=self.emitDone)
            #self.data = pool.apply_async(self.func, self.shotlist, callback=self.emitDone) #emit each time returned
            pool.close()
            self._executed = True
        except Exception as e:
            self._executed = False
            self._executedError = e
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print('Exception: {}, file: {}, line: {}'.format(
                exc_type, fname, exc_tb.tb_lineno))
        sys.stdout = sys.__stdout__

    def showProgressbar(self):
        if self.progressText:
            if not self.pb_widget:
                self.pb_widget = QDialog(self.parent())
                self.pb_widget.setWindowFlags(Qt.SplashScreen)
                self.pb_widget.setModal(True)
            hl = QHBoxLayout()
            pb = QProgressBar()
            pb.setRange(0, 0)
            hl.addWidget(pb)
            hl.addWidget(QLabel(self.progressText))
            self.pb_widget.setLayout(hl)
            self.pb_widget.show()

    def hideProgressbar(self):
        if self.pb_widget:
            self.pb_widget.hide()

    def write(self, text):
        self.message.emit(text)

    def flush(self):
        pass

    def emitDone(self, result):
        print('emitDone!')
        self.finished.emit('Done thread!')
        self.hideProgressbar()
Exemple #12
0
 def __init__(self, parent):
     
     dialog = QDialog(parent.parent)
     
     mainLayout = QVBoxLayout()
     
     aux = QHBoxLayout()
     name = QLabel("Signal Name: ")
     nameBox = QLineEdit()
     aux.addWidget(name)
     aux.addWidget(nameBox)
     aux2 = QWidget()
     aux2.setLayout(aux)
     mainLayout.addWidget(aux2)
     
     def fileChoosing():
         global fileName
         
         filePicker = QFileDialog()
         fileName = filePicker.getOpenFileName(parent, 'Select File')[0]
         filePicker.destroy() 
         fileLabel.setText("File: " + fileName)            
         filePicker.destroy()
     
     def addSignalClicked():
         global directory
         
         if fileName != "" and nameBox.text() != "":
             parent.parent.project.addSignal(nameBox.text(), fileName, commentaryBox.toPlainText())
             dialog.setVisible(False)
             label = parent.parent.project.signalList[-1][0].getImage()
             
             if parent.parent.mainWidget.columnCount() == 0: parent.parent.mainWidget.setColumnCount(1)
             
             parent.parent.mainWidget.setRowCount(parent.parent.mainWidget.rowCount() + 1)
             
             parent.parent.mainWidget.setCellWidget(len(parent.parent.project.signalList)-1,0,label)
             parent.parent.mainWidget.resizeColumnsToContents()
             parent.parent.mainWidget.resizeRowsToContents()
                             
             msg = QMessageBox(parent.parent)
             msg.setText("Signal added")
             msg.show()
             
                                    
     auxBox = QHBoxLayout()
     fileLabel = QLabel("File: ")
     button = QPushButton("...")
     button.clicked.connect(fileChoosing)
     auxBox.addWidget(fileLabel)
     auxBox.addWidget(button)
     auxWidget = QWidget()
     auxWidget.setLayout(auxBox)
     mainLayout.addWidget(auxWidget)
     
     auxBox = QHBoxLayout()
     commentaryLabel = QLabel("Commentary: ")
     commentaryBox = QTextEdit()
     auxBox.addWidget(commentaryLabel)
     auxBox.addWidget(commentaryBox)
     auxWidget = QWidget()
     auxWidget.setLayout(auxBox)
     mainLayout.addWidget(auxWidget)
     
     
     buttonOk = QPushButton("Add Signal")
     buttonOk.clicked.connect(addSignalClicked)
     mainLayout.addWidget(buttonOk)
     
     dialog.setLayout(mainLayout)
     dialog.show()  
Exemple #13
0
        return "{} {}".format(self.name, self.price)


# form_rendered._field_map['name'].set_value("king")
# form_rendered._field_map['price'].set_value("1337")

data = Data(name="King Kong", price=123)

d = {'list': ['alpha', 'beta', 'gamma'], 'group': data}

form_rendered = Render(form)
form_rendered.set_all_values(data)
form_rendered.read_all_values(data)
print(data)

d = QDialog()
view = PySide.QtWebKit.QWebView(d)
view.setZoomFactor(1.5)
# view.setHtml("Hello world <a href='eulu.html'>Link</a>")
# view.setUrl('file:///Users/stc/Dropbox/index.html')
view.setUrl(
    'file:///PORT-STC/PRIVATE/SlickGrid-2.2.6/examples/example14-highlighting.html'
)
top_layout = QHBoxLayout()
top_layout.addWidget(view)
top_layout.addLayout(form_rendered.render())
d.setLayout(top_layout)
d.show()

d.exec_()
 def __init__(self, parent):
             
     directory = ""      
     
     dialog = QDialog(parent.parent)
     
     mainLayout = QVBoxLayout()
     
     aux = QHBoxLayout()
     name = QLabel("Project Name: ")
     textBox = QLineEdit()
     
     aux.addWidget(name)
     aux.addWidget(textBox)
     aux2 = QWidget()
     aux2.setLayout(aux)
     mainLayout.addWidget(aux2)
     
     def fileChoosing():
         global directory
         
         filePicker = QFileDialog()
         directory = filePicker.getExistingDirectory(parent, "Get Directory")
         directoryLabel.setText("Directory: " + directory)            
         filePicker.destroy()
     
     def okClicked():
         global directory
         
         if directory != "" and textBox.text() != "":
             try:
                 os.mkdir(directory + "/"+ textBox.text())
                 parent.parent.project = Project(directory + "/"+ textBox.text(), textBox.text())
                 parent.parent.project.save()
                 dialog.setVisible(False)
                 
                 parent.parent.fileMenu.saveProjectAction.setEnabled(True)
                 parent.parent.signalMenu.addSignalAction.setEnabled(True)
                 parent.parent.signalMenu.applyOperationAction.setEnabled(True)
                 
                 msg = QMessageBox(parent.parent)
                 msg.setText("Project created")
                 msg.show()
                                   
                                
             except OSError:
                 msg = QErrorMessage(parent.parent)            
                 msg.showMessage("Project already exists")
                 
     auxBox = QHBoxLayout()
     directoryLabel = QLabel("Directory: ")
     button = QPushButton("...")
     button.clicked.connect(fileChoosing)
     auxBox.addWidget(directoryLabel)
     auxBox.addWidget(button)
     auxWidget = QWidget()
     auxWidget.setLayout(auxBox)
     mainLayout.addWidget(auxWidget) 
     
     buttonOk = QPushButton("Create Project")
     buttonOk.clicked.connect(okClicked)
     mainLayout.addWidget(buttonOk)
     
     dialog.setLayout(mainLayout)
     dialog.show() 
Exemple #15
0
    def matchResult(self, result):
        """
        显示匹配状态
        """
        isMatch = True
        match_num = 0

        def accept():
            if isMatch:
                self.passFlag = True
                dialog.accept()
                self.defaultConfig(False)
                self.close()
            else:
                self.passFlag = False
                dialog.reject()

        dialog = QDialog()
        ui = Ui_DialogMatch()
        ui.setupUi(dialog)
        ui.okButton.clicked.connect(accept)
        dialog.setModal(True)
        groupState = [
            ui.pressure1, ui.pressure2, ui.pressure3, ui.pressure4,
            ui.pressure5, ui.pressure6, ui.digital1, ui.digital2, ui.digital3,
            ui.digital4, ui.speed1, ui.speed2
        ]
        groupCheck = [
            self.pres_chk1, self.pres_chk2, self.pres_chk3, self.pres_chk4,
            self.pres_chk5, self.pres_chk6, self.num_chk1, self.num_chk2,
            self.num_chk3, self.num_chk4, self.speed_chk
        ]
        if not result:
            return
        else:
            for i, j in enumerate(result):
                if i < 11:
                    if result[i] == '0':
                        if groupCheck[i].isChecked():
                            groupState[i].setText(u'匹配')
                            palette = groupState[i].palette()
                            palette.setColor(QPalette.WindowText, Qt.green)
                            groupState[i].setPalette(palette)
                            match_num += 1
                        else:
                            groupState[i].setText(u'接通')
                            palette = groupState[i].palette()
                            palette.setColor(QPalette.WindowText, Qt.blue)
                            groupState[i].setPalette(palette)
                    else:
                        if groupCheck[i].isChecked():
                            groupState[i].setText(u'不匹配')
                            palette = groupState[i].palette()
                            palette.setColor(QPalette.WindowText, Qt.red)
                            groupState[i].setPalette(palette)
                            ui.okButton.setEnabled(False)
                            isMatch = False
                        else:
                            groupState[i].setText(u'断开')
                            palette = groupState[i].palette()
                            palette.setColor(QPalette.WindowText, Qt.gray)
                            groupState[i].setPalette(palette)
                else:
                    if result[i] == '0':
                        self.trigger_combo.setCurrentIndex(2)
                        groupState[i].setText(u'外触发启用')
                        palette = groupState[i].palette()
                        palette.setColor(QPalette.WindowText, Qt.green)
                        groupState[i].setPalette(palette)
                        match_num += 1
                    else:
                        if self.trigger_combo.currentIndex() == 2:
                            groupState[i].setText(u'不匹配')
                            palette = groupState[i].palette()
                            palette.setColor(QPalette.WindowText, Qt.red)
                            groupState[i].setPalette(palette)
                            ui.okButton.setEnabled(False)
                            isMatch = False
                        else:
                            groupState[i].setText(u'断开')
                            palette = groupState[i].palette()
                            palette.setColor(QPalette.WindowText, Qt.gray)
                            groupState[i].setPalette(palette)
            if isMatch:
                ui.linkState.setText(u'匹配成功,%d条线路匹配' % match_num)
            else:
                ui.linkState.setText(u'匹配失败,%d条线路匹配' % match_num)
            dialog.show()
            dialog.exec_()
Exemple #16
0
class UiMain(QMainWindow):
    """ The main gui interface, invokes all windows and ties everything
     together
    """
    def __init__(self):
        """ automatically called __init__ function """

        super(UiMain, self).__init__()

        # initialize all the variables that are going to be defined in the
        # future
        self.update_dialog = None
        self.update_dialog_lbl = None
        self.app_select_box = None
        self.selector_lbl = None
        self.current_playing_lbl = None
        self.current_playing = None
        self.misc_messages = None
        self.start_btn = None
        self.output_dir_lbl = None
        self.select_output_dir_btn = None
        self.output_cur_dir_lbl = None
        self.active_items_list = None
        self.inactive_items_list = None
        self.switch_active_item_button_off = None
        self.switch_active_item_button_on = None
        self.switch_output_split_btn = None
        self.switch_output_split_lbl = None

        # initialize the system tray
        # self.system_tray = QSystemTrayIcon(self)
        # self.system_tray.setIcon(QIcon(resource_path('icon.png')))
        # self.system_tray.show()
        # self.system_tray.setToolTip('SMG')
        # self.system_tray.activated.connect(self.on_systray_activated)

        # initialize the main window
        self.setObjectName('self')
        self.setWindowTitle('SMG - By Azeirah')
        self.resize(400, 250)

        # Gives the self an icon
        self.setWindowIcon(QIcon(resource_path('icon.png')))

        # create the tabs
        # the tab widget itself
        self.tabbed_windows = QTabWidget(self)
        self.tabbed_windows.resize(400, 300)

        # tab 1, contains the music player selection
        self.music_players = QFrame()

        # tab 2, contains options
        self.options = QFrame()
        self.tabbed_windows.addTab(self.music_players, 'Music players')
        self.tabbed_windows.addTab(self.options, 'Options')

        # initializes the two tabs, with all the code down below
        self.tab_music_players()
        self.tab_options()

        # shows the main window
        self.show()

        # self.update()
        CheckUpdateThread = Thread(target=self.update)
        CheckUpdateThread.setName('CheckUpdateThread')
        CheckUpdateThread.run()

    def closeEvent(self, event):
        """ an automatically called function when the program is about to
        close.
        """
        # Stops all Threads. These would continue to run in the background
        # Even if the window was closed.
        Main.running = False
        # close the ZuneNowPlaying.exe process
        if Constants.SUBP:
            Constants.SUBP.kill()

    def changeEvent(self, event):
        # if event.type() == QEvent.WindowStateChange:
        #     if self.isMinimized():
        #         event.ignore()
        #         self.hide()
        #         self.system_tray.showMessage('Running', 'Running in the
        #           background.')
        #         return

        super(UiMain, self).changeEvent(event)

    def on_systray_activated(self, reason):
        if reason == QSystemTrayIcon.DoubleClick:
            self.show()

    @staticmethod
    def toggle_split(event):
        # 0 = Qt.Unchecked The item is unchecked.
        # 1 = Qt.PartiallyChecked The item is partially checked. Items in
        # hierarchical models may be partially checked if some, but not all,
        # of
        # their children are checked.
        # 2 = Qt.Checked The item is checked.
        if event == 0:
            Constants.OPTIONS['splitText'] = False
        elif event == 2:
            Constants.OPTIONS['splitText'] = True

    def update(self):
        """ Checks a webpage for current version, compares this to built-in
        current versions, and shows update dialog if necessary
        """
        try:
            ver = urlopen('http://league-insanity.tk/Azeirah_content/version')\
                .read()
        except IOError:
            # if for some reason it couldn't retrieve the version, set it to
            # automatically ignore the update: False
            ver = False
        if not float(VERSION) >= float(ver):
            self.popup = QDialog(self)
            self.popup.setModal(True)
            self.popup.setGeometry(200, 100, 500, 100)
            self.popup.show()

            self.popup_text = QLabel(self.popup)
            self.popup_text.setGeometry(5, 5, 500, 30)
            self.popup_text.setOpenExternalLinks(True)
            self.popup_text.show()
            self.popup_text.setText(
                """There is an update available. Run update.exe or <a href='https://sourceforge.net/projects/obsmusicstreamd'>download the update manually</a>"""
            )
            # reply = QMessageBox.question(Constants.UI, 'Message',
            #                              "Do you want to update?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
            # if reply == QMessageBox.Yes:
            #     import atexit
            #     import subprocess

            #     def runUpdater():
            #         import time
            #         time.sleep(3)
            #         subprocess.Popen(resource_path('update.exe'))
            #     atexit.register(runUpdater)
            #     sys.exit()

            #     Constants.update_dialog = QWidget()
            #     Constants.update_dialog.resize(350, 100)
            #     Constants.update_dialog.setWindowIcon(QIcon(resource_path\
            #         ('icon.png')))
            #     Constants.update_dialog.setWindowTitle('Updater')
            #     Constants.update_dialog_lbl = QLabel(Constants.update_dialog)
            #     Constants.update_dialog_lbl.setGeometry(10, 40, 340, 12)
            #     Constants.update_dialog.show()

            #     updateThread = Thread(target = update.update)
            #     updateThread.setName('updateThread')
            #     updateThread.start()

    def tab_music_players(self):
        """ Everything inside the Music players tab gets created here."""
        # self.music_players
        # Creates the box with all the music players inside of it
        self.app_select_box = QComboBox(self.music_players)
        self.app_select_box.setGeometry(135, 10, 150, 25)
        # Whenever you change the application, it runs the selectnewapp func
        self.app_select_box.activated[str].connect(self.select_new_app)

        # Creates the label for the selection combobox
        self.selector_lbl = QLabel(self.music_players)
        self.selector_lbl.setGeometry(10, 10, 150, 25)
        self.selector_lbl.setText('Select your music player: ')

        # Creates the label for the current playing song (and the current
        # playing song label)
        self.current_playing_lbl = QLabel(self.music_players)
        self.current_playing_lbl.setGeometry(10, 45, 150, 25)
        self.current_playing_lbl.setText('Current playing song: ')

        self.current_playing = QLabel(self.music_players)
        self.current_playing.setGeometry(117, 45, 250, 25)
        self.current_playing.setText(Misc.noSongPlaying)

        # Creates a label which displays any additional messages
        self.misc_messages = QLabel(self.music_players)
        self.misc_messages.setGeometry(10, 80, 390, 24)
        self.misc_messages.setText(Misc.misc_message())
        self.misc_messages.setOpenExternalLinks(True)

        # adds all the music players into the combobox
        self.app_select_box.addItem(None)
        for item in Constants.ACTIVEITEMS:
            if item == '__name__' or item == 'active':
                continue
            self.app_select_box.addItem(item)

        # creates the start button
        self.start_btn = QPushButton(self.music_players)
        self.start_btn.setGeometry(75, 120, 250, 35)
        self.start_btn.setText('Start')

        # links the start button to the self.start function
        QObject.connect(
            self.start_btn, SIGNAL("clicked()"),
            lambda: Thread(target=self.start, name='startbutton').start())

    def tab_options(self):
        """ Everything inside the Options tab gets created here. """
        # self.options

        # This section is for selecting output dir
        # Creates the output dir label
        self.output_dir_lbl = QLabel(self.options)
        self.output_dir_lbl.setGeometry(10, 10, 125, 15)
        self.output_dir_lbl.setText('Change Output Directory: ')

        # Creates the output dir button
        self.select_output_dir_btn = QPushButton(self.options)
        self.select_output_dir_btn.setGeometry(137, 8, 30, 20)
        self.select_output_dir_btn.setText('...')

        # Creates the output dir currentdir Lineedit
        self.output_cur_dir_lbl = QLineEdit(self.options)
        self.output_cur_dir_lbl.setGeometry(170, 6, 210, 25)
        self.output_cur_dir_lbl.setReadOnly(True)
        self.output_cur_dir_lbl.setText(
            Constants.CONFIG.get('directories', 'current_song'))

        # when the '...' button is clicked, show a dialog (fire func
        # disp_dialog)
        QObject.connect(self.select_output_dir_btn, SIGNAL("clicked()"),
                        self.disp_dialog)

        # This section is for selecting what players you use
        # The box with all the active players
        self.active_items_list = QListWidget(self.options)
        self.active_items_list.setGeometry(10, 40, 150, 100)

        # The box with all the inactive players
        self.inactive_items_list = QListWidget(self.options)
        self.inactive_items_list.setGeometry(230, 40, 150, 100)
        # Populate the two boxes with active and inactive items
        for item in Constants.ACTIVEITEMS:
            if item == '__name__' or item == 'active':
                continue
            self.active_items_list.addItem(item)
        for item in Constants.INACTIVEITEMS:
            if item == '__name__' or item == 'active':
                continue
            self.inactive_items_list.addItem(item)

        # The buttons responsible for switching
        # off button
        self.switch_active_item_button_off = QPushButton(self.options)
        self.switch_active_item_button_off.setText('->'.decode('utf-8'))
        # Makes the -> readable and clear
        self.switch_active_item_button_off.setFont(QFont('SansSerif', 17))
        self.switch_active_item_button_off.setGeometry(175, 55, 40, 30)
        # on button
        self.switch_active_item_button_on = QPushButton(self.options)
        self.switch_active_item_button_on.setText('<-'.decode('utf-8'))
        # makes <- readable and clear
        self.switch_active_item_button_on.setFont(QFont('SansSerif', 17))
        self.switch_active_item_button_on.setGeometry(175, 90, 40, 30)

        QObject.connect(self.switch_active_item_button_on, SIGNAL("clicked()"),
                        self.switch_item_on)
        QObject.connect(self.switch_active_item_button_off,
                        SIGNAL("clicked()"), self.switch_item_off)

        # A button to toggle the split output in half option. It's a temporary
        # fix for the Foobar double output problem.
        self.switch_output_split_btn = QCheckBox(self.options)
        self.switch_output_split_btn.setCheckState(Qt.CheckState.Unchecked)
        self.switch_output_split_btn.setGeometry(10, 140, 40, 30)
        self.switch_output_split_btn.stateChanged.connect(self.toggle_split)

        # The label for the split toggle
        self.switch_output_split_lbl = QLabel(self.options)
        self.switch_output_split_lbl.setText(
            "Split the output text in half (don't use this if you don't need it)"
        )
        self.switch_output_split_lbl.setGeometry(30, 140, 300, 30)

    def switch_item_on(self):
        """ Switches items (musicapps) on """
        try:
            # If an item from the active box is selected
            # Remove it and place it inside the inactive box
            item_taken = self.inactive_items_list.takeItem(
                self.inactive_items_list.currentRow())
            self.active_items_list.addItem(item_taken)
            active_items = {}
            inactive_items = {}
            for i in range(self.active_items_list.count()):
                active_items[self.active_items_list.item(i).text()] =\
                    ITEMS[self.active_items_list.item(i).text()
                          .encode('utf-8')]
            for i in range(self.inactive_items_list.count()):
                inactive_items[self.inactive_items_list.item(i).text()] =\
                    ITEMS[self.inactive_items_list.item(i).text()
                          .encode('utf-8')]
            Constants.ACTIVE_ITEMS = active_items
            Constants.INACTIVE_ITEMS = inactive_items
            # clear the selection combobox
            self.app_select_box.clear()
            # Repopulate the combobox
            self.app_select_box.addItem(None)
            for item in active_items:
                self.app_select_box.addItem(item)
            Constants.CONFIG.set('active', item_taken.text(),
                                 ITEMS[item_taken.text()])
            Constants.CONFIG.remove_option('inactive', item_taken.text())
            # Updates the config file to be up to date with activeItems
            Constants.CONFIG.update()
        except:
            raise

    def switch_item_off(self):
        """ Switches items (musicapps) off """
        try:
            # If an item from the inactive box is selected.
            # Remove it and place it inside the active box
            item_taken = self.active_items_list.takeItem(
                self.active_items_list.currentRow())
            self.inactive_items_list.addItem(item_taken)
            # update activeItems
            active_items = {}
            inactive_items = {}
            for i in range(self.active_items_list.count()):
                active_items[self.active_items_list.item(i).text()] =\
                    ITEMS[self.active_items_list.item(i).text()
                          .encode('utf-8')]
            for i in range(self.inactive_items_list.count()):
                inactive_items[self.inactive_items_list.item(i).text()] =\
                    ITEMS[self.inactive_items_list.item(i).text()
                          .encode('utf-8')]
            Constants.ACTIVE_ITEMS = active_items
            Constants.INACTIVE_ITEMS = inactive_items
            # clear the selection combobox
            self.app_select_box.clear()
            # Repopulate the combobox
            self.app_select_box.addItem(None)
            for item in active_items:
                self.app_select_box.addItem(item)
            # Updates the active items Constants property
            Constants.CONFIG.set('inactive', item_taken.text(),
                                 ITEMS[item_taken.text()])
            Constants.CONFIG.remove_option('active', item_taken.text())
            # Updates the config file to be up to date with activeItems
            Constants.CONFIG.update()
        except:
            raise

    def disp_dialog(self):
        """  displays the dialog which select a directory for output. """
        fname = QFileDialog.getExistingDirectory()
        Constants.CONFIG.set('directories', 'current_song', fname)
        self.output_cur_dir_lbl.setText(
            Constants.CONFIG.get('directories', 'current_song'))

    def select_new_app(self, text):
        """ Sets the new application to check for """
        try:
            Main.selectedProgram = ITEMS[text]
        except KeyError:
            # catches the empty option, it's obviously not in the dict
            pass
        # custom message for zune
        if Main.selectedProgram == 'zune':
            self.misc_messages.setText(Misc.ZuneNotification)
        # custom message for webplayers which require the groovemarklet
        elif text.find('*'):
            self.misc_messages.setText(Misc.GetGroovemarklet)

    def start(self):
        """ When the start button is pressed, start the main program loop """
        if Main.selectedProgram:
            if not Main.running:
                self.start_btn.setText('Stop')
                Main.running = True
                try:
                    pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
                except pythoncom.com_error:
                    # already initialized.
                    pass
                thread = Thread(target=Main.enumWindows, name='enumWindows')
                thread.run()
            else:
                self.start_btn.setText('Start')
                Main.running = False
                self.set_playing(Misc.noSongPlaying)
                Wr.write('')

    def set_playing(self, title=''):
        """ Sets the text of the label of what song is playing """
        # print 'setting title: ', title
        self.current_playing.setText(title)
Exemple #17
0
class Widget_buttons( QWidget ):
    
    def __init__(self, *args, **kwargs ):
        
        self.mainWindow = args[0]
        
        QWidget.__init__( self, *args, **kwargs )
        mainLayout = QVBoxLayout( self )
        
        layout_expression = QHBoxLayout()
        b_create = QPushButton( "Create Expression" )
        b_delete = QPushButton( "Delete Expression" )
        layout_expression.addWidget( b_create )
        layout_expression.addWidget( b_delete )
        b_bake = QPushButton( "Bake" )
        
        mainLayout.addLayout( layout_expression )
        mainLayout.addWidget( b_bake )
        
        QtCore.QObject.connect( b_create, QtCore.SIGNAL( "clicked()" ), self.createExpression )
        QtCore.QObject.connect( b_delete, QtCore.SIGNAL( "clicked()" ), self.deleteExpression )
        QtCore.QObject.connect( b_bake,   QtCore.SIGNAL( "clicked()" ), self.bake )
    
    
    def createExpression(self):
        
        ctlsGroup = []
        for widget in self.mainWindow.w_ctlListGroup.getChildrenWidgets():
            ctls = widget.items
            allExists=True
            for ctl in ctls:
                if not pymel.core.objExists( ctl ): 
                    allExists=False
                    break
            if not allExists: continue
            ctlsGroup.append( ctls )
        
        mainCtl = self.mainWindow.w_mainCtl.lineEdit.text()
        BaseCommands.createSimulationSystemByCtlsGroup( mainCtl, ctlsGroup )
    
    
    def deleteExpression(self):
        
        BaseCommands.deleteSimulationSystem()
    
    
    def bake(self):
        
        self.bakeWidget = QDialog( self )
        
        def doCommand():
            ctlsGroup = []
            for widget in self.mainWindow.w_ctlListGroup.getChildrenWidgets():
                ctls = widget.items
                allExists=True
                for ctl in ctls:
                    if not pymel.core.objExists( ctl ): 
                        allExists=False
                        break
                if not allExists: continue
                ctlsGroup.append( ctls )
            mainCtl = self.mainWindow.w_mainCtl.lineEdit.text()
            minFrame = int( self.bakeWidget.le_minFrame.text() )
            maxFrame = int( self.bakeWidget.le_maxFrame.text() )
            BaseCommands.bake( mainCtl, ctlsGroup, minFrame, maxFrame )

        
        def closeCommand():
            self.bakeWidget.close()


        validator = QIntValidator( self )
        
        minFrame = pymel.core.playbackOptions( q=1, min=0 )
        maxFrame = pymel.core.playbackOptions( q=1, max=1 )
        
        mainLayout = QVBoxLayout( self.bakeWidget )
        
        timeRangeLayout = QHBoxLayout()
        l_minFrame = QLabel( "Min Frame : " )
        le_minFrame = QLineEdit(); le_minFrame.setValidator( validator )
        l_maxFrame = QLabel( "Max Frame : " )
        le_maxFrame = QLineEdit(); le_maxFrame.setValidator( validator )
        timeRangeLayout.addWidget( l_minFrame )
        timeRangeLayout.addWidget( le_minFrame )
        timeRangeLayout.addWidget( l_maxFrame )
        timeRangeLayout.addWidget( le_maxFrame )
        
        le_minFrame.setText( str( int(minFrame) ) )
        le_maxFrame.setText( str( int(maxFrame) ) )
        
        buttonsLayout = QHBoxLayout()
        b_bake = QPushButton( "Bake" )
        b_close = QPushButton( "Close" )
        buttonsLayout.addWidget( b_bake )
        buttonsLayout.addWidget( b_close )
        
        mainLayout.addLayout( timeRangeLayout )
        mainLayout.addLayout( buttonsLayout )
        
        QtCore.QObject.connect( b_bake,  QtCore.SIGNAL( "clicked()" ), doCommand )
        QtCore.QObject.connect( b_close, QtCore.SIGNAL( "clicked()" ), closeCommand )
        self.bakeWidget.show()

        self.bakeWidget.le_minFrame = le_minFrame
        self.bakeWidget.le_maxFrame = le_maxFrame
Exemple #18
0
class UiMain(QMainWindow):

    """ The main gui interface, invokes all windows and ties everything
     together
    """

    def __init__(self):
        """ automatically called __init__ function """

        super(UiMain, self).__init__()

        # initialize all the variables that are going to be defined in the
        # future
        self.update_dialog = None
        self.update_dialog_lbl = None
        self.app_select_box = None
        self.selector_lbl = None
        self.current_playing_lbl = None
        self.current_playing = None
        self.misc_messages = None
        self.start_btn = None
        self.output_dir_lbl = None
        self.select_output_dir_btn = None
        self.output_cur_dir_lbl = None
        self.active_items_list = None
        self.inactive_items_list = None
        self.switch_active_item_button_off = None
        self.switch_active_item_button_on = None
        self.switch_output_split_btn = None
        self.switch_output_split_lbl = None

        # initialize the system tray
        # self.system_tray = QSystemTrayIcon(self)
        # self.system_tray.setIcon(QIcon(resource_path('icon.png')))
        # self.system_tray.show()
        # self.system_tray.setToolTip('SMG')
        # self.system_tray.activated.connect(self.on_systray_activated)

        # initialize the main window
        self.setObjectName('self')
        self.setWindowTitle('SMG - By Azeirah')
        self.resize(400, 250)

        # Gives the self an icon
        self.setWindowIcon(QIcon(resource_path('icon.png')))

        # create the tabs
        # the tab widget itself
        self.tabbed_windows = QTabWidget(self)
        self.tabbed_windows.resize(400, 300)

        # tab 1, contains the music player selection
        self.music_players = QFrame()

        # tab 2, contains options
        self.options = QFrame()
        self.tabbed_windows.addTab(self.music_players, 'Music players')
        self.tabbed_windows.addTab(self.options, 'Options')

        # initializes the two tabs, with all the code down below
        self.tab_music_players()
        self.tab_options()

        # shows the main window
        self.show()
        
    def closeEvent(self, event):
        """ an automatically called function when the program is about to
        close.
        """
        # Stops all Threads. These would continue to run in the background
        # Even if the window was closed.
        Main.running = False
        # close the ZuneNowPlaying.exe process
        if Constants.SUBP:
            Constants.SUBP.kill()

    def changeEvent(self, event):
        # if event.type() == QEvent.WindowStateChange:
        #     if self.isMinimized():
        #         event.ignore()
        #         self.hide()
        #         self.system_tray.showMessage('Running', 'Running in the
        #           background.')
        #         return

        super(UiMain, self).changeEvent(event)

    def on_systray_activated(self, reason):
        if reason == QSystemTrayIcon.DoubleClick:
            self.show()

    @staticmethod
    def toggle_split(event):
        # 0 = Qt.Unchecked The item is unchecked.
        # 1 = Qt.PartiallyChecked The item is partially checked. Items in
        # hierarchical models may be partially checked if some, but not all,
        # of
        # their children are checked.
        # 2 = Qt.Checked The item is checked.
        if event == 0:
            Constants.OPTIONS['splitText'] = False
        elif event == 2:
            Constants.OPTIONS['splitText'] = True

    def update(self):
        """ Checks a webpage for current version, compares this to built-in
        current versions, and shows update dialog if necessary
        """
        try:
            ver = urlopen('http://league-insanity.tk/Azeirah_content/version')\
                .read()
        except IOError:
            # if for some reason it couldn't retrieve the version, set it to
            # automatically ignore the update: False
            ver = False
        if not float(VERSION) >= float(ver):
            self.popup = QDialog(self)
            self.popup.setModal(True)
            self.popup.setGeometry(200, 100, 500, 100)
            self.popup.show()

            self.popup_text = QLabel(self.popup)
            self.popup_text.setGeometry(5, 5, 500, 30)
            self.popup_text.setOpenExternalLinks(True)
            self.popup_text.show()
            self.popup_text.setText(
                """There is an update available. Run update.exe or <a href='https://sourceforge.net/projects/obsmusicstreamd'>download the update manually</a>""")
            # reply = QMessageBox.question(Constants.UI, 'Message',
            #                              "Do you want to update?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
            # if reply == QMessageBox.Yes:
            #     import atexit
            #     import subprocess

            #     def runUpdater():
            #         import time
            #         time.sleep(3)
            #         subprocess.Popen(resource_path('update.exe'))
            #     atexit.register(runUpdater)
            #     sys.exit()

            #     Constants.update_dialog = QWidget()
            #     Constants.update_dialog.resize(350, 100)
            #     Constants.update_dialog.setWindowIcon(QIcon(resource_path\
            #         ('icon.png')))
            #     Constants.update_dialog.setWindowTitle('Updater')
            #     Constants.update_dialog_lbl = QLabel(Constants.update_dialog)
            #     Constants.update_dialog_lbl.setGeometry(10, 40, 340, 12)
            #     Constants.update_dialog.show()

            #     updateThread = Thread(target = update.update)
            #     updateThread.setName('updateThread')
            #     updateThread.start()

    def tab_music_players(self):
        """ Everything inside the Music players tab gets created here."""
        # self.music_players
        # Creates the box with all the music players inside of it
        self.app_select_box = QComboBox(self.music_players)
        self.app_select_box.setGeometry(135, 10, 150, 25)
        # Whenever you change the application, it runs the selectnewapp func
        self.app_select_box.activated[str].connect(self.select_new_app)

        # Creates the label for the selection combobox
        self.selector_lbl = QLabel(self.music_players)
        self.selector_lbl.setGeometry(10, 10, 150, 25)
        self.selector_lbl.setText('Select your music player: ')

        # Creates the label for the current playing song (and the current
        # playing song label)
        self.current_playing_lbl = QLabel(self.music_players)
        self.current_playing_lbl.setGeometry(10, 45, 150, 25)
        self.current_playing_lbl.setText('Current playing song: ')

        self.current_playing = QLabel(self.music_players)
        self.current_playing.setGeometry(117, 45, 250, 25)
        self.current_playing.setText(Misc.noSongPlaying)

        # Creates a label which displays any additional messages
        self.misc_messages = QLabel(self.music_players)
        self.misc_messages.setGeometry(10, 80, 390, 24)
        self.misc_messages.setText(Misc.misc_message())
        self.misc_messages.setOpenExternalLinks(True)

        # adds all the music players into the combobox
        self.app_select_box.addItem(None)
        for item in Constants.ACTIVEITEMS:
            if item == '__name__' or item == 'active':
                continue
            self.app_select_box.addItem(item)

        # creates the start button
        self.start_btn = QPushButton(self.music_players)
        self.start_btn.setGeometry(75, 120, 250, 35)
        self.start_btn.setText('Start')

        # links the start button to the self.start function
        QObject.connect(self.start_btn, SIGNAL("clicked()"),
                        lambda: Thread(target=self.start, name='startbutton').start())

    def tab_options(self):
        """ Everything inside the Options tab gets created here. """
        # self.options

        # This section is for selecting output dir
        # Creates the output dir label
        self.output_dir_lbl = QLabel(self.options)
        self.output_dir_lbl.setGeometry(10, 10, 125, 15)
        self.output_dir_lbl.setText('Change Output Directory: ')

        # Creates the output dir button
        self.select_output_dir_btn = QPushButton(self.options)
        self.select_output_dir_btn.setGeometry(137, 8, 30, 20)
        self.select_output_dir_btn.setText('...')

        # Creates the output dir currentdir Lineedit
        self.output_cur_dir_lbl = QLineEdit(self.options)
        self.output_cur_dir_lbl.setGeometry(170, 6, 210, 25)
        self.output_cur_dir_lbl.setReadOnly(True)
        self.output_cur_dir_lbl.setText(Constants.CONFIG.
                                        get('directories', 'current_song'))

        # when the '...' button is clicked, show a dialog (fire func
        # disp_dialog)
        QObject.connect(self.select_output_dir_btn, SIGNAL("clicked()"),
                        self.disp_dialog)

        # This section is for selecting what players you use
        # The box with all the active players
        self.active_items_list = QListWidget(self.options)
        self.active_items_list.setGeometry(10, 40, 150, 100)

        # The box with all the inactive players
        self.inactive_items_list = QListWidget(self.options)
        self.inactive_items_list.setGeometry(230, 40, 150, 100)
        # Populate the two boxes with active and inactive items
        for item in Constants.ACTIVEITEMS:
            if item == '__name__' or item == 'active':
                continue
            self.active_items_list.addItem(item)
        for item in Constants.INACTIVEITEMS:
            if item == '__name__' or item == 'active':
                continue
            self.inactive_items_list.addItem(item)

        # The buttons responsible for switching
        # off button
        self.switch_active_item_button_off = QPushButton(self.options)
        self.switch_active_item_button_off.setText('->'.decode('utf-8'))
        # Makes the -> readable and clear
        self.switch_active_item_button_off.setFont(QFont('SansSerif', 17))
        self.switch_active_item_button_off.setGeometry(175, 55, 40, 30)
        # on button
        self.switch_active_item_button_on = QPushButton(self.options)
        self.switch_active_item_button_on.setText('<-'.decode('utf-8'))
        # makes <- readable and clear
        self.switch_active_item_button_on.setFont(QFont('SansSerif', 17))
        self.switch_active_item_button_on.setGeometry(175, 90, 40, 30)

        QObject.connect(self.switch_active_item_button_on, SIGNAL
                       ("clicked()"), self.switch_item_on)
        QObject.connect(self.switch_active_item_button_off, SIGNAL
                       ("clicked()"), self.switch_item_off)

        # A button to toggle the split output in half option. It's a temporary
        # fix for the Foobar double output problem.
        self.switch_output_split_btn = QCheckBox(self.options)
        self.switch_output_split_btn.setCheckState(Qt.CheckState.Unchecked)
        self.switch_output_split_btn.setGeometry(10, 140, 40, 30)
        self.switch_output_split_btn.stateChanged.connect(self.toggle_split)

        # The label for the split toggle
        self.switch_output_split_lbl = QLabel(self.options)
        self.switch_output_split_lbl.setText(
            "Split the output text in half (don't use this if you don't need it)")
        self.switch_output_split_lbl.setGeometry(30, 140, 300, 30)

    def switch_item_on(self):
        """ Switches items (musicapps) on """
        try:
            # If an item from the active box is selected
            # Remove it and place it inside the inactive box
            item_taken = self.inactive_items_list.takeItem(
                self.inactive_items_list.currentRow())
            self.active_items_list.addItem(item_taken)
            active_items = {}
            inactive_items = {}
            for i in range(self.active_items_list.count()):
                active_items[self.active_items_list.item(i).text()] =\
                    ITEMS[self.active_items_list.item(i).text()
                          .encode('utf-8')]
            for i in range(self.inactive_items_list.count()):
                inactive_items[self.inactive_items_list.item(i).text()] =\
                    ITEMS[self.inactive_items_list.item(i).text()
                          .encode('utf-8')]
            Constants.ACTIVE_ITEMS = active_items
            Constants.INACTIVE_ITEMS = inactive_items
            # clear the selection combobox
            self.app_select_box.clear()
            # Repopulate the combobox
            self.app_select_box.addItem(None)
            for item in active_items:
                self.app_select_box.addItem(item)
            Constants.CONFIG.set('active', item_taken.text(),
                                 ITEMS[item_taken.text()])
            Constants.CONFIG.remove_option('inactive', item_taken.text())
            # Updates the config file to be up to date with activeItems
            Constants.CONFIG.update()
        except:
            raise

    def switch_item_off(self):
        """ Switches items (musicapps) off """
        try:
            # If an item from the inactive box is selected.
            # Remove it and place it inside the active box
            item_taken = self.active_items_list.takeItem(
                self.active_items_list.currentRow())
            self.inactive_items_list.addItem(item_taken)
            # update activeItems
            active_items = {}
            inactive_items = {}
            for i in range(self.active_items_list.count()):
                active_items[self.active_items_list.item(i).text()] =\
                    ITEMS[self.active_items_list.item(i).text()
                          .encode('utf-8')]
            for i in range(self.inactive_items_list.count()):
                inactive_items[self.inactive_items_list.item(i).text()] =\
                    ITEMS[self.inactive_items_list.item(i).text()
                          .encode('utf-8')]
            Constants.ACTIVE_ITEMS = active_items
            Constants.INACTIVE_ITEMS = inactive_items
            # clear the selection combobox
            self.app_select_box.clear()
            # Repopulate the combobox
            self.app_select_box.addItem(None)
            for item in active_items:
                self.app_select_box.addItem(item)
            # Updates the active items Constants property
            Constants.CONFIG.set('inactive', item_taken.text(),
                                 ITEMS[item_taken.text()])
            Constants.CONFIG.remove_option('active', item_taken.text())
            # Updates the config file to be up to date with activeItems
            Constants.CONFIG.update()
        except:
            raise

    def disp_dialog(self):
        """  displays the dialog which select a directory for output. """
        fname = QFileDialog.getExistingDirectory()
        Constants.CONFIG.set('directories', 'current_song', fname)
        self.output_cur_dir_lbl.setText(Constants.CONFIG.
                                        get('directories', 'current_song'))

    def select_new_app(self, text):
        """ Sets the new application to check for """
        try:
            Main.selectedProgram = ITEMS[text]
        except KeyError:
            # catches the empty option, it's obviously not in the dict
            pass
        # custom message for zune
        if Main.selectedProgram == 'zune':
            self.misc_messages.setText(Misc.ZuneNotification)
        # custom message for webplayers which require the groovemarklet
        elif text.find('*'):
            self.misc_messages.setText(Misc.GetGroovemarklet)

    def start(self):
        """ When the start button is pressed, start the main program loop """
        if Main.selectedProgram:
            if not Main.running:
                self.start_btn.setText('Stop')
                Main.running = True
                try:
                    pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
                except pythoncom.com_error:
                    # already initialized.
                    pass
                thread = Thread(
                    target=Main.enumWindows, name='enumWindows')
                thread.run()
            else:
                self.start_btn.setText('Start')
                Main.running = False
                self.set_playing(Misc.noSongPlaying)
                Wr.write('')

    def set_playing(self, title=''):
        """ Sets the text of the label of what song is playing """
        # print 'setting title: ', title
        self.current_playing.setText(title)