Beispiel #1
0
    def __init__(self):
        super().__init__()

        layout = QVBoxLayout()

        self.progress = QProgressBar()

        button = QPushButton("START IT UP")
        button.pressed.connect(self.execute)

        self.status = QLabel("0 workers")

        layout.addWidget(self.progress)
        layout.addWidget(button)
        layout.addWidget(self.status)

        w = QWidget()
        w.setLayout(layout)

        # Dictionary holds the progress of current workers.
        self.worker_progress = {}

        self.setCentralWidget(w)

        self.show()

        self.threadpool = QThreadPool()
        print("Multithreading with maximum %d threads" %
              self.threadpool.maxThreadCount())

        self.timer = QTimer()
        self.timer.setInterval(100)
        self.timer.timeout.connect(self.refresh_progress)
        self.timer.start()
Beispiel #2
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.threadpool = QtCore.QThreadPool()  # 初始化线程池
        print("Multithreading with maximum %d threads" % self.threadpool.maxThreadCount())

        self.counter = 0

        layout = QtWidgets.QVBoxLayout()

        self.l = QtWidgets.QLabel("Start")

        b = QtWidgets.QPushButton("DANGER!")
        b.pressed.connect(self.oh_no)

        layout.addWidget(self.l)
        layout.addWidget(b)

        w = QWidget()
        w.setLayout(layout)

        self.setCentralWidget(w)

        self.show()

        self.timer = QTimer()
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.recurring_timer)
        self.timer.start()
Beispiel #3
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.counter = 0

        layout = QVBoxLayout()
        self.l = QLabel("Start")
        b = QPushButton("DANGER!")
        b.pressed.connect(self.oh_no)

        layout.addWidget(self.l)
        layout.addWidget(b)

        w = QWidget()
        w.setLayout(layout)

        self.setCentralWidget(w)
        self.show()

        self.timer = QTimer()
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.recurring_timer)
        self.timer.start()

    def oh_no(self):
        time.sleep(5)

    def recurring_timer(self):
        self.counter += 1
        self.l.setText("Count: %d" % self.counter)
Beispiel #4
0
	def __init__(self):
		super().__init__()

		self.undiscovered_color: str = "#000000"
		self.discovered_color: str = "#d9d9d9"
		self.win_timer_color: str = "#e30e0e"
		self.lose_timer_color: str = "#0cc431"


		self.curr_time = QTime(00,00,00)
		self.timer = QTimer()
		self.timer.timeout.connect(self.time)
		self.timer_already_started = False

		self.solved: bool = False
		
		self.player_ended: bool = False

		self.theme: str = "dark"

		self.list_of_mines: list = []

		self.difficulty_slider_default_value: int = 2
		self.number_of_mines: int = mines_number(NUMBER_OF_LABELS, self.difficulty_slider_default_value)


		self.create_GUI()
Beispiel #5
0
        def __init__(self, parent=None):
            QScrollArea.__init__(self)
            self.setParent(parent)
            self.text = ""

            # Set the background colour of the marquee text to white
            self.setStyleSheet("QScrollArea { background-color: rgba(255, 255, 255, 1)}")

            # Initialise the base label and text
            self.label = QLabel()

            # Set the font for marquee
            font = QFont()
            font.setItalic(True)
            font.setBold(True)
            font.setPixelSize(25)
            self.label.setFont(font)

            # Set the base label as the base widget of QScrollArea
            self.setWidget(self.label)

            # Set QScrollBar Policies
            self.setWidgetResizable(True)
            self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

            # Initialise timer and associated variables, used for marquee effect
            self.timer = QTimer(self)
            self.x = 0
            self.speed = 0
            
            # Connect a function to the timer, which controls the marquee effect
            self.timer.timeout.connect(self.updatePos)

            # TODO: Set a nominal speed
            self.setSpeed(33)
Beispiel #6
0
    def __init__(self, graphicsObject: QGraphicsObject):
        super().__init__()
        self._graphicsObject = graphicsObject

        timer = QTimer(self.GraphicsObject())
        timer.timeout.connect(self.Update)
        timer.start(30)
Beispiel #7
0
 def __set_camera(self):
     self.capture = cv2.VideoCapture(0)
     self.capture.set(cv2.CAP_PROP_FRAME_WIDTH, self.label.width())
     self.capture.set(cv2.CAP_PROP_FRAME_HEIGHT, self.label.height())
     self.timer = QTimer()
     self.timer.timeout.connect(self.display_pic)
     self.timer.start(30)
