コード例 #1
0
ファイル: curiwidget.py プロジェクト: battyone/CuriElements
    def __init__(self, parent=None):
        super(CuriWidget,
              self).__init__(parent,
                             Qt.FramelessWindowHint | Qt.WindowSystemMenuHint)
        self.addCustomAction()
        w = qApp.desktop().screenGeometry().width()
        h = qApp.desktop().screenGeometry().height()

        side = round((8 / 9) * min(w / cols, h / rows))
        self.setFixedSize(side * QSize(cols, rows))

        self.thread = SoundThread(self)
        self.dragPosition = QPoint()
        self.button = None

        self.setWindowIcon(QIcon(":curielements"))

        region = QRegion(QRect(0, 0, 2 * side, 2 * side), QRegion.Ellipse)
        region += QRegion(QRect(side, 0, 8 * side, 15 * side))
        region += QRegion(QRect(0, side, side, 13 * side))
        region += QRegion(QRect(0, 13 * side, 2 * side, 2 * side),
                          QRegion.Ellipse)
        region += QRegion(QRect(9 * side, side, side, 14 * side))
        region += QRegion(QRect(8 * side, 0, 2 * side, 2 * side),
                          QRegion.Ellipse)
        region += QRegion(QRect(10 * side, 2 * side, 19 * side, 13 * side))
        region += QRegion(QRect(28 * side, 2 * side, 2 * side, 2 * side),
                          QRegion.Ellipse)
        region += QRegion(QRect(29 * side, 3 * side, side, 11 * side))
        region += QRegion(QRect(28 * side, 13 * side, 2 * side, 2 * side),
                          QRegion.Ellipse)

        self.setMask(region)

        self.atoms = Atoms(self)
        self.atoms.setGeometry(
            QRect(1.5 * side, 1.5 * side, 7 * side, 7 * side))

        offset = QPoint(10 * side, 3 * side)
        file = QFile(":elements")
        file.open(QFile.ReadOnly | QFile.Text)
        colors = [blue, yellow]
        self.btns = []
        while not file.atEnd():
            x, y, name, symbol, electron, description, description2, _ = file.readLine(
            ).split(',')
            coordinate = QPoint(int(x), int(y))
            text = bytearray(name).decode()
            btn = ElementButton(QSize(side, side), colors, int(electron),
                                bytearray(symbol).decode(), text, self)
            btn.move(offset + coordinate * side)
            btn.clicked.connect(self.button_clicked)
            self.btns.append(btn)
        self.imageDescription = DescriptionButton(side * QSize(7, 4.5), blue,
                                                  self)
        self.imageDescription.move(1.5 * side, 9 * side)
        btnSound = DescriptionButton(side * QSize(2, 2), blue, self)
        btnSound.move(11 * side, 12 * side)
        btnSound.updateBackground(":soundOn")
        btnSound.clicked.connect(self.sound_clicled)
コード例 #2
0
ファイル: main_form.py プロジェクト: bluebird75/sxtool
 def loadFile(self, fname: str) -> bool:
     self.setProgramTitle(None, False)
     self.dataTable = DataTable(self, "DataTable")
     self.layoutWidget.gridLayout.addWidget(self.dataTable, 0, 0)
     res = self.dataTable.loadFile(fname)
     if not res:
         self.statusBar().showMessage("File %s could not be opened" % fname)
         return False
     self.setProgramTitle(fname, False)
     for a in self.actionList:
         a.setEnabled(True)
     self.dataTable.itemDoubleClicked.connect(self.slotEditRowData)
     self.dataTable.sigDataModifiedChanged.connect(
         self.slotFileModifiedChanged)
     self.statusBar().showMessage("File %s opened" % fname)
     deskSize = qApp.desktop().availableGeometry(qApp.desktop().screen())
     # only take 80% of the screen in best case
     reasonableSize = int(deskSize.width() * 0.8), int(deskSize.height() *
                                                       0.8)
     szHint = self.sizeHint()
     # sizeHint needs a little margin to account for ... I don't know exactly what
     goodSize = int(szHint.width() * 1.1), int(szHint.height() * 1.1)
     self.resize(min(goodSize[0], reasonableSize[0]),
                 min(goodSize[1], reasonableSize[1]))
     return True
コード例 #3
0
ファイル: viewer.py プロジェクト: madobet/Mask_RCNN
    def __init__(self, result, parent=None, width=1366, height=768, dpi=100):
        """
        :param result: MaskRCNNClient 类
        """
        super().__init__(parent)
        self.menubar = self.menuBar()             # 初始化菜单栏
        self.detect_result = result
        pix_width = QApplication.desktop().width()
        pix_height = QApplication.desktop().height()
        dpi_x = qApp.desktop().logicalDpiX()
        dpi_y = qApp.desktop().logicalDpiY()
        print("Screen: %d, %d\nDPI: %d, %d" % (pix_width, pix_height, dpi_x, dpi_y))
        self.mpl_preview = MplCanvas(self, pix_width/dpi_x, pix_height/dpi_y, (dpi_x + dpi_y)/2)
        # self.mpl_preview = MplCanvas(self)
        self.initUIMain()                         # 初始化剩余 UI

        self.resize(1200, 675)
        self.setWindowTitle("TF Viewer")
        self.setWindowIcon(QIcon("res/icon.png"))

        self.setCentralWidget(self.mpl_preview)   # 主界面
        self.visual_result()

        self.center()
        self.show()
コード例 #4
0
    def updatePreview(self):
        if self._loadingTheme:
            return

        currentScreen = qApp.desktop().screenNumber(self)
        screen = qApp.desktop().screenGeometry(currentScreen)

        px = createThemePreview(self._themeData, screen, self.lblPreview.size())
        self.lblPreview.setPixmap(px)
コード例 #5
0
    def updatePreview(self):
        if self._loadingTheme:
            return

        currentScreen = qApp.desktop().screenNumber(self)
        screen = qApp.desktop().screenGeometry(currentScreen)

        px = createThemePreview(self._themeData, screen, self.lblPreview.size())
        self.lblPreview.setPixmap(px)
コード例 #6
0
ファイル: welcome_window.py プロジェクト: 0xsunsama/myDwarf
    def __init__(self, parent=None):
        super(WelcomeDialog, self).__init__(parent=parent)

        self._prefs = parent.prefs

        self._sub_titles = [
            ['duck', 'dumb', 'doctor', 'dutch', 'dark', 'dirty', 'debugging'],
            ['warriors', 'wardrobes', 'waffles', 'wishes', 'worcestershire'],
            ['are', 'aren\'t', 'ain\'t', 'appears to be'],
            ['rich', 'real', 'riffle', 'retarded', 'rock'],
            [
                'as f**k', 'fancy', 'f****d', 'front-ended', 'falafel',
                'french fries'
            ],
        ]

        self._update_thread = None

        # setup size and remove/disable titlebuttons
        self.desktop_geom = qApp.desktop().availableGeometry()
        self.setFixedSize(self.desktop_geom.width() * .45,
                          self.desktop_geom.height() * .4)
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                               qApp.desktop().availableGeometry()))
        self.setSizeGripEnabled(False)
        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setWindowFlag(Qt.WindowContextHelpButtonHint, False)
        self.setWindowFlag(Qt.WindowCloseButtonHint, True)
        self.setModal(True)

        self._recent_list_model = QStandardItemModel(0, 2)
        self._recent_list_model.setHeaderData(0, Qt.Horizontal, 'Type')
        self._recent_list_model.setHeaderData(1, Qt.Horizontal, 'Path')

        self._recent_list = DwarfListView(self)
        self._recent_list.setModel(self._recent_list_model)

        self._recent_list.header().setSectionResizeMode(
            0, QHeaderView.ResizeToContents)
        self._recent_list.header().setSectionResizeMode(1, QHeaderView.Stretch)

        # setup ui elements
        self.setup_ui()

        random.seed(a=None, version=2)

        if not str(__file__).endswith('.pyc'):
            self.update_commits_thread = DwarfCommitsThread(parent)
            self.update_commits_thread.on_update_available.connect(
                self._on_dwarf_isupdate)
            self.update_commits_thread.start()
        # center
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                               qApp.desktop().availableGeometry()))
コード例 #7
0
ファイル: locker.py プロジェクト: TenKeyAngle/manuskript
    def lock(self):
        # Block others screens
        desktop = qApp.desktop()
        self._blackout.clear()
        if desktop.screenCount() > 1:
            for d in range(desktop.screenCount()):
                if desktop.screenNumber(self) != d:
                    w = QWidget()
                    w.setStyleSheet("background: black;")
                    w.move(desktop.screenGeometry(d).topLeft())
                    w.showFullScreen()
                    self._blackout.append(w)

        if self.rbtnWordTarget.isChecked():
            self._target = self._words + self.spnWordTarget.value()

        elif self.rbtnTimeTarget.isChecked():
            self.timer.setInterval(self.spnTimeTarget.value() * 1000 * 60)
            self.timer.start()
            self.timerSec.start()
            self.updateBtnText()

        self.setEnabled(False)
        self.locked.emit()
        self.lockChanged.emit(True)
コード例 #8
0
    def lock(self):
        # Block others screens
        desktop = qApp.desktop()
        self._blackout.clear()
        if desktop.screenCount() > 1:
            for d in range(desktop.screenCount()):
                if desktop.screenNumber(self) != d:
                    w = QWidget()
                    w.setStyleSheet("background: black;")
                    w.move(desktop.screenGeometry(d).topLeft())
                    w.showFullScreen()
                    self._blackout.append(w)

        if self.rbtnWordTarget.isChecked():
            self._target = self._words + self.spnWordTarget.value()

        elif self.rbtnTimeTarget.isChecked():
            self.timer.setInterval(self.spnTimeTarget.value() * 1000 * 60)
            self.timer.start()
            self.timerSec.start()
            self.updateBtnText()

        self.setEnabled(False)
        self.locked.emit()
        self.lockChanged.emit(True)
コード例 #9
0
ファイル: q_main.py プロジェクト: nocrater/Syllabus
 def set_ui(self) -> None:
     self.create_menu()
     self.setWindowTitle("Управление")
     geometry = qApp.desktop().availableGeometry(self)
     self.setFixedSize(geometry.width() * 0.8, geometry.height() * 0.8)
     self.stacked_widget = QStackedWidget(self)
     self.setCentralWidget(self.stacked_widget)
