Mercurial > libervia-desktop-kivy
comparison cagou/plugins/plugin_transfer_file.py @ 491:203755bbe0fe
massive refactoring from camelCase -> snake_case. See backend commit log for more details
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:44:32 +0200 |
parents | 3c9ba4a694ef |
children |
comparison
equal
deleted
inserted
replaced
490:962d17c4078c | 491:203755bbe0fe |
---|---|
56 self.default_path = storagepath.get_downloads_dir() | 56 self.default_path = storagepath.get_downloads_dir() |
57 | 57 |
58 super(FileTransmitter, self).__init__(*args, **kwargs) | 58 super(FileTransmitter, self).__init__(*args, **kwargs) |
59 | 59 |
60 if self.native_filechooser: | 60 if self.native_filechooser: |
61 thread = threading.Thread(target=self._nativeFileChooser) | 61 thread = threading.Thread(target=self._native_file_chooser) |
62 thread.start() | 62 thread.start() |
63 else: | 63 else: |
64 self.add_widget(FileChooserBox(default_path = self.default_path, | 64 self.add_widget(FileChooserBox(default_path = self.default_path, |
65 callback=self.onFiles, | 65 callback=self.on_files, |
66 cancel_cb=partial(self.cancel_cb, self))) | 66 cancel_cb=partial(self.cancel_cb, self))) |
67 | 67 |
68 def _nativeFileChooser(self, *args, **kwargs): | 68 def _native_file_chooser(self, *args, **kwargs): |
69 title=_("Please select a file to upload") | 69 title=_("Please select a file to upload") |
70 files = filechooser.open_file(title=title, | 70 files = filechooser.open_file(title=title, |
71 path=self.default_path, | 71 path=self.default_path, |
72 multiple=False, | 72 multiple=False, |
73 preview=True) | 73 preview=True) |
74 # we want to leave the thread when calling onFiles, so we use Clock | 74 # we want to leave the thread when calling on_files, so we use Clock |
75 Clock.schedule_once(lambda *args: self.onFiles(files=files), 0) | 75 Clock.schedule_once(lambda *args: self.on_files(files=files), 0) |
76 | 76 |
77 def onFiles(self, files): | 77 def on_files(self, files): |
78 if files: | 78 if files: |
79 self.callback(files[0]) | 79 self.callback(files[0]) |
80 else: | 80 else: |
81 self.cancel_cb(self) | 81 self.cancel_cb(self) |