Beispiel #8
0
    def __init__(self, parent=None):
        super(SettingsTree, self).__init__(parent)

        self._type_checker = TypeChecker()
        self.setItemDelegate(VariantDelegate(self._type_checker, self))

        self.setHeaderLabels(("Setting", "Type", "Value"))
        self.header().setSectionResizeMode(0, QHeaderView.Stretch)
        self.header().setSectionResizeMode(2, QHeaderView.Stretch)

        self.settings = None
        self.refresh_timer = QTimer()
        self.refresh_timer.setInterval(2000)
        self.auto_refresh = False

        self.group_icon = QIcon()
        style = self.style()
        self.group_icon.addPixmap(style.standardPixmap(QStyle.SP_DirClosedIcon),
                                  QIcon.Normal, QIcon.Off)
        self.group_icon.addPixmap(style.standardPixmap(QStyle.SP_DirOpenIcon),
                                  QIcon.Normal, QIcon.On)
        self.key_icon = QIcon()
        self.key_icon.addPixmap(style.standardPixmap(QStyle.SP_FileIcon))

        self.refresh_timer.timeout.connect(self.maybe_refresh)
Beispiel #9
0
    def __init__(self, programInstance: ProgramInstance, uniqueRun):
        super().__init__()

        AppGlobals.Instance().onChipModified.connect(self.UpdateParameterItems)

        self.editingParameterVisibility = False

        self.programInstance = programInstance
        self.uniqueRun = uniqueRun

        self._programNameWidget = QLabel()

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.runButton = QPushButton("Run")
        self.runButton.clicked.connect(self.RunProgram)

        self._stopButton = QPushButton("Stop")
        self._stopButton.clicked.connect(self.StopProgram)

        self.parameterItems: List[ProgramParameterItem] = []

        self._parametersLayout = QVBoxLayout()

        layout.addWidget(self._programNameWidget)
        layout.addLayout(self._parametersLayout)
        layout.addWidget(self.runButton)
        layout.addWidget(self._stopButton)
        timer = QTimer(self)
        timer.timeout.connect(self.UpdateInstanceView)
        timer.start(30)

        self.UpdateInstanceView()
        self.UpdateParameterItems()
Beispiel #10
0
    def __init__(self):

        # gui
        self.app = QApplication([])
        self.main_window = MainWindow(controller=self)

        # device
        self.device = Device()

        # fps stats
        self.fps_timer = QTimer()
        self.fps_timer.timeout.connect(self.update_ui_fps)
        self.spf = 1  # seconds per frame
        self.timestamp_last_capture = 0

        # acquisition thread
        self.continuous_acquisition = False
        self.worker_wait_condition = QWaitCondition()
        self.acquisition_worker = AcquisitionWorker(self.worker_wait_condition,
                                                    device=self.device)
        self.acquisition_thread = QThread()
        self.acquisition_worker.moveToThread(self.acquisition_thread)
        self.acquisition_thread.started.connect(self.acquisition_worker.run)
        self.acquisition_worker.finished.connect(self.acquisition_thread.quit)
        # self.acquisition_worker.finished.connect(self.acquisition_thread.deleteLater)
        # self.acquisition_thread.finished.connect(self.acquisition_worker.deleteLater)
        self.acquisition_worker.data_ready.connect(self.data_ready_callback)
        self.acquisition_thread.start()

        # default timebase
        self.set_timebase("20 ms")

        # on app exit
        self.app.aboutToQuit.connect(self.on_app_exit)
 def __init__(self,
              train_model,
              initalTC=25769816839,
              current_speed=0,
              trainID=1):
     super(TrainControllerHWInterface, self).__init__()
     self.train_model = train_model
     self.ui = Ui_TrainControllerHWInterface()
     self.ui.setupUi(self)
     self.utimer = QTimer()
     self.utimer.timeout.connect(self.timerCallback)
     self.ui.setParams.clicked.connect(self.set_kp_ki)
     self.ui.IDVal.setPlainText(str(trainID))
     self.power = 0
     self.curSpeed = current_speed
     self.encodedB = 0
     self.nFlag = 0
     self.eol = '\n'.encode('utf-8')
     self.encodedTC = initalTC
     self.rawToggle = 0
     self.sBrakePull = False
     self.EBrakePull = False
     self.LDoorOpen = False
     self.RDoorOpen = False
     self.IntLightsOn = False
     self.ExtLightsOn = False
     self.temperature = 0
     self.announcement = ''
     self.connectArduino()
     self.run = False
Beispiel #12
0
    def __init__(self):
        super().__init__()

        StylesheetLoader.RegisterWidget(self)
        self.setWindowIcon(QIcon("Images/UCIcon.png"))

        centralLayout = QVBoxLayout()
        centralWidget = QWidget()
        centralWidget.setLayout(centralLayout)
        self.setCentralWidget(centralWidget)

        self._tabWidget = QTabWidget()
        centralLayout.addWidget(self._tabWidget)

        menuBar = MenuBar()
        self.setMenuBar(menuBar)

        menuBar.saveProgram.connect(
            lambda: self._tabWidget.currentWidget().SaveProgram())
        menuBar.closeProgram.connect(
            lambda: self.RequestCloseTab(self._tabWidget.currentIndex()))

        self._tabWidget.tabCloseRequested.connect(self.RequestCloseTab)
        self._tabWidget.setTabsClosable(True)

        timer = QTimer(self)
        timer.timeout.connect(self.CheckPrograms)
        timer.start(30)