コード例 #10
0
    def show(self, timeout=0, above=False):
        self.cursor_start_col = self.textedit.textCursor().columnNumber()
        desktop = qApp.desktop()
        screen = desktop.screen(desktop.screenNumber(self))
        screen_width = screen.width()
        screen_height = screen.height()
        win_width = self.width()
        win_height = self.height()
        cursorRect = self.textedit.cursorRect()
        if above:
            pos = self.textedit.mapToGlobal(cursorRect.topLeft())
            pos.setY(pos.y() - win_height)
        else:
            pos = self.textedit.mapToGlobal(cursorRect.bottomLeft())
        if pos.y() < 0:
            pos = self.textedit.mapToGlobal(cursorRect.bottomLeft())
        if pos.y() + win_height > screen_height:
            pos = self.textedit.mapToGlobal(cursorRect.topLeft())
            pos.setY(pos.y() - win_height)
        if pos.x() + win_width > screen_width:
            pos.setX(screen_width - win_width)

        self.move(pos)
        QWidget.show(self)
        self.active = True
        if timeout:
            QTimer.singleShot(timeout * 1000, self.hide)
コード例 #11
0
ファイル: Gravity-Windows.py プロジェクト: jreus/artware
 def __init__(self, xpos, ypos, title):
     super(GravityWindow, self).__init__()
     self.acceleration = 5.0
     self.velocity = 0.0
     self.screenHeight = qApp.desktop().availableGeometry().height() # height of the screen
     self.sound = QSound("sounds/Sosumi.wav")
     self.makeWin(xpos, ypos, title)
コード例 #12
0
ファイル: assist.py プロジェクト: orehakamieshi/krita
    def show(self, timeout=0, above=False):
        self.cursor_start_col = self.textedit.textCursor().columnNumber()
        desktop = qApp.desktop()
        screen = desktop.screen(desktop.screenNumber(self))
        screen_width = screen.width()
        screen_height = screen.height()
        win_width = self.width()
        win_height = self.height()
        cursorRect = self.textedit.cursorRect()
        if above:
            pos = self.textedit.mapToGlobal(cursorRect.topLeft())
            pos.setY(pos.y() - win_height)
        else:
            pos = self.textedit.mapToGlobal(cursorRect.bottomLeft())
        if pos.y() < 0:
            pos = self.textedit.mapToGlobal(cursorRect.bottomLeft())
        if pos.y() + win_height > screen_height:
            pos = self.textedit.mapToGlobal(cursorRect.topLeft())
            pos.setY(pos.y() - win_height)
        if pos.x() + win_width > screen_width:
            pos.setX(screen_width - win_width)

        self.move(pos)
        QWidget.show(self)
        self.active = True
        if timeout:
            QTimer.singleShot(timeout * 1000, self.hide)
コード例 #13
0
    def show_context_menu(self, position):
        items = []
        for class_ in sorted(self._context_items.keys(), key=lambda i: str(i)):
            if isinstance(self.get_context_cue(), class_):
                items.extend(self._context_items[class_])

        if len(items) > 0:
            menu = QMenu(self)

            for item in items:
                if isinstance(item, QAction):
                    menu.addAction(item)
                elif isinstance(item, QMenu):
                    menu.addMenu(item)

            menu.move(position)
            menu.show()

            # Adjust the menu position
            desktop = qApp.desktop().availableGeometry()
            menu_rect = menu.geometry()

            if menu_rect.bottom() > desktop.bottom():
                menu.move(menu.x(), menu.y() - menu.height())
            if menu_rect.right() > desktop.right():
                menu.move(menu.x() - menu.width(), menu.y())
コード例 #14
0
 def showCurrentScreenCenter(self):
     screen = qApp.desktop()
     geometry = screen.screenGeometry(screen.screenNumber(QCursor.pos()))
     x = geometry.x() + (geometry.width() - self.width())/2
     y = geometry.y() + (geometry.height() - self.height())/2
     self.move(x, y)
     self.show()
コード例 #15
0
ファイル: device_window.py プロジェクト: renbingfei/Dwarf
    def setup_ui(self):
        self.setFixedSize(800, 400)

        main_wrap = QVBoxLayout(self)
        main_wrap.setContentsMargins(0, 0, 0, 0)

        self._dev_bar = DeviceBar(self, self.device_type)
        self._dev_bar.onDeviceUpdated.connect(self._update_device)
        # not needed on local
        #if self.device and self.device.type == 'local':
        #self._dev_bar.setVisible(False)

        main_wrap.addWidget(self._dev_bar)
        """frm_lyt = QFormLayout()
        frm_lyt.setContentsMargins(10, 10, 10, 10)

        _label = QLabel('Script to load (optional)')
        frm_lyt.addRow(_label)

        user_script_path = QLineEdit()
        load_button = QPushButton('...')

        frm_lyt.addRow(load_button, user_script_path)

        main_wrap.addLayout(frm_lyt)"""

        # procs/spawns lists
        spawns_vbox = QVBoxLayout()

        spawns_label = QLabel('SPAWN')
        spawns_label.setFont(QFont('Anton', 20, QFont.Normal))
        spawns_vbox.addWidget(spawns_label)
        self.spawn_list = SpawnsList(device=self.device)
        self.spawn_list.onProcessSelected.connect(self._spawn_selected)
        spawns_vbox.addWidget(self.spawn_list)

        procs_vbox = QVBoxLayout()
        procs_label = QLabel('PROCS')
        procs_label.setFont(QFont('Anton', 20, QFont.Normal))
        procs_vbox.addWidget(procs_label)

        self.proc_list = ProcessList(device=self.device)
        self.proc_list.onProcessSelected.connect(self._pid_selected)
        procs_vbox.addWidget(self.proc_list)

        inner_hbox = QHBoxLayout()
        inner_hbox.setContentsMargins(10, 10, 10, 10)
        inner_hbox.addLayout(spawns_vbox)
        inner_hbox.addLayout(procs_vbox)

        vbox = QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)
        #vbox.addWidget(self._dev_bar)
        main_wrap.addLayout(inner_hbox)

        #self.setLayout(vbox)
        # center
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                               qApp.desktop().availableGeometry()))
コード例 #16
0
    def restoreWidgetPosition(self):
        restored = False
        if self.save_position:
            geometry = self.savedWidgetGeometry
            if geometry is not None:
                restored = self.restoreGeometry(QByteArray(geometry))

            if restored:
                space = qApp.desktop().availableGeometry(self)
                frame, geometry = self.frameGeometry(), self.geometry()

                #Fix the widget size to fit inside the available space
                width = space.width() - (frame.width() - geometry.width())
                width = min(width, geometry.width())
                height = space.height() - (frame.height() - geometry.height())
                height = min(height, geometry.height())
                self.resize(width, height)

                # Move the widget to the center of available space if it is
                # currently outside it
                if not space.contains(self.frameGeometry()):
                    x = max(0, space.width() / 2 - width / 2)
                    y = max(0, space.height() / 2 - height / 2)

                    self.move(x, y)
        return restored
