Esempio n. 1
0
    def modifiers(self):
        modifiers = Qt.KeyboardModifiers()
        for key in self.__pressed_keys:
            if key == Qt.Key_Shift:
                modifiers |= Qt.ShiftModifier
            elif key == Qt.Key_Control:
                modifiers |= Qt.ControlModifier
            elif key == Qt.Key_Alt:
                modifiers |= Qt.AltModifier
            elif key == Qt.Key_Meta:
                modifiers |= Qt.MetaModifier

        return modifiers
Esempio n. 2
0
 def showMessage(self, msg):
     """Procedure to update message in splash
     
     [description]
     
     Arguments:
         - msg {[type]} -- [description]
     """
     align = Qt.Alignment(Qt.AlignBottom | Qt.AlignRight | Qt.AlignAbsolute)
     #color = QtGui.QColor(QtCore.Qt.White)
     color = QColor(0, 0, 0)
     QSplashScreen.showMessage(self, msg, align, color)
     QApplication.processEvents()
Esempio n. 3
0
 def __init__(self, parent=None):
     """
     Constructor
     
     @param parent reference to the parent widget (QObject)
     """
     super(WatchPointModel, self).__init__(parent)
     
     self.watchpoints = []
     self.header = [
         self.tr("Condition"),
         self.tr("Special"),
         self.tr('Temporary'),
         self.tr('Enabled'),
         self.tr('Ignore Count'),
     ]
     self.alignments = [Qt.Alignment(Qt.AlignLeft),
                        Qt.Alignment(Qt.AlignLeft),
                        Qt.Alignment(Qt.AlignHCenter),
                        Qt.Alignment(Qt.AlignHCenter),
                        Qt.Alignment(Qt.AlignRight),
                        ]
    def __init__(self, main_window: QMainWindow):
        """
        QDockWidget 基类
        :param main_window:
        """
        super().__init__(main_window)
        self.main_window = main_window

        # QDockWidget
        self.widget_contents = QWidget(self, Qt.WindowFlags())

        # QHBoxLayout
        self.layout = QHBoxLayout(self.widget_contents)
Esempio n. 5
0
 def __init__(self, index, ring, knobTendonModels, parent=None, flags=Qt.WindowFlags()):
     super().__init__(parent=parent, flags=flags)
     self.formLayout = QFormLayout()
     self.index = index
     self.knobTendonModels = knobTendonModels
     self._configFormLayout()
     
     box = QGroupBox(f"{self.index+1}-th segment")
     box.setLayout(self.formLayout)
     
     mainLayout = QHBoxLayout()
     mainLayout.addWidget(box)
     self.setLayout(mainLayout)
Esempio n. 6
0
    def keyClick(self, key, modifiers=Qt.NoModifier, widget=None):
        """Alias for ``QTest.keyClick``.

        If widget is none - focused widget will be keyclicked

        key may be QKeySequence or string
        """
        if widget is None:
            widget = QApplication.instance().focusWidget()

        if widget is None:
            widget = core.mainWindow()

        assert widget is not None

        if isinstance(key, str):
            assert modifiers == Qt.NoModifier, 'Do not set modifiers, if using text key'
            code = QKeySequence(key)[0]
            key = Qt.Key(code & 0x01ffffff)
            modifiers = Qt.KeyboardModifiers(code & 0xfe000000)

        QTest.keyClick(widget, key, modifiers)
Esempio n. 7
0
    def __init__(self, ascendent):
        super(Popup, self).__init__(ascendent=ascendent)
        if os.name == 'nt':
            self.setWindowFlags(Qt.WindowFlags(Qt.FramelessWindowHint))
        self.setStyleSheet(Style.replace_variables(Style.light))
        self.setAttribute(Qt.WA_TranslucentBackground, True)

        top_margin = Style.unit * 1.5
        left_margin = Style.unit * 2.5
        main_height = int(3 * Style.unit)
        main_width = int(5 * Style.unit)
        popup_width = int(Style.unit * 2)
        self.setGeometry(left_margin + (main_width / 2) - (popup_width / 2), top_margin + (main_height / 2) - (popup_width / 2), popup_width, popup_width)
Esempio n. 8
0
	def datachange(self):
		self.setlist.clear()
		flags= Qt.ItemFlags(Qt.ItemIsSelectable)|Qt.ItemFlags(Qt.ItemIsEnabled)|Qt.ItemFlags(Qt.ItemIsUserCheckable)|Qt.ItemFlags(Qt.ItemIsDragEnabled)
		keys=list(self.target().data.keys())
		visible = self.target().visibility
		keys.sort()
		parms = self.target().pparm # get the colors from this
		for i,j in enumerate(keys) :
			a = QtWidgets.QListWidgetItem(j)
			a.setFlags(flags)
			try: a.setForeground(qt_color_map[colortypes[parms[j][0]]])
			except:
				print("Color error")
				print(list(sorted(parms.keys())))
				print(parms[j][0])
				print(colortypes[parms[j][0]])
				print(qt_color_map[colortypes[parms[j][0]]])
			if visible[j]: a.setCheckState(Qt.Checked)
			else: a.setCheckState(Qt.Unchecked)
			self.setlist.addItem(a)
		if len(keys) > 0 : self.setlist.setCurrentRow(0)
		self.showslide.setRange(0,len(keys))
    def UploadImagem(self):
        Dialog = QFileDialog()
        Dialog.setOption(QFileDialog.DontUseNativeDialog, True)

        fname = Dialog.getOpenFileName(self, "Selecionar Imagem", "",
                                       "Image files (*.jpg *.png)")[0]

        self.lb_FotoProduto.setPixmap(
            QPixmap(fname).scaledToWidth(
                150, Qt.TransformationMode(Qt.FastTransformation)))
        # self.lb_FotoProduto.setScaledContents(True)
        self.bt_AddImagem.setHidden(True)
        self.bt_DelImagem.setVisible(True)
Esempio n. 10
0
 def __init__(self, parent=None, flags=Qt.WindowFlags()):
     super().__init__(parent=parent, flags=flags)
     self.login = None
     self.setupGuest(self)
     self.setupUser(self)
     self.setupSearchResult(self)
     self.setupHomepage(self)
     self.setupInformation(self)
     self.hideUser()
     self.hideSearchResult()
     self.hideInformation()
     self.setupUi(self)
     self.setWindowTitle('豆豉电影')
Esempio n. 11
0
 def on_errorsListWidget_currentTextChanged(self, text):
     """
     Private slot to handle the highlighted signal.
     
     @param text current text (string)
     """
     if text:
         for pattern in self.rxPatterns:
             text = re.sub(pattern, "", text)
         itm = self.testsListWidget.findItems(
             text, Qt.MatchFlags(Qt.MatchExactly))[0]
         self.testsListWidget.setCurrentItem(itm)
         self.testsListWidget.scrollToItem(itm)
Esempio n. 12
0
    def showImage(self, imageName):
        folderPath = os.path.join(self.imagesFolder, imageName)
        if not os.path.isdir(folderPath):
            filename = self.downloadImage(imageName)[imageName][0]
        else:
            filename = os.path.join(folderPath, os.listdir(folderPath)[0])
        pixmap = QPixmap(filename)

        self.Image.setPixmap(
            pixmap.scaledToHeight(600,
                                  Qt.TransformationMode(
                                      Qt.FastTransformation)))
        self.Image.resize(200, 100)
Esempio n. 13
0
    def __init__(self):
        super(LoggerWindow, self).__init__(flags=Qt.WindowFlags())

        self.title = QLabel(self)
        self.ip_label = QLabel(self)
        self.ip = QLineEdit(self)
        self.login_label = QLabel(self)
        self.login = QLineEdit(self)
        self.password_label = QLabel(self)
        self.password = QLineEdit(self)
        self.connect_button = QPushButton(self)

        self.setup()
    def UploadLogo(self):
        Dialog = QFileDialog()
        Dialog.setOption(QFileDialog.DontUseNativeDialog, True)

        fname = Dialog.getOpenFileName(self, "Selecionar Logo", "",
                                       "Image files (*.jpg *.png)")[0]

        self.lb_LogoEmpresa.setPixmap(
            QPixmap(fname).scaledToWidth(
                300, Qt.TransformationMode(Qt.FastTransformation)))
        # self.lb_LogoEmpresa.setScaledContents(True)
        self.bt_AddLogo.setHidden(True)
        self.bt_DelLogo.setVisible(True)
