Esempio n. 1
0
    def __init__(self):
        app = QtWidgets.QApplication(sys.argv)

        MainWindow = QtWidgets.QMainWindow()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(MainWindow)
        #--------------------------

        self.ui.pushButton.hide()
        #         self.ui.pushButton.setParent(None)  # deleting parent deletes the button
        self.drop_button = DragDropButton('DropButton', MainWindow)
        self.drop_button.setMinimumSize(QtCore.QSize(161, 0))
        self.ui.horizontalLayout_2.addWidget(self.drop_button)
        #--------------------------

        self.ui.comboBox.hide()
        self.drop_combo = DragDropCombo(MainWindow)
        self.drop_combo.setMinimumSize(QtCore.QSize(141, 0))
        self.ui.horizontalLayout_2.addWidget(self.drop_combo)

        #--------------------------
        self.update_tree()
        self.update_calendar()
        self.update_progressbar()

        MainWindow.show()
        sys.exit(app.exec_())
Esempio n. 2
0
    def __init__(self):
        app = QtWidgets.QApplication(sys.argv)

        MainWindow = QtWidgets.QMainWindow()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(MainWindow)

        self.update_tree()
        self.update_calendar()
        self.update_progressbar()

        MainWindow.show()
        sys.exit(app.exec_())
class MainWindow_EXEC():
   
    def __init__(self):
        app = QtWidgets.QApplication(sys.argv)
        
        MainWindow = QtWidgets.QMainWindow()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(MainWindow)   
        #-------------------------- 

        self.ui.pushButton.hide()
#         self.ui.pushButton.setParent(None)  # deleting parent deletes the button
                
        self.drop_button = DragDropButton('DropButton', MainWindow)
        self.drop_button.setMinimumSize(QtCore.QSize(161, 0))
        self.ui.horizontalLayout_2.addWidget(self.drop_button)
        

        
        #--------------------------
        self.update_tree()
        self.update_calendar()
        self.update_progressbar()
                    
        MainWindow.show()
        sys.exit(app.exec_())        

    #----------------------------------------------------------
    def update_tree(self): 
        self.ui.treeWidget.headerItem().setText(1, 'Header 2')
        self.ui.treeWidget.topLevelItem(0).setText(1, "Item 2")
        self.ui.treeWidget.topLevelItem(0).addChild(QtWidgets.QTreeWidgetItem())
        self.ui.treeWidget.topLevelItem(0).child(0).setText(1, "Subitem 2")
        
    def print_tree(self):
        header0 = self.ui.treeWidget.headerItem().text(0)
        header1 = self.ui.treeWidget.headerItem().text(1)
        print(header0 + '\n' + header1 + '\n')        
        
    #----------------------------------------------------------
    def update_calendar(self):
        self.ui.calendarWidget.selectionChanged.connect(self.update_date)

    def update_date(self):
        self.ui.dateEdit.setDate(self.ui.calendarWidget.selectedDate())      
    
    #----------------------------------------------------------
    def update_progressbar(self):
        self.ui.radioButton_start.clicked.connect(self.start_progressbar)
        self.ui.radioButton_stop.clicked.connect(self.stop_progressbar)
        self.ui.radioButton_reset.clicked.connect(self.reset_progressbar)
        self.progress_value = 0
        self.stop_progress = False

    def progressbar_counter(self, start_value=0):
        self.run_thread = RunThread(parent=None, counter_start=start_value)
        self.run_thread.start()
        self.run_thread.counter_value.connect(self.set_progressbar)
                
    def set_progressbar(self, counter):
        if not self.stop_progress:
            self.ui.progressBar.setValue(counter)        
                   
    def start_progressbar(self):
        self.stop_progress = False
        self.progress_value = self.ui.progressBar.value()        
        self.progressbar_counter(self.progress_value)
           
    def stop_progressbar(self):
        self.stop_progress = True
        try: self.run_thread.stop()
        except: pass
           
    def reset_progressbar(self):
        self.stop_progressbar()
        self.progress_value = 0
        self.stop_progress = False
        self.ui.progressBar.reset()