コード例 #17
0
ファイル: py_hud.py プロジェクト: danpicton/py_hud
 def __init__(self):
     QWebEngineView.__init__(self)
     # self.load(image)
     self.setHtml(html)
     self.setWindowOpacity(0.7)
     radius = 10.0
     path = QtGui.QPainterPath()
     self.resize(640, 480)
     path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
     mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
     self.setMask(mask)
     self.move(QtGui.QCursor.pos())
     self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint
                         | QtCore.Qt.FramelessWindowHint
                         # | QtCore.Qt.X11BypassWindowManagerHint
                         )
     self.setGeometry(
         QStyle.alignedRect(QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter,
                            QtCore.QSize(640, 480),
                            qApp.desktop().availableGeometry()))
     self.setStyleSheet(
         'QWebView{background-color: darkgray; border: 5px solid darkgray}')
     self.grabMouse()
     self.grabKeyboard()
     print(self.keyboardGrabber())
コード例 #18
0
    def initUI(self):
        self.setWindowTitle(self.title)
        self.setWindowFlags(Qt.WindowCloseButtonHint
                            | Qt.WindowMaximizeButtonHint)
        geometry = qApp.desktop().availableGeometry(self)
        self.frameGeometry().setCoords(200, 200,
                                       geometry.width() * 0.5,
                                       geometry.height() * 0.7)

        self.menu = self.menuBar()
        self.file_menu = self.menu.addMenu("File")

        exit_action = QAction("Exit", self)
        exit_action.setShortcut(QKeySequence.Quit)
        exit_action.triggered.connect(self.close)

        self.file_menu.addAction(exit_action)

        config_action = QAction("Config", self)
        config_action.setShortcut(QKeySequence.Quit)
        config_action.triggered.connect(self.toolbarConfigClick)

        self.file_menu.addAction(config_action)

        self.status = self.statusBar()
        self.status.showMessage("App Loaded")

        self.mainwindow = MainWindowLayout()
        self.setCentralWidget(self.mainwindow)
        self.setStyleSheet(open("resources/stylesheet.css").read())

        self.show()
コード例 #19
0
    def __init__(self, application_context):
        self.application_context = application_context
        self.reader = ScreenReader(application_context)

        QMainWindow.__init__(self)
        self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint
                            | Qt.X11BypassWindowManagerHint)
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter | Qt.AlignRight,
                               QSize(220, 700),
                               qApp.desktop().availableGeometry()))

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

        self.accuracy_label = QLabel()
        self.damage_label = QLabel()
        self.tokens_label = QLabel()

        self.cumulative_probabilities_label = QLabel()
        self.exact_probabilities_label = QLabel()
        self.expected_damage_label = QLabel()

        layout.addWidget(self.accuracy_label, alignment=Qt.AlignCenter)
        layout.addWidget(self.damage_label, alignment=Qt.AlignCenter)
        layout.addWidget(self.tokens_label, alignment=Qt.AlignCenter)
        layout.addWidget(self.cumulative_probabilities_label,
                         alignment=Qt.AlignCenter)
        layout.addWidget(self.exact_probabilities_label,
                         alignment=Qt.AlignCenter)
        layout.addWidget(self.expected_damage_label, alignment=Qt.AlignCenter)

        dummy_character = calculator.Character(0, 0, 0)
        self.dummy_encounter = calculator.Encounter([dummy_character])
コード例 #20
0
    def populatesThemesList(self):
        paths = allPaths("resources/themes")
        current = settings.fullScreenTheme
        self.lstThemes.clear()

        for p in paths:
            lst = [
                i for i in os.listdir(p) if os.path.splitext(i)[1] == ".theme"
            ]
            for t in lst:
                theme = os.path.join(p, t)
                editable = not appPath() in theme
                n = getThemeName(theme)

                item = QListWidgetItem(n)
                item.setData(Qt.UserRole, theme)
                item.setData(Qt.UserRole + 1, editable)
                item.setToolTip("{}{}".format(
                    n,
                    self.tr(" (read-only)") if not editable else ""))

                thumb = os.path.join(p, t.replace(".theme", ".jpg"))
                px = QPixmap(200, 120)
                px.fill(Qt.white)
                if not os.path.exists(thumb):
                    currentScreen = qApp.desktop().screenNumber(self)
                    screenRect = qApp.desktop().screenGeometry(currentScreen)
                    thumb = createThemePreview(theme, screenRect)

                icon = QPixmap(thumb).scaled(200, 120, Qt.KeepAspectRatio)
                painter = QPainter(px)
                painter.drawPixmap(px.rect().center() - icon.rect().center(),
                                   icon)
                painter.end()
                item.setIcon(QIcon(px))

                self.lstThemes.addItem(item)

                if current and current in t:
                    self.lstThemes.setCurrentItem(item)
                    current = None

        self.lstThemes.setIconSize(QSize(200, 120))

        if current:  # the theme from settings wasn't found
            # select the last from the list
            self.lstThemes.setCurrentRow(self.lstThemes.count() - 1)
コード例 #21
0
ファイル: dwarf_dialog.py プロジェクト: iGio90/Dwarf
 def showEvent(self, QShowEvent):  # pylint: disable=invalid-name
     """ center dialog update title
     """
     self.setWindowTitle(self.title)
     self.setGeometry(
         QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                            qApp.desktop().availableGeometry()))
     return super().showEvent(QShowEvent)
コード例 #22
0
def resize_window(main_win: QMainWindow, percent: float = 0.9):
    available_size = qApp.desktop().availableGeometry().size()
    width = available_size.width()
    height = available_size.height()
    width *= percent
    height *= percent
    new_size = QSize(width, height)
    main_win.resize(new_size)
コード例 #23
0
    def populatesThemesList(self):
        paths = allPaths("resources/themes")
        current = settings.fullScreenTheme
        self.lstThemes.clear()

        for p in paths:
            lst = [i for i in os.listdir(p) if os.path.splitext(i)[1] == ".theme"]
            for t in lst:
                theme = os.path.join(p, t)
                editable = not appPath() in theme
                n = getThemeName(theme)

                item = QListWidgetItem(n)
                item.setData(Qt.UserRole, theme)
                item.setData(Qt.UserRole + 1, editable)
                item.setToolTip("{}{}".format(
                    n,
                    self.tr(" (read-only)") if not editable else ""))

                thumb = os.path.join(p, t.replace(".theme", ".jpg"))
                px = QPixmap(200, 120)
                px.fill(Qt.white)
                if not os.path.exists(thumb):
                    currentScreen = qApp.desktop().screenNumber(self)
                    screenRect = qApp.desktop().screenGeometry(currentScreen)
                    thumb = createThemePreview(theme, screenRect)

                icon = QPixmap(thumb).scaled(200, 120, Qt.KeepAspectRatio)
                painter = QPainter(px)
                painter.drawPixmap(px.rect().center() - icon.rect().center(), icon)
                painter.end()
                item.setIcon(QIcon(px))

                self.lstThemes.addItem(item)

                if current and current in t:
                    self.lstThemes.setCurrentItem(item)
                    current = None

        self.lstThemes.setIconSize(QSize(200, 120))

        if current:  # the theme from settings wasn't found
            # select the last from the list
            self.lstThemes.setCurrentRow(self.lstThemes.count() - 1)
コード例 #24
0
    def __init__(self, parent=None):
        super(WelcomeDialog, self).__init__(parent=parent)

        self._prefs = parent.prefs

        self._sub_titles = [
            ['duck', 'dumb', 'doctor', 'dutch', 'dark', 'dirty', 'debugging'],
            ['warriors', 'wardrobes', 'waffles', 'wishes', 'worcestershire'],
            ['are', 'aren\'t', 'ain\'t', 'appears to be'],
            ['rich', 'real', 'riffle', 'retarded', 'rock'],
            [
                'as f**k', 'fancy', 'f****d', 'front-ended', 'falafel',
                'french fries'
            ],
        ]

        self._update_thread = None

        # setup size and remove/disable titlebuttons
        self.desktop_geom = qApp.desktop().availableGeometry()
        self.setFixedSize(self.desktop_geom.width() * .45,
                          self.desktop_geom.height() * .4)
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                               qApp.desktop().availableGeometry()))
        self.setSizeGripEnabled(False)
        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setWindowFlag(Qt.WindowContextHelpButtonHint, False)
        self.setWindowFlag(Qt.WindowCloseButtonHint, True)
        self.setModal(True)

        # setup ui elements
        self.setup_ui()

        random.seed(a=None, version=2)

        self.update_commits_thread = DwarfCommitsThread(parent)
        self.update_commits_thread.on_update_available.connect(
            self._on_dwarf_isupdate)
        self.update_commits_thread.start()
        # center
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                               qApp.desktop().availableGeometry()))
コード例 #25
0
 def takeScreenshot(self):
     x = self.desktopGeometry.x() + self.start.x()
     y = self.desktopGeometry.y() + self.start.y()
     w = self.end.x() - self.start.x()
     h = self.end.y() - self.start.y()
     self.screenshot = qApp.screens()[0].grabWindow(qApp.desktop().winId(), x, y, w, h)
     self.shotfilename = os.path.join(self.getFilePath(), "www", "temp", strftime('%Y%m%d-%H%M%S')) + ".png"
     self.screenshot.save(self.shotfilename, "PNG", 100)
     if not self.shotfilename is None and type(self.screenshot) is QPixmap:
         self.openTranslator()
コード例 #26
0
ファイル: notifications.py プロジェクト: c0re100/vidcutter
 def showEvent(self, event):
     if self.isVisible():
         self.shown.emit()
     self.msgLabel.setText(self._message)
     [self.left_layout.addWidget(btn) for btn in self.buttons]
     screen = qApp.desktop().screenNumber(self.parent)
     bottomright = qApp.screens()[screen].availableGeometry().bottomRight()
     self.setGeometry(bottomright.x() - (459 + 5),
                      bottomright.y() - (156 + 10), 459, 156)
     super(Notification, self).showEvent(event)