Esempio n. 15
0
    def append_event(self, ev):
        """Create a new KeySequence object with the given QKeyEvent added."""
        key = ev.key()
        modifiers = ev.modifiers()

        _assert_plain_key(key)
        _assert_plain_modifier(modifiers)

        if key == 0x0:
            raise KeyParseError(None, "Got nil key!")

        # We always remove Qt.GroupSwitchModifier because QKeySequence has no
        # way to mention that in a binding anyways...
        modifiers &= ~Qt.GroupSwitchModifier

        # We change Qt.Key_Backtab to Key_Tab here because nobody would
        # configure "Shift-Backtab" in their config.
        if modifiers & Qt.ShiftModifier and key == Qt.Key_Backtab:
            key = Qt.Key_Tab

        # We don't care about a shift modifier with symbols (Shift-: should
        # match a : binding even though we typed it with a shift on an
        # US-keyboard)
        #
        # However, we *do* care about Shift being involved if we got an
        # upper-case letter, as Shift-A should match a Shift-A binding, but not
        # an "a" binding.
        #
        # In addition, Shift also *is* relevant when other modifiers are
        # involved. Shift-Ctrl-X should not be equivalent to Ctrl-X.
        if (modifiers == Qt.ShiftModifier and
                _is_printable(ev.key()) and
                not ev.text().isupper()):
            modifiers = Qt.KeyboardModifiers()

        # On macOS, swap Ctrl and Meta back
        # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-51293
        if utils.is_mac:
            if modifiers & Qt.ControlModifier and modifiers & Qt.MetaModifier:
                pass
            elif modifiers & Qt.ControlModifier:
                modifiers &= ~Qt.ControlModifier
                modifiers |= Qt.MetaModifier
            elif modifiers & Qt.MetaModifier:
                modifiers &= ~Qt.MetaModifier
                modifiers |= Qt.ControlModifier

        keys = list(self._iter_keys())
        keys.append(key | int(modifiers))

        return self.__class__(*keys)
Esempio n. 16
0
 def mousePressEvent(self, event):
     if self.conspIsOpen and event.button() == Qt.MouseButton(1):
         self.changeBords()
         self.cursorClickCoords = [event.pos().x(), event.pos().y()]
         if self.clickedWidNum == []:  # нет ли уже кликнутого виджета
             for index in range(self.begWid, self.endWid +
                                1):  # по виджетам, которые видны
                 if self.piecelist[index][1].y() <= self.cursorClickCoords[1] <=\
                    self.piecelist[index][1].y() + self.piecelist[index][1].height():  # в куске ли
                     if self.cursorClickCoords[0] <= self.piecelist[index][
                             1].x() and index != 0:
                         self.clickedWidNum = [index, 0]
                         # виджеты для передвижения
                         self.moveButtons[0].move(
                             self.cursorClickCoords[0] +
                             int(self.width() * 0.025),
                             self.cursorClickCoords[1] +
                             int(self.height() * 0.025))
                         self.moveButtons[1].move(
                             self.cursorClickCoords[0] +
                             int(self.width() * 0.0625),
                             self.cursorClickCoords[1] + 0)
                         self.moveButtons[2].move(
                             self.cursorClickCoords[0] + 0,
                             self.cursorClickCoords[1] +
                             int(self.height() * 0.025))
                         self.moveButtons[3].move(
                             self.cursorClickCoords[0] +
                             int(self.width() * 0.125),
                             self.cursorClickCoords[1] +
                             int(self.height() * 0.025))
                         self.moveButtons[4].move(
                             self.cursorClickCoords[0] +
                             int(self.width() * 0.025),
                             self.cursorClickCoords[1] +
                             int(self.height() * 0.05))
                         self.moveButtons[5].move(
                             self.cursorClickCoords[0] +
                             int(self.width() * 0.1),
                             self.cursorClickCoords[1] +
                             int(self.height() * 0.05))
                         for wid in self.moveButtons:
                             wid.show()
                     elif self.width() * 0.95 >= self.cursorClickCoords[
                             0] >= self.piecelist[index][1].x():
                         self.clickedWidNum = [index, 1]
                     break
         else:  # есть уже выделенный виджет
             self.clickedWidNum = []
             for wid in self.moveButtons:
                 wid.hide()