Beispiel #13
0
    def __init__(self):
        super(Window, self).__init__()

        aliasedLabel = self.createLabel("Aliased")
        antialiasedLabel = self.createLabel("Antialiased")
        intLabel = self.createLabel("Int")
        floatLabel = self.createLabel("Float")

        layout = QGridLayout()
        layout.addWidget(aliasedLabel, 0, 1)
        layout.addWidget(antialiasedLabel, 0, 2)
        layout.addWidget(intLabel, 1, 0)
        layout.addWidget(floatLabel, 2, 0)

        timer = QTimer(self)

        for i in range(2):
            for j in range(2):
                w = CircleWidget()
                w.setAntialiased(j != 0)
                w.setFloatBased(i != 0)

                timer.timeout.connect(w.nextAnimationFrame)

                layout.addWidget(w, i + 1, j + 1)

        timer.start(100)
        self.setLayout(layout)

        self.setWindowTitle("Concentric Circles")
    def __init__(self):
        QWidget.__init__(self)
        self.setMinimumSize(800, 600)
        self.donuts = []
        self.chart_view = QChartView()
        self.chart_view.setRenderHint(QPainter.Antialiasing)
        self.chart = self.chart_view.chart()
        self.chart.legend().setVisible(False)
        self.chart.setTitle("Nested donuts demo")
        self.chart.setAnimationOptions(QChart.AllAnimations)

        self.min_size = 0.1
        self.max_size = 0.9
        self.donut_count = 5

        self.setup_donuts()

        # create main layout
        self.main_layout = QGridLayout(self)
        self.main_layout.addWidget(self.chart_view, 1, 1)
        self.setLayout(self.main_layout)

        self.update_timer = QTimer(self)
        self.update_timer.timeout.connect(self.update_rotation)
        self.update_timer.start(1250)
Beispiel #15
0
    def initTimes(self):        
        # Create the local and elapsed times labels
        self.counter = 0
        self.elapsedTime = QLabel()
        self.localTime = QLabel()

        # Base font for colours
        font = QFont()
        font.setBold(True)
        font.setItalic(True)

        # Center labels, transparent backgrounds, fonts, and colours
        for x in [self.elapsedTime, self.localTime]:
            # TODO: Scale times with app resize
            x.setFixedWidth(100)
            x.setAlignment(Qt.AlignCenter)
            x.setFont(font)
            x.setStyleSheet("color: rgb(255, 255, 255)")

        # Start the elapsedTime timer
        timer = QTimer(self)
        timer.timeout.connect(self.updateTimes)
        # Call updateTimes first to get the times displayed on startUp
        self.updateTimes()
        timer.start(500)
Beispiel #16
0
 def __init__(self, dirname, parent=None):
     super().__init__(parent)
     self.__image_url = ''
     self.__dirname = dirname
     self.__image_list = []
     self.__timer = QTimer(self)
     self.__timer.setInterval(IMAGE_INTERVAL)
     self.__timer.timeout.connect(self.on_timeout)
 def __init__(self, dirname, parent=None):
     super(ImageView, self).__init__()
     super(MouseEventMixin, self).__init__(parent)
     self.__dirname = dirname
     self.__image = None
     self.__image_list = []
     self.__timer = QTimer(self)
     self.init_ui()
Beispiel #18
0
    def __init__(self):
        super().__init__()

        # Define timer.
        self.timer = QTimer()
        self.timer.setInterval(100)  # msecs 100 = 1/10th sec
        self.timer.timeout.connect(self.update_time)
        self.timer.start()
Beispiel #19
0
 def play(self):
     """Starts a slideshow."""
     if self.play_button.isChecked():
         if self.browser_button.isChecked():
             self.reset_browser = True
         else:
             self.reset_browser = False
         QTimer.singleShot(3000, self.play)
         self.next()
Beispiel #20
0
	def reset(self) -> None:
		self.timer = QTimer()
		self.curr_time = QTime(00,00,00)
		self.timer.timeout.connect(self.time)
		self.solved = False
		self.timer_already_started = False
		self.player_ended = False
		self.difficulty_slider.setDisabled(False)
		self.difficulty_slider_default_value = self.difficulty_slider.value()
		self.create_GUI()
    def __init__(self, executor: MemoryOperationExecutor):
        super().__init__()
        ConnectionBackend.__init__(self, executor)
        self._permanent_pickups = []

        self._timer = QTimer(self)
        self._timer.timeout.connect(self._auto_update)
        self._timer.setInterval(self._dt * 1000)
        self._timer.setSingleShot(True)
        self._notify_status()
    def create_progress_bar(self):
        result = QProgressBar()
        init_widget(result, "progressBar")
        result.setRange(0, 10000)
        result.setValue(0)

        timer = QTimer(self)
        timer.timeout.connect(self.advance_progressbar)
        timer.start(1000)
        return result
