Pyloid Docs
GithubLanguage
  • 💎What is Pyloid?
  • Getting Started
    • Prerequisites
    • Create Pyloid App
  • Core Concepts
    • Thread Safety
  • API
    • Python (Backend)
      • Pyloid
      • BrowserWindow
      • Monitor
      • TrayEvent
      • Utility Functions
      • RPC
      • Store
    • Javascript (Frontend)
      • Event
      • BaseAPI
      • RPC
  • Guides
    • Load Webview
    • Serve Frontend
    • Calling Python from JS
    • Calling JS from Python
    • Keyboard Shotcuts
    • Notification
    • Tray
    • Timer
    • File Watcher
    • Clipboard
    • Window Position
    • Devtools
    • Window Drag Region
    • Window Radius And Transparent
    • Autostart
    • Production Utils
    • Desktop Monitor
    • File Dialog
    • Splash Screen
Powered by GitBook
On this page
  • Overview
  • Methods

Was this helpful?

Edit on GitHub
  1. API
  2. Python (Backend)

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.

The BrowserWindow object is created through the create_window method of the Pyloid class.

Methods

def load_file(self, file_path: str) -> None:

Loads a local HTML file into the web view.

  • Parameters:

    • file_path (str): Path to the HTML file to load

def load_url(self, url: str) -> None:

Loads the specified URL into the window.

  • Parameters:

    • url (str): URL to load

def set_title(self, title: str) -> None:

Sets the title of the window.

  • Parameters:

    • title (str): New window title

def set_size(self, width: int, height: int) -> None:

Sets the size of the window.

  • Parameters:

    • width (int): New window width

    • height (int): New window height

def set_position(self, x: int, y: int) -> None:

Sets the position of the window.

  • Parameters:

    • x (int): New x-coordinate

    • y (int): New y-coordinate

def set_frame(self, frame: bool) -> None:

Sets whether to show the window frame.

  • Parameters:

    • frame (bool): Whether to show the frame

def set_context_menu(self, context_menu: bool) -> None:

Sets whether to enable the context menu.

  • Parameters:

    • context_menu (bool): Whether to enable the context menu

def set_dev_tools(self, enable: bool) -> None:

Sets whether to enable developer tools.

  • Parameters:

    • enable (bool): Whether to enable developer tools

def open_dev_tools(self) -> None:

Opens the developer tools window.

def get_window_properties(self) -> dict:

Returns the properties of the window.

  • Returns: dict: A dictionary containing the window properties

def get_id(self) -> str:

Returns the ID of the window.

  • Returns: str: The window ID

def hide(self) -> None:

Hides the window.

def show(self) -> None:

Shows the window.

def focus(self) -> None:

Gives focus to the window.

def show_and_focus(self) -> None:

Shows the window and gives it focus.

def close(self) -> None:

Closes the window.

def toggle_fullscreen(self) -> None:

Toggles fullscreen mode.

def minimize(self) -> None:

Minimizes the window.

def maximize(self) -> None:

Maximizes the window.

def unmaximize(self) -> None:

Restores the window to its previous size.

def capture(self, save_path: str) -> Optional[str]:

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

def add_shortcut(self, key_sequence: str, callback: Callable) -> QShortcut:

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

def remove_shortcut(self, key_sequence: str) -> None:

Removes a keyboard shortcut from the window.

  • Parameters:

    • key_sequence (str): Shortcut key sequence to remove

def get_all_shortcuts(self) -> dict:

Returns all shortcuts registered to the window.

  • Returns:

    • dict: A dictionary containing shortcut sequences and their QShortcut objects

def invoke(self, event_name: str, data: Optional[Dict] = None) -> None:

Invokes an event to the JavaScript side.

  • Parameters:

    • event_name (str): Name of the event

    • data (dict, optional): Data to be sent with the event (default is None)

  • Examples:

    • (Python)

      app = Pyloid(app_name="Pyloid-App")
      window = app.create_window("pyloid-window")
      window.invoke("customEvent", {"message": "Hello, Pyloid!"})
    • (JavaScript)

      import { event } from 'pyloid-js';
      
      event.listen('customEvent', (data) => {
          console.log(data.message);
      });
PreviousPyloidNextMonitor

Last updated 29 days ago

Was this helpful?