pyloid 0.14.0__tar.gz → 0.14.1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyloid
3
- Version: 0.14.0
3
+ Version: 0.14.1
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyloid"
3
- version = "0.14.0"
3
+ version = "0.14.1"
4
4
  description = ""
5
5
  authors = ["aesthetics-of-record <111675679+aesthetics-of-record@users.noreply.github.com>"]
6
6
  readme = "README.md"
@@ -4,6 +4,7 @@ from PySide6.QtWidgets import (
4
4
  QApplication,
5
5
  QSystemTrayIcon,
6
6
  QMenu,
7
+ QFileDialog,
7
8
  )
8
9
  from PySide6.QtGui import (
9
10
  QIcon,
@@ -1240,3 +1241,83 @@ class Pyloid(QApplication):
1240
1241
  """
1241
1242
  self.file_watcher.directory_changed.connect(callback)
1242
1243
 
1244
+ ###########################################################################################
1245
+ # File dialog
1246
+ ###########################################################################################
1247
+ def open_file_dialog(self, dir: Optional[str] = None, filter: Optional[str] = None) -> Optional[str]:
1248
+ """
1249
+ Opens a file dialog to select a file to open.
1250
+
1251
+ Parameters
1252
+ ----------
1253
+ dir : str, optional
1254
+ The initial directory that the dialog will open in. If None, the dialog will open in the current working directory.
1255
+ filter : str, optional
1256
+ A string that specifies the file types that can be selected. For example, "Text Files (*.txt);;All Files (*)".
1257
+
1258
+ Returns
1259
+ -------
1260
+ Optional[str]
1261
+ The path of the selected file. Returns None if no file is selected.
1262
+
1263
+ Examples
1264
+ --------
1265
+ >>> app = Pyloid(app_name="Pyloid-App")
1266
+ >>> file_path = app.open_file_dialog(dir="/home/user", filter="Text Files (*.txt)")
1267
+ >>> if file_path:
1268
+ >>> print("Selected file:", file_path)
1269
+ """
1270
+ file_path, _ = QFileDialog.getOpenFileName(None, dir=dir, filter=filter)
1271
+ return file_path if file_path else None
1272
+
1273
+ def save_file_dialog(self, dir: Optional[str] = None, filter: Optional[str] = None) -> Optional[str]:
1274
+ """
1275
+ Opens a file dialog to select a file to save.
1276
+
1277
+ Parameters
1278
+ ----------
1279
+ dir : str, optional
1280
+ The initial directory that the dialog will open in. If None, the dialog will open in the current working directory.
1281
+ filter : str, optional
1282
+ A string that specifies the file types that can be saved. For example, "Text Files (*.txt);;All Files (*)".
1283
+
1284
+ Returns
1285
+ -------
1286
+ Optional[str]
1287
+ The path of the selected file. Returns None if no file is selected.
1288
+
1289
+ Examples
1290
+ --------
1291
+ >>> app = Pyloid(app_name="Pyloid-App")
1292
+ >>> file_path = app.save_file_dialog(dir="/home/user", filter="Text Files (*.txt)")
1293
+ >>> if file_path:
1294
+ >>> print("File will be saved to:", file_path)
1295
+ """
1296
+ file_path, _ = QFileDialog.getSaveFileName(None, dir=dir, filter=filter)
1297
+ return file_path if file_path else None
1298
+
1299
+ def select_directory_dialog(self, dir: Optional[str] = None) -> Optional[str]:
1300
+ """
1301
+ Opens a dialog to select a directory.
1302
+
1303
+ Parameters
1304
+ ----------
1305
+ dir : str, optional
1306
+ The initial directory that the dialog will open in. If None, the dialog will open in the current working directory.
1307
+
1308
+ Returns
1309
+ -------
1310
+ Optional[str]
1311
+ The path of the selected directory. Returns None if no directory is selected.
1312
+
1313
+ Examples
1314
+ --------
1315
+ >>> app = Pyloid(app_name="Pyloid-App")
1316
+ >>> directory_path = app.select_directory_dialog(dir="/home/user")
1317
+ >>> if directory_path:
1318
+ >>> print("Selected directory:", directory_path)
1319
+ """
1320
+ directory_path = QFileDialog.getExistingDirectory(None, dir=dir)
1321
+ return directory_path if directory_path else None
1322
+
1323
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes