Mercurial > libervia-desktop-kivy
comparison src/cagou/core/xmlui.py @ 99:f67b9baa81f0
xmlui: FileDialog first draft
implemented a basic file dialog. Really basic and ugly, need improvments!
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 29 Dec 2016 23:47:13 +0100 |
parents | a766c278b640 |
children | b6e6afb0dc46 |
comparison
equal
deleted
inserted
replaced
98:4d8c122b86a6 | 99:f67b9baa81f0 |
---|---|
21 from .constants import Const as C | 21 from .constants import Const as C |
22 from sat.core.log import getLogger | 22 from sat.core.log import getLogger |
23 log = getLogger(__name__) | 23 log = getLogger(__name__) |
24 from sat_frontends.tools import xmlui | 24 from sat_frontends.tools import xmlui |
25 from kivy.uix.scrollview import ScrollView | 25 from kivy.uix.scrollview import ScrollView |
26 from kivy.uix.boxlayout import BoxLayout | |
26 from kivy.uix.gridlayout import GridLayout | 27 from kivy.uix.gridlayout import GridLayout |
27 from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem | 28 from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem |
28 from kivy.uix.textinput import TextInput | 29 from kivy.uix.textinput import TextInput |
29 from kivy.uix.label import Label | 30 from kivy.uix.label import Label |
30 from kivy.uix.button import Button | 31 from kivy.uix.button import Button |
410 xmlui.NoteDialog.__init__(self, _xmlui_parent) | 411 xmlui.NoteDialog.__init__(self, _xmlui_parent) |
411 self.title, self.message, self.level = title, message, level | 412 self.title, self.message, self.level = title, message, level |
412 | 413 |
413 def _xmluiShow(self): | 414 def _xmluiShow(self): |
414 G.host.addNote(self.title, self.message, self.level) | 415 G.host.addNote(self.title, self.message, self.level) |
416 | |
417 | |
418 class FileDialog(xmlui.FileDialog, BoxLayout): | |
419 message = properties.ObjectProperty() | |
420 | |
421 def __init__(self, _xmlui_parent, title, message, level, filetype): | |
422 xmlui.FileDialog.__init__(self, _xmlui_parent) | |
423 BoxLayout.__init__(self) | |
424 self.message.text = message | |
425 if filetype == C.XMLUI_DATA_FILETYPE_DIR: | |
426 self.file_chooser.dirselect = True | |
427 | |
428 def _xmluiShow(self): | |
429 G.host.addNotifUI(self) | |
430 | |
431 def _xmluiClose(self): | |
432 # FIXME: notif UI is not removed if dialog is not shown yet | |
433 G.host.closeUI() | |
434 | |
435 def onSelect(self, path): | |
436 try: | |
437 path = path[0] | |
438 except IndexError: | |
439 path = None | |
440 if not path: | |
441 self._xmluiCancelled() | |
442 else: | |
443 self._xmluiValidated({'path': path}) | |
444 | |
445 def show(self, *args, **kwargs): | |
446 assert kwargs["force"] | |
447 G.host.showUI(self) | |
415 | 448 |
416 | 449 |
417 ## Factory ## | 450 ## Factory ## |
418 | 451 |
419 | 452 |