Esempio n. 17
0
    def __init__(self, TraceMain, name):
        super(QDockWidget, self).__init__(TraceMain)

        #self.dockWidget = QDockWidget(TraceMain)
        self.dockContents = QWidget(TraceMain)  # Create container

        self.setFeatures(QDockWidget.DockWidgetFloatable
                         | QDockWidget.DockWidgetMovable)
        self.setWindowTitle(name)  # set dockwidget title

        self.setWidget(self.dockContents)  # add container to dockwidget

        TraceMain.addDockWidget(Qt.DockWidgetArea(Qt.TopDockWidgetArea),
                                self)  # add widget to dock
        TraceMain.setTabPosition(Qt.DockWidgetArea(Qt.TopDockWidgetArea),
                                 QTabWidget.TabPosition(QTabWidget.North))

        Globals.dockList.append(self)  # Keep track of all docks

        if (len(Globals.dockList) > 1):
            for i, purge in enumerate(Globals.dockList):
                if i < len(Globals.dockList) - 1:
                    TraceMain.tabifyDockWidget(Globals.dockList[i],
                                               Globals.dockList[i + 1])

        self.parent = TraceMain  # Set parent, so we can access the MainWindow (e.g themeChange)

        # Initialize all modules
        self.name = name
        self.snifferConfig = ConfigurationData(self, name)
        self.snifferParser = SnifferFileParser()

        self.snifferFilter = SnifferFilter(self)
        self.snifferFilter.setSnifferFilterUi()

        self.snifferStats = SnifferStats()
        self.snifferStats.setSnifferStatsUi()
        self.logger = SnifferLogger(name)
Esempio n. 18
0
    def keyPressEvent(self, evt):
        """
        Protected method to handle key presses.
        
        @param evt reference to the key press event (QKeyEvent)
        """
        if evt.key() == Qt.Key_Escape:
            if self.__browser is not None:
                self.setText(
                    str(self.__browser.url().toEncoded(), encoding="utf-8"))
                self.selectAll()
            completer = self.completer()
            if completer:
                completer.popup().hide()
            return

        currentText = self.text().strip()
        if (evt.key() in [Qt.Key_Enter, Qt.Key_Return]
                and not currentText.lower().startswith(
                    ("http://", "https://"))):
            append = ""
            if evt.modifiers() == Qt.KeyboardModifiers(Qt.ControlModifier):
                append = ".com"
            elif evt.modifiers() == Qt.KeyboardModifiers(Qt.ControlModifier
                                                         | Qt.ShiftModifier):
                append = ".org"
            elif evt.modifiers() == Qt.KeyboardModifiers(Qt.ShiftModifier):
                append = ".net"

            if append != "":
                url = QUrl("http://www." + currentText)
                host = url.host()
                if not host.lower().endswith(append):
                    host += append
                    url.setHost(host)
                    self.setText(url.toString())

        E5LineEdit.keyPressEvent(self, evt)
