pyloid 0.14.0__py3-none-any.whl → 0.14.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyloid/pyloid.py CHANGED
@@ -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
+
@@ -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
@@ -7,11 +7,11 @@ pyloid/filewatcher.py,sha256=3M5zWVUf1OhlkWJcDFC8ZA9agO4Q-U8WdgGpy6kaVz0,4601
7
7
  pyloid/js_api/event_api.py,sha256=_52yyBonqecmMvJpFW7OMNi_jX8Nrteqw_kI6r-DGG0,951
8
8
  pyloid/js_api/window_api.py,sha256=JDAFIMMiw75PNcyO8_163PJdRY-dvFNBO3IN0TA-Xsw,5383
9
9
  pyloid/monitor.py,sha256=nmcoOmlHeTysrZVT5mmL92ASbqMg8aH-hQg35qKWi0M,27540
10
- pyloid/pyloid.py,sha256=e_5G4wdkhZchPiwgydo2w5IIIpj-ZP8ge4ZQp9lmcXs,37889
10
+ pyloid/pyloid.py,sha256=3YymePkpM_hKPzvHSSgELuSHkmbDsKW60HnRwwBMY7A,41178
11
11
  pyloid/timer.py,sha256=RqMsChFUd93cxMVgkHWiIKrci0QDTBgJSTULnAtYT8M,8712
12
12
  pyloid/tray.py,sha256=D12opVEc2wc2T4tK9epaN1oOdeziScsIVNM2uCN7C-A,1710
13
13
  pyloid/utils.py,sha256=VGZE2liY8_AElEqxVe1YLbk3fWlcAevpRc6oOTTgi-U,1927
14
- pyloid-0.14.0.dist-info/LICENSE,sha256=F96EzotgWhhpnQTW2TcdoqrMDir1jyEo6H915tGQ-QE,11524
15
- pyloid-0.14.0.dist-info/METADATA,sha256=QhNFQVNOyvDMqwD2QIz4RMpdxP_QUWkimmLaUsPO_jE,3634
16
- pyloid-0.14.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
17
- pyloid-0.14.0.dist-info/RECORD,,
14
+ pyloid-0.14.1.dist-info/LICENSE,sha256=F96EzotgWhhpnQTW2TcdoqrMDir1jyEo6H915tGQ-QE,11524
15
+ pyloid-0.14.1.dist-info/METADATA,sha256=eyeeXrbtl3ramdS7Lha7bbo0y77tGFt_WGF4luLyzhs,3634
16
+ pyloid-0.14.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
17
+ pyloid-0.14.1.dist-info/RECORD,,