Beispiel #23
0
    def __init__(self):
        super(DirectoryWidget, self).__init__()
        self.timer = QTimer()
        self.timer.setSingleShot(True)
        self.clicked.connect(self.Sl_check_double_click)

        self.setAccessibleName('Directory')

        self.setIcon(QIcon(resource_path("icons/Cartella.png")))
        self.setIconSize(QSize(45, 45))
        self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
Beispiel #24
0
def _create_timer(fn, period: int) -> QTimer:
    timer = QTimer()

    def _update_cycle():
        timer.stop()
        fn()
        timer.start(period)

    timer.timeout.connect(_update_cycle)
    timer.start(period)
    return timer
Beispiel #25
0
 def set_frameless_window(
         self,
         value: bool
 ) -> None:
     pos = self.pos()
     self.setWindowFlag(Qt.FramelessWindowHint, value)
     # workaround: window goes invisible otherwise
     self.setVisible(True)
     # workaround: window would move up otherwise
     if value:
         QTimer.singleShot(100, lambda: self.move(pos))
Beispiel #26
0
 def exposeEvent(self, event):
     if self.isExposed():
         self.render()
         if self.timer is None:
             self.timer = QTimer(self)
             self.timer.timeout.connect(self.slotTimer)
         if not self.timer.isActive():
             self.timer.start(10)
     else:
         if self.timer and self.timer.isActive():
             self.timer.stop()
Beispiel #27
0
 def flash_message(self,
                   msg: str,
                   wait: int = cfg.MESSAGE_FLASH_TIME_2) -> None:
     self.message_label.setText(msg)
     if self.message_timer:
         self.message_timer.stop()
         self.message_timer.deleteLater()
     self.message_timer = QTimer()
     self.message_timer.timeout.connect(
         self.delete_flashed_message)  # type: ignore
     self.message_timer.setSingleShot(True)  # type: ignore
     self.message_timer.start(wait)  # type: ignore
Beispiel #28
0
    def __init__(self):
        self.widgetsList: typing.List[QWidget] = []

        self.updateTimer = QTimer(QApplication.topLevelWidgets()[0])
        self.updateTimer.timeout.connect(self.TimerUpdate)
        self.updateTimer.start(1000)

        self.lastModifiedTime = None

        self.scriptFilename = "UI/STYLESHEET.css"

        self.stylesheet = None
Beispiel #29
0
    def __init__(self, dataType: DataType):
        super().__init__()

        self.dataType = dataType

        AppGlobals.Instance().onChipModified.connect(self.Repopulate)

        self.Repopulate()

        timer = QTimer(self)
        timer.timeout.connect(self.UpdateNames)
        timer.start(30)
Beispiel #30
0
class StylesheetLoader:
    _instance = None

    @staticmethod
    def _GetInstance():
        if StylesheetLoader._instance is None:
            StylesheetLoader._instance = StylesheetLoader()
        return StylesheetLoader._instance

    @staticmethod
    def RegisterWidget(widget: QWidget):
        instance = StylesheetLoader._GetInstance()
        if instance.stylesheet is None:
            instance.ReloadSS()
        instance.widgetsList.append(widget)
        widget.setStyleSheet(instance.stylesheet)

    @staticmethod
    def UnregisterWidget(widget: QWidget):
        instance = StylesheetLoader._GetInstance()
        if widget in instance.widgetsList:
            instance.widgetsList.remove(widget)

    def __init__(self):
        self.widgetsList: typing.List[QWidget] = []

        self.updateTimer = QTimer(QApplication.topLevelWidgets()[0])
        self.updateTimer.timeout.connect(self.TimerUpdate)
        self.updateTimer.start(1000)

        self.lastModifiedTime = None

        self.scriptFilename = "UI/STYLESHEET.css"

        self.stylesheet = None

    def TimerUpdate(self):
        currentModifiedTime = os.path.getmtime(self.scriptFilename)
        if currentModifiedTime != self.lastModifiedTime:
            self.ReloadSS()
            self.lastModifiedTime = currentModifiedTime

    def ReloadSS(self):
        f = open(self.scriptFilename)
        self.stylesheet = f.read()

        self.widgetsList: typing.List[QWidget] = [
            widget for widget in self.widgetsList if widget
        ]
        for widget in self.widgetsList:
            widget.setStyleSheet(self.stylesheet)
            widget.setStyle(widget.style())