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
  • Method Descriptions
  • open_file_dialog
  • save_file_dialog
  • select_directory_dialog
  • Note

Was this helpful?

Edit on GitHub
  1. Guides

File Dialog

Overview

This document explains how to open a file dialog and select files or directories. This functionality is implemented using PySide's QFileDialog class. This document covers three methods: open_file_dialog, save_file_dialog, and select_directory_dialog.

Method Descriptions

open_file_dialog

Opens a dialog to open a file.

Parameters

  • dir (str, optional): The directory where the dialog will initially open. Default is the current working directory.

  • filter (str, optional): A string specifying the selectable file types. For example, it can be used like "Text Files (*.txt);;All Files (*)".

Return Value

  • Optional[str]: Returns the path of the selected file. Returns None if no file is selected.

Example

app = Pyloid(app_name="Pyloid-App")
file_path = app.open_file_dialog(dir="/home/user", filter="Text Files (*.txt)")
if file_path:
    print("Selected file:", file_path)

save_file_dialog

Opens a dialog to save a file.

Parameters

  • dir (str, optional): The directory where the dialog will initially open. Default is the current working directory.

  • filter (str, optional): A string specifying the savable file types. For example, it can be used like "Text Files (*.txt);;All Files (*)".

Return Value

  • Optional[str]: Returns the path of the selected file. Returns None if no file is selected.

Example

app = Pyloid(app_name="Pyloid-App")
file_path = app.save_file_dialog(dir="/home/user", filter="Text Files (*.txt)")
if file_path:
    print("File will be saved to:", file_path)

select_directory_dialog

Opens a dialog to select a directory.

Parameters

  • dir (str, optional): The directory where the dialog will initially open. Default is the current working directory.

Return Value

  • Optional[str]: Returns the path of the selected directory. Returns None if no directory is selected.

Example

app = Pyloid(app_name="Pyloid-App")
directory_path = app.select_directory_dialog(dir="/home/user")
if directory_path:
    print("Selected directory:", directory_path)

Note

These methods are implemented using PySide6's QFileDialog class. PyQt is a binding that allows the use of the Qt library in Python. QFileDialog provides standard dialogs for selecting files and directories.

PreviousDesktop MonitorNextSplash Screen

Last updated 6 months ago

Was this helpful?