Esempio n. 19
0
 def __createItem(self, file, line, text, start, end, replTxt="", md5=""):
     """
     Private method to create an entry in the file list.
     
     @param file filename of file (string)
     @param line line number (integer)
     @param text text found (string)
     @param start start position of match (integer)
     @param end end position of match (integer)
     @param replTxt text with replacements applied (string)
     @keyparam md5 MD5 hash of the file (string)
     """
     if self.__lastFileItem is None:
         # It's a new file
         self.__lastFileItem = QTreeWidgetItem(self.findList, [file])
         self.__lastFileItem.setFirstColumnSpanned(True)
         self.__lastFileItem.setExpanded(True)
         if self.__replaceMode:
             self.__lastFileItem.setFlags(
                 self.__lastFileItem.flags() |
                 Qt.ItemFlags(Qt.ItemIsUserCheckable | Qt.ItemIsTristate))
             # Qt bug:
             # item is not user checkable if setFirstColumnSpanned
             # is True (< 4.5.0)
         self.__lastFileItem.setData(0, self.md5Role, md5)
     
     itm = QTreeWidgetItem(self.__lastFileItem)
     itm.setTextAlignment(0, Qt.AlignRight)
     itm.setData(0, Qt.DisplayRole, line)
     itm.setData(1, Qt.DisplayRole, text)
     itm.setData(0, self.lineRole, line)
     itm.setData(0, self.startRole, start)
     itm.setData(0, self.endRole, end)
     itm.setData(0, self.replaceRole, replTxt)
     if self.__replaceMode:
         itm.setFlags(itm.flags() | Qt.ItemFlags(Qt.ItemIsUserCheckable))
         itm.setCheckState(0, Qt.Checked)
         self.replaceButton.setEnabled(True)
Esempio n. 20
0
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.setWindowTitle("funkyD Widget")
        self.width = QDesktopWidget().availableGeometry().width()
        self.height = QDesktopWidget().screenGeometry().height()
        self.setFixedWidth(self.width)
        self.setFixedHeight(self.height)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        if (sys.platform == 'win32'):
            flags = Qt.WindowFlags(Qt.FramelessWindowHint | Qt.Tool)
        else:
            flags = Qt.WindowFlags(Qt.FramelessWindowHint
                                   | Qt.WindowTransparentForInput
                                   | Qt.WindowStaysOnBottomHint)
        self.setWindowFlags(flags)

        #Load Configuration json file
        self.loadConf()
        self.betas = []
        self.day()
        self.greeting()
        self.time()
        self.saveConf()
        print(self.betas)
        # self.cpu_usage()

        # self.setLayout(QGridLayout())
        # self.layout().addWidget(self.dayLabel,0,0)
        # self.layout().addWidget(self.timeLabel,1,0)
        # self.layout().addWidget(self.cpuLabel)
        # self.center()
        # self.layout().setSizeConstrafloat(QLayout.SetMinimumSize)
        # self.customPostition()

        #Works with X11 enable system like linux and macOS
        # self.setAttribute(Qt.WindowTransparentForInput)
        self.setAttribute(Qt.WA_X11NetWmWindowTypeDesktop, True)
Esempio n. 21
0
 def __init__(self,
              adb,
              battle,
              cwd,
              btnCheck,
              listGoTo,
              normal,
              high,
              parent=None,
              flags=Qt.WindowFlags(1)):
     super().__init__(parent=parent, flags=flags)
     self.initVar(adb, battle, cwd, btnCheck, normal, high)
     self.initAuto(listGoTo)
     self.initUI()
Esempio n. 22
0
 def __init__(self,
              Ui,
              sql_main=None,
              PKValue=None,
              sql_sub=None,
              edit_mode=JPEditFormDataMode.ReadOnly,
              flags=Qt.WindowFlags()):
     super().__init__(Ui,
                      sql_main=sql_main,
                      PKValue=PKValue,
                      edit_mode=edit_mode,
                      flags=flags)
     self.subSQL = sql_sub
     self.ui = Ui
Esempio n. 23
0
    def __init__(self, parent=None, flags=Qt.WindowFlags()):
        super().__init__(parent=parent, flags=flags)

        self.setWindowTitle("CaptureWords")
        self.setWindowFlags(
            Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Dialog
        )
        self.setWindowState(self.windowState() | Qt.WindowFullScreen)
        self.screen = QtWidgets.QApplication.screenAt(QtGui.QCursor.pos()).grabWindow(0)
        palette = QtGui.QPalette()
        palette.setBrush(self.backgroundRole(), QtGui.QBrush(self.screen))
        self.setPalette(palette)
        QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))
        self.start, self.end = QtCore.QPoint(), QtCore.QPoint()
