8.6.8.14. pymodaq_gui.utils.styling module
- class pymodaq_gui.utils.styling.Font(font_name='Tahoma', font_size=14, isbold=True, isitalic=False, color=None)[source]
Bases:
object- Attributes:
- color
Methods
apply_to_widget
get_font
- class pymodaq_gui.utils.styling.ThemeColor(*values)[source]
Bases:
StrEnumThe colours of a qt_themes theme, by name.
Pass these (or the equivalent plain strings, e.g.
'green') wherever a colour should follow the theme, e.g.add_action(..., icon_color=ThemeColor.GREEN): they are resolved against the theme applied when the icon is (re)built, so they follow a theme change. A QColor or a hex string is a fixed colour.Members behave as plain
str(ThemeColor.GREEN == 'green').- BASE = 'base'
- BLUE = 'blue'
- CRUST = 'crust'
- CYAN = 'cyan'
- GREEN = 'green'
- MAGENTA = 'magenta'
- MANTLE = 'mantle'
- ORANGE = 'orange'
- OVERLAY0 = 'overlay0'
- OVERLAY1 = 'overlay1'
- OVERLAY2 = 'overlay2'
- PRIMARY = 'primary'
- RED = 'red'
- SECONDARY = 'secondary'
- SUBTEXT0 = 'subtext0'
- SUBTEXT1 = 'subtext1'
- SURFACE0 = 'surface0'
- SURFACE1 = 'surface1'
- SURFACE2 = 'surface2'
- TEXT = 'text'
- YELLOW = 'yellow'
- pymodaq_gui.utils.styling.as_theme_role(color)[source]
Return the
ThemeColorof the current theme equal to color, else color.Compatibility shim: colours that follow the theme should be given by name (
ThemeColor). Code that passes a colour already resolved from the theme (get_theme().green) gets it mapped back to its name, so that it still follows the theme. Strings and colours that are not part of the theme are returned unchanged.
- pymodaq_gui.utils.styling.color_to_rgba(color, alpha=None)[source]
Return a rgba string to use for color argument in stylesheets
- pymodaq_gui.utils.styling.create_color(icon_color)[source]
Return a QColor from a QColor, a theme role name (resolved against the theme currently applied, see get_current_theme) or any string QColor accepts.
- pymodaq_gui.utils.styling.create_font(font_name=None, font_size=None, isbold=False, isitalic=False)[source]
- Return type:
- pymodaq_gui.utils.styling.create_icon(icon_name, icon_color=None, icon_checked_color=None, flip_h=False, flip_v=False, rotate=0, fill=None)[source]
Create an icon from various sources by order of preference:
icon_name is a MaterialIcon
icon_name is a regular QIcon
icon_name is a registered MaterialIcon
icon_name is a real path to a png
icon_name is a registered png in icon_library
icon_name is a registered ThemeIcon
icon_name is a registered StandardPixmap
- Parameters:
icon_name (
Union[QIcon,str,Path]) – Icon source — see priority list above.icon_color (
Union[QColor,bytes,str,None]) – Colour applied to the unchecked/off-state icon (MaterialIcon only).icon_checked_color (
Union[QColor,bytes,str,None]) – Colour applied to the checked/on-state icon (MaterialIcon only).flip_h (
bool) – Mirror the icon horizontally (left ↔ right).flip_v (
bool) – Mirror the icon vertically (top ↔ bottom).rotate (
int) – Rotate the icon given the value in degreesfill (
Optional[bool]) – Is Material Icon filled or edged. If None, left to the user configuration else force the choice on the iconrotate – rotation of the icon in degrees. If 0 nothing is done
- pymodaq_gui.utils.styling.get_current_theme()[source]
Return the theme applied to the running QApplication, else the configured one.
- Return type:
Optional[Theme]
- pymodaq_gui.utils.styling.make_shape_icon(shape='circle', filled=True, size=12, width=None, height=None, pen=None, brush=None, **kwargs)[source]
Return a small solid or outlined shape as a QIcon, using pyqtgraph’s mkPen/mkBrush.
- Parameters:
shape (
str) – Shape of the icon: ‘circle’, ‘triangle’, ‘square’, ‘rectangle’, or ‘diamond’.filled (
bool) – If True, the shape is filled; if False, only the outline is drawn.size (
int) – Diameter of the circle, side length of the square/diamond, or default side for triangle/rectangle in pixels (default 12).width (
int) – Width of the rectangle (if shape is ‘rectangle’). If None, defaults to size.height (
int) – Height of the rectangle (if shape is ‘rectangle’). If None, defaults to size.pen (
QPen) – QPen for the outline (e.g., pg.mkPen(‘blue’, width=2)).brush (
QBrush) – QBrush for filling the shape (e.g., pg.mkBrush(‘red’)).**kwargs – Optional arguments for creating pen/brush if not provided: - color: str (default: ‘black’) - pen_width: int (default: 1) - pen_style: str (e.g., ‘solid’, ‘dashed’, ‘dotted’, ‘dashdot’, ‘dashdotdot’) - brush_color: str (default: same as color)
- Return type:
- pymodaq_gui.utils.styling.transform_icon(icon, transform)[source]
Return a new QIcon with all pixmaps transformed by transform.
- Parameters:
icon (
QIcon) – The icon to transform.transform (
QTransform) – The transform to apply to the icon.
- Return type: