Skip to content

Commit

Permalink
Update directory selection to show currently selected location (Windo…
Browse files Browse the repository at this point in the history
…ws platforms) (#268)
  • Loading branch information
jmcoreymv authored Sep 10, 2023
1 parent 186ae0f commit d740af6
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions lumaviewpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import sys
import glob
from lvp_logger import logger
from tkinter import filedialog as tkinter_filedialog
from plyer import filechooser

if getattr(sys, 'frozen', False):
Expand Down Expand Up @@ -3302,17 +3303,48 @@ class FolderChooseBTN(Button):
selection = ListProperty([])

def choose(self, context):
logger.info('[LVP Main ] FolderChooseBTN.choose()')
logger.info(f'[LVP Main ] FolderChooseBTN.choose({context})')
self.context = context
filechooser.choose_dir(on_selection=self.handle_selection)
logger.info(f"Settings: {settings}")

# Show previously selected/default folder
selected_path = None
if (context == 'live_folder') and ('live_folder' in settings):
selected_path = settings['live_folder']
elif context in settings:
selected_path = settings[context]['save_folder']

# Note: Could likely use tkinter filedialog for all platforms
# but needs testing on Mac/Linux first
if sys.platform != 'win32':
filechooser.choose_dir(
on_selection=self.handle_selection
# path=selected_path
)
return

else:
# Tested for Windows platforms
selection = tkinter_filedialog.askdirectory(
initialdir=selected_path
)

# Nothing selected/cancel
if selection == '':
return

self.handle_selection(selection=[selection])


def handle_selection(self, selection):
logger.info('[LVP Main ] FolderChooseBTN.handle_selection()')
if selection:
self.selection = selection
self.on_selection_function()


def on_selection_function(self, *a, **k):
global settings
logger.info('[LVP Main ] FolderChooseBTN.on_selection_function()')
if self.selection:
path = self.selection[0]
Expand Down

0 comments on commit d740af6

Please sign in to comment.