Example #1
0
    def __init__(self, parent):
        """Init class.

        Args:
            parent (QWidget)
        """
        super().__init__(parent)
        # parameters
        self._filter_state = set()
        self._filter_empty_state = False
        self._search_text = ''
        self.search_delay = 200

        # create ui elements
        self._ui_vertical_layout = QVBoxLayout(self)
        self._ui_list = QListView()
        self._ui_edit = QLineEdit()
        self._ui_edit.setPlaceholderText('Search')
        self._ui_edit.setClearButtonEnabled(True)
        self._ui_buttons = QDialogButtonBox(QDialogButtonBox.Cancel
                                            | QDialogButtonBox.Ok)
        self._ui_vertical_layout.addWidget(self._ui_edit)
        self._ui_vertical_layout.addWidget(self._ui_list)
        self._ui_vertical_layout.addWidget(self._ui_buttons)

        # add models
        self._search_timer = QTimer(
        )  # Used to limit search so it doesn't search when typing
        self._search_timer.setSingleShot(True)

        self._filter_model = None
Example #2
0
    def registerThread(self):
        """
        This slot shall be called from each activated nexxT thread with a direct connection.

        :return:
        """
        t = QThread.currentThread()
        logger.internal("registering thread %s", t.objectName())
        with self._lockThreadSpecific:
            if not t in self._threadSpecificProfiling:
                self._threadSpecificProfiling[t] = ThreadSpecificProfItem()
                self._threadSpecificProfiling[t].timer = QTimer(
                    parent=self.sender())
                self._threadSpecificProfiling[t].timer.timeout.connect(
                    self._generateRecord, Qt.DirectConnection)
                self._threadSpecificProfiling[t].timer.setInterval(
                    int(ThreadSpecificProfItem.THREAD_PROFILING_PERIOD_SEC *
                        1e3))
                self.stopTimers.connect(
                    self._threadSpecificProfiling[t].timer.stop)
                self.startTimers.connect(
                    self._threadSpecificProfiling[t].timer.start)
                if self._loadMonitoringEnabled:
                    self._threadSpecificProfiling[t].timer.start()

            tmain = QCoreApplication.instance().thread()
            if self._mi is None and not tmain in self._threadSpecificProfiling:
                self._mi = MethodInvoker(
                    dict(object=self, method="registerThread", thread=tmain),
                    Qt.QueuedConnection)
    def __init__(self):
        QObject.__init__(self)

        # QTimer - Run Timer
        self.timer = QTimer()
        self.timer.timeout.connect(lambda: self.setTime())
        self.timer.start(1000)
Example #4
0
 def start_timer(self):
     if not self.timer:
         self.timer = QTimer(self)
         self.timer.timeout.connect(self.on_error_received)
         self.timer.setInterval(100)
         # self.timer.setSingleShot(True)
         self.timer.start()
Example #5
0
 def initializeGL(self):
     glMatrixMode(GL_PROJECTION)
     gluPerspective(45.0, self.width() / self.height(), 0.1, 100.0)
     glMatrixMode(GL_MODELVIEW)
     self.__timer = QTimer()
     self.__timer.timeout.connect(self.repaint)
     self.__timer.start(1000 / self.frameRate)
Example #6
0
    def __init__(self, *args, **kwargs):
        super(NetPosition, self).__init__(*args, **kwargs)
        self.timeout_count = 0  # 计算显示的次数,虚假显示‘正在计算’字样
        self.tips_animation_timer = QTimer(self)  # 显示文字提示的timer
        self.tips_animation_timer.timeout.connect(self.animation_tip_text)

        self.query_button.clicked.connect(self.get_net_position)
Example #7
0
 def __init__(self):
     super().__init__()
     self._timer = timer = QTimer()
     timer.setSingleShot(False)
     timer.setInterval(10)
     timer.timeout.connect(self._onTimer)
     timer.start()
Example #8
0
def main():
    basePath = os.path.dirname(os.path.realpath(__file__))
    app = QApplication(sys.argv)
    contextMenu = QMenu()
    fixAction = QAction(
        "Run 'create__ap --fix-unmanaged' in the terminal as root to fix possible issues"
    )
    contextMenu.addAction(fixAction)
    activeIcon = QIcon()
    activeIcon.addFile(os.path.join(basePath, "wifi.svg"))
    inactiveIcon = QIcon()
    inactiveIcon.addFile(os.path.join(basePath, "wifi-off.svg"))
    trayIcon = QSystemTrayIcon(inactiveIcon)
    trayIcon.setContextMenu(contextMenu)
    trayIcon.activated.connect(handleTrayIconClick)

    def syncIcon():
        if serviceIsActive():
            trayIcon.setIcon(activeIcon)
        else:
            trayIcon.setIcon(inactiveIcon)

    timer = QTimer()
    timer.setInterval(1000)
    timer.timeout.connect(syncIcon)
    timer.start()
    trayIcon.show()
    sys.exit(app.exec_())
