Import root modules:
import ohmygui as omgfrom ohmygui import core, widget, dialog, layout, utils, terminal, oml
Root packages expose:
omg.core- application wrapper,Window, mouse helpers, bind decoratoromg.widget- base widgets, standard UI controls, advanced widgets, page interfaceomg.layout- layout containers for window contentomg.dialog- standard dialogs and helper enumsomg.utils- color constants, audio playback, environment and OS helpers, sleep and version checksomg.terminal- console ANSI output helpersomg.oml- OML parser and conversion utilities
A singleton application wrapper around PySide6.
Constructor:
Application()- returns the shared application instance
Methods:
init_widget_mode() -> Self- initialize Qt widget mode (QApplication)init_qml_mode() -> Self- initialize QML mode (QGuiApplication)run() -> int- run the Qt event loopon_quit(event: Event) -> None- bind application quit callbackload_style_from(path: str) -> Self- load a QSS stylesheet from a fileload_style_string(qss: str) -> Self- load stylesheet from a stringload_oms_string(oms: str) -> Self- load OMS stylesheet stringload_oms_from(path: str) -> Self- load OMS stylesheet from a fileload_oml_string(oml: str) -> Self- convert and load OML from a stringload_oml_from(path: str) -> Self- convert and load OML from a fileload_qml_from(path: str) -> Self- load a QML file into the QML engine
Properties:
is_qml_mode: bool- whether current app is in QML mode
Aliases:
App = Application
Main application window wrapper.
Constructor:
Window(title: str = "", size: tuple[int, int] = (800, 500))
Properties:
x,y,w,h- window geometrysize-(width, height)tupleparent- Qt parent objectchildren- Qt child objectstop_widget- most recently bound widgettop_widgets- deprecated alias fortoplevel_widgettoplevel_widget- top-level native window widgetnative- underlyingQMainWindowbg_color- current background color stringmenus- added menu list
Methods:
set_size(size: tuple[int, int]) -> Selfset_position(pos: tuple[int, int]) -> Selfset_icon(ico_path: str) -> Selffix_size() -> Selfunfix_size() -> Selfbind_widget(widget: BaseWidget, dir: tuple[int, int]) -> Selfrelative_bind(widget: BaseWidget, reldir: tuple[float, float]) -> Selfset_parent(parent: Window) -> Selfset_layout(layout: BaseLayout) -> Selfset_interface(interface: Interface) -> Selfload_style_from(path: str) -> Selfload_style_string(qss: str) -> Selfload_oms_string(oms: str) -> Selfload_oms_from(path: str) -> Selfexport_QSS -> str- get current stylesheeton_resize(callback: Callable[[int, int], None]) -> Selfshow() -> Selfhide() -> Selfclose() -> Selfon_close(event: Callable[[Any], None]) -> Selfset_bg(color: str) -> Selfadd_menu(name: str, shortcut: str, actions: list[tuple[str, Callable] | None]) -> Selfdestroy() -> Selfset_frameless(option: bool) -> Selfsnap(layout: WinSize) -> Self
Enums:
WinSize-Maximum,Minimum,Regular,Left,Right,Top,Bottom
get_mouse_x() -> intget_mouse_y() -> intset_mouse_pos(pos: tuple[int, int]) -> None
bind(register_method)- decorator that binds a function through a register method, such ascore.bind(win.on_close)
Common widget base class for all widgets.
Methods:
show() -> Selfhide() -> Selfset_pos(x: int, y: int, w: int | None = None, h: int | None = None) -> Selfset_size(size: tuple[int, int]) -> Selfset_transparency(val: float) -> Selfon_hover(enter, leave=None, move=None) -> Selfload_stylesheet(qss: str) -> Selfload_omstylesheet(oms: str) -> Selflock() -> Selfunlock() -> Selfset_rounded_corner(radius: int) -> Selfon_any_keypressed(callback: Callable[[int], None]) -> Selfon_keypress(ascii: int, callback: Callable[[], None]) -> Selfset_shadow(blur_radius: int = 10, x_offset: int = 0, y_offset: int = 3, color: str = "#00000080") -> Selfremove_shadow() -> Selfget_size -> tuple[int, int]native- underlying Qt widget
Properties:
x_pos,y_pos,width,heightis_locked
Label widget.
Constructor:
Text(text: str = "", fg: str = "#000000", bg: str = "#ffffff")
Methods:
set_text(text: str) -> Selfset_foreground(fg: str) -> Selfset_background(bg: str) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str, size: int | None = None, bold: bool = False, italic: bool = False) -> Self
Properties:
text,fg,bg,font
Clickable push button.
Constructor:
Button(text: str, fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_text(text: str) -> Selfset_foreground(fg: str) -> Selfset_background(bg: str) -> Selfset_color(fg: str, bg: str) -> Selfon_click(event) -> Selfset_font(font: str, size: int | None = None, bold: bool = False, italic: bool = False) -> Self
Properties:
text,fg,bg,font
Single-line text input.
Constructor:
InputEntry(default_prompt: str = "", default_value: str = "")
Methods:
set_value(value: str) -> Selfclear_value() -> Selfon_submit(event) -> Selfon_key_press(callback: Callable[[str], None]) -> Selfset_font(font: str, size: int | None = None, bold: bool = False, italic: bool = False) -> Self
Properties:
value,font
Password input field.
Constructor:
PasswordEntry(default_prompt: str = "Password: ", default_value: str = "")
Methods:
show_password() -> Selfhide_password() -> Selfon_submit(event) -> Selfset_font(font: str, size: int | None = None, bold: bool = False, italic: bool = False) -> Self
Properties:
value,font
Single-selection radio button.
Constructor:
RadioButton(text: str, fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_text(text: str) -> Selfset_checked(state: bool) -> Selfon_click(event) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
text,fg,bg,checked
Dropdown selector.
Constructor:
ComboBox(fg: str = "#ffffff", bg: str = "#000000")
Methods:
add_item(text: str) -> Selfadd_items(items: list[str]) -> Selfclear_items() -> Selfset_current_index(index: int) -> Selfon_selection_change(event) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
current_text,current_index,fg,bg
List selection widget.
Constructor:
ListWidget(fg: str = "#ffffff", bg: str = "#000000")
Methods:
add_item(text: str) -> Selfadd_items(items: list[str]) -> Selfclear_items() -> Selfremove_current_item() -> Selfset_current_index(index: int) -> Selfon_selection_change(event) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
current_text,current_index,fg,bg
Grid table widget.
Constructor:
Table(rows: int = 0, cols: int = 0, fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_headers(headers: list[str]) -> Selfset_item(row: int, col: int, text: str) -> Selfadd_row() -> Selfremove_row(row: int) -> Selfclear() -> Selfclear_all() -> Selfset_row_count(rows: int) -> Selfset_col_count(cols: int) -> Selfon_cell_click(event) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
row_count,col_count,current_row,current_col,fg,bg
Slider control.
Constructor:
Slider(min_val: int = 0, max_val: int = 100, fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_value(val: int) -> Selfset_range(min_val: int, max_val: int) -> Selfset_single_step(step: int) -> Selfset_page_step(step: int) -> Selfon_value_change(event) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
value,min_value,max_value,fg,bg
Progress bar.
Constructor:
Progress(fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_value(value: int) -> Selfset_range(min_val: int, max_val: int) -> Selfreset() -> Selfon_value_change(event) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
value,maximum,minimum,fg,bg
Multi-line text editor.
Constructor:
TextEdit(fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_text(text: str) -> Selfappend(text: str) -> Selfclear() -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
text,fg,bg
Basic drawing view.
Constructor:
Canvas(fg: str = "#ffffff", bg: str = "#222222")
Methods:
set_foreground(fg: str) -> Selfset_background(bg: str) -> Selfset_color(fg: str, bg: str) -> Selfmake_dot(x: float, y: float, size: float = 4) -> Selfmake_line(x1: float, y1: float, x2: float, y2: float) -> Selfmake_rect(x: float, y: float, w: float, h: float) -> Selfmake_circle(x: float, y: float, radius: float) -> Selfclear() -> Selfset_font(font: str) -> Self
Properties:
fg,bg
Image widget supporting raster and SVG images.
Constructor:
Picture(path: str)
Methods:
load_picture(path: str) -> Self
Properties:
is_svg
Video playback widget.
Constructor:
Video(path)
Methods:
play() -> Selfstop() -> Selfset_fullscreen(option: bool) -> Selfset_loop(option: bool) -> Self
Properties:
audio_output,player_object,is_playing
Startup splash widget.
Constructor:
SplashScreen(pixmap: QPixmap, fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_color(fg: str, bg: str) -> Selfset_foreground(fg: str) -> Selfset_background(bg: str) -> Selfshow_message(msg: str, align: int = 64) -> Selffinish(main_win: Any) -> Selfshow() -> Selfclose() -> Selfset_font(font: str) -> Self
Page(layout: BaseLayout)set_layout(layout: BaseLayout) -> Selfshow() -> Selfhide() -> Self
Interface(pages: list[Page])all_pages -> list[Page]set_active_page(idx: int) -> Self
Common layout base class.
Methods:
add_widget(widget: BaseWidget) -> Selfdelete_widget(widget: BaseWidget) -> Selfclear() -> Selfadd_layout(layout: BaseLayout) -> Selflock() -> Selfunlock() -> Self
Properties:
is_locked,native
add_stretch(stretch: int = 0) -> Selfadd_spacing(size: int) -> Selfset_common_spacing(size: int) -> Selfset_common_margin(size: int) -> Selfset_common_stretch(stretch: int) -> Self
add_stretch() -> Selfadd_spacing(size: int) -> Selfadd_margin(size: int) -> Selfset_common_spacing(size: int) -> Selfset_common_margin(size: int) -> Selfset_common_stretch(stretch: int) -> Self
add_stretch() -> Selfadd_spacing(size: int) -> Selfadd_margin(size: int) -> Selfset_common_spacing(size: int) -> Selfset_common_margin(size: int) -> Selfset_common_stretch(stretch: int) -> Self
add_widget(widget: BaseWidget, row: int = 0, column: int = 0, row_span: int = 1, column_span: int = 1) -> Selfadd_margin(size: int) -> Selfset_common_spacing(size: int) -> Selfset_common_margin(size: int) -> Self
add_widget(widget: BaseWidget, label: str = "") -> Selfadd_margin(size: int) -> Noneset_common_spacing(size: int) -> Noneset_common_margin(size: int) -> None
Base dialog window.
Methods:
show() -> Selfhide() -> Selfclose() -> Selfset_title(title: str) -> Selfset_content(content: str) -> Selfload_stylesheet(qss: str) -> Selflock() -> Selfunlock() -> Self
Properties:
is_locked,get_title,get_content,native
Standard message dialog.
Constructor:
MessageBox(title: str, content: str, icon: Icon = Icon.NoIcon, buttons: Button = Button.Ok)
Methods:
set_icon(icon: QMessageBox.Icon) -> Selfset_content(content: str) -> Selfset_info(info: str) -> Selfset_detail(detail: str) -> Selfon_click(event: Callable[[int], None])set_buttons(buttons: Button) -> Self
File selection dialog.
Constructor:
FileChooser(title: str)
Methods:
get_selections() -> list[str]set_default_dir(dir: str) -> None
Color selection dialog.
Constructor:
ColorPicker(title: str, content: str)
Methods:
get_color() -> str
Icon- imported fromPySide6.QtWidgets.QMessageBox.IconButton- imported fromPySide6.QtWidgets.QMessageBox.StandardButton
Color constants:
WHITE,BLACK,GRAY,RED,ORANGE,YELLOW,GREEN,CYAN,BLUE,PURPLE,PINKLIGHT_GRAY,LIGHT_RED,LIGHT_ORANGE,LIGHT_YELLOW,LIGHT_GREEN,LIGHT_CYAN,LIGHT_BLUE,LIGHT_PURPLE,LIGHT_PINKDARK_GRAY,DARK_RED,DARK_ORANGE,DARK_YELLOW,DARK_GREEN,DARK_CYAN,DARK_BLUE,DARK_PURPLE,DARK_PINK
Message box templates:
ASSERTION,ERROR,WARNING,SAVE_FILE,CANT_OPEN_FILE,FILE_NOT_FOUND,OVERWRITE_FILE,INFO,CONFIRM_EXIT,PERMISSION_DENIED
play_audio(file_path: str, *, sync: bool = False) -> None
Supported audio formats: .wav, .mp3
get_environment_variable(key: str, default: str | None = None) -> strset_clip(text: str, /, *, strip: bool = True, encoding: str = "utf-8", errors: str = "strict")get_clip() -> strget_user_root_dir() -> strsend_system_notification(title_: str, text_: str) -> None
sleep(second: float) -> None- non-blocking sleep using a daemon threadsleep_ms(millisecond: int) -> None- non-blocking sleep in milliseconds
get_latest_ver(pkg: str = "oh-my-gui") -> Optional[str]get_local_version() -> strcompare_ver(v1: str, v2: str) -> Literal[-1, 0, 1]is_latest_version() -> boolupgrade_ohmygui() -> bool
Console helper for colored output.
Constructor:
ConsoleIO(fg: int = 0xffffff, bg: int = 0x000000)
Methods:
hex2ansi(rgb: int, *, bg: bool = False, highlight: bool = False, bold: bool = False, italic: bool = False, underline: bool = False) -> strprint(text: str, *, fg: int | None = None, bg: int | None = None, highlight: bool = False, bold: bool = False, italic: bool = False, underline: bool = False, end: str = "\n") -> Selfinput(prompt: str, *, fg: int | None = None, bg: int | None = None, highlight: bool = False, bold: bool = False, italic: bool = False, underline: bool = False, callback: Callable[[str], None] | None = None) -> strmake_progress(prompt: str, total: int, curr: int) -> Self
Convert OML source into a QML string.
ohmygui.core.Applicationis a singleton. UseApp = ApplicationorApplication()to get the instance.- Use
Window.show()beforeApplication.run(). - Bind widgets directly with
bind_widget()or useset_layout()to apply a layout. Window.load_style_from()accepts QSS files for theming.Application.load_oml_from()/load_oml_string()can load OML source through the internal OML converter.set_item(row: int, col: int, text: str) -> Selfadd_row() -> Selfremove_row(row: int) -> Selfclear() -> Selfclear_all() -> Selfset_row_count(rows: int) -> Selfset_col_count(cols: int) -> Selfon_cell_click(event) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
row_count,col_count,current_row,current_col,fg,bg
Horizontal slider control.
Constructor:
Slider(min_val: int = 0, max_val: int = 100, fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_value(val: int) -> Selfset_range(min_val: int, max_val: int) -> Selfset_single_step(step: int) -> Selfset_page_step(step: int) -> Selfon_value_change(event) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
value,min_value,max_value,fg,bg
Progress bar.
Constructor:
Progress(fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_value(value: int) -> Selfset_range(min_val: int, max_val: int) -> Selfreset() -> Selfon_value_change(event) -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
value,maximum,minimum,fg,bg
Multi-line text editor.
Constructor:
TextEdit(fg: str = "#ffffff", bg: str = "#000000")
Methods:
set_text(text: str) -> Selfappend(text: str) -> Selfclear() -> Selfset_color(fg: str, bg: str) -> Selfset_font(font: str) -> Self
Properties:
text,fg,bg
Basic drawing view.
Constructor:
Canvas(fg: str = "#ffffff", bg: str = "#222222")
Methods:
set_foreground(fg: str) -> Noneset_background(bg: str) -> Noneset_color(fg: str, bg: str) -> Nonemake_dot(x: float, y: float, size: float = 4) -> Nonemake_line(x1: float, y1: float, x2: float, y2: float) -> Nonemake_rect(x: float, y: float, w: float, h: float) -> Nonemake_circle(x: float, y: float, radius: float) -> Noneclear() -> Noneset_font(font: str) -> None
Properties:
fg,bg
Event helper for callbacks.
Event(func: Callable)set_func(func: Callable)get_func -> Callable
Common layout base.
Methods:
add_widget(widget: BaseWidget) -> Nonedelete_widget(widget: BaseWidget) -> Noneclear() -> Noneadd_layout(layout: BaseLayout) -> Nonelock() -> Noneunlock() -> None
Properties:
is_locked,native
add_stretch() -> Noneadd_spacing(size: int) -> Noneadd_margin(size: int) -> Noneset_common_spacing(size: int) -> Noneset_common_margin(size: int) -> Noneset_common_stretch(stretch: int) -> None
add_stretch() -> Noneadd_spacing(size: int) -> Noneadd_margin(size: int) -> Noneset_common_spacing(size: int) -> Noneset_common_margin(size: int) -> Noneset_common_stretch(stretch: int) -> None
add_widget(widget: BaseWidget, row: int = 0, column: int = 0, row_span: int = 1, column_span: int = 1) -> Noneadd_margin(size: int) -> Noneset_common_spacing(size: int) -> Noneset_common_margin(size: int) -> None
add_widget(widget: BaseWidget, label: str = "") -> Noneadd_margin(size: int) -> Noneset_common_spacing(size: int) -> Noneset_common_margin(size: int) -> None
Base dialog window.
Methods:
show() -> Nonehide() -> Noneclose() -> Noneset_title(title: str) -> Noneset_content(content: str) -> Noneload_stylesheet(qss: str) -> Nonelock() -> Noneunlock() -> None
Properties:
is_locked,get_title,get_content,native
Standard message dialog.
Constructor:
MessageBox(title: str, content: str, icon: Icon = Icon.NoIcon, buttons: Button = Button.Ok)
Methods:
set_icon(icon: QMessageBox.Icon) -> Noneset_content(content: str) -> Noneset_info(info: str) -> Noneset_detail(detail: str) -> Noneon_click(event: Callable[[int], None])set_buttons(buttons: Button) -> None
File selection dialog.
Methods:
get_selections() -> list[str]
Color selection dialog.
Methods:
get_color() -> str
Enums imported from PySide6.QtWidgets.QMessageBox.
Color constants:
WHITE,BLACK,GRAY,RED,ORANGE,YELLOW,GREEN,CYAN,BLUE,PURPLE,PINK, plus light/dark variants.
Message box templates:
ASSERTION,ERROR,WARNING,SAVE_FILE,CANT_OPEN_FILE,OVERWRITE_FILE,INFO,CONFIRM_EXIT,PERMISSION_DENIED
play_audio(file_path: str, *, sync: bool = False) -> None
Supported formats: .wav, .mp3
sleep(second: float) -> Nonesleep_ms(millisecond: int) -> None
Console helper for colored output.
Constructor:
ConsoleIO(fg: int = 0xffffff, bg: int = 0x000000)
Methods:
hex2ansi(rgb: int, *, bg: bool = False, highlight: bool = False, bold: bool = False, italic: bool = False, underline: bool = False) -> strprint(text: str, *, fg: int | None = None, bg: int | None = None, highlight: bool = False, bold: bool = False, italic: bool = False, underline: bool = False, end: str = "\n") -> Selfinput(prompt: str, *, fg: int | None = None, bg: int | None = None, highlight: bool = False, bold: bool = False, italic: bool = False, underline: bool = False, callback: Callable[[str], None] | None = None) -> strmake_progress(prompt: str, total: int, curr: int) -> Self
ohmygui.core.Applicationis a singleton.- Use
Window.show()beforeApplication.run(). - Bind widgets directly with
bind_widget()or useset_layout()to apply a layout. Window.load_style_from()accepts QSS files for theming.