Esempio n. 24
0
    def __init__(self, parent=None, flags=Qt.WindowFlags()):
        super().__init__(parent=parent, flags=flags)

        self.setWindowTitle("TextShot")
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
                            | Qt.Dialog)
        self.setWindowState(self.windowState() | Qt.WindowFullScreen)
        self.setStyleSheet("background-color: black")
        self.setWindowOpacity(0.5)

        QtWidgets.QApplication.setOverrideCursor(
            QtGui.QCursor(QtCore.Qt.CrossCursor))

        self.start, self.end = QtCore.QPoint(), QtCore.QPoint()
    def on_addButton_clicked(self):
        """
        Private slot to add a new entry.
        """
        menutext = self.menuEdit.text()
        icon = self.iconPicker.text()
        executable = self.executablePicker.text()
        arguments = self.argumentsEdit.text()
        redirect = self.redirectionModes[self.redirectCombo.currentIndex()][0]

        if not executable:
            E5MessageBox.critical(
                self, self.tr("Add tool entry"),
                self.tr("You have to set an executable to add to the"
                        " Tools-Menu first."))
            return

        if not menutext:
            E5MessageBox.critical(
                self, self.tr("Add tool entry"),
                self.tr("You have to insert a menuentry text to add the"
                        " selected program to the Tools-Menu first."))
            return

        if not Utilities.isinpath(executable):
            E5MessageBox.critical(
                self, self.tr("Add tool entry"),
                self.tr("The selected file could not be found or"
                        " is not an executable."
                        " Please choose an executable filename."))
            return

        if len(
                self.toolsList.findItems(menutext,
                                         Qt.MatchFlags(Qt.MatchExactly))):
            E5MessageBox.critical(
                self, self.tr("Add tool entry"),
                self.tr("An entry for the menu text {0} already exists.").
                format(menutext))
            return

        self.toolsList.addItem(menutext)
        tool = {
            'menutext': menutext,
            'icon': icon,
            'executable': executable,
            'arguments': arguments,
            'redirect': redirect,
        }
        self.toollist.append(tool)
Esempio n. 26
0
    def __init__(self, grid_layout_widget: QWidget, grid_layout: QGridLayout):
        self.grid_layout_widget = grid_layout_widget
        self.grid_layout = grid_layout

        self.aero = QGroupBox(self.grid_layout_widget)
        self.aero_grid_layout_widget = QWidget(self.aero, Qt.WindowFlags())
        self.aero_grid_layout = QGridLayout(self.aero_grid_layout_widget)

        self.alpha = QLabel(self.aero_grid_layout_widget)
        self.shadow_size = QLabel(self.aero_grid_layout_widget)
        self.shadow_sharp = QLabel(self.aero_grid_layout_widget)
        self.alpha_slider = QSlider(self.aero_grid_layout_widget)
        self.shadow_size_slider = QSlider(self.aero_grid_layout_widget)
        self.shadow_sharp_slider = QSlider(self.aero_grid_layout_widget)
Esempio n. 27
0
    def __init__(self, grid_layout_widget: QWidget, grid_layout: QGridLayout):
        self.grid_layout_widget = grid_layout_widget
        self.grid_layout = grid_layout

        self.hsb = QGroupBox(self.grid_layout_widget)
        self.hsb_grid_layout_widget = QWidget(self.hsb, Qt.WindowFlags())
        self.hsb_grid_layout = QGridLayout(self.hsb_grid_layout_widget)

        self.hue = QLabel(self.hsb_grid_layout_widget)
        self.saturation = QLabel(self.hsb_grid_layout_widget)
        self.brightness = QLabel(self.hsb_grid_layout_widget)
        self.hue_slider = QSlider(self.hsb_grid_layout_widget)
        self.saturation_slider = QSlider(self.hsb_grid_layout_widget)
        self.brightness_slider = QSlider(self.hsb_grid_layout_widget)
Esempio n. 28
0
    def __init__(self, parent=None, flags=Qt.WindowFlags()):
        super().__init__(parent=parent, flags=flags)
        self.setupUi(self)

        self.companyManager = CompanyInterface(True)
        self.genreManager = GenreInterface(True)
        self.directorManager = DirectorInterface(True)
        self.castManager = CastInterface(True)
        self.filmChecker = FilmInterface(False)

        self.searchCompany()
        self.searchGenre()
        self.searchDirector()
        self.searchCast()
    def __init__(self, confidence_level_name: str, parent=None):
        flags = Qt.WindowFlags()
        flags |= Qt.FramelessWindowHint

        super().__init__(parent=parent, flags=flags)

        self.setWindowModality(Qt.ApplicationModal)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle("GIWAXS analysis")
        self.setWindowIcon(Icon("window_icon"))

        self._init_ui(confidence_level_name)
        self._init_layout()
        self._init_connect()
