Mercurial > libervia-desktop-kivy
changeset 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 | 4d8c122b86a6 |
children | d7447c585603 |
files | src/cagou/core/xmlui.py src/cagou/kv/xmlui.kv |
diffstat | 2 files changed, 69 insertions(+), 0 deletions(-) [+] |
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 ##
--- a/src/cagou/kv/xmlui.kv Thu Dec 29 23:47:10 2016 +0100 +++ b/src/cagou/kv/xmlui.kv Thu Dec 29 23:47:13 2016 +0100 @@ -21,13 +21,16 @@ size_hint: 1, None height: dp(common_height) + <ButtonWidget>: size_hint: 1, None height: dp(button_height) + <BoolWidget>: size_hint: 1, 1 + <DividerWidget>: size_hint: 1, None height: dp(20) @@ -38,14 +41,17 @@ points: 0, dp(10), self.width, dp(10) width: dp(3) + <ListWidgetItem>: size_hint_y: None height: dp(button_height) + <ListWidget>: size_hint: 1, None height: dp(button_height) + <AdvancedListRow>: canvas.before: Color: @@ -63,29 +69,59 @@ pos: self.pos size: self.size + <AdvancedListContainer>: cols: 1 size_hint: 1, None height: self.minimum_height + <VerticalContainer>: cols: 1 size_hint: 1, None height: self.minimum_height + <PairsContainer>: cols: 2 size_hint: 1, None height: self.minimum_height + <TabsContainer>: size_hint: 1, None height: 100 + <FormButton>: size_hint: 1, None height: dp(button_height) + +<FileDialog>: + orientation: "vertical" + message: message + file_chooser: file_chooser + Label: + id: message + size_hint: 1, None + text_size: root.width, None + size: self.texture_size + FileChooserListView: + id: file_chooser + Button: + size_hint: 1, None + height: dp(50) + text: "choose" + on_release: root.onSelect(file_chooser.selection) + Button: + size_hint: 1, None + height: dp(50) + text: "cancel" + on_release: root.onCancel() + + + <XMLUIPanelGrid>: cols: 1 size_hint: 1, None