コード例 #27
0
ファイル: TextDialog.py プロジェクト: philipbel/Subtitles
 def _adjustGeometry(self):
     screenRect: QRect = qApp.desktop().screenGeometry()
     myGeometry = self.geometry()
     myGeometry.setHeight(screenRect.height() / PHI)
     myGeometry.setWidth(screenRect.width() / 2.5)
     if self.parent():
         myGeometry.moveCenter(self.parent().geometry().center())
     else:
         myGeometry.moveCenter(screenRect.center())
     self.setGeometry(myGeometry)
コード例 #28
0
    def __init__(self, screenNumber):
        self.wnck_screen = wnck.screen_get_default()         # wnck.Screen
        self.wnck_screen.force_update()                      # update wnc.Screen
        self.wnck_workspace = self.wnck_screen.get_active_workspace() # current workspace

        self.screen_rect = qApp.desktop().screenGeometry(screenNumber)
        self.screen_x = self.screen_rect.x()
        self.screen_y = self.screen_rect.y()
        self.screen_width = self.screen_rect.width()
        self.screen_height = self.screen_rect.height()

        self.windows_info = self.get_windows_info()
コード例 #29
0
ファイル: SkyMojiType.py プロジェクト: jreus/artware
 def __init__(self):
     super(TypingWindow, self).__init__()
     self.setWindowTitle("SkyMojiType")
     h = qApp.desktop().screenGeometry().height() - 200
     w = qApp.desktop().screenGeometry().width() - 200
     self.setGeometry(w / 10, h / 10, w, h)
     self.lineLength = w / self.charSpace
     self.charCount = 0
     self.cursorVisible = True
     self.emojis = []
     self.allImages = glob.glob(
         "skype/img/*anim*.png"
     )  # grab all file names containing 'anim' and ending in .png
     print "Total Animated Files Found: ", len(self.allImages)
     # Uncomment the following lines to make the typing window transparent
     #self.setWindowFlags(Qt.FramelessWindowHint) # needed to get transparent window in Windows
     #self.setAttribute(Qt.WA_TranslucentBackground)
     self.startTimer(
         200
     )  # Animation timer for cursor, don't save the ID as we don't plan to kill it
     self.show()
コード例 #30
0
ファイル: ragasiyangal.py プロジェクト: vijaypm/ragasiyangal
 def __init__(self, widget):
     super().__init__()
     self.setWindowTitle("Ragasiyangal - Password Manager")
     self.create_menu_bar()
     widget.setParent(self)
     self.table_widget = widget
     self.setCentralWidget(self.table_widget)
     geometry = qApp.desktop().availableGeometry(self)
     self.setMinimumSize(geometry.width() * 0.8, geometry.height() * 0.7)
     # Status Bar
     self.status = self.statusBar()
     self.needs_save = False
     self.filter_on = False
コード例 #31
0
 def getDesktopGeometry():
     totalWidth = 0
     maxHeight = 0
     minX = 0
     screens = (qApp.screens()[i] for i in range(qApp.desktop().screenCount()))
     rects = [screen.geometry() for screen in screens]
     for rect in rects:
         totalWidth += rect.width()
         if rect.x() < minX:
             minX = rect.x()
         if rect.height() > maxHeight:
             maxHeight = rect.height()
     return QRect(minX, 0, totalWidth, maxHeight)
コード例 #32
0
    def __init__(self, screenNumber):
        self.wnck_screen = wnck.screen_get_default()  # wnck.Screen
        self.wnck_screen.force_update()  # update wnc.Screen
        self.wnck_workspace = self.wnck_screen.get_active_workspace(
        )  # current workspace

        self.screen_rect = qApp.desktop().screenGeometry(screenNumber)
        self.screen_x = self.screen_rect.x()
        self.screen_y = self.screen_rect.y()
        self.screen_width = self.screen_rect.width()
        self.screen_height = self.screen_rect.height()

        self.windows_info = self.get_windows_info()
コード例 #33
0
    def show_context_menu(position):
        menu_edit = MainWindow().menuEdit
        menu_edit.move(position)
        menu_edit.show()

        # Adjust the menu position
        desktop = qApp.desktop().availableGeometry()
        menu_rect = menu_edit.geometry()

        if menu_rect.bottom() > desktop.bottom():
            menu_edit.move(menu_edit.x(), menu_edit.y() - menu_edit.height())
        if menu_rect.right() > desktop.right():
            menu_edit.move(menu_edit.x() - menu_edit.width(), menu_edit.y())
