Mercurial > libervia-desktop-kivy
diff 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 |
line wrap: on
line diff
--- a/src/cagou/core/xmlui.py Thu Dec 29 23:47:10 2016 +0100 +++ b/src/cagou/core/xmlui.py Thu Dec 29 23:47:13 2016 +0100 @@ -23,6 +23,7 @@ log = getLogger(__name__) from sat_frontends.tools import xmlui from kivy.uix.scrollview import ScrollView +from kivy.uix.boxlayout import BoxLayout from kivy.uix.gridlayout import GridLayout from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem from kivy.uix.textinput import TextInput @@ -414,6 +415,38 @@ G.host.addNote(self.title, self.message, self.level) +class FileDialog(xmlui.FileDialog, BoxLayout): + message = properties.ObjectProperty() + + def __init__(self, _xmlui_parent, title, message, level, filetype): + xmlui.FileDialog.__init__(self, _xmlui_parent) + BoxLayout.__init__(self) + self.message.text = message + if filetype == C.XMLUI_DATA_FILETYPE_DIR: + self.file_chooser.dirselect = True + + def _xmluiShow(self): + G.host.addNotifUI(self) + + def _xmluiClose(self): + # FIXME: notif UI is not removed if dialog is not shown yet + G.host.closeUI() + + def onSelect(self, path): + try: + path = path[0] + except IndexError: + path = None + if not path: + self._xmluiCancelled() + else: + self._xmluiValidated({'path': path}) + + def show(self, *args, **kwargs): + assert kwargs["force"] + G.host.showUI(self) + + ## Factory ##