def load(self, *l): self.button.disabled = True if os.path.isdir(meshdir): rep = meshdir self.fl = FileChooserListView(path=rep, rootpath=rep, filters=["*.mesh.ascii"], dirselect=False, size=(400, 400), center_x=250, center_y=250) else: rep = os.getcwd() self.fl = FileChooserListView(path=rep, filters=["*.mesh.ascii"], dirselect=False, size=(400, 400), center_x=250, center_y=250) '''if platform == 'android': rep = "." else: rep = "../../Mesh"''' self.fl.bind(selection=self.on_selected) super(Renderer, self).add_widget(self.fl)
def __init__(self, **kwargs): super(MainScreen, self).__init__(**kwargs) self.cols = 2 self.cuenta_imagenes = 1 # Image Widget self.test_image = Image() # File and Label Widget self.first_folder_label = Label(text="Carpeta pedestres", font_size=40) self.second_folder_label = Label(text="Carpeta no pedestres", font_size=40) self.test_folder_label = Label(text="Carpeta de pruebas", font_size=40) self.first_folder = FileChooserListView(path='.', dirselect=True) self.second_folder = FileChooserListView(path='.', dirselect=True) self.test_folder = FileChooserListView(path='.', dirselect=True) # Button Widget self.start_training = Button(text='Iniciar entrenamiento', width=200) self.start_training.bind(on_press=self.__on_click_train__) self.read_images = Button(text='Iniciar pruebas', width=200) self.read_images.bind(on_press=self.__on_click_test__) self.next_image = Button(text='Siguiente imagen', width=200) self.next_image.bind(on_press=self.__on_click_next_image__) # Add Widgets self.add_widget(self.first_folder_label) self.add_widget(self.first_folder) self.add_widget(self.second_folder_label) self.add_widget(self.second_folder) self.add_widget(self.start_training)
def btn_select_file(self, btn): ## Create popup if self.last_path: self.fileChooser = FileChooserListView(path=self.last_path) else: self.fileChooser = FileChooserListView() self.fileChooser.bind(on_touch_up=self.on_file_select) if self.chooser == None: self.chooser = Popup(title='Select file', size_hint=(None, None), size=(Window.width-50, Window.height-100), #content=self.fileChooser ) self.chooser.content = self.fileChooser ## Show popup self.chooser.open()
def __init__(self, font_name, chisel): self.font_name = font_name self.chisel = chisel layout = BoxLayout(orientation="vertical", spacing=dp(34), padding=(dp(20), dp(15))) self.file_chooser = FileChooserListView(path=get_saves_path(), filters=[self._filter_file], size_hint=(1, 0.85)) self.btn = Button(_("Please select a file."), font_name, disabled=True, font_size=sp(16), size_hint=(1, 0.15)) self.file_chooser.bind(path=self._change_title, selection=self._change_btn_name) self.btn.bind(on_release=self._select_file) layout.add_widget(self.file_chooser) layout.add_widget(self.btn) super().__init__("", font_name, layout, size_hint=(0.7, 0.9)) self._change_title()
def open_popup(self): layout = BoxLayout(orientation="vertical", spacing=10, padding=10) select = BoxLayout(size_hint=(1, .25), spacing=10, padding=10) gallery = FileChooserListView(size_hint=(1, 1), path="./") object = Button(background_normal='', background_color=(0.157, 0.455, 0.753, 1.0), text="Object") text = Button(background_normal='', background_color=(0.157, 0.455, 0.753, 1.0), text="Text") closeButton = Button(background_normal='img\close.png', background_down='img\close.png', size_hint=(.38, .4), pos_hint={"center_x": .5}) layout.add_widget(gallery) select.add_widget(object) select.add_widget(text) layout.add_widget(select) layout.add_widget(closeButton) popup = Popup(title='Filemanager', content=layout, size_hint=(.8, .9)) popup.open() object.bind(on_release=lambda x: self.object(gallery.selection)) text.bind(on_release=lambda x: self.text(gallery.selection)) closeButton.bind(on_press=popup.dismiss)
def file_dialog(title=None, path='.', filter='files', events_callback=None, size=None): def is_dir(directory, filename): return os.path.isdir(os.path.join(directory, filename)) def is_file(directory, filename): return os.path.isfile(os.path.join(directory, filename)) if not size: size = (.7, .5) file_manager = FileChooserListView(path=path, filters=['\ *.png']) if isinstance(events_callback, types.FunctionType) or \ isinstance(events_callback, types.MethodType): file_manager.ids.layout.ids.button_ok.bind( on_release=lambda x: events_callback(file_manager.path)) file_manager.bind(selection=lambda *x: events_callback(x[1:][0][0])) if filter == 'folders': file_manager.filters = [is_dir] elif filter == 'files': file_manager.filters = [is_file] dialog = card(file_manager, title, size=size) return dialog, file_manager
def __init__(self, **kwargs): super(FileExplorer, self).__init__(**kwargs) self.orientation = 'vertical' self.fichoo = FileChooserListView(size_hint_y=0.8, path='./') self.fichoo.dirselect = True self.add_widget(self.fichoo) self.update_lbl_filename = '' control = GridLayout(cols=5, row_force_default=True, row_default_height=35, size_hint_y=0.14, padding=[10, 10]) lbl_dir = Label(text='Folder', size_hint_x=None, width=150) self.tein_dir = TextInput(size_hint_x=None, width=400) bt_dir = Button(text='Select file', size_hint_x=None, width=80) bt_dir.bind(on_release=self.on_button_select) self.fichoo.bind(selection=self.on_mouse_select) control.add_widget(lbl_dir) control.add_widget(self.tein_dir) control.add_widget(bt_dir) self.add_widget(control) return
def show_save(self, *args): stack = GridLayout(cols=1, row_force_default=True, row_default_height=1000) fchooser = FileChooserListView(path="/storage/emulated/0/Download") saveButton = Button(text='Backup', font_size=40, size_hint_y=None, height=60) loadButton = Button(text='Load', font_size=40, size_hint_y=None, height=60) grid = GridLayout(cols=2, row_force_default=True, row_default_height=60) loadButton.bind(on_release=partial(self.loadSelected, fchooser)) saveButton.bind(on_release=lambda x: self.save(fchooser.path)) grid.add_widget(saveButton) grid.add_widget(loadButton) stack.add_widget(fchooser) stack.add_widget(grid) self._popup = Popup(title="Save file", content=stack, size_hint=(0.85, 0.85)) self._popup.open()
def excelOpen(self): popupLayout = BoxLayout(orientation='vertical') buttonLayout = BoxLayout(orientation='horizontal', size_hint=(1, 0.1)) from pathlib import Path home = str(Path.home()) file = FileChooserListView(path=home) popupLayout.add_widget(file) popupLayout.add_widget(buttonLayout) def callback(instance): if (instance.text == 'OPEN'): self.filePopup.dismiss() #excelIO.excelManip(file.selection) excelIO.threads(file.selection) openBtn = Button(text='OPEN') openBtn.bind(on_press=callback) buttonLayout.add_widget(openBtn) closeBtn = Button(text='Cancel') buttonLayout.add_widget(closeBtn) self.filePopup = Popup(title='Choose Excel', content=popupLayout, size_hint=(0.75, 0.75)) closeBtn.bind(on_press=self.filePopup.dismiss) self.filePopup.open()
def __init__(self, **kwargs): super(FilePopup, self).__init__(**kwargs) self.title = "Choose file" # create popup layout containing a boxLayout content = BoxLayout(orientation='vertical', spacing=5) self.popup = popup = Popup(title=self.title, content=content, size_hint=(None, None), size=(600, 400)) self.fileChooser = fileChooser = FileChooserListView(size_hint_y=None) drives = win32api.GetLogicalDriveStrings() drives = drives.split('\000')[:-1] def test(drive): # first, create the scrollView fileChooser.path = drive fileChooser.bind(on_submit=self._validate) fileChooser.height = 500 # this is a bit ugly... scrollView.add_widget(fileChooser) # construct the content, widget are used as a spacer content.add_widget(Widget(size_hint_y=None, height=5)) content.add_widget(scrollView) content.add_widget(Widget(size_hint_y=None, height=5)) # 2 buttons are created for accept or cancel the current value btnlayout = BoxLayout(size_hint_y=None, height=50, spacing=5) btn = Button(text='Ok') btn.bind(on_release=self._validate) btnlayout.add_widget(btn) btn = Button(text='Cancel') btn.bind(on_release=popup.dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) dropdown.clear_widgets() mainbutton.clear_widgets() mainbutton.disabled mainbutton.text = drive dropdown = DropDown() for index in drives: btn = Button(text=index, size_hint_y=None, height=44) btn.bind(on_release=lambda btn: test(btn.text)) dropdown.add_widget(btn) self.scrollView = scrollView = ScrollView() mainbutton = Button(text='Drive', size_hint_y=None, height=44) mainbutton.bind(on_release=dropdown.open) dropdown.bind( on_select=lambda instance, x: setattr(mainbutton, 'text', x)) content.add_widget(mainbutton) # all done, open the popup ! popup.open()
def addfile(self): print('addfile:', self.files) box = BoxLayout(orientation='vertical', padding=10, spacing=10) botones = BoxLayout(padding=10, spacing=10, size_hint_y=None, height=30) self.filechooser = FileChooserListView() # self.filechooser.height = 400 # this is a bit ugly... self.filechooser.path = '.' box.add_widget(self.filechooser) pop = Popup(title='Select Directory', content=box, size_hint=(None, None), size=(400, 600)) si = Button(text='Si', on_release=self.on_load, height='30dp', width='20dp') no = Button(text='No', on_release=pop.dismiss, height='30dp', width='20dp') botones.add_widget(si) botones.add_widget(no) box.add_widget(botones) pop.open()
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
def getdir(self): fc = FileChooserListView(path=self.pPath) p = Popup(title='Open Directory/Folder', content=fc, size_hint=(0.5, 0.5)) p.bind(on_dismiss=lambda x: self.setDir(fc.path)) p.open()
def _create_popup(self, instance): # create popup layout content = BoxLayout(orientation='vertical', spacing=5) popup_width = min(0.95 * Window.width, dp(500)) self.popup = popup = Popup(title=self.title, content=content, size_hint=(None, 0.9), width=popup_width) # create the filechooser initial_path = os.path.join(os.getcwd(), app_settings.flame_log_dir) self.textinput = textinput = FileChooserListView( path=initial_path, size_hint=(1, 1), dirselect=False, show_hidden=self.show_hidden, filters=['*.csv']) #textinput.bind(on_path=self._print_csv_data) # construct the content content.add_widget(textinput) content.add_widget(SettingSpacer()) # 2 buttons are created for accept or cancel the current value btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp') btn = Button(text='Open') btn.bind(on_release=self._csv_data_popup) btnlayout.add_widget(btn) btn = Button(text='Close') btn.bind(on_release=self._dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) # all done, open the popup ! popup.open()
def __init__(self): super(Widg, self).__init__(orientation='vertical', spacing=20) self.s = "" self.txt = TextInput(multiline=False, font_size=24) self.bsel = Button(text='select files', font_size=24, background_color=[0.8, 0.2, 0.1, 1]) self.bfrq = Button(text='compute frequency', font_size=24, background_color=[0.2, 0.8, 0.1, 1]) self.lsel = ListView(item_strings=[""]) self.lles = ListView(item_strings=[""]) self.lmos = ListView(item_strings=[""]) self.f = FileChooserListView(path=path, filters=['*.txt'], multiselect=True) self.bsel.bind(on_release=self.on_files) self.bfrq.bind(on_release=self.on_conv) self.bb = BoxLayout(size_hint=(1, 0.2)) self.ff = BoxLayout() self.lm = BoxLayout(size_hint=(1, 0.6)) self.ff.add_widget(self.f) self.ff.add_widget(self.lsel) self.bb.add_widget(self.bsel) self.bb.add_widget(self.bfrq) self.lm.add_widget(self.lles) self.lm.add_widget(self.lmos) self.add_widget(self.lm) self.add_widget(self.bb) self.add_widget(self.ff)
def _create_popup(self, instance): # create popup layout content = BoxLayout(orientation='vertical', spacing=5) self.popup = popup = Popup(title=self.title, content=content, size_hint=(None, None), size=(400, 400)) # create the filechooser self.textinput = textinput = FileChooserListView(size_hint=(1, 1), dirselect=False, filters=["*.sf2"]) if str(self.value) not in ("", "None"): self.textinput.path = os.path.dirname(str(self.value)) textinput.bind(on_path=self._validate) self.textinput = textinput # construct the content content.add_widget(textinput) content.add_widget(SettingSpacer()) # 2 buttons are created for accept or cancel the current value btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp') btn = Button(text='OK') btn.bind(on_release=self._validate) btnlayout.add_widget(btn) btn = Button(text='Cancel') btn.bind(on_release=self._dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) # all done, open the popup ! popup.open()
def __init__(self): super(TraceAnalysisApp, self).__init__() content = Button(text='Success', size_hint_y=None, height=30) self.popup = Popup(title='Analysis finished', content=content, auto_dismiss=True, size_hint_y=None, height=30) content.bind(on_press=self.popup.dismiss) error_content = Button( text= 'Unknown error encountered when parsing trace. Please try a different trace.', size_hint_y=None, height=30) self.error_in_trace_popup = Popup(title='Error', content=error_content) error_content.bind(on_press=self.error_in_trace_popup.dismiss) self.bl = BoxLayout() self.root = ScrollView(size_hint=(1, None), size=(Window.width, Window.height)) self.root.add_widget(self.bl) self.possible_trace_event_transitions = {} self.reverse_possible_trace_event_transitions = {} self.traceAttrs = {} self.trace_id_to_CSEW_events = {} self.selected_trace_tb = None self.trace_file = None self.trace = None self.trace_ids = {} self.fcl = self.fcl = FileChooserListView( path=os.path.realpath("trace-configurations/"), dirselect=True) # type: FileChooserListView self.fcl.bind(selection=self.selected_traceid_to_csem_events_map_file) self.bl.add_widget(self.fcl)
def _create_popup(self, instance): # create popup layout content = BoxLayout(orientation='vertical', spacing=5) popup_width = min(0.95 * Window.width, dp(500)) self.popup = popup = Popup( title=self.title, content=content, size_hint=(None, 0.9), width=popup_width) # create the filechooser initial_path = self.value or os.getcwd() self.textinput = textinput = FileChooserListView( path=initial_path, size_hint=(1, 1), dirselect=self.dirselect, show_hidden=self.show_hidden) textinput.bind(on_path=self._validate) # construct the content content.add_widget(textinput) content.add_widget(SettingSpacer()) # 2 buttons are created for accept or cancel the current value btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp') btn = Button(text='Ok') btn.bind(on_release=self._validate) btnlayout.add_widget(btn) btn = Button(text='Cancel') btn.bind(on_release=self._dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) # all done, open the popup ! popup.open()
def Load(self): """ Load from the Disk Button > Load() """ from functools import partial from kivy.uix import filechooser from kivy.uix.filechooser import FileChooserListView, FileChooserIconView main = ModalView(size_hint=(.8, .8)) # everything on this Modal is 80% BL = BoxLayout(portrait="vertical") FLV = FileChooserListView(path="coreEngine/Saved", ) def cTexloader(instance): Selected = FLV.selection Selected_Attr = Selected LStoString = str(Selected_Attr[0]) self.Loader_NoErr(ctexSaved=LStoString, fixedPath=LStoString) Load_Btn = Button(text="Load this File") Load_Btn.bind(on_press=cTexloader) main.add_widget(BL) BL.add_widget(FLV) BL.add_widget(Load_Btn) main.open()
def __init__(self, **kwargs): """Initialize the class""" super(Templates, self).__init__(**kwargs) self.orientation = 'vertical' self.file_chooser = FileChooserListView() self.file_chooser.rootpath = TEMPLATE_DIR self.file_chooser.path = TEMPLATE_DIR self.file_chooser.multiselect = True self.add_widget(self.file_chooser)
def __init__(self, *args, **kwargs): super(Files, self).__init__(*args, **kwargs) self.orientation = "vertical" self.id = "files" self.selection = None self.fichoo = FileChooserListView() self.btn = SelectFileButton() self.add_widget(self.fichoo) self.add_widget(self.btn)
def show_file_explorer(self): popup = Popup(size_hint=(0.8, 0.8)) file_explorer = FileChooserListView( filters=['*.jpg', '*.png', '*.jpeg']) file_explorer.bind(on_submit=self.show_add_slide) file_explorer.popup = popup popup.content = file_explorer popup.title = _('File explorer') popup.open()
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()
def test_filechooserlistview_unicode(self): from kivy.uix.filechooser import FileChooserListView from kivy.clock import Clock from os.path import join wid = FileChooserListView(path=self.basepathu) for i in range(1): Clock.tick() files = [join(self.basepathu, f) for f in wid.files] for f in self.ufiles: self.assertIn(f, files) # we cannot test the bfiles because we'd have to know the system # unicode encoding to be able to compare to returned unicode for f in self.exitsfiles: self.assertIn(f, files) wid = FileChooserListView(path=self.basepathb) Clock.tick() files = [join(self.basepathb, f) for f in wid.files] for f in self.bfiles: self.assertIn(f, files)
def __init__(self, **kwargs): super(LoadDialog, self).__init__(**kwargs) self.Win_To_Draw = RelativeLayout() self.BoxLay1 = BoxLayout() self.FCL = FileChooserListView() self.BoxLay2 = BoxLayout() self.BCancel = Button() self.BLoad = Button() self.Bind_Cancel = None self.Bind_Load = None return
def load_dict(self, obj): layout = BoxLayout(orientation='vertical') file_chooser = FileChooserListView(path='/home/') layout.add_widget(file_chooser) btn = Button(text="load") btn.bind(on_release=partial(self.on_load_btn, file_chooser)) layout.add_widget(btn) popup = Popup(content=layout) btn.bind(on_release=popup.dismiss) popup.open()
def __init__(self, hobbes_db, **kwargs): super(SaveDialog, self).__init__(**kwargs) self.hobbes_db = hobbes_db file_chooser = FileChooserListView(dirselect=True, path=self.hobbes_db) self.add_widget(file_chooser) # Pay attention to keyboard events Window.bind(on_key_down=self.on_keyboard) self.bind(on_dismiss=self.on_custom_dismiss)
def open_for_load(self): # create input folder if not existing input_path = os.path.join(self.cwd, 'input') if not os.path.isdir(input_path): os.mkdir(input_path) self.page_load_browser = Popup(title='Select file', content=FileChooserListView( on_submit=self.call_load, path=input_path), size_hint=(.5, .5)) self.page_load_browser.open()
def __init__(self, **kwargs): super(SaveDialog, self).__init__(**kwargs) self.Win_To_Draw = RelativeLayout() self.BoxLay1 = BoxLayout() self.FCL = FileChooserListView() self.TIinput = TextInput() self.BoxLay2 = BoxLayout() self.BCancel = Button() self.BSave = Button() self.Bind_Cancel = None self.Bind_Save = None return
def __init__(self): super().__init__() self.download_path = StringProperty('') self.file_chooser = FileChooserListView(dirselect = True) self.btn_ok = Button(size_hint_y=0.075,text="Select") self.content_pop_download = BoxLayout(orientation = 'vertical') self.content_pop_download.add_widget(self.file_chooser) self.content_pop_download.add_widget(self.btn_ok) self.pop_downloader = Popup( size_hint = (0.8,0.8), title="Choose file", content = self.content_pop_download, auto_dismiss=True)