Exemplo n.º 1
0
 def init_selector(self, _height):
     # Use a FileChooserListView for selector
     _selector = FileChooserListView()
     _selector.height = _height
     _selector.dirselect = True
     _selector.bind(selection = self.set_selector_text)
     return _selector
Exemplo n.º 2
0
def ImportFilesPopup(x=None):
    layout = BoxLayout(orientation='vertical')

    hlp = Label(text="""Choose a directory to sync with.
     All files in the directory will be imported, 
     (dir/foo.txt will map to foo.txt, and all files in the stream that
     are not in the folder will be deleted from the stream.
     
     Include an index.html to create a website.
     """)
    fch = FileChooserListView()
    fch.path = os.getcwd()
    fch.dirselect = True
    filename = TextInput(hint_text="Foldername",
                         multiline=False,
                         size_hint=(1, 0.1))

    button = Button(text='Select', font_size=14, size_hint=(1, 0.1))

    def s(x, y):
        try:
            filename.text = os.path.basename(str(fch.selection[0]))
        except:
            filename.text = ''

    fch.bind(selection=s)
    n = []

    def f(j):
        try:
            fn = os.path.join(fch.path, filename.text)
            if fn:
                if os.path.isdir(fn):
                    db.importFiles(fn, True)
                else:
                    presentError("Not a directory")
            else:
                presentError("Nothing selected!s")
        except:
            presentError(traceback.format_exc())
        popup.dismiss()

    layout.add_widget(hlp)
    layout.add_widget(fch)
    layout.add_widget(filename)

    layout.add_widget(button)

    popup = Popup(title='Open or Create a Stream',
                  content=layout,
                  size_hint=(None, None),
                  size=(600, 400))

    button.bind(on_press=f)

    popup.open()
Exemplo n.º 3
0
    def save_dict(self, obj):
        layout = BoxLayout(orientation='vertical')
        file_chooser = FileChooserListView(path='/home/')
        file_chooser.dirselect = True
        layout.add_widget(file_chooser)
        btn = Button(text="save")

        textinput = TextInput()

        popup = Popup(content=layout)
        btn.bind(on_release=partial(self.on_save_btn, file_chooser, textinput))
        btn.bind(on_release=popup.dismiss)
        layout.add_widget(textinput)
        layout.add_widget(btn)

        popup.open()
Exemplo n.º 4
0
    def build(self):
        # Datei/Ordner-Auswahl-Widget
        file_chooser = FileChooserListView(size_hint_y=1)
        file_chooser.dirselect = True
        file_chooser.multiselect = False
        file_chooser.filter = ["*.-----"]  # Nonsens-Dateiendung um nur Ordner anzuzeigen
        file_chooser.bind(selection=lambda _, x: self.on_select(file_chooser.selection))
        file_chooser.size_hint_min_y = 400

        # Auswahlknopf
        select_button = Button(text="Auswählen", size_hint=(1, .2))
        select_button.bind(on_release=lambda x: self.on_submit())

        # Container für Knopf und Ordnerauswahl
        container = BoxLayout(orientation="vertical")
        container.add_widget(file_chooser)
        container.add_widget(Padding(select_button, 200, 5))

        # Screens
        self.browser_screen.add_widget(container)
        self.main_screen.add_widget(BuRnScreen(switch_dirs=self.switch_dirs, run_process=self.run_process))

        self.sm.switch_to(self.browser_screen)  # Anfangsbildschirm ist die Ordnerauswahl
        return self.sm  # ScreenManager ist "root" der Oberfläche