class ImagesMenu(BaseScreen): def __init__(self, name, *navigate_screens): super(ImagesMenu, self).__init__(name, *navigate_screens) self.lower_grid = BoxLayout(orientation='vertical', spacing=5, padding=5) self.lower_panel.add_widget(self.lower_grid) self.filechooser = FileChooserListView() if platform == 'android': self.filechooser.path = '/sdcard/DCIM' else: self.filechooser.path = os.getcwd() self.filechooser.bind( on_selection=lambda x: self.selected(self.filechooser.selection)) self.open_file_button = MDRaisedButton(text='Upload Image', size_hint=(1, .1)) self.open_file_button.bind(on_release=lambda x: self.open_f( self.filechooser.path, self.filechooser.selection)) self.lower_grid.add_widget( TextInput(size_hint=(1, .12), text='Image name')) self.lower_grid.add_widget(self.open_file_button) self.lower_grid.add_widget(self.filechooser) def open_f(self, path, filename): if not filename: img_file = None image_pop = Popup() image_pop.add_widget( MDLabel(text='No image file selected', halign='center')) image_pop.open() else: img_file = os.path.join(path, filename[0]) image_pop = Popup() image_pop.add_widget(Image(source=img_file)) image_pop.open() if img_file else '' def open_image_screen_callback(self): self.upper_panel.navigate_next()
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
def __init__(self, textinput): self.textinput = textinput chooser = FileChooserListView() chooser.bind(selection=self.select) super(Browser_Popup, self).__init__(title='Choosing File', content=chooser, size_hint=(None, None), height=(500), width=(350))
class FileDialog(FloatLayout): path = ObjectProperty(None) file = ObjectProperty(None) def __init__(self, **kwargs): self.mode = kwargs.get('mode') super(FileDialog, self).__init__(**kwargs) self.register_event_type('on_cancel') self.register_event_type('on_submit') vbox = self.vbox = BoxLayout(orientation='vertical') self.add_widget(vbox) self.chooser = FileChooserListView(path=self.path) vbox.add_widget(self.chooser) self.text_input = TextInput(size_hint_y=None, height=30, multiline=False) if self.file: self.text_input.text = self.file vbox.add_widget(self.text_input) hbox = BoxLayout(size_hint_y=None, height=30) vbox.add_widget(hbox) self.cancel_btn = Button(text='Cancel') hbox.add_widget(self.cancel_btn) self.confirm_btn = Button(text=self.mode.title()) hbox.add_widget(self.confirm_btn) self.text_input.bind(text=self.on_text_input_text) self.chooser.bind(path=self.on_chooser_path, selection=self.on_chooser_selection, on_submit=self.on_chooser_submit) self.cancel_btn.bind(on_release=self.on_cancel_btn_release) self.confirm_btn.bind(on_release=self.on_confirm_btn_release) def do_layout(self, *args): if self.parent is not None: self.pos = self.parent.pos self.size = self.parent.size self.vbox.pos = self.parent.pos self.vbox.size = self.parent.size super(FileDialog, self).do_layout(*args) def on_text_input_text(self, instance, value): if not self.text_input.focus: return self.file = value def on_chooser_path(self, instance, value): self.path = value def on_chooser_selection(self, instance, value): self.file = value[0] self.text_input.text = self.file def on_chooser_submit(self, *args): self.dispatch('on_submit') def on_cancel_btn_release(self, *args): self.dispatch('on_cancel') def on_confirm_btn_release(self, *args): if self.file: self.dispatch('on_submit') def on_cancel(self, *args): pass def on_submit(self, *args): pass
def __init__(self, **kwargs): self.mode = kwargs.get('mode') super(FileDialog, self).__init__(**kwargs) self.register_event_type('on_cancel') self.register_event_type('on_submit') vbox = self.vbox = BoxLayout(orientation='vertical') self.add_widget(vbox) self.chooser = FileChooserListView(path=self.path) vbox.add_widget(self.chooser) self.text_input = TextInput(size_hint_y=None, height=30, multiline=False) if self.file: self.text_input.text = self.file vbox.add_widget(self.text_input) hbox = BoxLayout(size_hint_y=None, height=30) vbox.add_widget(hbox) self.cancel_btn = Button(text='Cancel') hbox.add_widget(self.cancel_btn) self.confirm_btn = Button(text=self.mode.title()) hbox.add_widget(self.confirm_btn) self.text_input.bind(text=self.on_text_input_text) self.chooser.bind(path=self.on_chooser_path, selection=self.on_chooser_selection, on_submit=self.on_chooser_submit) self.cancel_btn.bind(on_release=self.on_cancel_btn_release) self.confirm_btn.bind(on_release=self.on_confirm_btn_release)
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 __init__(self, **kwargs): super(ScreenThree, self).__init__(**kwargs) container = BoxLayout(orientation='vertical') filechooser = FileChooserListView() filechooser.bind( on_selection=lambda x: self.selected(filechooser.selection)) open_btn = Button(text='Open and predict!', font_size='30sp', size_hint=(1, .2)) open_btn.bind(on_release=lambda x: self.open(filechooser.selection)) container.add_widget(filechooser) container.add_widget(open_btn) self.add_widget(container)
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 _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(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 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 __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) 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 self.textinput = textinput = FileChooserListView(path=self.value, size_hint=(1, 1), dirselect=True) 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 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 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 __init__(self, main_app, **kwargs): super(MemeAppMainView, self).__init__(**kwargs) self.main_app = main_app self.cols = 2 self.text_grid = GridLayout(rows=5, size_hint_x=None, width=400) self.load_button = Button(text='Select Image', size_hint=(1.0, 0.25)) self.load_button.bind(on_press=self.select_image) self.save_button = Button(text='Save', size_hint=(1.0, 0.25)) self.save_button.bind(on_press=self.save_image) self.text_grid.add_widget(MemeTextBox(self.on_top_changed)) self.text_grid.add_widget(MemeTextBox(self.on_mid_changed)) self.text_grid.add_widget(MemeTextBox(self.on_bot_changed)) self.text_grid.add_widget(self.load_button) self.text_grid.add_widget(self.save_button) self.add_widget(self.text_grid) # Sadly can't load from a buffer and need to create files with current strategy. :( self.main_app.meme.render_no_text('preview.gif') self.main_app.meme.render_text_image('text.png') self.image_view = Image(source='preview.gif', anim_delay=0.05, pos_hint={ 'x': 0, 'y': 0 }, allow_stretch=True, keep_ratio=True) self.image_text = Image(source='text.png', pos_hint={ 'x': 0, 'y': 0 }, allow_stretch=True, keep_ratio=True) self.image_float = FloatLayout() self.image_float.add_widget(self.image_view) self.image_float.add_widget(self.image_text) self.add_widget(self.image_float) self.file_select_view = Popup(title='Select Image') self.file_chooser = FileChooserListView(rootpath='./') self.file_chooser.bind(on_submit=self.on_image_selected) self.file_select_view.add_widget(self.file_chooser)
def __init__(self, font_name, chisel): self.font_name = font_name self.chisel = chisel self.save_type = None self.choices = {"background": ".png " + _("(with background)"), "transparent": ".png " + _("(transparent)"), "project": PROJECT_EXTENSION, "all": _("All")} 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.75)) sublayout = BoxLayout(orientation="horizontal", spacing=dp(10), size_hint=(1, 0.1)) self.text_input = TextInput(text="Untitled", multiline=False, font_name=font_name, font_size=sp(16), size_hint_x=0.6) self.save_type_btn = KivyButton(text=_("Select file type"), font_name=font_name, size_hint_x=0.4) sublayout.add_widget(self.text_input) sublayout.add_widget(self.save_type_btn) self.save_btn = Button(_("Please select a file type."), font_name=font_name, disabled=True, font_size=sp(16), size_hint=(1, 0.15)) self.file_chooser.bind(path=self._change_title, selection=self._set_text) self.text_input.bind(text=self._on_text_input, on_text_validate=self._save_file) self.save_type_btn.bind(on_release=self.open_save_type_popup) self.save_btn.bind(on_release=self._save_file) for widget in (self.file_chooser, sublayout, self.save_btn): layout.add_widget(widget) super().__init__("", font_name, layout, size_hint=(0.7, 0.9)) self._change_title()
def __init__(self, **kwargs): super(mygrid, self).__init__(**kwargs) self.cols = 2 #-----FileChooser on the right side right = FileChooserListView() right.rootpath = "/home/stevenbaur/Musik" right.filters = ['*.wav', '*.mp3'] #-----Test-Arrea on the left side left = Button() left.text = "test" left.bind(on_release=partial(self.load_from_filechooser, right)) self.add_widget(left) self.add_widget(right)
def __init__(self, **kwargs): super(FileChooserPopup, self).__init__(**kwargs) self.title = 'Select features file' layout = RelativeLayout() file_chooser_list_view = FileChooserListView(filters=['*.txt', '*.data'], size_hint=(1, 0.8), pos_hint={'x': 0, 'y': 0.2}) file_chooser_list_view.bind(selection=self.file_chooser_selection_do) self.text_input = TextInput(text='', readonly=True, size_hint=(1, 0.1), pos_hint={'x': 0, 'y': 0.1}) layout.add_widget(file_chooser_list_view) layout.add_widget(self.text_input) layout.add_widget(Button(text='Select', italic=True, on_release=self.dismiss, size_hint=(0.25, 0.1), pos_hint={'x': 0.25, 'y': 0})) layout.add_widget(Button(text='Cancel', italic=True, on_release=self.cancel_btn_do, size_hint=(0.25, 0.1), pos_hint={'x': 0.5, 'y': 0})) self.content = layout
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 open_pop_up(self, button): layout = BoxLayout(orientation='vertical') # open button filechooser = FileChooserListView(path=os.getcwd()) filechooser.bind(on_selection=lambda x: self.selected(filechooser.selection)) popup_menubar = GridLayout(cols=2, size_hint=(1,None)) open_btn = Button(text='open', size_hint=(0.5, None)) open_btn.bind(on_release=lambda x: self.open(filechooser.path, filechooser.selection)) self.popup = Popup(title='Demo Popup', content=layout) self.popup.open() closebtn = Button(text='close', on_press=self.close, size_hint=(0.5, None)) popup_menubar.add_widget(open_btn) popup_menubar.add_widget(closebtn) layout.add_widget(filechooser) layout.add_widget(popup_menubar)
def __init__(self, **kwargs): """Initialize the class""" super(MyFiles, self).__init__(**kwargs) self.orientation = 'vertical' self.file_chooser = FileChooserListView() self.file_chooser.rootpath = BACKUP_DIR self.file_chooser.path = BACKUP_DIR self.file_chooser.multiselect = True self.add_widget(self.file_chooser)
def __init__(self, **kwargs): print("In FileBrowser") super(FileBrowser, self).__init__(**kwargs) self.app = MDApp.get_running_app() self.Browser = Popup(size_hint=(0.75, 0.75)) fc = FileChooserListView() fc.rootpath = os.environ["PULSO_APP_ROOT"] exit = Button(text='Cancel', size_hint=(1, 0.1), on_release=self.Browser.dismiss) layout = BoxLayout(orientation='vertical') layout.add_widget(fc) layout.add_widget(exit) self.Browser.add_widget(layout) fc.bind(selection=lambda instance, x: self.set_select(x)) self.picker_btn.bind( on_release=lambda x: self.Browser.open(self.Browser))
class FileExplorer(BoxLayout): 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 on_button_select(self, instance): self.update_lbl_filename = os.path.join(self.fichoo.path, self.fichoo.selection[0]) self.parent.parent.parent.dismiss() return def on_mouse_select(self, obj, val): self.tein_dir.text = str(self.fichoo.path) return def on_touch_up(self, touch): if self.fichoo.selection: self.tein_dir.text = str(self.fichoo.selection[0]) return super().on_touch_up(touch)
def __init__(self, open_callback, popuptitle): self.m_fctOpenCallback = open_callback layout = BoxLayout(orientation="vertical") self.selection = TextInput(multiline=False,text=os.getcwd() + os.sep, readonly=False,size_hint=(1,0.1),focus=True) layout.add_widget(self.selection) filechooser = FileChooserListView(filters=["*.py","*.txt"],path=os.getcwd()) layout.add_widget(filechooser) filechooser.bind(selection = self.on_selection) buttonslayout = BoxLayout(size_hint=(1, 0.1),orientation="horizontal") btn1 = Button(text='OK', size_hint=(0.5, 1)) btn1.bind(on_release = self.on_ok_button) buttonslayout.add_widget(btn1) btn2 = Button(text='Cancel', size_hint=(0.5, 1)) btn2.bind(on_release = self.on_cancel_button) buttonslayout.add_widget(btn2) layout.add_widget(buttonslayout) self.popup = Popup(title=popuptitle,content=layout,size_hint=(1,1)) self.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, load_callback, **kwargs): self.load_callback = load_callback super(FileChooserWindow, self).__init__(**kwargs) self.layout = RelativeLayout() fc = FileChooserListView(filters=["*.csv", "*.xlsx", "*.txt"], size_hint=(.8, 1)) fc.bind(on_submit=self.file_chosen) self.layout.add_widget(fc) exit_btn = Button(text='Exit', size_hint=(.1, .1), pos_hint={ 'center_x': .9, 'center_y': .9 }) exit_btn.bind(on_press=self.dismiss) self.layout.add_widget(exit_btn) self.add_widget(self.layout)
def _acquireCoverArt(self, instance): """Creates a window for the user to select a cover art image from the file system.""" self.pic_selection = "No picture selected." user_path = expanduser('~') + sep + 'Pictures' self.file_chooser = FileChooserListView( path=user_path, filters=["*.jpg", "*.jpeg", "*.png"]) self.file_chooser.bind(on_submit=self._retrieveFileSelection) self.close_button = Button(text="Close", size_hint_y=None, height=30) self.close_button.bind(on_press=self._dismissFileSelectionWindow) self.file_chooser_grid = GridLayout(rows=2) self.file_chooser_grid.add_widget(self.close_button) self.file_chooser_grid.add_widget(self.file_chooser) self.file_chooser_window = Popup(title="Image Selector", content=self.file_chooser_grid) self.file_chooser_window.open()
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, **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, 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 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 __init__(self, **kvargs): super(FDialog, self).__init__(**kvargs) box = BoxLayout(orientation='vertical', spacing=10) fdialog = FileChooserListView(path=self.path) fdialog.bind(selection=self.events_callback) box.add_widget(fdialog) if self.filter == 'folder': box.add_widget(SettingSpacer()) box.add_widget( Button(text=self.text_button_ok, size_hint=(1, .1), background_normal=self.background_image_buttons[0], background_down=self.background_image_shadows[0], on_press=self.events_callback) ) fdialog.filters = [self.is_dir] elif self.filter == 'files': fdialog.filters = [self.is_file] self.content = box self.open()
def __init__(self, **kwargs): super(ScreenManager, self).__init__(**kwargs) EventLoop.window.bind(on_keyboard=self.goback) self.startmenu = StartMenu() self.startmenu.filebtn.bind(on_press=self.selectfile) self.add_widget(self.startmenu) self.filemenu = FileChooserListView() self.filemenu.bind(on_submit=self.openfile) self.mode_menu = None
def __init__(self, **kvargs): super(FileChooser, self).__init__(**kvargs) box = BoxLayout(orientation="vertical", spacing=10) filechooser = FileChooserListView() filechooser.bind(selection=self.select_callback) box.add_widget(filechooser) if self.filter == "folder": box.add_widget(SettingSpacer()) box.add_widget(Button(text=self.text_button_select, size_hint=(1, .1), on_press=self.select_callback)) filechooser.filters = [self.is_dir] elif self.filter == "files": filechooser.filters = [self.is_file] self.body = Popup(title=self.title, content=box, size_hint=self.size, auto_dismiss=self.auto_dismiss, background=self.background_image) self.body.bind(on_dismiss=self.dismiss_callback) self.body.open()
class ScreenManager(FloatLayout): log = None logpath = '' def __init__(self, **kwargs): super(ScreenManager, self).__init__(**kwargs) EventLoop.window.bind(on_keyboard=self.goback) self.startmenu = StartMenu() self.startmenu.filebtn.bind(on_press=self.selectfile) self.add_widget(self.startmenu) self.filemenu = FileChooserListView() self.filemenu.bind(on_submit=self.openfile) self.mode_menu = None def selectfile(obj, value): # wait for old input to clear Clock.schedule_once(partial(obj.switchscreen, obj.filemenu), 0.15) def openfile(obj, value, selected, event): progbar = ProgressBar() obj.logpath = selected obj.switchscreen(progbar) obj.tlog = mp.TelemetryLog(selected[0], progbar, obj.postopen, obj.posterror) #callback for succesfully opening a log def postopen(self, dt): if self.tlog is None: return else: self.log = self.tlog.packets self.mode_menu = ModeMenu() self.mode_menu.readbtn.bind(on_press=self.readlog) self.mode_menu.graphbtn.bind(on_press=self.graphlog) self.mode_menu.exportbtn.bind(on_press=self.exportmenu) self.switchscreen(self.mode_menu) #callback for encountering an error #while opening a log def posterror(self, message, dt): print(message) self.switchscreen(self.startmenu) errorpopup = Popup(title='Error', content=Label(text=message), size_hint=(None, None), size=(600,200)) errorpopup.open() def readlog(obj, value): rl = Reader(obj.log) obj.switchscreen(rl) def graphlog(obj, value): graph = TelemetryGraphScreen(obj, obj.log) def exportmenu(obj, value): obj.switchscreen(ExportMenu(obj.log, obj.logpath)) def switchscreen(self, widget, *args): self.clear_widgets() self.add_widget(widget) def goback(self, window, key, *args): if key == 27: exit_on_back = StartMenu startmenu_on_back = (FileChooserListView, ModeMenu) if isinstance(self.children[0], exit_on_back): return False if isinstance(self.children[0], startmenu_on_back): self.switchscreen(self.startmenu) else: self.switchscreen(self.mode_menu) return True
def build(self): if (not self.is_desktop()): Config.set('postproc', 'retain_time', '10') Config.set('postproc', 'double_tap_time', '1') Config.set('postproc', 'triple_tap_time', '2') Config.set('graphics', 'fullscreen', 'auto') Config.write() ################################## platform = kivy.utils.platform() ################################## # Start screen ################################## start_screen = Screen(name='start') start_screen.bind(on_pre_enter=self.generate_start_screen) ################################## # Card screen ################################## card_layout = BoxLayout(orientation='vertical',size_hint=(1,.95)) card_widget = BoxLayout(size_hint=(1,.85)) card_buttons_widget = BoxLayout(size_hint=(1,.15)) self.card_label = Label(markup=True, pos=(0,0), font_name='img/ipag.ttf', font_size=64, halign="center", valign="top") self.card_label.bind(on_touch_down=self.on_card_press) card_widget.add_widget(self.card_label) again_btn = Button(markeup=True) again_btn.text = "again" again_btn.bind(on_press=self.process_card_btn) card_buttons_widget.add_widget(again_btn) soon_btn = Button(markeup=True) soon_btn.text = "soon" soon_btn.bind(on_press=self.process_card_btn) card_buttons_widget.add_widget(soon_btn) later_btn = Button(markeup=True) later_btn.text = "later" later_btn.bind(on_press=self.process_card_btn) card_buttons_widget.add_widget(later_btn) never_btn = Button(markeup=True) never_btn.text = "never" never_btn.bind(on_press=self.process_card_btn) card_buttons_widget.add_widget(never_btn) card_layout.add_widget(card_widget) card_layout.add_widget(card_buttons_widget) card_screen = Screen(name='main') card_screen.add_widget(card_layout) card_screen.bind(on_enter=self.card_refresh) ################################## # Settings screen ################################## settings_screen = SettingsScreen(name='settings') settings_screen.add_widget(self.generate_settings()) ################################## # No more cards screen ################################## no_more_layout = BoxLayout(size_hint=(1,1), orientation='vertical') no_more_label = Label(markup=True, pos=(0,0), font_name='img/ipag.ttf', size_hint=(1,.85), font_size=64, halign="center", text="No more cards to review.") no_more_layout.add_widget(no_more_label) no_more_btn_layout = BoxLayout(size_hint=(1,.15)) no_more_home_btn = Button(markup=True) no_more_home_btn.text = "Home" no_more_home_btn.bind(on_press=self.go_to_start_screen) no_more_btn_layout.add_widget(no_more_home_btn) no_more_exit_btn = Button(markup=True) no_more_exit_btn.text = "Done" no_more_exit_btn.bind(on_press=sys.exit) no_more_btn_layout.add_widget(no_more_exit_btn) no_more_layout.add_widget(no_more_btn_layout) no_more_screen = Screen(name='finished') no_more_screen.add_widget(no_more_layout) import_layout = BoxLayout(size_hint=(1,1), orientation='vertical') self.import_msg_label = Label(markup=True, pos=(0,0), font_name = 'img/ipag.ttf', size_hint=(1,.1), font_size=24, halign='left', text='Please select a .tsv file.') import_layout.add_widget(self.import_msg_label) #TODO P3: Can we increase text size? import_file_chooser = FileChooserListView(on_submit=self.import_list, path='/') import_file_chooser.bind(selection=self.import_list) import_layout.add_widget(import_file_chooser) import_cancel_button = Button(text="Cancel", on_press=self.go_to_start_screen, size_hint=(1,.15)) import_layout.add_widget(import_cancel_button) import_screen = Screen(name='import') import_screen.add_widget(import_layout) # Add screens # sm = ScreenManager(transition=SlideTransition()) sm = ScreenManager(transition=FadeTransition()) sm.add_widget(start_screen) sm.add_widget(card_screen) sm.add_widget(settings_screen) sm.add_widget(no_more_screen) sm.add_widget(import_screen) self.on_load(1) return sm