Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions plyer/platforms/android/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,19 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.select_code = randint(123456, 654321)
self.selection = None
self._handle_selection = None

# bind a function for a response from filechooser activity
activity.bind(on_activity_result=self._on_activity_result)

@staticmethod
def _handle_selection(selection):
'''
Dummy placeholder for returning selection from
``android.app.Activity.onActivityResult()``.

.. versionadded:: 1.4.0
'''
return selection

def _open_file(self, **kwargs):
'''
Running Android Activity is non-blocking and the only call
that blocks is onActivityResult running in GUI thread

.. versionadded:: 1.4.0
'''

# set up selection handler
# startActivityForResult is async
# onActivityResult is sync
self._handle_selection = kwargs.pop(
'on_selection', self._handle_selection
)
self._handle_selection = kwargs.pop("on_selection")

# create Intent for opening
file_intent = Intent(Intent.ACTION_GET_CONTENT)
Expand Down
11 changes: 1 addition & 10 deletions plyer/platforms/linux/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,12 @@ class SubprocessFileChooser:
show_hidden = False

def __init__(self, *args, **kwargs):
self._handle_selection = kwargs.pop(
'on_selection', self._handle_selection
)
self._handle_selection = kwargs.pop("on_selection")

# Simulate Kivy's behavior
for i in kwargs:
setattr(self, i, kwargs[i])

@staticmethod
def _handle_selection(selection):
'''
Dummy placeholder for returning selection from chooser.
'''
return selection

_process = None

def _run_command(self, cmd):
Expand Down
11 changes: 1 addition & 10 deletions plyer/platforms/macosx/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,12 @@ class MacFileChooser:
use_extensions = False

def __init__(self, *args, **kwargs):
self._handle_selection = kwargs.pop(
'on_selection', self._handle_selection
)
self._handle_selection = kwargs.pop("on_selection")

# Simulate Kivy's behavior
for i in kwargs:
setattr(self, i, kwargs[i])

@staticmethod
def _handle_selection(selection):
'''
Dummy placeholder for returning selection from chooser.
'''
return selection

def run(self):
panel = None
if self.mode in ("open", "dir"):
Expand Down
11 changes: 1 addition & 10 deletions plyer/platforms/win/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,12 @@ class Win32FileChooser:
show_hidden = False

def __init__(self, *args, **kwargs):
self._handle_selection = kwargs.pop(
'on_selection', self._handle_selection
)
self._handle_selection = kwargs.pop("on_selection")

# Simulate Kivy's behavior
for i in kwargs:
setattr(self, i, kwargs[i])

@staticmethod
def _handle_selection(selection):
'''
Dummy placeholder for returning selection from chooser.
'''
return selection

def run(self):
self.selection = []
try:
Expand Down