Beispiel #1
0
 def mouseMoveEvent(self,
                    event: PySide2.QtWidgets.QGraphicsSceneMouseEvent):
     p = self.addEllipse(
         QCursor.pos().x(),
         QCursor.pos().y(), 20, 20,
         QPen(QColor(self.color[0], self.color[1], self.color[2])),
         QBrush(QColor(self.color[0], self.color[1], self.color[2])))
Beispiel #2
0
 def syncBrush(self, zooming):
     """
     Sync current brush with tool bar and zoom coeff.
     Overrides or changes the application cursor.
     @param zooming:
     @type zooming: float
     """
     minSize = 16
     # bSize = self.brushUpdate()
     bSize = self.State['brush']['size']  # TODO modified 26/01/20 validate
     w = bSize * zooming
     if w >= minSize:
         cursor = QCursor(self.State['brush']['cursor'].scaled(w, w),
                          hotX=w / 2,
                          hotY=w / 2)
     else:
         d = int((minSize - w) / 2)
         cursor = QCursor(self.State['brush']['cursor'].scaled(
             minSize, minSize),
                          hotX=d,
                          hotY=d)
     if QApplication.overrideCursor():
         QApplication.changeOverrideCursor(cursor)
     else:
         QApplication.setOverrideCursor(cursor)
    def __init__(self, app: QApplication, origin_draw_position: QPoint):
        """
        Locate a desktop window rectangle with the mouse cursor

        :param QApplication app: App to install event filter on
        :param QPoint origin_draw_position: Position of the line, indicating the tracked cursor, is drawn from
        """
        super(FindDesktopWindowInteractive, self).__init__()
        self.app = app

        self.tracking_timer = QTimer()
        self.tracking_timer.setInterval(self.tracking_rate)
        self.tracking_timer.timeout.connect(self._track_cursor)

        self.paint_timer = QTimer()
        self.paint_timer.setInterval(self.painting_rate)
        self.paint_timer.timeout.connect(self._trigger_paint)

        self.cursor = QCursor()
        self.pywin_desktop = Desktop()

        self.highlight_rect = QRect()

        self.origin_draw_pos = origin_draw_position

        # -- Transparent widget across the desktop to draw on --
        self.desk_draw_widget = DesktopDrawWidget(app.desktop())
        self.desk_draw_widget.paintEvent = self._paint_event_override
 def mousePressEvent(self, event: QMouseEvent):
     if event.button() == Qt.LeftButton:
         self.dragPosition = event.globalPos() - self.frameGeometry(
         ).topLeft()
         self.cursor = QCursor()
         self.cursor.setShape(Qt.SizeAllCursor)
         self.setCursor(self.cursor)
Beispiel #5
0
 def contextMenuEvent(self, event):
     index = self.listview.selectionModel().currentIndex()
     path = self.fileModel.fileInfo(index).absoluteFilePath()
     self.menu = QMenu(self.listview)
     if self.listview.hasFocus():
         self.menu.addAction(self.actionFolderNew)
         self.menu.addSeparator()
         self.menu.addAction(self.actionFileRename)
         self.menu.addSeparator()
         self.menu.addAction(self.actionFileCopy)
         self.menu.addAction(self.actionFileCut)
         self.menu.addAction(self.actionFilePaste)
         #            self.menu.addAction(self.pasteFolderAction)
         self.menu.addSeparator()
         self.menu.addAction(self.actionFileDel)
         self.menu.addSeparator()
         self.menu.addAction(self.actionRefresh)
         self.menu.addAction(self.actionSwitchHide)
         self.menu.addSeparator()
         self.menu.addAction(self.actionHelp)
         self.menu.popup(QCursor.pos())
     else:
         index = self.treeview.selectionModel().currentIndex()
         path = self.dirModel.fileInfo(index).absoluteFilePath()
         dprint("current path is: %s" % path)
         self.menu = QMenu(self.treeview)
         if os.path.isdir(path):
             self.menu.addAction(self.actionFolderNew)
             self.menu.addAction(self.actionFolderRename)
             self.menu.addAction(self.actionFolderCopy)
             self.menu.addAction(self.actionFolderPaste)
             self.menu.addAction(self.actionFolderDel)
         self.menu.popup(QCursor.pos())
Beispiel #6
0
def play_scrub(multiplier):
    import time
    from PySide2.QtGui import QCursor

    mouse_last = hou.getenv("mouse", "0")
    mouse_last = float(mouse_last)
    mouse_now = QCursor().pos()

    time_now = time.time()
    time_last = hou.getenv("time", "0")
    time_last = float(time_last)
    time_diff = time_now - time_last

    mouse_now = round(mouse_now.x() / 10)

    if time_diff > 0.1:
        mouse_last = mouse_now

    skip = mouse_last - mouse_now
    skip = skip * multiplier
    if abs(skip) > 20:
        skip = skip * 2

    frame_now = hou.frame()
    frame_now = hou.frame() - skip
    hou.setFrame(frame_now)

    hou.putenv("mouse", str(mouse_now))
    hou.putenv("time", str(time_now))
Beispiel #7
0
 def refresh():
     self.setCursor(QCursor(Qt.WaitCursor))
     self.status_bar.showMessage("Чистим дерево")
     self.tree.clear()
     self.status_bar.showMessage("Получаем данные")
     self.load_from_google()
     self.status_bar.showMessage("Данные обновлены")
     self.setCursor(QCursor(Qt.ArrowCursor))
Beispiel #8
0
	def context_menu(self):
		# Menu con click derecho
		if self.ui.tabla_db.selectedIndexes() and self.modo_boton_editar_guardar == "guardar":
			menu = QMenu()
			borrar_data = menu.addAction("Borrar linea de la base de datos")
			borrar_data.triggered.connect(lambda: self.borrar_linea(self.ui.tabla_db.currentIndex().row()))
			cursor = QCursor()
			menu.exec_(cursor.pos())
Beispiel #9
0
    def show_rightclick_menu(self):
        """

        :type self: SteamAccountSwitcherGui
        """

        right_menu = QMenu()

        selected = self.accounts_list.currentItem()
        if not self.accounts_list.selectedItems():
            add_account_action = QAction(_("Add account"), self)
            add_account_action.triggered.connect(
                lambda: self.account_dialog(True))
            right_menu.addAction(add_account_action)
            right_menu.exec_(QCursor.pos())
            return
        login_name = selected.data(5)
        account = self.switcher.settings["users"].get(login_name, {})

        login_action = QAction(_("Login"), self)
        edit_action = QAction(_("Edit"), self)
        delete_action = QAction(_("Delete"), self)
        open_profile_action = QAction(_("Steam profile"), self)
        steampage_menu = QMenu(_("Steam profile"), self)

        edit_action.setIcon(QIcon.fromTheme("document-edit"))
        delete_action.setIcon(QIcon.fromTheme("edit-delete"))
        open_profile_action.setIcon(QIcon.fromTheme("internet-web-browser"))

        right_menu.addActions([login_action, edit_action, delete_action])
        right_menu.addSeparator()
        right_menu.addAction(open_profile_action)
        right_menu.addMenu(steampage_menu)

        login_action.triggered.connect(lambda: self.steam_login(login_name))
        edit_action.triggered.connect(lambda: self.account_dialog())
        delete_action.triggered.connect(
            lambda: self.remove_account(login_name))

        open_profile_action.triggered.connect(
            lambda: self.open_steam_profile(account))

        steampage_menu.triggered.connect(
            lambda: self.open_steam_profile(account))

        steampage_menu_actions = QActionGroup(steampage_menu)
        steampage_menu_inventory = QAction(_('Inventory'),
                                           steampage_menu_actions,
                                           checkable=True,
                                           data="nothing")

        open_profile_action.setDisabled(True)
        if account.get("steam_user", {}).get("profileurl"):
            open_profile_action.setEnabled(True)
            steampage_menu.addActions([steampage_menu_inventory])

        if self.accounts_list.selectedItems():
            right_menu.exec_(QCursor.pos())
    def __init__(self):
        super(GameHub, self).__init__()
        self.setGeometry(90, 50, 524, 186)
        self.setMinimumSize(524, 186)
        self.setMaximumSize(524, 186)
        self.setWindowIcon(QIcon('arti.PNG'))
        self.setWindowTitle('GameHub')

        palette = QPalette()
        palette.setColor(palette.Window, QColor('#000000'))
        palette.setColor(palette.WindowText, QColor('#FFFFFF'))
        palette.setColor(palette.Button, QColor("#00FF00"))
        palette.setColor(palette.ButtonText, QColor("#000000"))
        self.setPalette(palette)

        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(0, 0, 682, 21)
        self.menubar.setFont(QFont('Roboto', 10))

        self.date_menu = QMenu(self.menubar)
        self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y')))

        self.setMenuBar(self.menubar)
        self.menubar.addAction(self.date_menu.menuAction())

        self.label = QLabel(self)
        self.label.setGeometry(QRect(10, 30, 501, 51))
        self.label.setText(
            "Hello, I am your host, Artigence. Welcome to GameHub. Please click on below buttons to "
            "choose a game of your choice.")
        self.label.setWordWrap(True)
        self.label.setAlignment(Qt.AlignHCenter)
        self.label.setFont(QFont('Roboto', 12))

        self.pong = QPushButton(self)
        self.pong.setGeometry(QRect(20, 130, 95, 33))
        self.pong.setCursor(QCursor(Qt.PointingHandCursor))
        self.pong.setText('Pong')

        self.tictactoe = QPushButton(self)
        self.tictactoe.setGeometry(150, 130, 95, 33)
        self.tictactoe.setCursor(QCursor(Qt.PointingHandCursor))
        self.tictactoe.setText('Tic-Tac-Toe')

        self.connect_four = QPushButton(self)
        self.connect_four.setGeometry(290, 130, 95, 33)
        self.connect_four.setCursor(QCursor(Qt.PointingHandCursor))
        self.connect_four.setText('Connect-4')

        self.snake = QPushButton(self)
        self.snake.setGeometry(420, 130, 95, 33)
        self.snake.setCursor(QCursor(Qt.PointingHandCursor))
        self.snake.setText('Snake')

        self.pong.clicked.connect(lambda: pong())
        self.tictactoe.clicked.connect(lambda: tictactoe())
        self.connect_four.clicked.connect(lambda: connect_four())
        self.snake.clicked.connect(lambda: snake())