Esempio n. 30
0
def keySequenceClicks(widget, keySequence, extraModifiers=Qt.NoModifier):
    """Use QTest.keyClick to send a QKeySequence to a widget."""

    # This is based on a simplified version of http://stackoverflow.com/questions/14034209/convert-string-representation-of-keycode-to-qtkey-or-any-int-and-back. I added code to handle the case in which the resulting key contains a modifier (for example, Shift+Home). When I execute QTest.keyClick(widget, keyWithModifier), I get the error "ASSERT: "false" in file .\qasciikey.cpp, line 495". To fix this, the following code splits the key into a key and its modifier.
    # Bitmask for all modifier keys.
    modifierMask = int(Qt.ShiftModifier | Qt.ControlModifier | Qt.AltModifier
                       | Qt.MetaModifier | Qt.KeypadModifier)
    ks = QKeySequence(keySequence)
    # For now, we don't handle a QKeySequence("Ctrl") or any other modified by itself.
    assert ks.count() > 0
    for _, key in enumerate(ks):
        modifiers = Qt.KeyboardModifiers((key & modifierMask) | extraModifiers)
        key = key & ~modifierMask
        QTest.keyClick(widget, key, modifiers)
Esempio n. 31
0
    def load(self, f):
        if not QFile.exists(f):
            return False

        fh = QFile(f)
        if not fh.open(QFile.ReadOnly):
            return False

        data = fh.readAll()
        codec = QTextCodec.codecForHtml(data)
        unistr = codec.toUnicode(data)

        if Qt.mightBeRichText(unistr):
            self.textEdit.setHtml(unistr)
        else:
            self.textEdit.setPlainText(unistr)

        self.setCurrentFileName(f)
        return True
Esempio n. 32
0
 def __init__(self, parent, dvar, dvalue, dtype):
     """
     Constructor
     
     @param parent reference to the parent item
     @param dvar variable name (string)
     @param dvalue value string (string)
     @param dtype type string (string)
     """
     self.__value = dvalue
     if len(dvalue) > 2048:     # 1024 * 2
         dvalue = QCoreApplication.translate(
             "VariableItem", "<double click to show value>")
         self.__tooltip = dvalue
     else:
         if Qt.mightBeRichText(dvalue):
             self.__tooltip = Utilities.html_encode(dvalue)
         else:
             self.__tooltip = dvalue
         lines = dvalue.splitlines()
         if len(lines) > 1:
             # only show the first non-empty line;
             # indicate skipped lines by <...> at the
             # beginning and/or end
             index = 0
             while index < len(lines) - 1 and lines[index] == "":
                 index += 1
             dvalue = ""
             if index > 0:
                 dvalue += "<...>"
             dvalue += lines[index]
             if index < len(lines) - 1:
                 dvalue += "<...>"
     
     super(VariableItem, self).__init__(parent, [dvar, dvalue, dtype])
     
     self.populated = True
Esempio n. 33
0
from PyQt5.QtCore import Qt as Q

QT_KEYS = {k[4:]: Q.__getattribute__(Q, k) for k in dir(Q) if k.startswith('Key_')}

LEFT_KEYS = (QT_KEYS['A'], QT_KEYS['Left'])
RIGHT_KEYS = (QT_KEYS['D'], QT_KEYS['Right'])
UP_KEYS = (QT_KEYS['W'], QT_KEYS['Up'])
DOWN_KEYS = (QT_KEYS['S'], QT_KEYS['Down'])

def is_left(key, left_keys=LEFT_KEYS):
    return key in left_keys
    
def is_right(key, right_keys=RIGHT_KEYS):
    return key in right_keys

def is_up(key, up_keys=UP_KEYS):
    return key in up_keys

def is_down(key, down_keys=DOWN_KEYS):
    return key in down_keys