Example #9
0
    def __init__(self, window, G, options, main=None):
        super().__init__()
        self.timer = QTimer()
        self.alive_timer = QElapsedTimer()
        self.g = G
        self.window = window
        self.view_menu = QMenu()
        self.file_menu = QMenu()
        self.forces_menu = QMenu()
        self.main_widget = window
        self.docks = {}
        self.widgets = {}
        self.widgets_by_type = {}

        available_geometry = QApplication.desktop().availableGeometry()
        window.move((available_geometry.width() - window.width()) / 2,
                    (available_geometry.height() - window.height()) / 2)
        self.__initialize_file_menu()
        viewMenu = window.menuBar().addMenu(window.tr("&View"))
        forcesMenu = window.menuBar().addMenu(window.tr("&Forces"))
        actionsMenu = window.menuBar().addMenu(window.tr("&Actions"))
        restart_action = actionsMenu.addAction("Restart")

        self.__initialize_views(options, main)
        self.alive_timer.start()
        self.timer.start(500)
Example #10
0
    def __init__(self):
        QObject.__init__(self)

        # AUTO REFRESH / DYNAMIC INFOS
        timer = QTimer(self)
        timer.start(1000)
        timer.timeout.connect(lambda: self.setDynamicInfo())
Example #11
0
    def __init__(self, log_lvl):
        super(LogFileHandler, self).__init__()
        logging.debug('LogFileHandler::__init__() called')
        self.log_lvl = log_lvl
        self.log_path = Path.home() / 'Pythonic' / 'log'
        self.log_date = datetime.datetime.now()
        self.formatter = logging.Formatter(
            fmt='%(asctime)s - %(levelname)s - %(message)s',
            datefmt='%H:%M:%S')
        self.logger = logging.getLogger()

        # Apply log_lvl
        self.logger.setLevel(self.log_lvl)
        self.logger.propagate = False
        # Remove default Stream Handler
        self.logger.removeHandler(self.logger.handlers[0])

        # Create directory structure for logging
        self.log_date_str = self.log_date.strftime('%Y_%m_%d')

        file_path = '{}/{}.txt'.format(str(self.log_path), self.log_date_str)

        # Setup logger

        file_handler = logging.FileHandler(file_path)
        file_handler.setLevel(self.log_lvl)
        file_handler.setFormatter(self.formatter)

        self.logger.addHandler(file_handler)

        self.timer = QTimer()
        self.timer.start(1000)
        self.timer.timeout.connect(self.checkLogDate)
Example #12
0
    def __init__(self, png, tank_item: TankItem, direction: Direction):
        QGraphicsPixmapItem.__init__(self, png)

        self.tank_item = tank_item
        self.tank = tank_item.tank
        self.direction = direction
        self.available = True

        if self.direction == Direction.UP:
            self.setX(self.tank_item.x() + cube_size / 2 - 3)
            self.setY(self.tank_item.y())
        elif self.direction == Direction.DOWN:
            self.setX(self.tank_item.x() + cube_size / 2 + 3)
            self.setY(self.tank_item.y() + cube_size)
            self.setRotation(180)
        elif self.direction == Direction.LEFT:
            self.setX(self.tank_item.x())
            self.setY(self.tank_item.y() + cube_size / 2 + 3)
            self.setRotation(270)
        elif self.direction == Direction.RIGHT:
            self.setX(self.tank_item.x() + cube_size)
            self.setY(self.tank_item.y() + cube_size / 2 - 3)
            self.setRotation(90)

        self.timer = QTimer()
        self.timer.setInterval(interval)
        self.timer.timeout.connect(self.move)
        self.timer.start()
Example #13
0
 def __init__(self, png):
     super().__init__(png, Direction.DOWN)
     self.setRotation(180)
     self.auto_timer = QTimer()
     self.auto_timer.setInterval(1000)
     self.auto_timer.timeout.connect(self.auto)
     self.auto_timer.start()
