def build(self): Config.set('input','mouse', 'mouse,disable_multitouch') self.title = 'Snarky Screening' self.root = Builder.load_string(kv) self.root.remove_widget(self.root.ids.bottom_layout) self.root.add_widget(self.root.ids.bottom_layout) fc = FileChooserIconView() fc.on_submit = self.handle_selection self.popup = Popup(title='Open file', content=fc) self.root.ids.snarky_opendialog.on_release = self.popup.open self.root.remove_widget(self.root.ids.snarky_divider) self.root.remove_widget(self.root.ids.snarky_opendialog) self.root.ids._context_menu.add_widget(self.root.ids.snarky_divider) self.root.ids._context_menu.add_widget(self.root.ids.snarky_opendialog) if UseLucidaFax: self.root.ids.snarky_chatstream.font_name = 'LucidaFax' self.root.ids.snarky_chatstream.text += """ Welcome to a [b]Snarky Screening[/b]! [i]You[/i] need to kick off [i]auto-scroll[/i] by scrolling this text up so you can see the whole thing. You'll also need to re-do it if you [i]resize[/i] the window.""" if len(argv) > 1: self.root.ids.video.source = argv[1] reactor.listenTCP(8000, EchoFactory(self))
def browser(self, op): """ This function creates the file chooser to select image""" # Create Layout for popup try: self.popup.dismiss() except PopupException: pass self.current = 'Abrir Ficheiro' b_main_lay = GridLayout(rows=3) if op is 'seg_fg': file = FileChooserIconView(path=self.path, size_hint_y=0.9, multiselect=True) elif op is 'seg_bg': file = FileChooserIconView(path=self.path, size_hint_y=0.9, multiselect=True) else: file = FileChooserIconView(path=self.path, size_hint_y=0.9, multiselect=False) # this popup buttons and actions select = Button(text='Abrir', size_hint_y=0.1) select.bind(on_press=lambda x: self.open(file.selection, op)) cancel = Button(text='Cancelar', size_hint_y=0.1) cancel.bind(on_press=self.cancel_callback) b_main_lay.add_widget(file) b_main_lay.add_widget(select) b_main_lay.add_widget(cancel) self.s_open_file.add_widget(b_main_lay)
def on_triple_tap(self): filechoser_layout = AnchorLayout() #filechoser = FileChooserIconView( size_hint = (0.75,0.85), path=settings['kraken_path'] +'/picture') #, multiselect = True) filechoser = FileChooserIconView(size_hint=(0.75, 0.85), path='/home') #, multiselect = True) filechoser_list_layout = AnchorLayout(anchor_x='left', anchor_y='top') filechoser_list_layout.add_widget(filechoser) button_layout = AnchorLayout(anchor_x='left', anchor_y='bottom') box = BoxLayout(orientation='vertical', size_hint=(0.75, None), height=96) bli = BoxLayout(orientation='horizontal') ok_button = Button(text='Ok') cancel_button = Button(text='Cancel') bli2 = BoxLayout(orientation='horizontal') ti = TextInput(size_hint=(1, None), height=48) bli2.add_widget(Label(text='Enter File Name : ')) bli2.add_widget(ti) bli.add_widget(ok_button) bli.add_widget(cancel_button) box.add_widget(bli2) box.add_widget(bli) button_layout.add_widget(box) image_layout = AnchorLayout(anchor_x='right', anchor_y='center') wimg = Image(source=settings['kraken_path'] + '/picture/girl.jpg', size_hint=(0.25, None), size=(200, Window.size[1])) image_layout.add_widget(wimg) filechoser_layout.add_widget(filechoser_list_layout) filechoser_layout.add_widget(button_layout) filechoser_layout.add_widget(image_layout) popup_browser = Popup(title='Select File') popup_browser.add_widget(filechoser_layout) def save_path(instance): if ti.text != '': self.text = filechoser.path + '/' + ti.text else: self.text = filechoser.selection[0] popup_browser.dismiss() def file_select(self, file): if file: wimg.source = file[0] cancel_button.bind(on_press=popup_browser.dismiss) ok_button.bind(on_press=save_path) filechoser.bind(selection=file_select) popup_browser.open()
def __init__(self, **kwargs): super().__init__(**kwargs) self.partitions_caption = os.popen( 'wmic logicaldisk get caption').read() self.partitions_caption = self.partitions_caption.split() self.partitions_caption.remove('Caption') print(self.partitions_caption) self.partitions_btn = GridLayout(cols=10, rows=1, size_hint_y=0.1, spacing=2) for partition in self.partitions_caption: self.part_btn = Button(text=partition, id=partition + "\\") #self.part_btn.bind(on_release=lambda *args: self.change_main_direct(self.part_btn.id, *args)) self.part_btn.bind( on_release=partial(self.change_main_direct, self.part_btn.id)) #print(self.part_btn.id) self.partitions_btn.add_widget(self.part_btn) self.add_widget(self.partitions_btn) self.text_btn_grid = GridLayout(cols=1, rows=1, size_hint=(1, 0.09), spacing=5, padding=1) self.path_Text = TextInput(multiline=False, size_hint_x=1, font_size=11) #self.change_design_btn = Button(text="Lists", size_hint_x=0.2) #self.change_design_btn.bind(on_release=self.change_design_fn) self.text_btn_grid.add_widget(self.path_Text) #self.text_btn_grid.add_widget(self.change_design_btn) self.add_widget(self.text_btn_grid) self.file_chooser_list = FileChooserIconView(size_hint_y=0.8) self.file_chooser_list.dirselect = True self.file_chooser_list.bind(selection=self.on_select) self.file_chooser_list.path = "D:\\" self.add_widget(self.file_chooser_list) """self.file_chooser_Icon = FileChooserIconView(size_hint_y=0.8) self.file_chooser_Icon.dirselect = True self.file_chooser_Icon.bind(selection=self.on_select) self.file_chooser_Icon.path = "D:\\" self.add_widget(self.file_chooser_Icon)""" self.buttons_grid = GridLayout(cols=2, rows=2, size_hint_y=0.1, spacing=2) self.select_btn = Button(text="Select", size_hint=(0.4, 0.1)) self.cancel_btn = Button(text="Cancel", size_hint=(0.4, 0.1)) self.buttons_grid.add_widget(self.select_btn) self.buttons_grid.add_widget(self.cancel_btn) self.orientation = 'vertical' self.add_widget(self.buttons_grid) self.path = ""
def show_load_popup(self, *args): if os.path.exists(os.path.abspath('saves/')): file_chooser = FileChooserIconView(path="saves") elif os.path.exists(os.path.abspath('../saves')): file_chooser = FileChooserIconView(path="../saves") else: file_chooser = FileChooserIconView(path=".") load_btn = Button(font_name='src/fonts/Enchanted_Land.otf', font_size=24, text='Load', size_hint=(.08, .05)) back_btn = Button(font_name='src/fonts/Enchanted_Land.otf', font_size=24, text='Back', size_hint=(.08, .05), pos_hint={ 'center_x': .95, 'bottom_y': .05 }) content = FloatLayout() content.clear_widgets() content.add_widget(file_chooser) content.add_widget(load_btn) content.add_widget(back_btn) popup = Popup(title="Load a file", content=content) load_callback = lambda load: self.load(file_chooser.path, file_chooser. selection, popup) load_btn.bind(on_release=load_callback) back_btn.bind(on_release=popup.dismiss) popup.open()
def build_output_path_options(self): lbl_file_path = Label(text='Output Directory', size_hint=(.1, .05), pos_hint={'x': 0.5, 'y': .4}) self.text_output_directory = TextInput(text="", multiline=False, size_hint=(.5, .05), pos_hint={'x': .3, 'y': .35}) self.text_output_directory.bind(text=self.select_output_dir) self.text_output_directory.disabled = True self.btn_browse_directory = Button(text='Browse', size_hint=(.09, .05), pos_hint={'x': .8, 'y': .35}) self.btn_browse_directory.disabled = True self.btn_browse_directory.bind(on_release=lambda show_file_selection_dialog: file_chooser_dialog.open()) self.app.add_widget(lbl_file_path) self.app.add_widget(self.text_output_directory) self.app.add_widget(self.btn_browse_directory) file_chooser_dialog = Popup(title="Select Output Directory", size=(500, 500)) file_chooser = FileChooserIconView() file_chooser.path = os.getcwd() file_chooser_layout = FloatLayout(size=(500, 500)) file_chooser_layout.add_widget(file_chooser) file_chooser_dialog.add_widget(file_chooser_layout) btn_open_file = Button(text='Select Folder', size_hint=(.15, .05), pos_hint={'x': .75, 'y': .01}) btn_open_file.bind( on_release=lambda load_file: self.select_directory(self.text_output_directory, file_chooser_dialog, file_chooser.path)) btn_cancel_file = Button(text='Cancel', size_hint=(.1, .05), pos_hint={'x': .9, 'y': .01}) btn_cancel_file.bind(on_release=lambda cancel_file_selection_dialog: file_chooser_dialog.dismiss()) file_chooser_layout.add_widget(btn_open_file) file_chooser_layout.add_widget(btn_cancel_file)
def __init__(self, load_callback, pex_error_callback, error_callback, on_new_config): super(LoadPopup, self).__init__() self.load_callback = load_callback self.pex_error_callback = pex_error_callback self.error_callback = error_callback self.on_new_config = on_new_config self.content_holder = BoxLayout() self.filechooser = FileChooserIconView(path=os.getcwd(), size_hint=(.8, .8)) self.load_bt = Button(text='Select', size_hint=(.1, .1), background_normal='button6.png', background_down='button6down.png') self.filechooser.bind(on_entry_added=self.update_path) self.load_bt.bind(on_release=self.load) self.content_holder.add_widget(self.filechooser) self.content_holder.add_widget(self.load_bt) self.title = 'load file from {}'.format(self.filechooser.path) self.content = self.content_holder self.size_hint = (.7, .7) self.pos_hint = {'center_x': .5, 'center_y': .5}
def __init__(self, save_callback, pex_error_callback): super(SavePopup, self).__init__() self.save_callback = save_callback self.pex_error_callback = pex_error_callback self.content_holder = BoxLayout(orientation='vertical') self.filechooser = FileChooserIconView(path=os.getcwd(), size_hint=(1, .8)) self.config_name = TextInput(hint_text='config.pex', multiline=False, size_hint=(.3, .1)) self.save_bt = Button(text='Save', size_hint=(.1, .1), background_normal='button6.png', background_down='button6down.png') self.filechooser.bind(on_entry_added=self.update_path) self.config_name.bind(on_text_validate=self.save) self.save_bt.bind(on_release=self.save) self.content_holder.add_widget(self.filechooser) self.content_holder.add_widget(self.config_name) self.content_holder.add_widget(self.save_bt) self.title = 'save file to {}'.format(self.filechooser.path) self.content = self.content_holder self.size_hint = (.7, .7) self.pos_hint = {'center_x': .5, 'center_y': .5}
def build(self): f = FloatLayout() b = Button(pos_hint={'x': 0.5, 'center_y': .5},text='Hello world', font_size=14) s = Scatter() l = Label(text="Hello!",font_size=150) def select_to(*args): try: print args[1][0] except: pass fi = FileChooserIconView() f.add_widget(s) s.add_widget(l) l.add_widget(b) def callback(instance): print('The button <%s> is being pressed' % instance.text) f.add_widget(fi) b.bind(on_press=callback) fi.bind(on_selection=select_to) return f
def showSetFilepathPopup(self, instance): popup_layout = FloatLayout() if platform == 'android': self.file_chooser = FileChooserIconView(pos_hint={ 'x': 0, 'top': 1 }, size_hint=(1, .9), path=primary_ext_storage) else: self.file_chooser = FileChooserIconView(pos_hint={ 'x': 0, 'top': 1 }, size_hint=(1, .9)) select_button = Button(text="select", pos_hint={ 'x': .4, 'bottom': .5 }, size_hint=(.2, .1)) select_button.bind(on_press=self.saveSelectedPath) popup_layout.add_widget(self.file_chooser) popup_layout.add_widget(select_button) self.popup = Popup(title='Select where the Data for the app is stored', content=popup_layout, size_hint=(.9, .9)) self.popup.open()
def create_save_file_dialog(self): chooser = BoxLayout() container = BoxLayout(orientation='vertical') filechooser = FileChooserIconView() filechooser.path = os.path.expanduser("~") container.add_widget(filechooser) def save_file(path, filename): filepath = os.path.join(path, filename) path, ext = os.path.splitext(filepath) if ext != ".xlsx": filepath += ".xlsx" self.save_filepath = filepath self.finish() button_layout = BoxLayout() button_layout.size_hint = (1, .1) file_name = TextInput(text="File name.xlsx") button_layout.add_widget(file_name) save_btn = Button(text='save', size_hint=(.2,1)) save_btn.bind(on_release=lambda x: save_file(filechooser.path, file_name.text)) button_layout.add_widget(save_btn) container.add_widget(button_layout) chooser.add_widget(container) file_chooser = Popup(title='Save report', content=chooser, size_hint=(.9, .7 ), pos_hint={'center_x': 0.5, 'center_y': 0.5}) return file_chooser
def ad(self, instance): chos = FileChooserIconView(path="./", ) chos.bind(selection=self.aded) popup = Popup(title='Test popup', content=chos, size_hint=(None, None), size=(400, 400)) popup.open()
def Load(self, *l): print "Load" self.fl = FileChooserIconView(path=".", rootpath=".", filters=["*.ftp"], dirselect=False) #, size_hint_y = None) #self.fl.height = 500 self.fl.bind(selection=self.on_selected) self.add_widget(self.fl)
def choose_file(self, instances): filechooser = FileChooserIconView() filechooser.bind( on_selection=lambda x: self.selected(filechooser.selection)) self.main_layout.add_widget(filechooser) btn2 = Button(text='Add', size_hint=(1, .2)) x = btn2.bind(on_release=lambda x: self.open(filechooser.path, filechooser.selection)) self.main_layout.add_widget(btn2) return x
def openfile(self, *args): global pop3 self.filechoose = FileChooserIconView(path=".") pop3 = Popup(title="File Manager", content=self.filechoose, size_hint=(1, 1), pos_hint={ 'x': 0, 'y': 0 }) self.add_widget(pop3) self.filechoose.bind(on_submit=self.pk)
class FileBrowserIconView(SettingPath): def _create_popup(self, instance): #Main Container content = BoxLayout(orientation='vertical') self.popup = popup = Popup(content=content, title=self.title, size_hint=(0.7, 0.9), auto_dismiss=True) popup.open() #Header with Current Path - enter a new value and press return header = BoxLayout(size_hint_y=None, height='35dp', spacing='5dp') btn1 = Button(text="Path: ", size_hint=(.1, 1)) btn1.bind(on_release=self._updatePath) header.add_widget(btn1) #TODO: Uncomment for production #header.add_widget(Label(text="Current Path: ", size_hint=(.1,1))) #Current Path Input self.pathInput = TextInput(text=self.value, size_hint=(.9, 1), multiline=False) self.pathInput.bind(on_text_validate=self._updatePath) header.add_widget(self.pathInput) content.add_widget(header) content.add_widget(SettingSpacer()) self.textinput = FileChooserIconView(path=self.value, size_hint=(1, 1), dirselect=True, show_hidden=False) self.textinput.bind(on_path=self.val) content.add_widget(self.textinput) # 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) def val(self): self.value = self.textinput self._validate() def _updatePath(self, instance): print(self.pathInput.text) self.textinput.path = self.pathInput.text
class LoadPopup(Popup): def __init__(self, load_callback, pex_error_callback, error_callback, on_new_config): super(LoadPopup, self).__init__() self.load_callback = load_callback self.pex_error_callback = pex_error_callback self.error_callback = error_callback self.on_new_config = on_new_config self.content_holder = BoxLayout() self.filechooser = FileChooserIconView(path=os.getcwd(), size_hint=(.8, .8)) self.load_bt = Button(text='Select', size_hint=(.1, .1), background_normal='button6.png', background_down='button6down.png') self.filechooser.bind(on_entry_added=self.update_path) self.load_bt.bind(on_release=self.load) self.content_holder.add_widget(self.filechooser) self.content_holder.add_widget(self.load_bt) self.title = 'load file from {}'.format(self.filechooser.path) self.content = self.content_holder self.size_hint = (.7, .7) self.pos_hint = {'center_x': .5, 'center_y': .5} def load(self, *kwargs): if self.filechooser.selection != []: config_path = self.filechooser.selection[0] if not config_path.endswith('.pex'): self.pex_error_callback() return try: # hand off config path to particle.load_config self.load_callback(config_path) # call App to update slider defaults and emitter type self.on_new_config() # close popup window self.dismiss() except: # config file cannot be loaded self.error_callback() def update_path(self, *kwargs): self.title = 'load file from {}'.format(self.filechooser.path)
def __init__(self, next_screen, previous_screen, secretary, screen_manager, **kwargs): super().__init__(**kwargs) self.main_layout = RelativeLayout() self.label_screen = Label(text="Choose save location", font_size=UiConstants.UiConstants.labe_main_screen, size_hint=(0.5, 0.2), pos_hint={'x': 0.25, 'y': 0.8}, color=[0, 0, 0, 1], font_name="fonts/RobotoMono-Bold.ttf",) self.file_chooser = FileChooserIconView(size_hint=(0.7, 0.4), pos_hint={'y': 0.4, 'x': 0.15}) self.current_directory = self.file_chooser.path self.file_chooser.bind(path=self.okay) self.button_next_screen = Button(text="NEXT",font_size=UiConstants.UiConstants.label_font_size, size_hint=(0.25, 0.1), pos_hint={'x': 0.5, 'y': 0.0}, background_normal="backgrounds/next-button.jpg", background_down="backgrounds/next-button-pressed.jpg", font_name="fonts/RobotoMono-Bold.ttf", on_release=lambda btn: self.go_to_next_screen(next_screen=next_screen, secretary=secretary, screen_manager=screen_manager)) self.button_previous_screen = Button(text="PREV", size_hint=(0.25, 0.1), pos_hint={'x': 0.25, 'y': 0}, background_normal="backgrounds/back-button.jpg", font_size=UiConstants.UiConstants.label_font_size, background_down="backgrounds/back-button-down.jpg", font_name="fonts/RobotoMono-Bold.ttf", on_release=lambda btn: self.go_back(previous_screen=previous_screen, screen_manager=screen_manager)) self.label_current_directory_field = Label(text="Current Directory: ", font_name="fonts/RobotoMono-Regular.ttf", size_hint=(0.25, 0.1), pos_hint={'x': 0.25, 'y': 0.30}, color=[0, 0, 0, 1]) self.label_current_directory = TextInput(text=self.current_directory, size_hint=(0.25, 0.1), font_name="fonts/RobotoMono-Regular.ttf", pos_hint={'x': 0.5, 'y': 0.3} , background_normal="backgrounds/input-background.jpg", disabled="true", background_disabled_normal="backgrounds/input-background.jpg") self.label_file_name = Label(text="File name:", size_hint=(0.25, 0.1), pos_hint={'y': 0.18, 'x': 0.25}, font_name="fonts/RobotoMono-Regular.ttf", color=[0, 0, 0, 1]) self.text_input_file_name = TextInput(size_hint=(0.25, 0.1), pos_hint={'y': 0.18, 'x': 0.5}, font_name="fonts/RobotoMono-Regular.ttf" , background_normal="backgrounds/input-background.jpg") self.text_input_file_name.input_filter = self.filename_text_filter self.main_layout.add_widget(self.label_screen) self.main_layout.add_widget(self.file_chooser) self.main_layout.add_widget(self.label_current_directory_field) self.main_layout.add_widget(self.label_current_directory) self.main_layout.add_widget(self.label_file_name) self.main_layout.add_widget(self.text_input_file_name) self.main_layout.add_widget(self.button_next_screen) self.main_layout.add_widget(self.button_previous_screen) Clock.schedule_once(self.custom_init, 1)
def __init__(self, **kwargs): super(DavChooser, self).__init__(**kwargs) self.orientation = "vertical" self.spacing = "5dp" self.chooser = FileChooserIconView(path=self.path) self.chooser.bind(selection=self.on_file_select, path=self.setter("path")) self.fileentry = TextInput(size_hint_y=None, height="30dp", text=self.filename, multiline=False) self.fileentry.bind(text=self.setter("filename")) self.davbar = BoxLayout(orientation="horizontal", size_hint_y=None, height="45dp", spacing="5dp") self.levelup = Button(on_press=hide_keyboard, on_release=self.on_levelup, height=40, width=40, size_hint=(None, None), background_normal=os.path.join(curdir, "images/levelup_normal.png"), background_down=os.path.join(curdir, "images/levelup_down.png")) self.newdir = Button(on_press=hide_keyboard, on_release=self.on_newdir, height=40, width=40, size_hint=(None, None), background_normal=os.path.join(curdir, "images/newdir_normal.png"), background_down=os.path.join(curdir, "images/newdir_down.png")) self.davbar.add_widget(self.levelup) scroll = ScrollView(pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_y=False, size_hint=(1, 1)) self.navbar = GridLayout(cols=1, orientation="horizontal", spacing=5, padding=[5, 0, 0, 0]) self.navbar.bind(minimum_height=self.navbar.setter('height')) scroll.add_widget(self.navbar) self.davbar.add_widget(scroll) self.davbar.add_widget(self.newdir) self.chooser.bind(path=self.on_path) self.on_path(None, self.path) self.add_widget(self.davbar) self.add_widget(self.fileentry) self.add_widget(self.chooser)
def _save(self, instance): """ Creates a popup to allow the user to save an image file directly to his or her device. Parameter instance: The position where the button was pressed Precondition: instance is a valid position """ content = BoxLayout(orientation='vertical') # Create file chooser self._file_chooser = FileChooserIconView(rootpath='.', filters=['*.png']) content.add_widget(self._file_chooser) # Create text box self._text_input = TextInput(size_hint_y=None, height=30, font_size=14, multiline=False) content.add_widget(self._text_input) # Create buttons options = BoxLayout(size_hint_y=None, height=30) cancel_choice = Button(text='Cancel', on_release=self._dismiss_popup) options.add_widget(cancel_choice) load_choice = Button(text='Save', on_release=self._save_file) options.add_widget(load_choice) content.add_widget(options) # Create popup self._popup = Popup(title='Save image', content=content, size_hint=(0.8, 0.8), pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self._popup.open()
def _load(self, instance): """ Creates a popup to allow the user to load an image file directly from his or her device. Parameter instance: The position where the button was pressed Precondition: instance is a valid position """ content = BoxLayout(orientation='vertical') # Create file chooser self._file_chooser = FileChooserIconView(path='.', filters=['*.png']) content.add_widget(self._file_chooser) # Create label self._label = Label(size_hint_y=None, height=30, font_size=14, text='') content.add_widget(self._label) # Create buttons options = BoxLayout(size_hint_y=None, height=30) cancel_choice = Button(text='Cancel', on_release=self._dismiss_popup) options.add_widget(cancel_choice) load_choice = Button(text='Load', on_release=self._load_file) options.add_widget(load_choice) content.add_widget(options) # Create popup self._popup = Popup(title='Load image', content=content, size_hint=(0.8, 0.8), pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self._popup.open()
def __init__(self, **kwargs): super(FileSelect, self).__init__(**kwargs) container = BoxLayout(orientation='vertical') file_chooser = FileChooserIconView() file_chooser.bind( on_selection=lambda x: self.selected(file_chooser.selection)) open_btn = Button(text='Open selected file', size_hint=(1, .2)) open_btn.bind(on_release=lambda x: open_file(file_chooser.path, file_chooser.selection)) container.add_widget(file_chooser) container.add_widget(open_btn) self.add_widget(container)
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=(0.7, 0.9)) # create the filechooser initial_path = self.value or os.getcwd() self.textinput = textinput = FileChooserIconView( 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 browser(self, op): """ This function creates the file chooser to select image""" # Create Layout for popup try: self.popup.dismiss() except PopupException: pass self.current = 'Selecionar Ficheiro' b_main_lay = GridLayout(rows=2) action_layout = BoxLayout(orientation='horizontal', size_hint_y=0.1) file = FileChooserIconView(path=self.path, size_hint_y=0.9, multiselect=False) # this popup buttons and actions select = Button(text='Selecionar') select.bind(on_press=lambda x: self.open(file.selection, op)) cancel = Button(text='Cancelar') cancel.bind(on_press=self.cancel_callback) action_layout.add_widget(select) action_layout.add_widget(cancel) b_main_lay.add_widget(file) b_main_lay.add_widget(action_layout) self.s_open_file.add_widget(b_main_lay)
def popup_load(self, instance): def cancel(instance): popup.dismiss() def ok(instance): load_file = fileChooser.selection[0] print(str(load_file)) with open(load_file, 'r') as stream: print(stream.read()) fileChooser = FileChooserIconView(path="/home") popup_content = BoxLayout(orientation='vertical') buttons_box = BoxLayout(orientation='horizontal', size_hint=(0.3, 0.3)) ok_button = Button(text="Ok", font_size=14) cancel_button = Button(text="Cancel", font_size=14) ok_button.bind(on_press=ok) cancel_button.bind(on_press=cancel) buttons_box.add_widget(ok_button) buttons_box.add_widget(cancel_button) popup_content.add_widget(fileChooser) popup_content.add_widget(buttons_box) popup = Popup(title="Load Preference", content=popup_content, size_hint=(0.5, 0.5)) popup.open()
def show_load(self): self.filechooser = FileChooserIconView() bl1 = BoxLayout(size=self.size, pos=self.pos, orientation="vertical") bl2 = BoxLayout(size_hint_y=None, height=30) self._popup = Popup(title="Selecionar Pasta", content=bl1, size_hint=(0.9, 0.9), background="./img/blue.png") self.filechooser.path = f'{Path.home()}/Desktop/' bt1 = Builder.load_string(''' Botao: text: "Cancelar" size_hint: .5,1 ''') bt1.bind(on_press=self.dismiss_popup) bt2 = Builder.load_string(''' Botao: text: "Selecionar Esta Pasta" size_hint: .5,1 ''') bt2.bind(on_press=self.carregar) bl2.add_widget(bt1) bl2.add_widget(bt2) bl1.add_widget(self.filechooser) bl1.add_widget(bl2) self._popup.open()
def __init__(self, **kwargs): super(MainWindowShareFile, self).__init__(**kwargs) self.orientation = 'vertical' self.spacing = 5 self.padding = 2 self.share_settings_file_title = Label(text='Browse file to share', font_size='32sp') self.share_settings_file_title.size_hint = (1, 0.1) self.share_settings_file_title.color = (0, 0, 0, 0.8) self.share_settings_file_title.halign = 'center' self.add_widget(self.share_settings_file_title) self.share_settings_file_filechooser = FileChooserIconView() self.share_settings_file_filechooser.filters = filters = [ '*.jpeg', '*.jpg', '*.gif', '*.png', '*.tiff', '*.svg', '*.bmp', '*.doc', '*.docx', '*.xlsx', '*.xls', '*.pptx', '*.ppt', '*.pdf', '*.odt', '*.ods', '*.odg', '*.odp', '*.csv', '*.txt' ] self.share_settings_file_filechooser.size_hint = (1, 0.8) self.add_widget(self.share_settings_file_filechooser) self.share_settings_file_upload = Button(text='Upload selected file') self.share_settings_file_upload.size_hint = (1, 0.1) self.share_settings_file_upload.background_color = (1, 0, 0, 1) self.share_settings_file_upload.bind( on_press=self.share_settings_file_upload_callback) self.add_widget(self.share_settings_file_upload) self.popup_message = Label(text='Please select a file to share') self.popup_message.halign = 'center' self.share_settings_file_message = Popup(title='Files browser', content=self.popup_message, auto_dismiss=True) self.share_settings_file_message.title_align = 'center' self.share_settings_file_message.size_hint = (0.8, 0.3)
def save(self, popup): popup.dismiss() popup = Popup(title='Charger', size_hint=(0.9, 0.9), auto_dismiss=False) bl_main = BoxLayout(orientation='vertical') bl = BoxLayout(orientation='vertical') flc = FileChooserIconView() bl_main.add_widget(flc) newFile = Button(text="Nouveau fichier") newFile.bind(on_press=lambda a: self.p_newfile(flc.path)) bl.add_widget(newFile) confirm = Button(text="Confirmer") confirm.bind( on_press=lambda a: self.save_confirm(flc.selection, popup)) bl.add_widget(confirm) cancel_button = Button(text="Annuler") cancel_button.bind(on_press=lambda a: popup.dismiss()) bl.add_widget(cancel_button) bl_main.add_widget(bl) popup.content = bl_main popup.open()
def load(self, popup): popup.dismiss() popup = Popup(title='Charger', size_hint=(0.9, 0.9), auto_dismiss=False) bl_main = BoxLayout(orientation='vertical') bl = BoxLayout(orientation='vertical') flc = FileChooserIconView() bl_main.add_widget(flc) confirm_button = Button(text="Confirmer") confirm_button.bind( on_press=lambda a: self.load_confirm(flc.selection, popup)) bl.add_widget(confirm_button) cancel_button = Button(text="Annuler") cancel_button.bind(on_press=lambda a: popup.dismiss()) bl.add_widget(cancel_button) bl_main.add_widget(bl) popup.content = bl_main popup.open()
def __init__(self, next_screen, previous_screen, screen_manager, secretary, **kwargs): super().__init__(**kwargs) self.main_layout = RelativeLayout() self.label_select_sequence_file = Label( text="Select Sequence File", size_hint_y=0.2, color=[0, 0, 0, 1], size_hint_x=0.5, pos_hint={ 'y': 0.8, 'x': 0.25 }, font_name="fonts/RobotoMono-Bold.ttf", font_size=sqFdUi.UiConstants.labe_main_screen) self.file_chooser_icon_view = FileChooserIconView(size_hint_y=0.4, size_hint_x=0.7, pos_hint={ 'y': 0.4, 'x': 0.15 }) self.button_next_screen = Button( text="NEXT", size_hint_y=0.1, size_hint_x=0.25, pos_hint={ 'y': 0.0, 'x': 0.5 }, font_size=sqFdUi.UiConstants.label_font_size, background_normal="backgrounds/next-button.jpg", background_down="backgrounds/next-button-pressed.jpg", font_name="./fonts/RobotoMono-Bold.ttf", on_release=lambda btn: self.go_to_next_screen( next_screen=next_screen, secretary=secretary, screen_manager=screen_manager, btn=btn)) self.button_previous_screen = Button( text="PREV", size_hint_y=0.1, size_hint_x=0.25, pos_hint={ 'y': 0.0, 'x': 0.25 }, background_normal="backgrounds/back-button.jpg", background_down="backgrounds/back-button-down.jpg", font_name="fonts/RobotoMono-Bold.ttf", font_size=sqFdUi.UiConstants.label_font_size, on_release=lambda btn: self.go_back(previous_screen= previous_screen, screen_manager=screen_manager)) self.main_layout.add_widget(self.file_chooser_icon_view) self.main_layout.add_widget(self.label_select_sequence_file) self.main_layout.add_widget(self.button_next_screen) self.main_layout.add_widget(self.button_previous_screen) Clock.schedule_once(self.custom_init, 1)
def build(self): test = MyWidget(cols=2) filechooser = FileChooserIconView(size_hint=(0.5,0.5)) train_button = Button(size_hint=(1,None),text="Train", height=100) train_button.bind(on_press=lambda _: self.test(filechooser.selection)) test.add_widget(filechooser) test.add_widget(train_button) return test
class HackApp(App): def update(self, select, instance, value): file = self.chooser.selection self.imagebox.clear_widgets() selected = Image(source=file[0]) self.imagebox.add_widget(selected) class_found, pourc = predict(file[0]) self.resultlabel.text = f'Classe : {class_found}\nPourcentage : {pourc}' def build(self): self.title = "HackApp" mainwindow = BoxLayout(orientation="vertical") imagelayout = BoxLayout(orientation="vertical") resultlayout = BoxLayout() self.imagebox = BoxLayout() popupbutton = Button(text="Choose the photo to analyse", size_hint=(0.5, 0.2), pos_hint={'x': 0.25}, background_color=color_button) launchbutton = Button(text="Launch Analysis", size_hint=(0.5, 0.2), pos_hint={'x': 0.25}, background_color=color_button) popup = Popup(size_hint=(0.5, 0.5)) ospath = os.path.abspath(os.getcwd()) self.chooser = FileChooserIconView(path=ospath) self.resultlabel = Label(text="", color=color_text) ledimage = Image(source="led-sunlight-300x230.jpg") popupbutton.bind(on_press=popup.open) self.chooser.bind(on_submit=self.update) popup.add_widget(self.chooser) imagelayout.add_widget(self.imagebox) imagelayout.add_widget(popupbutton) imagelayout.add_widget(launchbutton) resultlayout.add_widget(self.resultlabel) resultlayout.add_widget(ledimage) mainwindow.add_widget(imagelayout) mainwindow.add_widget(resultlayout) return mainwindow
def choose_file(self): self.view = view = ModalView(size_hint=(0.7, 0.7), pos_hint={ 'center_x': 0.5, 'top': 1 }) filechooser = FileChooserIconView(on_submit=self.change_file) view.add_widget(filechooser) view.open()
class DavChooser(BoxLayout): filename = StringProperty("") chooser = ObjectProperty(None, allownone=True) path = StringProperty(home) def __init__(self, **kwargs): super(DavChooser, self).__init__(**kwargs) self.orientation = "vertical" self.spacing = "5dp" self.chooser = FileChooserIconView(path=self.path) self.chooser.bind(selection=self.on_file_select, path=self.setter("path")) self.fileentry = TextInput(size_hint_y=None, height="30dp", text=self.filename, multiline=False) self.fileentry.bind(text=self.setter("filename")) self.davbar = BoxLayout(orientation="horizontal", size_hint_y=None, height="45dp", spacing="5dp") self.levelup = Button(on_press=hide_keyboard, on_release=self.on_levelup, height=40, width=40, size_hint=(None, None), background_normal=os.path.join(curdir, "images/levelup_normal.png"), background_down=os.path.join(curdir, "images/levelup_down.png")) self.newdir = Button(on_press=hide_keyboard, on_release=self.on_newdir, height=40, width=40, size_hint=(None, None), background_normal=os.path.join(curdir, "images/newdir_normal.png"), background_down=os.path.join(curdir, "images/newdir_down.png")) self.davbar.add_widget(self.levelup) scroll = ScrollView(pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_y=False, size_hint=(1, 1)) self.navbar = GridLayout(cols=1, orientation="horizontal", spacing=5, padding=[5, 0, 0, 0]) self.navbar.bind(minimum_height=self.navbar.setter('height')) scroll.add_widget(self.navbar) self.davbar.add_widget(scroll) self.davbar.add_widget(self.newdir) self.chooser.bind(path=self.on_path) self.on_path(None, self.path) self.add_widget(self.davbar) self.add_widget(self.fileentry) self.add_widget(self.chooser) def on_path(self, instance, path): splitpath = os.path.abspath(path).split(os.sep) self.navbar.clear_widgets() if splitpath[0] == "": splitpath[0] = os.sep #print splitpath for i in splitpath: if i != "": btn = Button(text=i, on_press=hide_keyboard, on_release=self.navigate, height=40, size_hint=(None, None)) btn.path = os.path.normpath(os.sep.join(splitpath[:splitpath.index(i)+1])) #print "buttonpath", btn.path, splitpath[:splitpath.index(i)+1], "i:", i, splitpath.index(i) self.navbar.cols = len(self.navbar.children) + 1 self.navbar.add_widget(btn) def on_levelup(self, *args): #print "levelup", os.sep.join(self.chooser.path.split(os.sep)[:-1]), self.chooser.path newpath = os.sep.join(self.chooser.path.split(os.sep)[:-1]) if newpath == "": newpath = os.sep self.chooser.path = newpath def on_newdir(self, *args): content = BoxLayout(orientation="vertical", spacing="5dp") self.popup = Popup(size_hint=(.5, .5), content=content, title="New folder") buttonbox = BoxLayout(orientation="horizontal", spacing="5dp", height=45) ok = Button(text="OK", on_press=hide_keyboard, on_release=self.mkdir, height=40, size_hint_y=None) cancel = Button(text="Cancel", on_press=hide_keyboard, on_release=self.popup.dismiss, height=40, size_hint_y=None) buttonbox.add_widget(ok) buttonbox.add_widget(cancel) self.direntry = TextInput(height=30, size_hint_y=None, on_text_validate=self.mkdir, multiline=False) content.add_widget(self.direntry) content.add_widget(buttonbox) self.popup.open() def mkdir(self, *args): #print "mkdir", os.path.join(self.chooser.path, self.direntry.text) os.mkdir(os.path.join(self.chooser.path, self.direntry.text)) # This should make the view refresh self.chooser.path = os.sep + self.chooser.path[:] self.popup.dismiss() def navigate(self, button): #print "navigate", button.path self.chooser.path = button.path def on_file_select(self, instance, selection): try: self.fileentry.text = selection and os.path.basename(selection[0]) or "" except: self.fileentry.text = "" self.filename = selection[0]
class TreeViewBlock(Button, TreeViewNode): def __init__(self, *args, **kwargs): super(TreeViewBlock, self).__init__(*args, **kwargs) print args self.background_normal="images/button.png" self.background_down="images/button.png" self.background_color=[0,0,0,0] self.color=[.2,0.2,0.2,1] self.size_hint_y=None self.height=30 self.bind(on_release=self.click) self.color_selected=[.9,.5,.3,1] the_layout=BoxLayout(orientation="vertical") b1 = BoxLayout(size_hint_y=None, height=45, padding=5) l= Label(text="Title : ",font_size=16) t = TextInput(text=self.text, multiline=False, font_size=18) t.bind(on_text_validate=self.onTextChange) b1.add_widget(l) b1.add_widget(t) b2=BoxLayout(padding=8) l1=Label(text="Add ") b3=BoxLayout(orientation="vertical") btn1=Button(text="Application",font_size=14) btn1.bind(on_release=self.appsPopupOpen) btn2=Button(text="File",font_size=14) btn2.bind(on_release=self.filesPopupOpen) btn3=Button(text="Folder",font_size=14) btn3.bind(on_release=self.foldersPopupOpen) b3.add_widget(btn1) b3.add_widget(btn2) b3.add_widget(btn3) l2=Label(text="To Block.") b2.add_widget(l1) b2.add_widget(b3) b2.add_widget(l2) rem = Button(text="Remove this block", size_hint_y=None, height=30, background_normal="images/button.png", background_color=[.8,.2,.2,1]) rem.bind(on_release=self.removeBlock) the_layout.add_widget(b1) the_layout.add_widget(Label(text="----",size_hint_y=None,height=20)) the_layout.add_widget(b2) the_layout.add_widget(rem) self.popupWindow = Popup(title="Block: '{}'".format(self.text), size_hint=(None,None), size=(400,230), separator_color=[.9,.4,.2,1], background_color=[0,0,0,.6], content=the_layout ) ###Apps b = BoxLayout(orientation="vertical") self.app_list =AddAppList() a_btn=Button(text="Add This Application", size_hint_y=None, height=40) a_btn.bind(on_release=self.addApp) b.add_widget(self.app_list) b.add_widget(a_btn) self.appsPopup = Popup(title="Add Application to '{}'".format(self.text), size_hint=(None,None), size=(400,400), separator_color=[.9,.4,.2,1], background_color=[0,0,0,.6], content=b ) ##Files box = BoxLayout(orientation="vertical") self.f=FileChooserIconView(multiselect=False, path= os.path.expanduser("~")) self.f.bind(on_submit=self.addFile) l=Label(text="Double click on a file to add it.",size_hint_y=None,height=40) box.add_widget(self.f) box.add_widget(l) self.filesPopup = Popup(title="Add File to '{}'".format(self.text), size_hint=(None,None), size=(500,500), separator_color=[.9,.4,.2,1], background_color=[0,0,0,.6], content=box ) ##Folders box1=BoxLayout(orientation="vertical") self.f2=FileChooserIconView(multiselect=False, path= os.path.expanduser("~")) self.f2.bind(on_entry_added=self.updateFolders) b=BoxLayout(size_hint_y=None, height=50, padding=5) self.folder_label = Label(text=self.f2.path,id="FileLabel") btn=Button(text="Add Folder", size_hint_x=None,width=150) btn.bind(on_release=self.addFolder) b.add_widget(self.folder_label) b.add_widget(btn) box1.add_widget(self.f2) box1.add_widget(b) self.foldersPopup = Popup(title="Add Folder to '{}'".format(self.text), size_hint=(None,None), size=(500,500), separator_color=[.9,.4,.2,1], background_color=[0,0,0,.6], content=box1 ) def onTextChange(self, *args): for b in pickle.loads(d_cfg.get()['blocks']): if b["name"] == self.text: b["name"]=args[0].text self.text=args[0].text blocks=createBlockDicts(self.parentTree.iterate_all_nodes()) updateConfig({'blocks':blocks}) def appsPopupOpen(self,*args): self.popupWindow.dismiss() self.appsPopup.open() def filesPopupOpen(self,*args): self.popupWindow.dismiss() self.filesPopup.open() def foldersPopupOpen(self,*args): self.popupWindow.dismiss() self.foldersPopup.open() def addApp(self, *args): s = self.app_list.adapter.selection[0].text if s!=None: #Update node= self.parentTree.selected_node new=TreeViewButton(text=s) new.parentTree=self.parentTree self.parentTree.add_node(new,node) self.appsPopup.dismiss() blocks= createBlockDicts(self.parentTree.iterate_all_nodes()) updateConfig({"blocks":blocks}) def addFile(self,*args): for b in pickle.loads(d_cfg.get()["blocks"]): if b["name"]==self.text: #Update Tree node= self.parentTree.selected_node new=TreeViewButton(text=str(args[1][0])) new.parentTree=self.parentTree self.parentTree.add_node(new,node) self.filesPopup.dismiss() blocks= createBlockDicts(self.parentTree.iterate_all_nodes()) updateConfig({"blocks":blocks}) def addFolder(self,*args): p = self.f2.path if os.path.exists(p): #Update node= self.parentTree.selected_node new=TreeViewButton(text=p) new.parentTree=self.parentTree self.parentTree.add_node(new,node) self.foldersPopup.dismiss() blocks= createBlockDicts(self.parentTree.iterate_all_nodes()) print blocks updateConfig({"blocks":blocks}) def updateFolders(self,*args): self.folder_label.text = self.f2.path def removeBlock(self,*args): try: self.parentTree.remove_node(self) blocks= createBlockDicts(self.parentTree.iterate_all_nodes()) updateConfig({"blocks":blocks}) except:pass self.popupWindow.dismiss() def click(self,*args): self.popupWindow.open()
def __init__(self, *args, **kwargs): super(TreeViewBlock, self).__init__(*args, **kwargs) print args self.background_normal="images/button.png" self.background_down="images/button.png" self.background_color=[0,0,0,0] self.color=[.2,0.2,0.2,1] self.size_hint_y=None self.height=30 self.bind(on_release=self.click) self.color_selected=[.9,.5,.3,1] the_layout=BoxLayout(orientation="vertical") b1 = BoxLayout(size_hint_y=None, height=45, padding=5) l= Label(text="Title : ",font_size=16) t = TextInput(text=self.text, multiline=False, font_size=18) t.bind(on_text_validate=self.onTextChange) b1.add_widget(l) b1.add_widget(t) b2=BoxLayout(padding=8) l1=Label(text="Add ") b3=BoxLayout(orientation="vertical") btn1=Button(text="Application",font_size=14) btn1.bind(on_release=self.appsPopupOpen) btn2=Button(text="File",font_size=14) btn2.bind(on_release=self.filesPopupOpen) btn3=Button(text="Folder",font_size=14) btn3.bind(on_release=self.foldersPopupOpen) b3.add_widget(btn1) b3.add_widget(btn2) b3.add_widget(btn3) l2=Label(text="To Block.") b2.add_widget(l1) b2.add_widget(b3) b2.add_widget(l2) rem = Button(text="Remove this block", size_hint_y=None, height=30, background_normal="images/button.png", background_color=[.8,.2,.2,1]) rem.bind(on_release=self.removeBlock) the_layout.add_widget(b1) the_layout.add_widget(Label(text="----",size_hint_y=None,height=20)) the_layout.add_widget(b2) the_layout.add_widget(rem) self.popupWindow = Popup(title="Block: '{}'".format(self.text), size_hint=(None,None), size=(400,230), separator_color=[.9,.4,.2,1], background_color=[0,0,0,.6], content=the_layout ) ###Apps b = BoxLayout(orientation="vertical") self.app_list =AddAppList() a_btn=Button(text="Add This Application", size_hint_y=None, height=40) a_btn.bind(on_release=self.addApp) b.add_widget(self.app_list) b.add_widget(a_btn) self.appsPopup = Popup(title="Add Application to '{}'".format(self.text), size_hint=(None,None), size=(400,400), separator_color=[.9,.4,.2,1], background_color=[0,0,0,.6], content=b ) ##Files box = BoxLayout(orientation="vertical") self.f=FileChooserIconView(multiselect=False, path= os.path.expanduser("~")) self.f.bind(on_submit=self.addFile) l=Label(text="Double click on a file to add it.",size_hint_y=None,height=40) box.add_widget(self.f) box.add_widget(l) self.filesPopup = Popup(title="Add File to '{}'".format(self.text), size_hint=(None,None), size=(500,500), separator_color=[.9,.4,.2,1], background_color=[0,0,0,.6], content=box ) ##Folders box1=BoxLayout(orientation="vertical") self.f2=FileChooserIconView(multiselect=False, path= os.path.expanduser("~")) self.f2.bind(on_entry_added=self.updateFolders) b=BoxLayout(size_hint_y=None, height=50, padding=5) self.folder_label = Label(text=self.f2.path,id="FileLabel") btn=Button(text="Add Folder", size_hint_x=None,width=150) btn.bind(on_release=self.addFolder) b.add_widget(self.folder_label) b.add_widget(btn) box1.add_widget(self.f2) box1.add_widget(b) self.foldersPopup = Popup(title="Add Folder to '{}'".format(self.text), size_hint=(None,None), size=(500,500), separator_color=[.9,.4,.2,1], background_color=[0,0,0,.6], content=box1 )