Beispiel #11
0
    def setupMainUI(self, Main):
        if not Main.objectName():
            Main.setObjectName(u"Main")
        Main.resize(463, 92)
        Main.setMinimumSize(QSize(463, 92))
        Main.setMaximumSize(QSize(463, 92))
        icon = QIcon()
        icon.addFile(u"icons/favicon.ico", QSize(), QIcon.Normal, QIcon.Off)
        Main.setWindowIcon(icon)
        #Font 16
        font = QFont()
        font.setFamily(u"Yandex Sans Text")
        font.setPointSize(16)
        #Autolocation
        self.wbtn = QPushButton(Main)
        self.wbtn.setObjectName(u"wbtn")
        self.wbtn.setGeometry(QRect(380, 10, 31, 31))
        self.wbtn.setFont(font)
        self.wbtn.setCursor(QCursor(Qt.PointingHandCursor))
        self.wbtn.setAcceptDrops(False)
        self.wbtn.setCheckable(False)
        #City
        self.lineedit = QLineEdit(Main)
        self.lineedit.setObjectName(u"lineedit")
        self.lineedit.setGeometry(QRect(60, 10, 351, 31))
        self.lineedit.setFont(font)
        self.lineedit.setFrame(True)
        self.lineedit.setEchoMode(QLineEdit.Normal)
        #GetWeather
        self.wbtnr = QPushButton(Main)
        self.wbtnr.setObjectName(u"wbtnr")
        self.wbtnr.setGeometry(QRect(60, 50, 351, 31))
        self.wbtnr.setFont(font)
        self.wbtnr.setCursor(QCursor(Qt.PointingHandCursor))
        #Settings
        self.setbtn = QPushButton(Main)
        self.setbtn.setObjectName(u"setbtn")
        self.setbtn.setGeometry(QRect(420, 10, 31, 31))
        icon1 = QIcon()
        icon1.addFile(u"icons/settings.ico", QSize(), QIcon.Normal, QIcon.Off)
        self.setbtn.setIcon(icon1)
        self.setbtn.setIconSize(QSize(25, 25))
        self.setbtn.setCursor(QCursor(Qt.PointingHandCursor))

        self.lineedit.raise_()
        self.wbtnr.raise_()
        self.wbtn.raise_()
        self.setbtn.raise_()

        if language == "ru":
            self.TextMainRu(Main)
        else:
            self.TextMainEn(Main)

        QMetaObject.connectSlotsByName(Main)
