Esempio n. 1
0
    def create_open_file_dialog(self):
        chooser = BoxLayout()
        container = BoxLayout(orientation='vertical')

        def open_file(path, filename):
            try:
                filepath = os.path.join(path, filename[0])
                self.__open_filename = filepath
                self.open_file_dialog_to_report_selector()
            except IndexError:
                self.error_message("Please pick an appendix (.csv) file")

        filechooser = FileChooserListView()
        filechooser.path = os.path.expanduser("~")
        filechooser.bind(on_selection=lambda x: filechooser.selection)
        filechooser.filters = ["*.csv"]

        open_btn = Button(text='open', size_hint=(.2,.1), pos_hint={'center_x': 0.5, 'center_y': 0.5})
        open_btn.bind(on_release=lambda x: open_file(filechooser.path, filechooser.selection))

        container.add_widget(filechooser)
        container.add_widget(open_btn)
        chooser.add_widget(container)

        file_chooser = Popup(title='Open file',
        content=chooser,
        size_hint=(.9, .7 ), pos_hint={'center_x': 0.5, 'center_y': 0.5})

        return file_chooser 
Esempio 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()
Esempio n. 3
0
def FilePopup(x):
    layout = BoxLayout(orientation='vertical')

    fch = FileChooserListView()
    fch.path = os.getcwd()

    pubkey = TextInput(
        hint_text=
        "Public Key of the stream, leave blank to create new stream or accept the one in the file",
        multiline=False,
        size_hint=(1, 0.1))
    filename = TextInput(hint_text="Filename",
                         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:
            if filename.text:
                openStream(os.path.join(fch.path, filename.text), pubkey.text)
                n.extend(fch.selection)
            else:
                presentError("Nothing selected!s")
        except:
            presentError(traceback.format_exc())
        popup.dismiss()

    layout.add_widget(pubkey)
    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()