Skip to content

Commit

Permalink
Use Zenity to handle file selection
Browse files Browse the repository at this point in the history
Should solve #3 provided that zenity is installed
  • Loading branch information
redromnon committed May 19, 2024
1 parent 0fdafa4 commit bd1465b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from ui.encrypt import Encrypt
from ui.operations import Operation
import pymobiledevice3.lockdown, pymobiledevice3.exceptions, pymobiledevice3.services.mobilebackup2
import subprocess

class App(ft.UserControl):

Expand All @@ -26,17 +27,15 @@ def build(self):

self.error_message_dlg = ft.SnackBar(content=None)

#Folder
self.folder_picker = ft.FilePicker(on_result=self.folder_dialog_result)

#Folder
self.display_folderpath = ft.TextField(
hint_text="Select folder icon", width=400, read_only=True, border="none",
filled=True, max_lines=3, color=ft.colors.WHITE70
)

self.select_folder_icon = ft.IconButton(
icon=ft.icons.FOLDER_ROUNDED, tooltip="Select folder location",
icon_size=36, on_click=lambda e: self.folder_picker.get_directory_path(),
icon_size=36, on_click=self.select_folder,
icon_color=ft.colors.WHITE70
)

Expand All @@ -61,7 +60,7 @@ def build(self):

#UI component groups
self.folder_container = ft.Row(
[self.display_folderpath, self.select_folder_icon, self.folder_picker],
[self.display_folderpath, self.select_folder_icon],
spacing=10, alignment="center"
)

Expand All @@ -88,10 +87,16 @@ def build(self):



#Display folder path in textfield and enable options
def folder_dialog_result(self, e: ft.FilePickerResultEvent):
#Handle folder picker and display folder path
def select_folder(self, e):

self.display_folderpath.value = e.path
res = subprocess.run(
['zenity --file-selection --title="Choose backup folder" --directory'],
shell=True,
#stdout=subprocess.PIPE,
capture_output=True
)
self.display_folderpath.value = res.stdout.decode().strip()

self.update()

Expand Down

0 comments on commit bd1465b

Please sign in to comment.