Beispiel #12
0
    def setCursorShape(self, e_pos: QPoint):
        diff = 3
        # Left - Bottom

        if (((e_pos.y() > self.y() + self.height() - diff) and  # Bottom
             (e_pos.x() < self.x() + diff)) or  # Left
                # Right-Bottom
            ((e_pos.y() > self.y() + self.height() - diff) and  # Bottom
             (e_pos.x() > self.x() + self.width() - diff)) or  # Right
                # Left-Top
            ((e_pos.y() < self.y() + diff) and  # Top
             (e_pos.x() < self.x() + diff)) or  # Left
                # Right-Top
            (e_pos.y() < self.y() + diff) and  # Top
            (e_pos.x() > self.x() + self.width() - diff)):  # Right
            # Left - Bottom
            if ((e_pos.y() > self.y() + self.height() - diff) and  # Bottom
                (e_pos.x() < self.x() + diff)):  # Left
                self.mode = Mode.RESIZEBL
                self.setCursor(QCursor(QtCore.Qt.SizeBDiagCursor))
                # Right - Bottom
            if ((e_pos.y() > self.y() + self.height() - diff) and  # Bottom
                (e_pos.x() > self.x() + self.width() - diff)):  # Right
                self.mode = Mode.RESIZEBR
                self.setCursor(QCursor(QtCore.Qt.SizeFDiagCursor))
            # Left - Top
            if ((e_pos.y() < self.y() + diff) and  # Top
                (e_pos.x() < self.x() + diff)):  # Left
                self.mode = Mode.RESIZETL
                self.setCursor(QCursor(QtCore.Qt.SizeFDiagCursor))
            # Right - Top
            if ((e_pos.y() < self.y() + diff) and  # Top
                (e_pos.x() > self.x() + self.width() - diff)):  # Right
                self.mode = Mode.RESIZETR
                self.setCursor(QCursor(QtCore.Qt.SizeBDiagCursor))
        # check cursor horizontal position
        elif ((e_pos.x() < self.x() + diff) or  # Left
              (e_pos.x() > self.x() + self.width() - diff)):  # Right
            if e_pos.x() < self.x() + diff:  # Left
                self.setCursor(QCursor(QtCore.Qt.SizeHorCursor))
                self.mode = Mode.RESIZEL
            else:  # Right
                self.setCursor(QCursor(QtCore.Qt.SizeHorCursor))
                self.mode = Mode.RESIZER
        # check cursor vertical position
        elif ((e_pos.y() > self.y() + self.height() - diff) or  # Bottom
              (e_pos.y() < self.y() + diff)):  # Top
            if e_pos.y() < self.y() + diff:  # Top
                self.setCursor(QCursor(QtCore.Qt.SizeVerCursor))
                self.mode = Mode.RESIZET
            else:  # Bottom
                self.setCursor(QCursor(QtCore.Qt.SizeVerCursor))
                self.mode = Mode.RESIZEB
        else:
            self.setCursor(QCursor(QtCore.Qt.ArrowCursor))
            self.mode = Mode.MOVE
Beispiel #13
0
 def enterEvent(self, event):
     """
     Mouse enter event handler
     @param event:
     @type event
     """
     if not self.enterAndLeave:
         return
     window = self.window
     if QApplication.overrideCursor():
         # don't stack multiple cursors
         return
     # tool cursors
     w = window.verticalSlider1.value()
     layer = window.label.img.getActiveLayer()
     if window.btnValues['drawFG'] or window.btnValues['drawBG']:
         if w > 10:
             QApplication.setOverrideCursor(
                 QCursor(window.cursor_Circle_Pixmap.scaled(
                     w * 2.0, w * 2.0),
                         hotX=w,
                         hotY=w))
         else:
             QApplication.setOverrideCursor(Qt.CrossCursor)
     elif layer.isDrawLayer() and (window.btnValues['brushButton']
                                   or window.btnValues['eraserButton']):
         self.syncBrush(self.img.resize_coeff(self))
     elif window.btnValues['drag']:
         QApplication.setOverrideCursor(Qt.OpenHandCursor)
     elif window.btnValues['colorPicker']:
         if layer.isAdjustLayer():
             if layer.view.isVisible():
                 QApplication.setOverrideCursor(window.cursor_EyeDropper)
