示例#1
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()
示例#2
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))
示例#3
0
    def incorrect(self):
        """Вызывается, если на вопрос был дан неверный ответ."""

        global next_question_delay, bad_words, is_auto_next, is_repeat, is_reset_progress, repeats_amount, \
            is_smart_offer

        # Отключение происходит сразу же, чтобы пользователь больше не нажимал
        # на кнопки с последствиями
        self.designalize_buttons()

        # НЕ в режиме повторения добавляем ошибочное слово в список для дальнейшего повторения
        if not is_repeat:
            bad_words.append(self.current_word)

            if is_smart_offer:
                self.smart_add()
        # В режиме повторения, если включена опция, сбрасываем прогресс для слова,
        # если ответ на него неверен
        elif is_repeat and is_reset_progress:
            self.word_progress[self.current_repeat_w] = repeats_amount

        # Меняем стиль виджетов
        self.ui.l_header.setText("Неправильно!")

        self.ui.l_header.setObjectName("training-header-incorr")
        self.ui.l_header.style().unpolish(self.ui.l_header)
        self.ui.l_header.style().polish(self.ui.l_header)

        self.ui.progressBar.setObjectName("training-prb-incorr")
        self.ui.progressBar.style().unpolish(self.ui.progressBar)
        self.ui.progressBar.style().polish(self.ui.progressBar)

        # Показываем правильный ответ
        self.show_correct()

        self.update_stats()

        # Аналогично, как и в correct()
        if is_auto_next:
            # Создаём таймер, по истечению которого перейдём к следующему вопросу.
            a_timer = QTimer()
            a_timer.singleShot(next_question_delay, self.next_question)
            a_timer.start()
        else:
            self.ui.pb_next.show()
示例#4
0
    def correct(self):
        """Вызывается, если на вопрос был дан верный ответ."""

        # Отключение происходит сразу же, чтобы пользователь больше не нажимал
        # на кнопки с последствиями
        self.designalize_buttons()

        global next_question_delay, is_auto_next, is_repeat, score

        # Меняем стиль виджетов
        self.ui.l_header.setText("Правильно!")

        self.ui.l_header.setObjectName("training-header-corr")
        self.ui.l_header.style().unpolish(self.ui.l_header)
        self.ui.l_header.style().polish(self.ui.l_header)

        self.ui.progressBar.setObjectName("training-prb-corr")
        self.ui.progressBar.style().unpolish(self.ui.progressBar)
        self.ui.progressBar.style().polish(self.ui.progressBar)

        score += 1
        self.update_stats()

        # Показываем правильный ответ
        self.show_correct()

        # Если мы в режиме повторения, то меняем прогресс для данного слова
        if is_repeat:
            self.word_progress[self.current_repeat_w] -= 1

        # Срабатывает, если включена опция автоматического перехода
        if is_auto_next:
            # Создаём таймер, по истечению которого перейдём к следующему вопросу.
            a_timer = QTimer()
            a_timer.singleShot(next_question_delay, self.next_question)
            a_timer.start()
        # Иначе демонстрируем кнопку
        else:
            self.ui.pb_next.show()
示例#5
0
 def set_dirty(self, d):
     if self._dirty != d:
         self._dirty = d
         self.dirtyChanged.emit()
     if self._dirty and self._autoUpdate:
         QTimer.singleShot(0, self.update) # schedule an update as soon as we go back to event loop, but not before
示例#6
0
文件: main.py 项目: KDAB/KDChart
            return

        if from_ >= len(self.m_tasks) or to >= len(self.m_tasks) + 1:
            return

        if self.beginMoveRows(QModelIndex(), from_, from_, QModelIndex(), to):
            self.m_tasks.insert(to, self.m_tasks.pop(from_))
            self.endMoveRows()
        else:
            return


if __name__ == '__main__':
    app = QApplication(sys.argv)
    view = View()
    model = MyTaskModel()

    constraints = ConstraintModel()
    constraints.addConstraint(Constraint(model.index(0, 0), model.index(1, 0)))
    constraints.addConstraint(Constraint(model.index(0, 0), model.index(2, 0)))
    constraints.addConstraint(Constraint(model.index(1, 0), model.index(3, 0)))

    view.setModel(model)
    view.setConstraintModel(constraints)
    view.show()

    # After 5 seconds, move row 1 to pos 0: #
    QTimer.singleShot(5000, lambda: model.moveRow(1, 0))

    sys.exit(app.exec_())
示例#7
0
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.text)
        self.layout.addWidget(self.button)
        self.setLayout(self.layout)

        # Connecting the signal
        self.button.clicked.connect(self.magic)

    @Slot()
    def magic(self):
        self.text.setText(random.choice(self.hello))


if __name__ == "__main__":
    print("Start of hello.py      ", time.ctime())
    print("  sys.version         = {}".format(sys.version.splitlines()[0]))
    print("  platform.platform() = {}".format(platform.platform()))

    app = QApplication()

    widget = MyWidget()
    widget.resize(800, 600)
    widget.show()
    if sys.pyside_uses_embedding:
        milliseconds = 2 * 1000  # run 2 second
        QTimer.singleShot(milliseconds, app.quit)
    retcode = app.exec_()
    print("End of hello.py        ", time.ctime())
    sys.exit(retcode)
