예제 #1
0
 def get_available_sizes(self,
                         mode: ModeStr = "normal",
                         state: StateStr = "off") -> list[core.Size]:
     if mode not in MODE:
         raise InvalidParamError(mode, MODE)
     if state not in STATE:
         raise InvalidParamError(state, STATE)
     return [
         core.Size(i) for i in self.availableSizes(MODE[mode], STATE[state])
     ]
예제 #2
0
 def add_pixmap(
     self,
     pixmap: QtGui.QPixmap,
     mode: gui.icon.ModeStr,
     state: gui.icon.StateStr,
 ):
     if mode not in gui.icon.MODE:
         raise InvalidParamError(mode, gui.icon.MODE)
     if state not in gui.icon.STATE:
         raise InvalidParamError(state, gui.icon.STATE)
     self.addPixmap(pixmap, gui.icon.MODE[mode], gui.icon.STATE[state])
예제 #3
0
파일: screen.py 프로젝트: phil65/PrettyQt
 def get_angle_between(
     self,
     orientation_1: constants.ScreenOrientationStr,
     orientation_2: constants.ScreenOrientationStr,
 ):
     if orientation_1 not in constants.SCREEN_ORIENTATION:
         raise InvalidParamError(orientation_1, constants.SCREEN_ORIENTATION)
     if orientation_2 not in constants.SCREEN_ORIENTATION:
         raise InvalidParamError(orientation_2, constants.SCREEN_ORIENTATION)
     self.angleBetween(
         constants.SCREEN_ORIENTATION[orientation_1],
         constants.SCREEN_ORIENTATION[orientation_2],
     )
예제 #4
0
    def set_feature_weight(self, feature: FeatureTypeStr, weight: FeatureWeightStr):
        """Set the feature weight.

        Args:
            feature: Feature type
            weight: Feature weight

        Raises:
            InvalidParamError: feature weight / type does not exist
        """
        if weight not in FEATURE_WEIGHTS:
            raise InvalidParamError(weight, FEATURE_WEIGHTS)
        if feature not in FEATURE_TYPES:
            raise InvalidParamError(feature, FEATURE_TYPES)
        self.setFeatureWeight(FEATURE_TYPES[feature], FEATURE_WEIGHTS[weight])
예제 #5
0
 def get_pixmap(
     self,
     size: types.SizeType | int,
     mode: ModeStr = "normal",
     state: StateStr = "off",
 ) -> QtGui.QPixmap:
     if mode not in MODE:
         raise InvalidParamError(mode, MODE)
     if state not in STATE:
         raise InvalidParamError(state, STATE)
     if isinstance(size, tuple):
         size = core.Size(*size)
     elif isinstance(size, int):
         size = core.Size(size, size)
     return self.pixmap(size, MODE[mode], STATE[state])
예제 #6
0
    def set_path(cls, fmt: FormatStr, scope: ScopeStr, path: types.PathType):
        """Set the path to the settings file.

        Args:
            fmt: the default format to use
            scope: the scope to use

        Raises:
            InvalidParamError: invalid format or scope
        """
        if fmt not in FORMAT:
            raise InvalidParamError(fmt, FORMAT)
        if scope not in SCOPE:
            raise InvalidParamError(scope, SCOPE)
        cls.setPath(FORMAT[fmt], SCOPE[scope], os.fspath(path))
예제 #7
0
 def get_display_name(
     self,
     datetime: QtCore.QDateTime | TimeTypeStr,
     name_type: NameTypeStr = "default",
     locale: core.Locale | None = None,
 ) -> str:
     if isinstance(datetime, str):
         if datetime not in TIME_TYPE:
             raise InvalidParamError(datetime, TIME_TYPE)
         datetime = TIME_TYPE[datetime]
     if name_type not in NAME_TYPE:
         raise InvalidParamError(name_type, NAME_TYPE)
     if locale is None:
         locale = core.Locale()
     return self.displayName(datetime, NAME_TYPE[name_type], locale)
예제 #8
0
 def get_image(self, mode: ModeStr = "clipboard") -> gui.Image | None:
     if mode not in MODES:
         raise InvalidParamError(mode, MODES)
     img = gui.Image(self.item.image(MODES[mode]))
     if img.isNull():
         return None
     return img
예제 #9
0
 def get_pixmap(self, mode: ModeStr = "clipboard") -> gui.Pixmap | None:
     if mode not in MODES:
         raise InvalidParamError(mode, MODES)
     pix = gui.Pixmap(self.item.pixmap(MODES[mode]))
     if pix.isNull():
         return None
     return pix