Beispiel #14
0
    def setupUi(self, Dialog):
        if not Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(400, 98)
        self.horizontalLayout = QHBoxLayout(Dialog)
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalLayout.setContentsMargins(5, 5, 5, 5)
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.gridLayout = QGridLayout()
        self.gridLayout.setObjectName(u"gridLayout")
        self.label_ExpName = QLabel(Dialog)
        self.label_ExpName.setObjectName(u"label_ExpName")

        self.gridLayout.addWidget(self.label_ExpName, 0, 0, 1, 2)

        self.lineEdit = QLineEdit(Dialog)
        self.lineEdit.setObjectName(u"lineEdit")

        self.gridLayout.addWidget(self.lineEdit, 0, 2, 1, 1)

        self.label_ExpScript = QLabel(Dialog)
        self.label_ExpScript.setObjectName(u"label_ExpScript")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_ExpScript.sizePolicy().hasHeightForWidth())
        self.label_ExpScript.setSizePolicy(sizePolicy)
        self.label_ExpScript.setMaximumSize(QSize(150, 16777215))

        self.gridLayout.addWidget(self.label_ExpScript, 1, 0, 1, 1)

        self.label_ExpScriptFile = QLabel(Dialog)
        self.label_ExpScriptFile.setObjectName(u"label_ExpScriptFile")
        font = QFont()
        font.setUnderline(True)
        self.label_ExpScriptFile.setFont(font)
        self.label_ExpScriptFile.setCursor(QCursor(Qt.PointingHandCursor))

        self.gridLayout.addWidget(self.label_ExpScriptFile, 1, 2, 1, 1)


        self.verticalLayout.addLayout(self.gridLayout)

        self.buttonBox = QDialogButtonBox(Dialog)
        self.buttonBox.setObjectName(u"buttonBox")
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)

        self.verticalLayout.addWidget(self.buttonBox)


        self.horizontalLayout.addLayout(self.verticalLayout)


        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)

        QMetaObject.connectSlotsByName(Dialog)
 def contextMenuEvent(self, event:'PySide2.QtGui.QContextMenuEvent') -> None:
     rows = self.selectionModel().selectedIndexes()
     contextMenu = QMenu(self)
     saveSeed = contextMenu.addAction("&Save Seed")
     action = contextMenu.exec_(QCursor.pos())
     if action == saveSeed:
         self.saveSeed(rows)
Beispiel #16
0
 def upload(self):
     try:
         login = self.lineEdit_3.text()
         password = self.lineEdit_4.text()
         group_id = abs(int(self.lineEdit.text()))
         path_to_folder = self.lineEdit_2.text()
         QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
         uploader = Uploader(login, password, group_id, path_to_folder)
         self.progressBar = QtWidgets.QProgressBar(self.gridLayoutWidget)
         self.progressBar.setEnabled(True)
         self.progressBar.setValue(0)
         self.progressBar.setTextVisible(True)
         self.progressBar.setObjectName("progressBar")
         self.gridLayout.addWidget(self.progressBar, 10, 0, 1, 1)
         self.pushButton.setEnabled(False)
         self.pushButton_2.setEnabled(False)
         self.update()
         for i, j in uploader.upload_album():
             self.progressBar.setValue(int(i / j * 100))
             QApplication.processEvents()
     except Exception as e:
         errMsgBox = QErrorMessage()
         errMsgBox.showMessage(repr(e))
         errMsgBox.exec_()
     finally:
         self.progressBar.setParent(None)
         self.pushButton.setEnabled(True)
         self.pushButton_2.setEnabled(True)
         QApplication.restoreOverrideCursor()