Example #14
0
    def __init__(self):
        self.logger = logging_util.SporeLogger(__name__)

        self.timer = QTimer()
        self.timer.timeout.connect(self.send_report)
        self.last_msg = 0.0
        self.msg_stack = []
Example #15
0
    def __init__(self, ui):
        """ Initializes file drag&drop events on to the Main Window and handles the py shop layering threads.

        :param modules.gui.main_window.MainWindow ui: Application QMainWindow
        """
        super(FileDrop, self).__init__(parent=ui)
        self.ui = ui

        self.ui.cancelBtn.released.connect(self.cancel_thread)

        # --- Install file drop on main window ---
        self.ui.setAttribute(Qt.WA_AcceptDrops)
        self.ui.installEventFilter(self)

        # -- Open file delay --
        self.file_timer = QTimer()
        self.file_timer.setInterval(1500)
        self.file_timer.setSingleShot(True)
        self.file_timer.timeout.connect(self._open_psd_file)

        # Hide cancel btn
        self.ui.cancelBtn.hide()
        self.ui.lastFileWidget.hide()

        self.py_shop_thread = CreateLayeredPsdThread(self, list())
Example #16
0
    def __init__(self, qmp):

        QMainWindow.__init__(self)
        self.qmp = qmp

        shortcut = QShortcut(QKeySequence('Ctrl+r'),
                             self,
                             activated=self.disp_output)

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.disp_output)
        # self.timer.start(100)

        self.activated = 0

        open('/tmp/errors.log', 'w').close()

        self.qmp.hmp_command('logfile /tmp/errors.log')
        self.qmp.hmp_command('log guest_error')

        self.setWindowTitle('Error Log')
        self.setGeometry(100, 100, 600, 400)

        self.menu_bar()
        self.init_ui()
Example #17
0
    def __init__(self, app, state: State, screenFPS, fixedFPS, parent=None):
        """
        The MainWindow is created by the application, here we handle ui/scenes and send out updates.
        :param state: The current state we want to start with.
        :param parent: The widget this held under, None by default because this is top widget
        """
        QMainWindow.__init__(self, parent)
        self.app = app  # the application created
        self.gameScreen = None  # where all graphics are drawn
        self.uiManager = UiManager(self, customWidgets=[
            GameScreen
        ])  # Loads widgets into window from a file
        self.stateManager = StateManager(
            self, state)  # Manages state updates and transitions

        self.updateFPSTimer = QTimer(self)  # Used to manage frame timings
        self.updateFPSTimer.timeout.connect(self.__calculateFPS)

        self.fixedFps = 0  # Calculated FPS
        self.screenFps = 0

        self.fixedFrames = 0  # Accumulated Frames
        self.screenFrames = 0

        self.targetFixedFPS = fixedFPS
        self.targetUpdateFPS = screenFPS
        self.fixedTiming = 1 / self.targetFixedFPS
        self.screenTiming = 1 / self.targetUpdateFPS
        self.fixedNeeded = fixedFPS
        self.screenNeeded = screenFPS
        self.lastTime = 0
        self.setMouseTracking(True)

        self.uiManager.keepWidgets = self.children()
Example #18
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)
             self.timer.start(10)
Example #19
0
    def __init__(self):
        super().__init__()

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

        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()
Example #20
0
    def __init__(self, scatter, s_data):
        self.scatter = scatter
        self._s_data = s_data
        self.timer = QTimer()

        self.series = QtDataVisualization.QScatter3DSeries()
        self.data = [
            QVector3D(0.5, 0.5, 0.5),
            QVector3D(-0.3, -0.5, -0.4),
            QVector3D(0.0, -0.3, 0.2)
        ]
        self.series.dataProxy().addItems(self.data)
        self.series.setItemSize(0.5)
        self.series.setMeshSmooth(True)

        self.scatter.addSeries(self.series)
        self.scatter.setAspectRatio(1.0)
        self.scatter.setHorizontalAspectRatio(1.0)

        # Setting of plot limits
        self.scatter.axisX().setRange(0, s_data.getBoxWidth())
        self.scatter.axisY().setRange(0, s_data.getBoxWidth())
        self.scatter.axisZ().setRange(0, s_data.getBoxWidth())

        self._time_step = s_data.getTimeStep() * 1000
        self.timer.timeout.connect(self.makeStep)
        # Drowing of the data and starting of the timer
        self.drawData()
        self.timer.start(self._time_step)