示例#8
0
 def CursorChangedEvent(self, obj, evt):
     """Called when the CursorChangedEvent fires on the render window."""
     # This indirection is needed since when the event fires, the current
     # cursor is not yet set so we defer this by which time the current
     # cursor should have been set.
     QTimer.singleShot(0, self.ShowCursor)
    def _tab_show_event(self, event: QtGui.QShowEvent):
        if self._window_manager.preset_manager.should_do_migration():
            QTimer.singleShot(0, self._do_migration)

        return self._original_show_event(event)
        source_model.invisibleRootItem().appendRow(row)
        list.append("FancyTextNumber {}".format(i))

    # Needed by QMLModelViewClient
    role_names = {
        Qt.DisplayRole: QByteArray(b'_text'),
        Qt.BackgroundRole: QByteArray(b'_color')
    }
    source_model.setItemRoleNames(role_names)

    roles = [Qt.DisplayRole, Qt.BackgroundRole]

    print("Creating registry host")
    node = QRemoteObjectRegistryHost(QUrl("local:registry"))

    node2 = QRemoteObjectHost(QUrl("local:replica"), QUrl("local:registry"))
    node2.enableRemoting(source_model, "RemoteModel", roles)

    view = QTreeView()
    view.setWindowTitle("SourceView")
    view.setModel(source_model)
    view.show()
    handler = TimerHandler(source_model)
    QTimer.singleShot(5000, handler.change_data)
    QTimer.singleShot(10000, handler.insert_data)
    QTimer.singleShot(11000, handler.change_flags)
    QTimer.singleShot(12000, handler.remove_data)
    QTimer.singleShot(13000, handler.move_data)

    sys.exit(app.exec_())
示例#11
0
 def _get_result_later(self, msec: tp.Optional[int] = None) -> None:
     if msec is None:
         msec = 10
     QTimer.singleShot(msec, self._get_model_result)
示例#12
0
	def set_time(self, time, period):
		#print('in set_time')
		self.get_power()
		#self.train.samplePeriod = period/2
		QTimer.singleShot(period/2, self.get_power)
示例#13
0
 def __init__(
         self,
         config_file: str
 ) -> None:
     super().__init__()
     # load config
     try:
         self.config = Config(config_file)
     except Exception as e:
         QMessageBox.critical(self, 'Config error', str(e))
         QTimer.singleShot(0, self.close)
         return
     # load settings
     self.settings = Settings()
     # state
     self.state_key: Optional[int] = None
     # label widget
     self.label_ping = ClickableLabel('Loading ...', self.post_history)
     self.label_ping.setTextFormat(Qt.RichText)
     self.label_ping.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
     layout_ping = QGridLayout()
     layout_ping.setContentsMargins(0, 0, 0, 0)
     layout_ping.addWidget(self.label_ping)
     self.widget_ping = QWidget()
     self.widget_ping.setLayout(layout_ping)
     self.addWidget(self.widget_ping)
     # alert widget
     self.label_alert = QLabel()
     self.label_alert.setWordWrap(True)
     self.label_alert.setAlignment(Qt.AlignCenter)
     self.label_alert.setStyleSheet(f'background: #dddddd;')
     self.addWidget(self.label_alert)
     # context menu
     self.action_report_done = QAction('Report done ...')
     self.action_report_done.triggered.connect(self.report_done)
     self.action_exit = QAction('Exit')
     self.action_exit.triggered.connect(self.close)
     self.action_frameless = QAction('Frameless window')
     self.action_frameless.setCheckable(True)
     self.action_frameless.triggered.connect(self.set_frameless_window)
     self.action_homepage = QAction('Open homepage')
     self.action_homepage.triggered.connect(self.open_homepage)
     self.context_menu = QMenu()
     self.context_menu.addAction(self.action_report_done)
     self.context_menu.addAction(self.action_exit)
     self.context_menu.addAction(self.action_frameless)
     self.context_menu.addAction(self.action_homepage)
     # threads
     self.thread_communication = QThread()
     self.thread_communication.start()
     # workers
     self.worker_communication = CommunicationWorker(
         netloc=self.config.netloc,
         base_path=self.config.base_path,
         api_key=self.config.api_key,
         guild=self.config.guild,
         member=self.config.member)
     self.worker_communication.moveToThread(self.thread_communication)
     # signals
     self.worker_communication.signal_get_ping_done.connect(self.get_ping_done)
     self.worker_communication.signal_post_history_done.connect(self.post_history_done)
     self.signal_get_ping.connect(self.worker_communication.get_ping)
     self.signal_post_history.connect(self.worker_communication.post_history)
     # get ping timer
     QTimer.singleShot(0, self.get_ping)
     self.timer_ping = QTimer()
     self.timer_ping.timeout.connect(self.get_ping)
     self.timer_ping.setTimerType(Qt.VeryCoarseTimer)
     self.timer_ping.start(self.INTERVAL_SECS * 1000)
     # switch label timer
     self.timer_label = QTimer()
     self.timer_label.timeout.connect(lambda: self.setCurrentWidget(self.widget_ping))
     self.timer_label.setSingleShot(True)
     self.timer_label.setTimerType(Qt.CoarseTimer)
     # window attributes
     size = self.settings.get('window', 'size', type_=QSize)
     if size is not None:
         self.resize(size)
     pos = self.settings.get('window', 'pos', type_=QPoint)
     if pos is not None:
         self.move(pos)
     frameless = self.settings.get('window', 'frameless', type_=bool)
     if frameless is not None and frameless:
         QTimer.singleShot(100, self.action_frameless.trigger)
     self.setWindowFlag(Qt.WindowStaysOnTopHint, self.config.window_stays_on_top)
     self.setAttribute(Qt.WA_TranslucentBackground)
     self.setWindowTitle('Evelyn Reminder')