Beispiel #17
0
    def drawAction(self, painter, actionName, pixmap, left, top,
                   highlightedColor, drawDisclosure, borderColor):
        if (pixmap != None):
            iconRect = QRect(left, top, self.ICON_WIDTH, self.ICON_WIDTH)
            if highlightedColor is not None:
                painter.fillRect(iconRect, highlightedColor)

            # draw the icon.  Its opacity depends on mouse over.
            p = self.treeView().mapFromGlobal(QCursor.pos())
            if not iconRect.contains(p):
                painter.setOpacity(0.7)
            else:
                painter.setOpacity(1.0)
                self.lastHitAction = actionName
            self.drawPixmap(painter, pixmap, left, top)
            painter.setOpacity(1.0)

            if drawDisclosure:
                painter.drawPixmap(iconRect, self.DISCLOSURE_IMAGE)

            if borderColor:
                oldPen = painter.pen()
                painter.setPen(QPen(borderColor, 1))
                painter.drawRect(iconRect)
                painter.setPen(oldPen)
Beispiel #18
0
 def initializePage(self):
     processing, code, process = {
         "add": (
             "Installing",
             'using Pkg; pkg"registry add General https://github.com/Spine-project/SpineJuliaRegistry.git"; '
             'pkg"add SpineOpt"',
             "installation",
         ),
         "update": ("Updating", 'using Pkg; pkg"up SpineOpt"', "update"),
     }[self.wizard().required_action]
     self.setTitle(f"{processing} SpineOpt")
     julia_exe = self.field("julia_exe")
     julia_project = self.field("julia_project")
     args = [f"--project={julia_project}", "-e", code]
     self._exec_mngr = QProcessExecutionManager(self,
                                                julia_exe,
                                                args,
                                                semisilent=True)
     self.completeChanged.emit()
     self._exec_mngr.execution_finished.connect(
         self._handle_spine_opt_add_up_finished)
     self.msg_success.emit(f"SpineOpt {process} started")
     cmd = julia_exe + " " + " ".join(args)
     self.msg.emit(f"$ <b>{cmd}<b/>")
     qApp.setOverrideCursor(QCursor(Qt.BusyCursor))  # pylint: disable=undefined-variable
     self._exec_mngr.start_execution()
Beispiel #19
0
    def __init__(self, parent, piece_type, row, col, move=False):
        super(Piece, self).__init__(parent)
        self.main_window = parent.parent().parent().parent(
        )  # CenterWidget >> AspectRatioWidget >> MainWindow
        # self.move(0, 0)
        # self.resize(50, 50)
        self.setStyleSheet("background: " + "red; border-radius: 50px")
        self.border_radius = 10
        self.offset = QPoint()
        self.crs = QCursor()
        self.table_width = 50
        self.piece_type = piece_type
        self.col = col
        self.row = row
        self.movable = move
        self.possible_jumps = []
        self.animator = QPropertyAnimation(self, b"geometry")
        self.styles = {}

        self.shadow = QGraphicsDropShadowEffect()
        self.shadow.setBlurRadius(0)
        self.shadow.setXOffset(0)
        self.shadow.setYOffset(0)
        self.setGraphicsEffect(self.shadow)
        self.confirm_jump_stop = False
Beispiel #20
0
    def load_montage(self, event=None) -> None:
        """Load the selected montage."""
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        if event is None:
            montage_name, channels = self.core.config.get(
                'montages', 'last_montage').split('|')
            channels = channels.split(',')
        else:
            montage_name = self.parent_frame.tableWidget_montages.item(
                event.row(), 0).text()
            channels = self.parent_frame.tableWidget_montages.item(
                event.row(), 2).text()
            channels = channels.split(' ')
            self.core.config.set('montages', 'last_montage',
                                 f"{montage_name}|{','.join(channels)}")
            self.core.config.save()

        self.parent_frame.comboBox_montages.setCurrentText(montage_name)
        self.parent_frame.comboBox_montage_channels.setCurrentIndex(
            len(channels) - 1)

        self.generate_list_channels()
        [
            wg.setCurrentText(ch)
            for wg, ch in zip(self.channels_names_widgets, channels)
        ]
        self.update_topoplot()
        QApplication.restoreOverrideCursor()
def create_button(*args, **kwargs):
    e = kwargs.pop("event", None)
    b = QPushButton(*args, **kwargs)
    b.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
    if e:
        b.mousePressEvent = e
    return b
Beispiel #22
0
 def take_link(self, link):
     """Remove link, then start drawing another one from the same source connector."""
     self.remove_link(link)
     self.draw_links(link.src_connector)
     # noinspection PyArgumentList
     self.link_drawer.tip = self.mapToScene(self.mapFromGlobal(QCursor.pos()))
     self.link_drawer.update_geometry()
    def mousePressEvent(self, event):
        """
        Determines if self is the start or end node or neither, and updates things accordingly
        NOTE: The mouse release event is handled by the window
        """

        if self.node.isStart:
            QApplication.setOverrideCursor(
                QCursor(
                    QPixmap(":/icon/icons/start.png").scaledToHeight(
                        self.height())))
            self.clear()
            self.draw(Cell.EMPTY)
            self.mainWindow.changingStart = True
        elif self.node.isEnd:
            QApplication.setOverrideCursor(
                QPixmap(":/icon/icons/end.png").scaledToHeight(self.height()))
            self.clear()
            self.draw(Cell.EMPTY)
            self.mainWindow.changingEnd = True
        elif self.node.wall:
            self.mainWindow.erasingWall = True
            self.setWall(False)
        else:
            self.mainWindow.drawingWall = True
            self.setWall(True)
Beispiel #24
0
    def contextMenuEvent(self, event):
        index = self.indexAt(event.pos())
        item = self.model().get_item(index)
        children = item.child_count()

        if index.column() == KEY_COL and children:
            menu = QMenu(self)
            collapse = menu.addAction('Collapse All')
            expand = menu.addAction('Expand All')
            check = None
            uncheck = None
            if children:
                menu.addSeparator()
                check = menu.addAction('Check All')
                uncheck = menu.addAction('Uncheck All')
            action = menu.exec_(QCursor.pos())

            if action == collapse:
                self.collapse_selection(item, index)
            elif action == expand:
                self.expand_selection(item, index)
            elif action == check:
                self.itemDelegateForColumn(STATUS_COL).setChildData(
                    item, True)
                self.itemDelegateForColumn(STATUS_COL).updateModel(index)
            elif action == uncheck:
                self.itemDelegateForColumn(STATUS_COL).setChildData(
                    item, False)
                self.itemDelegateForColumn(STATUS_COL).updateModel(index)
Beispiel #25
0
    def analysePlugins(self):
        if self.check2to3Script():
            self._ui.label_2.setText(
                '2to3.py script not found.\nPlease locate it in the Options tab.'
            )
            return
        else:
            self._pluginUpdater._pluginUpdateDict = {}
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            package = importlib.reload(sys.modules[PLUGINS_PACKAGE_NAME])
            #             try:
            #                 package = imp.reload(sys.modules['mapclientplugins'])
            #             except Exception:
            #                 package = importlib.reload(sys.modules['mapclientplugins'])
            for _, modname, ispkg in pkgutil.iter_modules(package.__path__):
                if ispkg and modname != 'imagesourcestep' and modname != 'pointcloudserializerstep':
                    self._pluginUpdater._directory = _.path
                    (plugin_init_update, plugin_resources_update,
                     plugin_syntax_update, plugin_tabbed_indentation,
                     resourcesDirs, tabbed_modules) = performPluginAnalysis(
                         _.path, modname, self._resourceFiles)
                    self._pluginUpdater.pluginUpdateDict(modname, plugin_init_update, plugin_resources_update, plugin_syntax_update, \
                                                        plugin_tabbed_indentation, os.path.join(_.path, modname, '__init__.py'), resourcesDirs, tabbed_modules)
            self.fillUpdatesList()

            if self._ui.listWidget.count() == 0:
                self._ui.label_2.setText(
                    'None of your plugins require updates at this time.')
            else:
                self._ui.label_2.setText(
                    'Tip: Update a single plugin by double-clicking!')
Beispiel #26
0
 def set_menu(self, _):
     delete_option = QMenu()
     delete_option.addAction(
         QAction("删除",
                 delete_option,
                 triggered=self.delete_table_thread.start))
     delete_option.exec_(QCursor.pos())
