BrowserWindow
Overview
The BrowserWindow class is designed to manage browser windows within a Pyloid application. It extends PySide6's QMainWindow to provide additional functionality for creating and managing browser windows.
Constructor
Initializes a BrowserWindow object.
Parameters:
app
: Pyloid instancetitle
(str): Window title (default: "pylon app")width
(int): Window width (default: 800)height
(int): Window height (default: 600)x
(int): Window x-coordinate (default: 200)y
(int): Window y-coordinate (default: 200)frame
(bool): Whether to show window frame (default: True)context_menu
(bool): Whether to enable context menu (default: False)dev_tools
(bool): Whether to enable developer tools (default: False)js_apis
(List[PyloidAPI]): List of JavaScript APIs to add (default: [])
Methods
Loads a local HTML file into the web view.
Parameters:
file_path
(str): Path to the HTML file to load
Loads the specified URL into the window.
Parameters:
url
(str): URL to load
Sets the title of the window.
Parameters:
title
(str): New window title
Sets the size of the window.
Parameters:
width
(int): New window widthheight
(int): New window height
Sets the position of the window.
Parameters:
x
(int): New x-coordinatey
(int): New y-coordinate
Sets whether to show the window frame.
Parameters:
frame
(bool): Whether to show the frame
Sets whether to enable the context menu.
Parameters:
context_menu
(bool): Whether to enable the context menu
Sets whether to enable developer tools.
Parameters:
enable
(bool): Whether to enable developer tools
Opens the developer tools window.
Returns the properties of the window.
Returns: dict: A dictionary containing the window properties
Returns the ID of the window.
Returns: str: The window ID
Hides the window.
Shows the window.
Gives focus to the window.
Shows the window and gives it focus.
Closes the window.
Toggles fullscreen mode.
Minimizes the window.
Maximizes the window.
Restores the window to its previous size.
Captures the current window.
Parameters:
save_path
(str): Path to save the captured image
Returns:
Optional[str]: Path to the saved image or None if failed
Adds a keyboard shortcut to the window.
Parameters:
key_sequence
(str): Shortcut key sequence (e.g., "Ctrl+C")callback
(Callable): Function to execute when the shortcut is pressed
Returns:
QShortcut: The created QShortcut object
Removes a keyboard shortcut from the window.
Parameters:
key_sequence
(str): Shortcut key sequence to remove
Returns all shortcuts registered to the window.
Returns:
dict: A dictionary containing shortcut sequences and their QShortcut objects
Emits an event to the JavaScript side.
Parameters:
event_name
(str): Name of the eventdata
(Optional[Dict]): Data to be sent with the event (default: None)
Last updated