Example #21
0
    def __init__(self, owner):
        super(self.__class__, self).__init__(owner)
        Ui_Loading.__init__(self)
        self.setupUi(self)
        self.owner = weakref.ref(owner)
        self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
        self.setWindowFlag(QtCore.Qt.Dialog)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        self.setWindowModality(QtCore.Qt.ApplicationModal)
        # frmX = self.width()
        # frmY = self.height()
        # w = QDesktopWidget()
        # w.width()
        # movePoint = QPoint(int(w.width()/2-frmX/2), int(w.height()/2 - frmY/2))
        # self.move(movePoint)
        self.index = 1
        self.qMapList = []
        for i in range(1, 11):
            data = resources.DataMgr.GetData("loading_{}".format(str(i)))
            img = QImage()
            img.loadFromData(data)
            self.qMapList.append(img)

        self.label.setFixedSize(QPixmap.fromImage(self.qMapList[0]).size())
        self.label.setPixmap(QPixmap.fromImage(self.qMapList[0]))
        self.label.setScaledContents(True)
        self.timer = QTimer(self.label)
        self.timer.setInterval(100)

        self.cnt = 0
        self.closeCnt = 50
        self.timer.timeout.connect(self.UpdatePic)
Example #22
0
    def reset(self) -> bool:
        """Reset the dimmer and start counting down again. If it was busy dimming, it will
        immediately stop dimming. Callback fires to set brightness back to normal."""

        self.__stopped = False
        if self.__timer:
            self.__timer.stop()

        if self.__change_timer:
            self.__change_timer.stop()

        if self.timeout:
            self.__timer = QTimer()
            self.__timer.setSingleShot(True)
            self.__timer.timeout.connect(partial(self.change_brightness))
            self.__timer.start(self.timeout * 1000)

        if self.__dimmer_brightness != self.brightness:
            previous_dimmer_brightness = self.__dimmer_brightness
            self.brightness_callback(self.brightness)
            self.__dimmer_brightness = self.brightness
            if previous_dimmer_brightness < 10:
                return True

        return False
Example #23
0
    def __init__(self,
                 title,
                 finish: datetime.datetime,
                 maxRemain=3000000000,
                 display_fmt="ms",
                 parent=None):
        super().__init__(parent)
        self.setupUi(self)

        self.display_fmt = display_fmt
        self.finish = finish
        self.maxRemain = maxRemain
        self.remainer.setMaximum(maxRemain // 1000)
        self.setTitle(title)

        self.timerUpdate = QTimer(self)
        self.timerUpdate.timeout.connect(self.updateRemainer)

        if self.display_fmt in ("ms", "xms"):
            self.timerUpdate.start(47)
        elif self.display_fmt in ("sec", "xsec"):
            self.timerUpdate.start(900)
        elif self.display_fmt in ("min", "xmin"):
            self.timerUpdate.start(5000)
        elif self.display_fmt in ("hour", "xhr"):
            self.timerUpdate.start(5000)
        elif self.display_fmt in ("day", "xday"):
            self.timerUpdate.start(10000)
        else:
            self.display_fmt = "ms"
            self.timerUpdate.start(47)

        self.updateRemainer()
Example #24
0
 def __init__(self):
     # 按钮使能(否)
     gui.pushButton_3.setEnabled(False)
     gui.file = gui.open_video()
     if not gui.file:
         return
     gui.label.setText("正在读取请稍后...")
     # 设置时钟
     self.v_timer = QTimer()  # self.
     # 读取视频
     self.cap = cv2.VideoCapture(gui.file)
     if not self.cap:
         print("打开视频失败")
         return
     # 获取视频FPS
     self.fps = self.cap.get(cv2.CAP_PROP_FPS)  # 获得码率
     # 获取视频总帧数
     self.total_f = self.cap.get(cv2.CAP_PROP_FRAME_COUNT)
     # 获取视频当前帧所在的帧数
     self.current_f = self.cap.get(cv2.CAP_PROP_POS_FRAMES)
     # 设置定时器周期,单位毫秒
     self.v_timer.start(int(1000 / self.fps))
     print("FPS:".format(self.fps))
     # 连接定时器周期溢出的槽函数,用于显示一帧视频
     self.v_timer.timeout.connect(self.show_pic)
     # 连接按钮和对应槽函数,lambda表达式用于传参
     gui.pushButton_5.clicked.connect(self.go_pause)
     print("init OK")
Example #25
0
 def cycle_images(self):
     if self.radioButton.isChecked():
         self.timer = QTimer(self)
         self.timer.timeout.connect(self.load_image)
         self.timer.start(1500)
     else:
         self.timer.stop()
Example #26
0
    def __init__(self):
        super().__init__()

        self.node_set = NodeSet()
        self.parent = QWidget()
        self.parent.hide()
        self.parent.setWindowFlags(self.parent.windowFlags() & ~QtCore.Qt.Tool)

        self.system_tray = SystemTray(self.parent, self.node_set)

        self.setQuitOnLastWindowClosed(False)

        self.aboutToQuit.connect(self.quit_app)

        self.system_tray.show()

        self.system_tray.showMessage('Nodes starting...',
                                     'Bitcoin and Lightning are syncing')

        self.node_set.bitcoin.file.file_watcher.fileChanged.connect(
            self.check_restart_required)
        self.node_set.lnd.file.file_watcher.fileChanged.connect(
            self.check_restart_required)

        self.timer = QTimer(self)
        self.timer.start(1000)
        self.timer.timeout.connect(self.check_restart_required)
        self.timer.singleShot(1000, self.check_version)
Example #27
0
    def __init__(self, config, resource):
        """Setup each channel widget and place in QVBoxlayout"""
        QWidget.__init__(self)
        self.config = config
        self.resource = resource

        area = QScrollArea()
        contents = QWidget()
        rows = QVBoxLayout(contents)
        layout = QVBoxLayout(self)
        layout.addWidget(area)
        area.setWidget(contents)
        area.setWidgetResizable(True)
        layout.setContentsMargins(0, 0, 0, 0)
        rows.setContentsMargins(0, 0, 0, 0)
        rows.setSpacing(0)

        self.channels = []
        for channel in config["channels"]:
            self.channels.append(
                ChannelWidget(channel["channel"], config, resource))
            rows.addWidget(self.channels[-1])

        # Set initial status and set status timer
        self.update_status()
        self.timer = QTimer()
        self.timer.timeout.connect(self.update_status)
        self.timer.start(UPDATE_INTERVAL)
Example #28
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.date_view = QListView()
        self.forum_view = QListView()
        self.contentMax = 0
        self.ioloop = asyncio.get_event_loop()
        icon = QIcon()
        icon.addPixmap(QPixmap(FAVICON_ICO), QIcon.Normal)
        self.setWindowIcon(icon)
        self.setWindowTitle(APP_TITLE)

        self.settings = QSettings('karoStudio', 'nnm-stats')
        self.resize(self.settings.value('main/size', QSize(640, 480)))
        self.move(self.settings.value('main/pos', QPoint(200, 200)))

        self.splitter = QSplitter()
        self.get_menu()

        self.content = QScrollArea()
        self.content.verticalScrollBar().valueChanged.connect(
            self.scrollBarChanged)
        self.content.verticalScrollBar().rangeChanged.connect(
            self.rangeChanged)
        self.torrents_list_view = QWidget()
        layout = QGridLayout()
        self.torrents_list_view.setLayout(layout)
        self.content.setWidget(self.torrents_list_view)
        self.splitter.addWidget(self.content)
        self.splitter.setSizes([160, 350])
        self.setCentralWidget(self.splitter)

        self.timer = QTimer()
        self.timer.singleShot(1600, self.load_task)
Example #29
0
    def __init__(self, ui_file, parent=None):
        self.remaining_time = 10

        super(Form, self).__init__(parent)
        ui_file = QFile(ui_file)
        ui_file.open(QFile.ReadOnly)

        loader = QUiLoader()
        self.window = loader.load(ui_file)
        ui_file.close()

        self.btn_clear = self.window.findChild(QPushButton, "btn_clear")
        self.btn_skip = self.window.findChild(QPushButton, "btn_skip")
        self.btn_undo = self.window.findChild(QPushButton, "btn_undo")

        self.label_timer = self.window.findChild(QLabel, "label_timer")
        self.log = self.window.findChild(QPlainTextEdit, "log")
        self.picture_holder = self.window.findChild(QLabel, "picture_holder")
        self.gen_line = QLine()

        self.timer = QTimer(self)
        #self.timer.timeout.connect(self.stop_game)
        self.timer.start(1000)
        #QTimer.singleShot(1000, self.redraw_label_timer)
        QObject.connect(self.timer, SIGNAL('timeout()'),
                        self.redraw_label_timer)

        self.window.show()
    def __init__(self):
        QWidget.__init__(self)
        self.setMinimumSize(800, 600)
        self.donuts = []
        self.chart_view = QtCharts.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(QtCharts.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)