Beispiel #27
0
    def _drag_resize(self):
        mouse_cur_pos = QCursor.pos()
        move_pos = mouse_cur_pos - self._mouse_move_pre_pos
        after_resize_geometry = self._rt_pre_geometry
        if MousePosition.TopLeftPos == self._cursor_calc_type:
            after_resize_geometry.setTopLeft(self._rt_pre_geometry.topLeft() +
                                             move_pos)
        elif MousePosition.LeftPos == self._cursor_calc_type:
            after_resize_geometry.setLeft(self._rt_pre_geometry.left() +
                                          move_pos.x())
        elif MousePosition.BottomLeftPos == self._cursor_calc_type:
            after_resize_geometry.setBottomLeft(
                self._rt_pre_geometry.bottomLeft() + move_pos)
        elif MousePosition.BottomPos == self._cursor_calc_type:
            after_resize_geometry.setBottom(self._rt_pre_geometry.bottom() +
                                            move_pos.y())
        elif MousePosition.BottomRightPos == self._cursor_calc_type:
            after_resize_geometry.setBottomRight(
                self._rt_pre_geometry.bottomRight() + move_pos)
        elif MousePosition.RightPos == self._cursor_calc_type:
            after_resize_geometry.setRight(self._rt_pre_geometry.right() +
                                           move_pos.x())
        elif MousePosition.TopRightPos == self._cursor_calc_type:
            after_resize_geometry.setTopRight(
                self._rt_pre_geometry.topRight() + move_pos)
        elif MousePosition.TopPos == self._cursor_calc_type:
            after_resize_geometry.setTop(self._rt_pre_geometry.top() +
                                         move_pos.y())

        self.setGeometry(after_resize_geometry)
        self._mouse_move_pre_pos = mouse_cur_pos
        self._rt_pre_geometry = after_resize_geometry
Beispiel #28
0
    def contextMenuEvent(self, event):
        # Allow user to delete selected file(s)
        menu = QMenu(self.ui)
        remove = menu.addAction('Remove Selected Files')
        action = menu.exec_(QCursor.pos())

        # Re-selects the current row if context menu is called on disabled cell
        i = self.ui.file_options.indexAt(event)
        self.ui.file_options.selectRow(i.row())

        indices = []
        if action == remove:
            for index in self.ui.file_options.selectedIndexes():
                indices.append(QPersistentModelIndex(index))

            for idx in indices:
                self.ui.file_options.removeRow(idx.row())

            if self.ui.file_options.rowCount():
                for i in range(len(self.files)):
                    self.files[i] = []
                for row in range(self.ui.file_options.rowCount()):
                    f = self.ui.file_options.item(row, 0).text()
            else:
                self.files = []
        self.enable_read()
Beispiel #29
0
    def show(self):
        pos = QCursor.pos()
        pos.setY(pos.y() + 10)

        self.setGeometry(QRect(pos, self.layout().sizeHint()))

        super(WarningList, self).show()
Beispiel #30
0
 def chooseFileContextMenu(self):
     if hasattr(self, 'dataDisplay'):
         menu = QMenu(self)
         addStatementAction = QAction('Add Statement')
         addStatementAction.triggered.connect(self.addFile)
         menu.addAction(addStatementAction)
         menu.exec_(QCursor.pos())
Beispiel #31
0
 def wheelEvent (self, eventQWheelEvent):
     oldscale = self.scale
     self.scale += eventQWheelEvent.delta() / 1200.0
     if (self.scale < 0.1):
         self.scale = oldscale
     screenpoint = self.mapFromGlobal(QCursor.pos())
     dx, dy = screenpoint.x(), screenpoint.y()
     oldpoint = (screenpoint.x() + self.position[0], screenpoint.y() + self.position[1])
     newpoint = (oldpoint[0] * (self.scale/oldscale), oldpoint[1] * (self.scale/oldscale))
     self.position = (newpoint[0] - dx, newpoint[1] - dy)
     print(self.position[0])
     print(self.position[1])
     print("  ")
     self.update()
Beispiel #32
0
 def _activate_traymenu(self, reason):
     if reason == QSystemTrayIcon.ActivationReason.DoubleClick:
         self.restore_window()
     else:
         self.trayIconMenu.activateWindow()
         self.trayIconMenu.popup(QCursor.pos())