예제 #10
0
 def set_edit_triggers(self, *triggers: EditTriggerStr | None):
     items = ["none" if t is None else t for t in triggers]
     for item in items:
         if item not in EDIT_TRIGGERS:
             raise InvalidParamError(item, EDIT_TRIGGERS)
     flags = helpers.merge_flags(items, EDIT_TRIGGERS)
     self.setEditTriggers(flags)
예제 #11
0
 def get_style_icon(cls, icon: widgets.style.StandardPixmapStr) -> gui.Icon:
     style = cls.style()
     # icon_size = style.pixelMetric(QtWidgets.QStyle.PM_MessageBoxIconSize)
     if icon not in widgets.style.STANDARD_PIXMAP:
         raise InvalidParamError(icon, widgets.style.STANDARD_PIXMAP)
     icon = style.standardIcon(widgets.style.STANDARD_PIXMAP[icon])
     return gui.Icon(icon)
예제 #12
0
 def add_resource(
     self, resource_type: ResourceTypeStr, name: types.PathType, resource
 ):
     if resource_type not in RESOURCE_TYPES:
         raise InvalidParamError(resource_type, RESOURCE_TYPES)
     url = core.Url(name)
     self.addResource(RESOURCE_TYPES[resource_type], url, resource)
예제 #13
0
 def set_bar_style(self, style: BarStyleStr):
     if style not in BAR_STYLE:
         raise InvalidParamError(style, BAR_STYLE)
     if style != self.bar_style:
         self.bar_style = style
         self._rebuild_brush = True
         self.update()
예제 #14
0
 def get_actual_size(
     self,
     size: types.SizeType | int,
     mode: gui.icon.ModeStr = "normal",
     state: gui.icon.StateStr = "off",
 ) -> core.Size:
     if mode not in gui.icon.MODE:
         raise InvalidParamError(mode, gui.icon.MODE)
     if state not in gui.icon.STATE:
         raise InvalidParamError(state, gui.icon.STATE)
     if isinstance(size, tuple):
         size = core.Size(*size)
     elif isinstance(size, int):
         size = core.Size(size, size)
     return core.Size(
         self.actualSize(size, gui.icon.MODE[mode], gui.icon.STATE[state]))
예제 #15
0
 def get_pixmap(self, typ: widgets.wizard.WizardPixmapStr) -> gui.Pixmap | None:
     if typ not in widgets.wizard.WIZARD_PIXMAP:
         raise InvalidParamError(typ, widgets.wizard.WIZARD_PIXMAP)
     pix = gui.Pixmap(self.pixmap(widgets.wizard.WIZARD_PIXMAP[typ]))
     if pix.isNull():
         return None
     return pix
예제 #16
0
 def set_resize_mode(self, mode: ModeStr, col: int | None = None):
     if mode not in MODES:
         raise InvalidParamError(mode, MODES)
     if col is None:
         self.setSectionResizeMode(MODES[mode])
     else:
         self.setSectionResizeMode(col, MODES[mode])
예제 #17
0
 def scroll_to_item(
     self,
     item: QtWidgets.QListWidgetItem,
     mode: widgets.abstractitemview.ScrollHintStr = "ensure_visible",
 ):
     if mode not in widgets.abstractitemview.SCROLL_HINT:
         raise InvalidParamError(mode, widgets.abstractitemview.SCROLL_HINT)
     self.scrollToItem(item, widgets.abstractitemview.SCROLL_HINT[mode])
예제 #18
0
파일: textline.py 프로젝트: phil65/PrettyQt
 def x_to_cursor(
         self,
         x: float,
         cursor_pos: CursorPositionStr = "cursor_between_characters"
 ) -> int:
     if cursor_pos not in CURSOR_POSITION:
         raise InvalidParamError(cursor_pos, CURSOR_POSITION)
     return self.xToCursor(x, CURSOR_POSITION[cursor_pos])
예제 #19
0
파일: scroller.py 프로젝트: phil65/PrettyQt
 def handle_input(
     self, input_type: InputStr, position: types.PointFType, timestamp: int = 0
 ) -> bool:
     if isinstance(position, tuple):
         position = core.PointF(*position)
     if input_type not in INPUT:
         raise InvalidParamError(input_type, INPUT)
     return self.handleInput(INPUT[input_type], position, timestamp)
예제 #20
0
 def set_pixmap(self,
                pixmap: QtGui.QPixmap | None,
                mode: ModeStr = "clipboard"):
     if mode not in MODES:
         raise InvalidParamError(mode, MODES)
     if pixmap is None:
         pixmap = QtGui.QPixmap()
     self.item.setPixmap(pixmap, MODES[mode])
