BrowserWindow
The BrowserWindow class is designed to manage browser windows within a pyloid application
The BrowserWindow object is created through the create_window method of the Pyloid class
Window Content
load_file
Loads a local HTML file into the web view.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.load_file("path/to/index.html")
Parameters
Prop
Type
Returns
None
load_url
Sets the URL of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.load_url("https://example.com")
Parameters
Prop
Type
Returns
None
load_html
Loads HTML content directly into the web view.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
html_content = "<html><body><h1>Hello Pyloid!</h1></body></html>"
window.load_html(html_content)
Parameters
Prop
Type
Returns
None
Window Properties
set_title
Sets the title of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_title("New Title")
Parameters
Prop
Type
Returns
None
set_size
Sets the size of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_size(800, 600)
Parameters
Prop
Type
Returns
None
set_position
Sets the position of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_position(100, 100)
Parameters
Prop
Type
Returns
None
set_position_by_anchor
Positions the window at a specific location on the screen.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_position_by_anchor("center")
Parameters
Prop
Type
Returns
None
set_frame
Sets the frame of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_frame(True)
Parameters
Prop
Type
Returns
None
set_context_menu
Sets the context menu of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_context_menu(True)
Parameters
Prop
Type
Returns
None
set_dev_tools
Sets the developer tools of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_dev_tools(True)
Parameters
Prop
Type
Returns
None
open_dev_tools
Opens the developer tools window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.open_dev_tools()
Returns
None
get_window_properties
Returns the properties of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
properties = window.get_window_properties()
print(properties)
Returns
dict
A dictionary containing the window properties.get_id
Returns the ID of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window_id = window.get_id()
print(window_id)
Returns
str
The window ID.get_transparent
Returns the transparency state of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
is_transparent = window.get_transparent()
print(f"Is transparent: {is_transparent}")
Returns
bool
True if the window is set to be transparent, False otherwise.get_size
Returns the size of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
size = window.get_size()
print(f"Size: {size['width']}x{size['height']}")
Returns
Dict[str, int]
Dictionary containing the width and height of the window with keys 'width' and 'height'.get_position
Returns the position of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
position = window.get_position()
print(f"Position: ({position['x']}, {position['y']})")
Returns
Dict[str, int]
Dictionary containing the x and y coordinates of the window with keys 'x' and 'y'.get_title
Returns the title of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
title = window.get_title()
print(f"Title: {title}")
Returns
str
The title of the window.get_url
Returns the URL of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
url = window.get_url()
print(f"URL: {url}")
Returns
str
The URL currently loaded in the window.get_visible
Returns the visibility of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
is_visible = window.get_visible()
print(f"Is visible: {is_visible}")
Returns
bool
True if the window is visible, False otherwise.get_frame
Returns the frame enabled state of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
has_frame = window.get_frame()
print(f"Has frame: {has_frame}")
Returns
bool
True if the window has a frame, False otherwise.Window Visibility
hide
Hides the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.hide()
Returns
None
show
Shows the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.show()
Returns
None
focus
Focuses the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.focus()
Returns
None
show_and_focus
Shows and focuses the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.show_and_focus()
Returns
None
close
Closes the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.close()
Returns
None
Window State
toggle_fullscreen
Toggles the fullscreen mode of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.toggle_fullscreen()
Returns
None
minimize
Minimizes the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.minimize()
Returns
None
maximize
Maximizes the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.maximize()
Returns
None
unmaximize
Restores the window from maximized state.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.unmaximize()
Returns
None
fullscreen
Enters fullscreen mode.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.fullscreen()
Returns
None
toggle_maximize
Toggles the maximized state of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.toggle_maximize()
Returns
None
is_fullscreen
Returns True if the window is fullscreen.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
is_fullscreen = window.is_fullscreen()
print(f"Is fullscreen: {is_fullscreen}")
Returns
bool
True if the window is in fullscreen mode, False otherwise.is_maximized
Returns True if the window is maximized.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
is_maximized = window.is_maximized()
print(f"Is maximized: {is_maximized}")
Returns
bool
True if the window is maximized, False otherwise.Window Capture
capture
Captures the current window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
image_path = window.capture("screenshot.png")
Parameters
Prop
Type
Returns
Optional[str]
Path to the saved image or None if failed.Keyboard Shortcuts
add_shortcut
Adds a keyboard shortcut to the window if it does not already exist.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
def on_shortcut():
print("Shortcut pressed!")
shortcut = window.add_shortcut("Ctrl+C", on_shortcut)
Parameters
Prop
Type
Returns
QShortcut
The created QShortcut object.remove_shortcut
Removes a keyboard shortcut from the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.remove_shortcut("Ctrl+C")
Parameters
Prop
Type
Returns
None
get_all_shortcuts
Returns all registered shortcuts in the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
shortcuts = window.get_all_shortcuts()
print(shortcuts)
Returns
dict
A dictionary containing shortcut sequences and their QShortcut objects.Events
invoke
Invokes an event to the JavaScript side. Event
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.invoke("customEvent", {"message": "Hello, Pyloid!"})
Parameters
Prop
Type
Returns
None
Window Resizing
set_resizable
Sets whether the window can be resized by the user.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_resizable(True)
Parameters
Prop
Type
Returns
None
set_minimum_size
Sets the minimum size of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_minimum_size(400, 300)
Parameters
Prop
Type
Returns
None
set_maximum_size
Sets the maximum size of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
window.set_maximum_size(1024, 768)
Parameters
Prop
Type
Returns
None
get_minimum_size
Returns the minimum size of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
min_size = window.get_minimum_size()
print(f"Minimum size: {min_size['width']}x{min_size['height']}")
Returns
Dict[str, int]
Dictionary containing the minimum width and height of the window with keys 'width' and 'height'.get_maximum_size
Returns the maximum size of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
max_size = window.get_maximum_size()
print(f"Maximum size: {max_size['width']}x{max_size['height']}")
Returns
Dict[str, int]
Dictionary containing the maximum width and height of the window with keys 'width' and 'height'.get_resizable
Returns the resizability of the window.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
is_resizable = window.get_resizable()
print(f"Is resizable: {is_resizable}")
Returns
bool
True if the window is resizable, False otherwise.Splash Screen
Provides splash screen functionality displayed during application loading. Supports both static images and animated GIFs with customizable positioning and behavior.
set_static_image_splash_screen
Displays a static image as a splash screen during window loading. The splash screen automatically positions itself and can be configured to close on page load or stay visible until manually closed.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
########## Usage ##########
# Basic usage with default settings
window.set_static_image_splash_screen("assets/loading.png")
# Advanced configuration
window.set_static_image_splash_screen(
image_path="assets/loading.png",
close_on_load=True,
stay_on_top=True,
clickable=True,
position="center"
)
Parameters
Prop
Type
Returns
None
set_gif_splash_screen
Displays an animated GIF as a splash screen during window loading. Provides visual feedback during long loading operations with smooth animations and customizable display options.
from pyloid import Pyloid
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
########## Usage ##########
# Basic usage with default settings
window.set_gif_splash_screen("assets/loading.gif")
# Advanced configuration for loading screens
window.set_gif_splash_screen(
gif_path="assets/loading.gif",
close_on_load=True,
stay_on_top=True,
clickable=True,
position="center"
)
Parameters
Prop
Type
Returns
None
close_splash_screen
Manually closes the splash screen if it is currently displayed. Useful when you want to control the timing of splash screen dismissal independently of page load events.
from pyloid import Pyloid
from pyloid.timer import PyloidTimer
app = Pyloid(app_name="MyApp", single_instance=True)
window = app.create_window(title="My Window")
########## Usage ##########
# Manual closure after specific operations
window.set_static_image_splash_screen("assets/loading.png")
# Close splash screen and show main window after 3 seconds
timer_manager = PyloidTimer()
timer_manager.start_single_shot_timer(3000, lambda: (
window.close_splash_screen(),
window.show_and_focus()
))
# Or close immediately when ready
window.close_splash_screen()
Returns
None