コード例 #34
0
def main():
    global view
    global settings
    global windoInfo
    global menu_controller

    cursor_pos = QCursor.pos()
    desktop = qApp.desktop()
    screen_num = desktop.screenNumber(cursor_pos)
    screen_geo = desktop.screenGeometry(screen_num)
    pixmap = qApp.primaryScreen().grabWindow(0)
    pixmap = pixmap.copy(screen_geo.x(), screen_geo.y(), screen_geo.width(), screen_geo.height())
    pixmap.save(TMP_IMAGE_FILE)

    settings.showOSD = startFromDesktopValue
    settings.tmpImageFile = TMP_IMAGE_FILE
    menu_controller = MenuController()
    windoInfo = WindowInfo(screen_num)

    notificationsInterface.ActionInvoked.connect(_actionInvoked)
    notificationsInterface.NotificationClosed.connect(_notificationClosed)

    if fullscreenValue:
        saveScreenshot(pixmap)
    elif topWindowValue:
        wInfos = windoInfo.get_windows_info()
        if len(wInfos) > 0:
            wInfo = wInfos[0]
            pix = pixmap.copy(wInfo[0] - screen_geo.x(), wInfo[1] - screen_geo.y(), wInfo[2], wInfo[3])
            saveScreenshot(pix)
    else:
        view = Window(settings, windoInfo)
        view.setX(screen_geo.x())
        view.setY(screen_geo.y())
        view.setWidth(screen_geo.width())
        view.setHeight(screen_geo.height())
        view.visibleChanged.connect(_windowVisibleChanged)

        qml_context = view.rootContext()
        qml_context.setContextProperty("windowView", view)
        qml_context.setContextProperty("qApp", qApp)
        qml_context.setContextProperty("screenWidth", view.window_info.screen_width)
        qml_context.setContextProperty("screenHeight", view.window_info.screen_height)
        qml_context.setContextProperty("_menu_controller", menu_controller)

        view.setSource(QUrl.fromLocalFile(MAIN_QML))
        view.disable_zone()
        view.showWindow()

        menu_controller.preMenuShow.connect(view.ungrabFocus)
        menu_controller.postMenuHide.connect(view.grabFocus)
コード例 #35
0
    def contextMenuEvent(self, event):
        if self.layout.geometry().contains(event.pos()):
            self.menuEdit.move(event.globalPos())
            self.menuEdit.show()

            # Adjust the menu position
            desktop = qApp.desktop().availableGeometry()
            menu_rect = self.menuEdit.geometry()
    
            if menu_rect.bottom() > desktop.bottom():
                self.menuEdit.move(self.menuEdit.x(),
                                   self.menuEdit.y() - self.menuEdit.height())
            if menu_rect.right() > desktop.right():
                self.menuEdit.move(self.menuEdit.x() - self.menuEdit.width(),
                                   self.menuEdit.y())
コード例 #36
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.screenHeight = QtWidgets.qApp.primaryScreen().size().height()
        self.screenWidth = QtWidgets.qApp.primaryScreen().size().width()
        self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint
                            | Qt.X11BypassWindowManagerHint)

        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignLeft,
                               QSize(self.screenWidth, self.screenWidth),
                               qApp.desktop().availableGeometry()))
        QMainWindow.setWindowOpacity(self, 0.5)

        self.mouse_start_pos = None
        self.mouse_curr_pos = None
        self.coords = None
コード例 #37
0
ファイル: Home.py プロジェクト: subins2000/TorrentBro
    def initUI(self):
        self.ui = Ui_Home()
        self.ui.setupUi(self)

        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                               qApp.desktop().availableGeometry()))
        self.show()

        self.ui.searchButton.clicked.connect(self.onSearch)
        self.ui.searchTextbox.returnPressed.connect(self.onSearch)

        self.ui.torrentList.selectionModel().selectionChanged.connect(
            self.onTorrentSelect)

        self.ui.torrentInfoMagnetLink.linkActivated.connect(self.onLinkClick)
        self.ui.torrentInfoTorrentLink.linkActivated.connect(self.onLinkClick)
コード例 #38
0
    def __init__(self, parent: QWidget = None):
        super().__init__(parent)

        self.setWindowTitle(self.tr("Confuse window"))
        self.setWindowFlag(Qt.WindowContextHelpButtonHint, False)
        self.setWindowFlag(Qt.WindowTitleHint, True)
        self.setMinimumSize(800, 400)
        self.resize(qApp.desktop().screen().size() * 0.75)

        self.status = ConfuseWindow.Nothing
        self.index = 0
        self.answer = ""

        self.text_edit_confuse = QTextEdit("")
        self.highlighter_confuse = PairParserHighlighter(self.text_edit_confuse.document())

        self.text_edit_answer = QTextEdit("")
        self.highlighter_answer = PairParserHighlighter(self.text_edit_answer.document())

        self.push_button_ok = QPushButton(self.tr("OK"))

        self.image_viewer = ImageViewer()

        self.layout_down = QHBoxLayout()
        self.layout_down.addStretch(1)
        self.layout_down.addWidget(self.push_button_ok)

        self.layout_left = QVBoxLayout()
        self.layout_left.addWidget(self.text_edit_confuse)
        self.layout_left.addWidget(self.text_edit_answer)

        self.layout_center = QHBoxLayout()
        self.layout_center.addLayout(self.layout_left, 3)
        self.layout_center.addWidget(self.image_viewer, 2)

        self.layout_main = QVBoxLayout()
        self.layout_main.addLayout(self.layout_center)
        self.layout_main.addLayout(self.layout_down)

        self.setLayout(self.layout_main)

        # connection
        self.push_button_ok.clicked.connect(self.push_button_ok_clicked)
コード例 #39
0
    def show_cue_context_menu(self, position):
        menu = QMenu(self)

        cue_class = self.get_context_cue().__class__
        for item in self.cm_registry.filter(cue_class):
            if isinstance(item, QAction):
                menu.addAction(item)
            elif isinstance(item, QMenu):
                menu.addMenu(item)

        menu.move(position)
        menu.show()

        # Adjust the menu position
        desktop = qApp.desktop().availableGeometry()
        menu_rect = menu.geometry()

        if menu_rect.bottom() > desktop.bottom():
            menu.move(menu.x(), menu.y() - menu.height())
        if menu_rect.right() > desktop.right():
            menu.move(menu.x() - menu.width(), menu.y())
コード例 #40
0
    def show_context_menu(self, position):
        menu = QMenu(self)

        cue_class = self.get_context_cue().__class__
        for item in self.cm_registry.filter(cue_class):
            if isinstance(item, QAction):
                menu.addAction(item)
            elif isinstance(item, QMenu):
                menu.addMenu(item)

        menu.move(position)
        menu.show()

        # Adjust the menu position
        desktop = qApp.desktop().availableGeometry()
        menu_rect = menu.geometry()

        if menu_rect.bottom() > desktop.bottom():
            menu.move(menu.x(), menu.y() - menu.height())
        if menu_rect.right() > desktop.right():
            menu.move(menu.x() - menu.width(), menu.y())
コード例 #41
0
ファイル: Home.py プロジェクト: subins2000/MJournal
    def initUI(self):
        self.ui = Ui_Home()
        self.ui.setupUi(self)

        '''
        Check if Qt WebEngine is available
        '''
        try:
            from PyQt5.QtWebEngineWidgets import QWebEngineView

            self.webEngineView()
        except:
            self.noWebEngineView()

        self.setGeometry(
            QStyle.alignedRect(
                Qt.LeftToRight,
                Qt.AlignCenter,
                self.size(),
                qApp.desktop().availableGeometry()
            )
        )

        self.show()
コード例 #42
0
    def main(self):
        fullscreenValue = self.argValues["fullscreen"]
        topWindowValue = self.argValues["topWindow"]
        startFromDesktopValue = self.argValues["startFromDesktop"]
        savePathValue = self.argValues["savePath"]
        noNotificationValue = self.argValues["noNotification"]

        cursor_pos = QCursor.pos()
        desktop = qApp.desktop()
        screen_num = desktop.screenNumber(cursor_pos)
        screen_geo = desktop.screenGeometry(screen_num)
        pixmap = qApp.primaryScreen().grabWindow(0)
        pixmap = pixmap.copy(screen_geo.x(), screen_geo.y(),
                             screen_geo.width(), screen_geo.height())
        pixmap.save(self.settings.tmpImageFile)

        show_osd = self.settings.getOption("showOSD", "show")
        if show_osd == True or show_osd == "true":
            self.settings.showOSD = startFromDesktopValue
            if self.settings.showOSD:
                self.settings.setOption("showOSD", "show", QVariant(False))
        else:
            self.settings.showOSD = False
        self.menu_controller = MenuController()
        self.windowInfo = WindowInfo(screen_num)

        if not noNotificationValue:
            notificationsInterface.ActionInvoked.connect(
                self._actionInvoked)
            notificationsInterface.NotificationClosed.connect(
                self._notificationClosed)

        self.pixmap = pixmap
        self.window = Window(ref(self)())

        if fullscreenValue:
            self.saveScreenshot(pixmap)
        elif topWindowValue:
            wInfo = self.windowInfo.get_active_window_info()
            pix = pixmap.copy(wInfo[0], wInfo[1], wInfo[2], wInfo[3])
            self.saveScreenshot(pix)
        else:
            self.window.setX(screen_geo.x())
            self.window.setY(screen_geo.y())
            self.window.setWidth(screen_geo.width())
            self.window.setHeight(screen_geo.height())
            self.window.windowClosing.connect(self._windowClosing)
            self.window.visibleChanged.connect(self._windowVisibleChanged)

            # NOTE: make sure that all the objects that are set as context
            # property are always referenced by others through the lifetime
            # of this application, otherwise it'll cause problems.
            qml_context = self.window.rootContext()
            qml_context.setContextProperty("windowView", self.window)
            qml_context.setContextProperty("qApp", qApp)
            qml_context.setContextProperty("screenWidth",
                self.window.window_info.screen_width)
            qml_context.setContextProperty("screenHeight",
                self.window.window_info.screen_height)
            qml_context.setContextProperty("tmpImageFile",
                self.settings.tmpImageFile)
            qml_context.setContextProperty("blurImageFile",
                self.settings.tmpBlurFile)
            qml_context.setContextProperty("mosaicImageFile",
                self.settings.tmpMosaiceFile)
            qml_context.setContextProperty("_menu_controller",
                self.menu_controller)

            self.window.setSource(QUrl.fromLocalFile(MAIN_QML))
            self.window.showWindow()
            rootObject = self.window.rootObject()
            rootObject.helpView.connect(self.helpManual)
            rootObject.setProperty("saveSpecifiedPath", savePathValue)

            self.menu_controller.preMenuShow.connect(self.window.ungrabFocus)
            self.menu_controller.postMenuHide.connect(self.window.grabFocus)
コード例 #43
0
ファイル: qmldialog.py プロジェクト: binwen925/QMusic
 def moveCenter(self):
     from PyQt5.QtWidgets import qApp
     qr = self.frameGeometry()
     cp =  qApp.desktop().availableGeometry().center()
     qr.moveCenter(cp)
     self.setPosition(qr.topLeft())
コード例 #44
0
ファイル: MainWindow.py プロジェクト: raof01/utilities
 def __move_to_center(self):
     rect = qApp.desktop().availableGeometry(self)
     center = rect.center()
     self.setGeometry(0, 0, self.__WINDOW_WIDTH, self.__WINDOW_HEIGHT)
     self.move(center.x() - self.__WINDOW_HEIGHT * 0.5, center.y() - self.__WINDOW_HEIGHT * 0.5)