예제 #21
0
 def colliding_items(
     self,
     item: QtWidgets.QGraphicsItem,
     mode: constants.ItemSelectionModeStr = "intersects_shape",
 ) -> list[QtWidgets.QGraphicsItem]:
     if mode not in constants.ITEM_SELECTION_MODE:
         raise InvalidParamError(mode, constants.ITEM_SELECTION_MODE)
     return self.collidingItems(item, constants.ITEM_SELECTION_MODE[mode])
예제 #22
0
파일: widget.py 프로젝트: phil65/PrettyQt
 def set_window_flags(self, *flags: constants.WindowFlagStr, append: bool = False):
     for flag in flags:
         if flag not in constants.WINDOW_FLAGS:
             raise InvalidParamError(flag, constants.WINDOW_FLAGS)
     result = helpers.merge_flags(flags, constants.WINDOW_FLAGS)
     if append:
         result = result | self.windowFlags()
     self.setWindowFlags(result)
예제 #23
0
파일: widget.py 프로젝트: phil65/PrettyQt
 def set_cursor(self, cursor: constants.CursorShapeStr | QtGui.QCursor) -> None:
     if isinstance(cursor, QtGui.QCursor):
         curs = cursor
     else:
         if cursor not in constants.CURSOR_SHAPE:
             raise InvalidParamError(cursor, constants.CURSOR_SHAPE)
         curs = gui.Cursor(constants.CURSOR_SHAPE[cursor])
     self.setCursor(curs)
예제 #24
0
 def set_image(self,
               image: QtGui.QImage | None,
               mode: ModeStr = "clipboard"):
     if mode not in MODES:
         raise InvalidParamError(mode, MODES)
     if image is None:
         image = QtGui.QImage()
     self.item.setImage(image, MODES[mode])
예제 #25
0
 def add_file(
     self,
     path: types.PathType,
     size: types.SizeType | int,
     mode: gui.icon.ModeStr,
     state: gui.icon.StateStr,
 ):
     if mode not in gui.icon.MODE:
         raise InvalidParamError(mode, gui.icon.MODE)
     if state not in gui.icon.STATE:
         raise InvalidParamError(state, gui.icon.STATE)
     if isinstance(size, tuple):
         size = core.Size(*size)
     elif isinstance(size, int):
         size = core.Size(size, size)
     self.addFile(os.fspath(path), size, gui.icon.MODE[mode],
                  gui.icon.STATE[state])
예제 #26
0
 def elided_text(self,
                 text: str,
                 mode: constants.ElideModeStr,
                 width: int,
                 flags=0) -> str:
     if mode not in constants.ELIDE_MODE:
         raise InvalidParamError(mode, constants.ELIDE_MODE)
     return self.elidedText(text, constants.ELIDE_MODE[mode], width, flags)
예제 #27
0
 def set_pixmap(
     self, typ: widgets.wizard.WizardPixmapStr, pixmap: QtGui.QPixmap | None
 ):
     if typ not in widgets.wizard.WIZARD_PIXMAP:
         raise InvalidParamError(typ, widgets.wizard.WIZARD_PIXMAP)
     if pixmap is None:
         pixmap = QtGui.QPixmap()
     self.setPixmap(widgets.wizard.WIZARD_PIXMAP[typ], pixmap)
예제 #28
0
    def set_composition_mode(self, mode: CompositionModeStr):
        """Set the current composition mode.

        Raises:
            InvalidParamError: composition mode does not exist
        """
        if mode not in COMPOSITION_MODE:
            raise InvalidParamError(mode, COMPOSITION_MODE)
        self.setCompositionMode(COMPOSITION_MODE[mode])
예제 #29
0
    def get_feature_weight(self, feature: FeatureTypeStr) -> FeatureWeightStr:
        """Return current feature weight.

        Returns:
            Feature weight
        """
        if feature not in FEATURE_TYPES:
            raise InvalidParamError(feature, FEATURE_TYPES)
        return FEATURE_WEIGHTS.inverse[self.featureWeight(FEATURE_TYPES[feature])]
예제 #30
0
 def add_pixmap(
     self,
     data: QtCore.QByteArray | QtGui.QPixmap | bytes,
     mode: ModeStr = "normal",
     state: StateStr = "off",
 ):
     if mode not in MODE:
         raise InvalidParamError(mode, MODE)
     if state not in STATE:
         raise InvalidParamError(state, STATE)
     if isinstance(data, bytes):
         data = QtCore.QByteArray(data)
     if isinstance(data, QtCore.QByteArray):
         pixmap = QtGui.QPixmap()
         pixmap.loadFromData(data)
     else:
         pixmap = data
     self.addPixmap(pixmap, MODE[mode], STATE[state])