Skip to content

Widgets

Shawn edited this page Nov 19, 2023 · 5 revisions

This page is intended to be a visual library of available widgets to make choosing one to match a given data source easier. All widgets are screenshotted in the same page.py as the only widget on a pure black background of default size.

ArcsWidget

arcs
One or more arcs that function as curved progress bars, showing numerical data in the range [0,100].

Data type: percentage

Parameters:

parent: the parent widget of this widget, usually the main window.
percs: either a list of commands producing floats or a single function/command that produces a list of floats. Results must match the percent argument.
percent: whether percs is in percentage (0-100) or decimal (0-1).
size: the radius of the arcs, in decimal percentage of parent height (1=100%). Use 0 to manage manually (ie calling set_size from a parent widget).
update_interval: the time in ms between calls to the percs function(s). Can be None if you call do_cmds() manually.
arccol: the color of the arcs as a Qt color. Leave as None to use the parent widget's default color.
arcthic: the thickness of the arcs in decimal percentage of the text height (1 = 100%). Use 0 to manage manually.
arcstart: the angle in degrees to start drawing the arc at, relative to the x-axis and moving counter-clockwise (ie 90 is straight up).
arcspan: the angle in degrees the arc should span in total; positive moves counter-clockwise.
arcspace: the spacing between the centers of each arc, in decimal percentage of the space between text lines (1 = 100%).

See also:

ProgressArcsWidget, ProgressBarWidget

ProgressArcsWidget

progressArcs
Progress bars in the form of arcs, aligned with a large text box with each bar matching lines of text (where possible).

Data type: percentage, multi-line text

Parameters:

parent: the parent widget of this widget, usually the main window.
text: the text for the arcs to be drawn around. Can be a static string, a JITstring, or a PyCmd.
percs: either a list of commands producing floats or a single function/command that produces a list of floats. Results must match the percent argument.
percent: whether the results of percs are in percent (0-100) or decimal (0-1).
height: the height of the widget in decimal percentage of the screen height (1 = 100%).
update_interval: the time in ms between calls to the percs function(s).
arccol: the color of the arcs as a Qt color. Leave as None to use the parent widget's default color.
arcthic: the thickness of the arcs relative to the text height. Set to 0 to auto-match the default underline position.
title: an optional title that sits above the text.
arcpos: where to place the arcs; one of ["top left", "top right", "bottom left", "bottom right"]

See also:

ArcsWidget, the html_table function from widgets.py

ProgressBarWidget

progressBar
A linear progress bar that can be manually updated or given a command and an update interval for automatic updates.

Data type: percentage

Parameters:

parent: the parent widget of this widget, usually a sub-widget of the main window.
perc: a function/command that produces a float between 0 and 1. If given, make sure to set update_interval or call set_progress() manually.
height: the height of the widget in pixels. If none, the height is a tenth of the parent widget's.
update_interval: the time in ms between calls to the perc function. Only relevant if perc is given too.
barcol: the color of the bar as a Qt color.
bgcol: the color of the unfilled portion of the bar as a Qt color. Leave as None to use the page default.
squareness: how square the corners should be. Radius of curvature is height divided by this.

See also:

ArcsWidget

GraphWidget

graph
A graph of some value(s) over time (default 1 min).

Data type: percentage, numerical, text, time-series

Parameters:

parent: the parent widget of this widget, usually the main window.
title: the title for the graph.
getdata: a function or command that returns numerical data.
height: the height of the widget in pixels. Set to None for responsive, and -1 to automatically set fixed height (default).
update_interval: how often (in ms) the graph should update.
time_span: the range in ms for the x-axis.
yrange: the range for the y-axis, as a tuple with (bottom, top).
ylabel_str_fn: a function returning the labels for the y-axis. Must take a y value and return a str.
linecolor: the color of the graph's line. Can be (R,G,B,[A]) tuple (values from 0-255), "#RGB" or "#RRGGBBAA" hex strings, QColor, etc. See documentation for pyqtgraph.mkColor() for all options. Leave as None to use the parent widget's default color.
linecolors: can only use if lines > 1 and linecolor is None. Must be a list containing colors in the same format as linecolor, in the same order as the data returned by getdata.
linewidth: the width of the line.
lines: how many lines to be drawn - if greater than 1, getdata must return a list of the multiple line data.

See also:

VisualizerWidget

VisualizerWidget

visualizer
A mirrored line graphing some value with no title or axes. Intended for use in other widgets (primarily for showing Fourier transforms of music).

Data type: percentage, numerical, time-series

Parameters:

parent: the parent widget of this widget.
getdata: a function or PyCmd that returns a list of floats. The length of the list must be the same each call.
yrange: the range for the y-axis, as a tuple with (bottom, top).
linecolor: the color of the graph's line. Can be (R,G,B,[A]) tuple (values from 0-255), "#RGB" or "#RRGGBBAA" hex strings, QColor, etc. See documentation for pyqtgraph.mkColor() for all options. Leave as None to use the parent widget's default color.
linewidth: the width of the line.
update_interval: how often get_data should be called and the graph updated.

See also:

GraphWidget

ImageWithTextWidget

imageWithText
Displays an image and text.

Data type: image, multi-line text

Parameters:

parent: the parent widget of this widget.
text: the text to display.
img: the image to display as bytes, or a callable (function, PyCmd, etc) that returns an image in bytes.
text_and_img: one callable that returns both text and img parameters in a tuple of (text, img). Both text and img parameters are ignored if this isn't None.
img_size: a fixed size for the image in pixels. Default is dependent on how much space the image has.
img_side: which side of the widget the image is on.
update_interval: the time in ms between updates - defaults to 1 hour. Set to None to disable updates.

See also:

Qt's QLabel for an image alone, or TextWidget for showing only text

MediaWidget

media
Shows a thumbnail or album art and any available media controls for currently playing media on the system. Theoretically usable on its own, but intended to be automatically managed by a MediaListWidget. Not yet implemented on Mac. Requires async on Windows.

Data type: system

Parameters:

Platform dependent. See source code.

See also:

MediaListWidget

MediaListWidget

mediaList
Watches for advertised media streams and creates a MediaWidget for each, destroying it when the stream ends. Uses System Media Transport Controls (not a very common standard) on Windows and MPRIS (much more commonly supported) on Linux. Not yet implemented on Mac. Requires async on Windows.

Data types: system

Parameters:

parent: the parent widget of this widget, usually the main window.
imgsize: the size of the album art image in pixels.
butsize: the size of the media control buttons in pixels.
update_interval: the time in ms between updates for progress bars. Set to None to disable updates.

See also:

MediaWidget

NotificationWidget

incomplete, windows development stalled due to winsdk's notification listener being bugged on many systems (including mine).

Data types: system

Parameters:

See also:

MediaListWidget

HrWidget

hr
A simple horizontal rule (thin line for separating things).

Data types: None

Parameters:

parent: the parent widget containing this one.
height: the height in pixels of the line.
color: the color of the line, as a css string.

See also:

ProgressBarWidget

TextWidget

text

Data types: multi-line text

Parameters:

parent: the parent widget containing this one.
text: the text to be displayed.
alignment: the alignment style for the text; any of Qt's values, such as "Center", "Left", "Right", etc.
wordwrap: whether word wrap should be enabled for the text.
update_interval: how often to refresh the text, if it's dynamic. Leave as None for static text.

See also:

html_table function from widgets.py