class CharacterSpellsTab(TabbedPanelItem): def __init__(self, character, *args, **kwargs): super(CharacterSpellsTab, self).__init__(*args, **kwargs) self.character = character self.text = 'Spells' self.content = BoxLayout(orientation='vertical') self.spacing = 10 self.spells = ScrollView(size=(Window.width, Window.height)) self.layout = GridLayout(cols=1, spacing=1, size_hint_y=None) self.layout.bind(minimum_height=self.layout.setter('height')) self.spells.add_widget(self.layout) def add_spell(button): popup = AddSpellPopup(self) popup.open() buttons = BoxLayout(orientation='horizontal', size_hint=(1, .1)) buttons.add_widget(Button(text='Add spell', on_press=add_spell)) self.content.add_widget(buttons) self.content.add_widget(SpellHeader()) self.content.add_widget(self.spells) self.set_spells() def set_spells(self): self.layout.clear_widgets() spells = (session.query(SpellbookEntry).filter( SpellBookEntry.character == self.character.name).all()) for spell in spells: self.layout.add_widget( SpellbookEntry(self, spell, height=60, size_hint_y=None)) self.layout.bind(minimum_height=self.layout.setter('height'))
def OnIceFenwickStats(obj): # Clear widgets in order to hide previous table if user searched for other play stat categories first Layout.clear_widgets() Layout.add_widget(BackToPlayerSearch) Layout.add_widget(PlayerSearchLabel) Layout.add_widget(IndividualButton) Layout.add_widget(On_Ice_Goals_Button) Layout.add_widget(On_Ice_Fenwick_Button) Grid = GridLayout(rows = len(On_ice_Fenwick_stats) + 1, cols = len(On_ice_Fenwick_categories), size_hint = (None, None)) Grid.bind(minimum_height=Grid.setter('height'), minimum_width = Grid.setter('width')) for stat_category in On_ice_Fenwick_categories: Grid.add_widget(TextInput(text = str(stat_category), size_hint = (None, None), font_size = 18, readonly = True)) for i in range(len(On_ice_Fenwick_stats)): if i % 2 == 0: ColorBackGround = [200./255, 204./255, 255./255, 1] else: ColorBackGround = [1,1,1,1] season = On_ice_Fenwick_stats[i] for stat in season: Grid.add_widget(TextInput(text = str(stat), size_hint = (None, None), font_size = 18, background_color = ColorBackGround, readonly = True)) Scroll = ScrollView(size_hint = (1, .65)) Scroll.add_widget(Grid) Layout.add_widget(Scroll)
class MyScroll(ScrollView): def __init__(self, **kwargs): super(MyScroll, self).__init__(**kwargs) self.grid1 = GridLayout(cols=10) self.add_widget(self.grid1) self.grid1.size_hint = None, None self.grid1.bind(minimum_height=self.grid1.setter("height")) self.grid1.bind(minimum_width=self.grid1.setter("width")) for i in range(20): for j in range(10): ti = TextInput(size_hint=(None, None)) ti.width = metrics.sp(160) ti.height = metrics.sp(40) if i > 2: ti.row = i ti.col = j self.grid1.add_widget(ti) ti.bind(text=self.textChanged) return def textChanged(self, instance, val): if getattr(instance, "row", None): print instance.row, instance.col, val else: print "Variable row is not implimented"
def build(self): layout1 = GridLayout(cols=4, spacing=10, size_hint=(None, None)) layout1.bind(minimum_height=layout1.setter('height'), minimum_width=layout1.setter('width')) for i in range(40): btn = Button(text=str(i), size_hint=(None, None), size=(200, 100)) layout1.add_widget(btn) scrollview1 = ScrollView(bar_width='2dp') scrollview1.add_widget(layout1) layout2 = GridLayout(cols=4, spacing=10, size_hint=(None, None)) layout2.bind(minimum_height=layout2.setter('height'), minimum_width=layout2.setter('width')) for i in range(40): btn = Button(text=str(i), size_hint=(None, None), size=(200, 100)) layout2.add_widget(btn) scrollview2 = ScrollView(scroll_type=['bars'], bar_width='9dp', scroll_wheel_distance=100) scrollview2.add_widget(layout2) root = GridLayout(cols=2) root.add_widget(scrollview1) root.add_widget(scrollview2) return root
def generate_folder_buttons(self): """ Generate buttons with folder names on MainScreen """ #Clear widgets self.ids.mainscreen_default_output.clear_widgets() #No folder choosen when folders are being shown manager_of_track_list.active_folder = '' #If there is no folders - generate Button for rescan removable media: if manager_of_track_list.track_list == []: #Grid layout which will contain this button grid = GridLayout(cols=1, spacing=50, size_hint_y=None) grid.bind(minimum_height=grid.setter('height')) #Button for rescan but = Button(text='Scan removable media' ,strip=True, text_size=(300,300),halign='center',valign='middle') grid.add_widget(but) #Show sv = self.ids.mainscreen_default_output sv.add_widget(grid) else: #Grid layout which will contain all folder buttons grid = GridLayout(cols=2, spacing=(25,10), size_hint_y=None, padding = [10,10,10,10], row_force_default=True, row_default_height=100) grid.bind(minimum_height=grid.setter('height')) sv = self.ids.mainscreen_default_output sv.add_widget(grid) #Count folders to display it number in header: self.total_counter = 0 #Iterating folders: manager_of_track_list.track_list[{'folder_name'}] for tr_rec in manager_of_track_list.track_list: #header text counter self.total_counter += 1 #folder name for button text folder_name = tr_rec['folder_name'] #Create Button but = Button(text=folder_name, size_hint_y=None, halign='center',valign='middle') but.bind(on_release=self.generate_track_view) grid.add_widget(but) #update header self.ids.mainscreen_header.text = 'Folders: %s' % str(self.total_counter)
def set_list(self): #Get all image file name in Images Craft Bottles first_list = [] second_list = [] if self.query_result is None: i = 0 for name in os.listdir('./images/bottles/'): if i%2 == 0: first_list.append(name) else: second_list.append(name) i = i + 1 #get all Items else: i = 0 for name in self.query_result: if i%2 == 0: first_list.append(name+'.jpg') else: second_list.append(name+'.jpg') i = i + 1 # Clear widget first self.scroll_view_one.clear_widgets() self.scroll_view_two.clear_widgets() self.remove_widget(self.scroll_view_one) self.remove_widget(self.scroll_view_two) #First Horizontal Scrollable View grid_one_layout = GridLayout(cols=len(first_list), spacing=10, size_hint_x=None) #Make sure the height is such that there is something to scroll. grid_one_layout.bind(minimum_width=grid_one_layout.setter('width')) for file_name in first_list: anchor_one_layout = AnchorLayout(size_hint_x=None, size_hint_y=None, height=240, width=200, anchor_x='center', anchor_y='bottom') btn = Button(text=file_name, color=[0,0,0,0], size_hint_y=None, size_hint_x=None, height=240, width=200, background_color=[1,1,1,1], background_normal='images/bottles/{f_name}'.format(f_name=file_name)) btn.bind(on_press=self.on_item_click) beer_name = file_name[:-4] label = Label(text=beer_name, color=[0,0,0,1], italic=True, font_size='12dp', size_hint=(None, None), height=30, width=anchor_one_layout.width, halign='center', pos_hint={'x':0,'y':0}) anchor_one_layout.add_widget(btn) anchor_one_layout.add_widget(label) grid_one_layout.add_widget(anchor_one_layout) self.scroll_view_one.add_widget(grid_one_layout) self.add_widget(self.scroll_view_one) #First Horizontal Scrollable View grid_two_layout = GridLayout(cols=len(second_list), spacing=10, size_hint_x=None) #Make sure the height is such that there is something to scroll. grid_two_layout.bind(minimum_width=grid_two_layout.setter('width')) for file_name in second_list: anchor_two_layout = AnchorLayout(size_hint_x=None, size_hint_y=None, height=240, width=200, anchor_x='center', anchor_y='bottom') btn = Button(text=file_name, color=[0,0,0,0], size_hint_y=None, size_hint_x=None, height=240, width=200, background_color=[1,1,1,1], background_normal='images/bottles/{f_name}'.format(f_name=file_name)) btn.bind(on_press=self.on_item_click) beer_name = file_name[:-4] label = Label(text=beer_name, color=[0,0,0,1], italic=True, font_size='12dp', size_hint=(None, None), height=30, width=anchor_two_layout.width, halign='center', pos_hint={'x':0,'y':0}) anchor_two_layout.add_widget(btn) anchor_two_layout.add_widget(label) grid_two_layout.add_widget(anchor_two_layout) self.scroll_view_two.add_widget(grid_two_layout) self.add_widget(self.scroll_view_two)
def showQuestions(self): Play = ScrollView(size_hint=(self.qScrollW, self.qScrollH), pos_hint={ "center_x": self.qScrollX, "center_y": self.qScrollY }, size=(Window.width, Window.height)) Roll = GridLayout(cols=1, spacing=25, padding=10, size_hint_y=None) Roll.bind(minimum_height=Roll.setter('height')) Play.add_widget(Roll) self.add_widget(Play) for qNo in range(len(self.questions)): qTab = GridLayout(cols=1, size_hint=(1.0, None), height=self.qTabHeight, spacing=5, padding=10) qTab.bind(minimum_height=qTab.setter('height')) question = Button(text=self.questions[qNo], halign='center', font_size=self.fontSize, background_color=(0.4, 0.4, 0.4, 0.4), size_hint=(1.0, None), font_name=self.fontStyle, color=(1, 1, 1, 1)) question.bind( width=lambda s, w: s.setter("text_size")(s, (w, None))) question.bind(texture_size=question.setter("size")) qTab.add_widget(question) for listNo in range(len(self.options)): optTab = GridLayout(cols=len(self.options[listNo]), size_hint=(1.0, None)) optTab.bind(minimum_height=optTab.setter('height')) for optNo in range(len(self.options[listNo])): btn = ToggleButton(text=self.options[listNo][optNo], halign='center', state="normal", group=str(qNo) + "-" + str(listNo), font_name=self.fontStyle, font_size=self.fontSize, background_color=(0.5, 0.5, 0.5, 0.5), size_hint_y=None) btn.bind( width=lambda s, w: s.setter("text_size")(s, (w, None))) btn.bind(texture_size=btn.setter("size")) btn.bind(on_release=partial(self.set_option, qNo, listNo, optNo)) if (self.answers[self.images[self.currIndex][0] - 1, self.images[self.currIndex][1] - 1, qNo, listNo] == optNo + 1): btn.state = "down" optTab.add_widget(btn) qTab.add_widget(optTab) Roll.add_widget(qTab)
def build(self): kv = Builder.load_file("setupapp\\setup.kv") load_screen = kv.get_screen("load_project") load_button_grid = GridLayout(cols=1, size_hint_y=None) load_button_grid.bind(minimum_height=load_button_grid.setter('height')) load_scrollview = ScrollView(size_hint=(1, 1), do_scroll_y=True) continue_screen = kv.get_screen("continue_project") continue_button_grid = GridLayout(cols=1, size_hint_y=None) continue_button_grid.bind( minimum_height=continue_button_grid.setter('height')) continue_scrollview = ScrollView(size_hint=(1, 1), do_scroll_y=True) export_screen = kv.get_screen("export_project") export_button_grid = GridLayout(cols=1, size_hint_y=None) export_button_grid.bind( minimum_height=export_button_grid.setter('height')) export_scrollview = ScrollView(size_hint=(1, 1), do_scroll_y=True) projects = project_manager.get_projects() for project in sorted(projects): load_button = Button(text=project, size_hint_y=None, height=40) load_buttoncallback = partial(start_main_software, project, False) load_button.bind(on_release=load_buttoncallback) load_button_grid.add_widget(load_button) continue_button = Button(text=project, size_hint_y=None, height=40) continue_buttoncallback = partial(start_main_software, project, True) continue_button.bind(on_release=continue_buttoncallback) continue_button_grid.add_widget(continue_button) export_button = Button(text=project, size_hint_y=None, height=40) export_buttoncallback = partial(export_project, project) export_button.bind(on_release=export_buttoncallback) export_button_grid.add_widget(export_button) load_scrollview.add_widget(load_button_grid) load_screen.children[0].add_widget(load_scrollview) load_screen.children[0].add_widget(get_go_back_button()) continue_scrollview.add_widget(continue_button_grid) continue_screen.children[0].add_widget(continue_scrollview) continue_screen.children[0].add_widget(get_go_back_button()) export_scrollview.add_widget(export_button_grid) export_screen.children[0].add_widget(export_scrollview) export_screen.children[0].add_widget(get_go_back_button()) return kv
def update_layout(self, sn): # TODO: Figure out why this isn't loading with # the correct height. Eg. scrollview is too short # TODO: Delete the old scrollview child on entering. # we can only have one active at a time. ids = self.screens[self.sidx[sn]].ids if (sn == 'newuser'): content = ids.newuser_list_sv content.clear_widgets() # Delete any old children from the scroll view layout = GridLayout(cols=1, spacing=10, size_hint_y=None) layout.bind(minimum_height=layout.setter('height')) for user in self.data_users: ud = self.data_users[user] sublayout = GridLayout(cols=2, size_hint_y=None) userlayout = BoxLayout(orientation='vertical') userlayout.add_widget( Label(text=ud.name) ) userlayout.add_widget( Label(text=ud.netid) ) sublayout.add_widget(userlayout) sublayout.add_widget( Button(text='Del',size_hint=(.25,1))) #TODO: Add a promote and remove librarian option layout.add_widget(sublayout) # Finally add to the screen content.add_widget(layout) elif (sn == 'user'): content = ids.user_list_sv content.clear_widgets() layout = GridLayout(cols=1, spacing=10, size_hint_y=None) layout.bind(minimum_height=layout.setter('height')) # Get the user checkedout books and display them ud = self.data_users[self.current_user] for book_id in ud.books: book = data_books[book_id] sublayout = GridLayout(cols=2, size_hint_y=None) sublayout.add_widget( Label(text="Title: ") ) sublayout.add_widget( Label(text=book.title) ) sublayout.add_widget( Label(text="Author: ") ) sublayout.add_widget( Label(text=book.author) ) sublayout.add_widget( Label(text="Year: ") ) sublayout.add_widget( Label(text=book.year) ) sublayout.add_widget( Label(text="Copy #: ") ) sublayout.add_widget( Label(text=book.copy) ) layout.add_widget(sublayout) # Finally add to the screen content.add_widget(layout) else: #All other screen names pass return
def select(self, case): grid = GridLayout(rows=3, cols=3, spacing=10, size_hint=(None, None), pos_hint={ 'center_x': .5, 'center_y': .5 }) for valign in ('bottom', 'middle', 'top'): for halign in ('left', 'center', 'right'): label = BoundedLabel(text='V: %s\nH: %s' % (valign, halign), size_hint=(None, None), halign=halign, valign=valign) if case == 0: label.text_size = (None, None) elif case == 1: label.text_size = (label.width, None) elif case == 2: label.text_size = (None, label.height) else: label.text_size = label.size grid.add_widget(label) if self.grid: self.root.remove_widget(self.grid) grid.bind(minimum_size=grid.setter('size')) self.grid = grid self.root.add_widget(grid)
def __init__(self, **kwargs): super(popu2, self).__init__(**kwargs) self.title='full-details' self.background='background.jpeg' x=value() k=GridLayout(rows=len(x)+1, size_hint_y=None) k.bind(minimum_height=k.setter('height')) r=ScrollView(do_scroll_x=False) for i in range(len(x)): j=BoxLayout(height='129sp',size_hint_y= None) if (i==0): j.add_widget(Label(text='actual')) elif (i==(len(x)-1)): j.add_widget(Label(text='final')) else: j.add_widget(Label(text=(str((i)*6)+' months'))) y=TextInput(text=x[i],readonly='True') j.add_widget(y) k.add_widget(j) s=Button(text='back',on_press=lambda a:self.ok(),size_hint=(1,0.2),background_normal='button-on.jpeg',background_down='button-down.jpeg',) r.add_widget(k) p=GridLayout(rows=2) p.add_widget(r) p.add_widget(s) self.add_widget(p)
def build(self): # create a default grid layout with custom width/height layout = GridLayout(cols=1, spacing=10, size_hint=(None, None), width=500) # when we add children to the grid layout, its size doesn't change at # all. we need to ensure that the height will be the minimum required to # contain all the childs. (otherwise, we'll child outside the bounding # box of the childs) layout.bind(minimum_height=layout.setter('height')) # add button into that grid for i in range(30): btn = Button(text=str(i), size=(480, 40), size_hint=(None, None)) layout.add_widget(btn) # create a scroll view, with a size < size of the grid root = ScrollView(size_hint=(None, None)) root.size = (480, 320) root.center = Window.center root.add_widget(layout) return root
def ShowList(self): ''' Shows the discover results ''' # create the popup oContent = GridLayout(cols=1, spacing='5dp') oScrollview = ScrollView( do_scroll_x=False) self.oScrollContent = StackLayout(size_hint=(None, None)) self.oPopup = oPopup = Popup(content=oContent, title=ReplaceVars('$lvar(5028)'), size_hint=(0.9, 0.9), auto_dismiss=False) #we need to open the popup first to get the metrics oPopup.open() #Add some space on top oContent.add_widget(Widget(size_hint_y=None, height=dp(2))) aDiscoverScripts=oORCA.oScripts.GetScriptListForScriptType("DEVICE_DISCOVER") aScrollContent=[] for uDiscoverScriptName in aDiscoverScripts: oScrollContentSingle = GridLayout(size_hint=(None, None)) aScrollContent.append(oScrollContentSingle) oScrollContentSingle.bind(minimum_height=oScrollContentSingle.setter('height')) oORCA.oScripts.RunScript(uDiscoverScriptName,{'createlist':1,'oGrid':oScrollContentSingle}) self.oScrollContent.add_widget(cLabel(text=oORCA.oScripts.aScripts[uDiscoverScriptName].uSubType, background_color=[0.2, 0.2, 0.2, 1.0], color=[0.9, 0.9, 0.9, 1.0], size=(oPopup.width, dp(30)),size_hint=(None, None), halign='center')) self.oScrollContent.add_widget(oScrollContentSingle) self.oScrollContent.add_widget(SettingSpacer()) # finally, add a cancel button to return on the previous panel oScrollview.add_widget(self.oScrollContent) oContent.add_widget(oScrollview) oContent.add_widget(SettingSpacer()) oBtn = Button(text=ReplaceVars('$lvar(5000)'), size=(oPopup.width, dp(50)),size_hint=(1, None)) oBtn.bind(on_release=self.On_Cancel) oContent.add_widget(oBtn) #resize the Scrollcontent to fit to all Childs. Needs to be done, after the popup has been shown Clock.schedule_once(self.SetScrollSize, 0)
def _create_subpopup(self, instance): ''' shows the sub popup ''' # create the popup content = GridLayout(cols=1, spacing='5dp') scrollview = ScrollView( do_scroll_x=False) scrollcontent = GridLayout(cols=1, spacing='5dp', size_hint=(None, None)) scrollcontent.bind(minimum_height=scrollcontent.setter('height')) self.subpopup = popup = Popup(content=content, title=self.uOption, size_hint=(0.5, 0.9), auto_dismiss=False) #we need to open the popup first to get the metrics popup.open() #Add some space on top content.add_widget(Widget(size_hint_y=None, height=dp(2))) # add all the options uid = str(self.uid) for option in self.aSubOption: state = 'down' if option == self.value else 'normal' oTbtn = ToggleButton(text=option, state=state, group=uid, size=(popup.width, dp(55)), size_hint=(None, None)) oTbtn.bind(on_release=self._set_suboption) scrollcontent.add_widget(oTbtn) # finally, add a cancel button to return on the previous panel scrollview.add_widget(scrollcontent) content.add_widget(scrollview) content.add_widget(SettingSpacer()) oMbtn = cMultiLineButton(text=ReplaceVars('$lvar(5009)'), size=(popup.width, dp(50)),size_hint=(0.9, None), halign='center', valign='middle') oMbtn.bind(on_release=popup.dismiss) content.add_widget(oMbtn)
def kernel_mods(self): Box = BoxLayout(orientation="vertical", spacing=10) msg = GridLayout(cols=1, padding=15, spacing=10, size_hint_y=None) btn_layout = GridLayout(cols=1) done = Button(text="Done") btn_layout.add_widget(done) msg.bind(minimum_height=msg.setter('height')) over = CustomButton(text='OverClocking', size=(475, 40), size_hint=(None, None)) over.bind(on_release=overclock) gpu = CustomButton(text='Gpu Overclock', size=(475, 40), size_hint=(None, None)) gpu.bind(on_release=gpu_overclock) gov = CustomButton(text='Governors', size=(475, 40), size_hint=(None, None)) gov.bind(on_release=gov_select) mhl = CustomButton(text='MHL Refresh Hack', size=(475, 40), size_hint=(None, None)) mhl.bind(on_release=msl_options) msg.add_widget(over) msg.add_widget(gpu) msg.add_widget(gov) msg.add_widget(mhl) root = ScrollView(size_hint=(None, None),bar_margin=-22, size=(475, 390), do_scroll_x=False) root.add_widget(msg) Box.add_widget(root) Box.add_widget(btn_layout) popup = Popup(background='atlas://images/eds/pop', title='Kernel Mods',content=Box, auto_dismiss=True, size_hint=(None, None), size=(520, 500)) done.bind(on_release=popup.dismiss) popup.open()
def ShowList(self): """ Shows the discover results """ # create the popup oContent = GridLayout(cols=1, spacing='5dp') oScrollview = ScrollView( do_scroll_x=False) self.oScrollContent = StackLayout(size_hint=(None, None)) self.oPopup = oPopup = Popup(content=oContent, title=ReplaceVars('$lvar(5028)'), size_hint=(0.9, 0.9), auto_dismiss=False) #we need to open the popup first to get the metrics oPopup.open() #Add some space on top oContent.add_widget(Widget(size_hint_y=None, height=dp(2))) aDiscoverScripts=Globals.oScripts.GetScriptListForScriptType("DEVICE_DISCOVER") aScrollContent=[] for uDiscoverScriptName in aDiscoverScripts: oScrollContentSingle = GridLayout(size_hint=(None, None),size=(oPopup.width, dp(10))) aScrollContent.append(oScrollContentSingle) oScrollContentSingle.bind(minimum_height=oScrollContentSingle.setter('height')) Globals.oScripts.RunScript(uDiscoverScriptName,**{'createlist':1,'oGrid':oScrollContentSingle}) self.oScrollContent.add_widget(cLabel(text=Globals.oScripts.dScripts[uDiscoverScriptName].uSubType, background_color=[0.2, 0.2, 0.2, 1.0], color=[0.2, 0.9, 0.9, 1.0], size=(oPopup.width, dp(30)),size_hint=(None, None), halign='center')) self.oScrollContent.add_widget(oScrollContentSingle) self.oScrollContent.add_widget(SettingSpacer()) # finally, add a cancel button to return on the previous panel oScrollview.add_widget(self.oScrollContent) oContent.add_widget(oScrollview) oContent.add_widget(SettingSpacer()) oBtn = Button(text=ReplaceVars('$lvar(5000)'), size=(oPopup.width, dp(50)),size_hint=(1, None)) oBtn.bind(on_release=self.On_Cancel) oContent.add_widget(oBtn) #resize the Scrollcontent to fit to all Childs. Needs to be done, after the popup has been shown Clock.schedule_once(self.SetScrollSize, 0)
def getPropertyEditors(self, skin): """ get all the controls for editing the extra properties of this control. The list of controls that is returned, our bound to this object (changes will be stored in the skin object) :param skin: json object :return: a list of kivy controls that can be used for editing the properties for the skin. """ items = [] grd = GridLayout(cols=2) grd.bind(minimum_height = grd.setter('height')) grd.size_hint = (1, None) chk = CheckBox(active=sm.getVar(skin, self.asset, "show_label", False), height='28dp', size_hint=(1, None)) chk.bind(active=self.on_show_labelChanged) lbl = Label(text='show label', height='28dp', size_hint=(1, None), halign='right') lbl.bind(size = lbl.setter('text_size')) grd.add_widget(lbl) grd.add_widget(chk) chk = CheckBox(active=sm.getVar(skin, self.asset, "show_marker", False), height='28dp', size_hint=(1, None)) chk.bind(active=self.on_show_markerChanged) lbl = Label(text='show marker', height='28dp', size_hint=(1, None), halign='right') lbl.bind(size = lbl.setter('text_size')) grd.add_widget(lbl) grd.add_widget(chk) chk = CheckBox(active=sm.getVar(skin, self.asset, "send_on_release", False), height='28dp', size_hint=(1, None)) chk.bind(active=self.on_send_on_release_Changed) lbl = Label(text='send on release', height='28dp', size_hint=(1, None), halign='right') lbl.bind(size = lbl.setter('text_size')) grd.add_widget(lbl) grd.add_widget(chk) items.append(grd) return items
def _create_popup(self, instance): # create the popup content = BoxLayout(orientation='vertical', spacing='5dp') box = GridLayout(cols=1, spacing="5dp") box.bind(minimum_height=box.setter('height')) self.popup = popup = Popup(content=content, title=self.title, size_hint=(None, 1), width='400dp') #popup.height = len(self.options) * dp(55) + dp(150) # add all the options content.add_widget(Widget(size_hint_y=None, height=1)) uid = str(self.uid) for option in self.options: state = 'down' if option == self.value else 'normal' btn = ToggleButton(text=option, state=state, group=uid) btn.bind(on_release=self._set_option) box.add_widget(btn) #box.height = metrics.dp(35) * len(self.options) scroll = ScrollView(pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_x=False, size_hint=(1, 1)) scroll.add_widget(box) content.add_widget(scroll) # 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.popup.dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) # and open the popup ! popup.open()
def taskMenu_inner(_=None): self.clear_widgets() taskMenuLayout = GridLayout(cols=1, spacing=10, size_hint_y=None) taskMenuLayout.bind(minimum_height=taskMenuLayout.setter('height')) self.scroll_y = 1 self.add_widget(taskMenuLayout) backButton = Button(text=getTaskName(tid), size_hint_y=None, height=100) statusLabel = Label(font_size='12sp', valign = 'top', halign='left') if isRunning(tid, True): backButton.background_color = (0.8,1,0.8,1) statusLabel.text = localisation.get(language, "end") + " " + getDateString(getLastDeadline(tid)) elif isComplete(tid): backButton.background_color = (1,0.8,0.8,1) statusLabel.text = localisation.get(language, "cooldown") + " " + getDateString(getCompletionExpirationDate(tid)) else: statusLabel.text = localisation.get(language, "limbo") + " " + getDateString(getCompletionExpirationDate(tid)) backButton.bind(on_press=self.buildMainScreen) taskMenuLayout.add_widget(backButton) taskMenuLayout.add_widget(statusLabel) for milestone in getMilestones(tid): taskMenuLayout.add_widget(self.makeMilestoneLayout(tid, milestone, oldScore if milestone == getNextMilestone(tid) else None)) newMilestoneButton = Button(text=localisation.get(language,"newdate"), bold=True, size_hint_y=None, height=100) taskMenuLayout.add_widget(newMilestoneButton) newMilestoneButton.bind(on_press=self.mileStonePopup(tid)) delConfirmSwitch = Switch() delConfirmPopup = Popup(title=localisation.get(language, "sure"), content=delConfirmSwitch, size_hint=(None, None), size=(200, 200)) delConfirmPopup.bind(on_dismiss=self.deleteTask(tid, delConfirmSwitch)) delButton = Button(text=localisation.get(language,"deltask"), bold=True, size_hint_y=None, height=100) delButton.bind(on_press=delConfirmPopup.open) taskMenuLayout.add_widget(delButton)
def subscroll(self): """ opens scroll list of substitute characters in a popup """ for btn in SMApp.teamlist: if btn.state == 'down': SMApp.nameOff = btn btn.state = 'normal' curs.execute('SELECT * FROM Subs') layout2 = GridLayout(cols=2, spacing=10, size_hint_y=None) layout2.bind(minimum_height=layout2.setter('height')) for row in curs: btn = ToggleButton(text=str(row[0]), size_hint_y=None, height=40) if row[1] == 1: btn.background_color = (0.5, 1, 0.9, 1) layout2.add_widget(btn) btn.bind(on_press=subChar) SMApp.sublist.append(btn) lbl = Label(text=str(row[2]), size_hinty=None, height=40) layout2.add_widget(lbl) root = ScrollView(size_hint=(None, None), size=(400, 400)) root.add_widget(layout2) SMApp.popup2 = Popup(content=root, size=(7, 10), size_hint=(0.55, 0.8), title="list of subs") SMApp.popup2.open()
def build(self): topic = 'Python' layout = GridLayout(cols=2, size_hint_y=None, spacing=10, padding=(10,10,10,10)) layout.bind(minimum_height=layout.setter('height')) message = fetch(topic) for data in message: l = Button(text=data, text_size=(300, None), size_hint_y=None, padding=(5, 5), bold=True) # calculating height here before = l._label.render() l.text_size=(300, None) after = l._label.render() l.height = 60 + (after[1]/before[1])*before[1] # ammount of rows * single row height # end layout.add_widget(l) sub = ScrollView() sub.add_widget(layout) root = GridLayout(cols=1) title = Label(text='Facebook Mining Topic: ' + topic, font_size=30, size_hint_y=None, height=100) root.add_widget(title) textinput = TextInput(hint_text='Search ...', multiline=False, size_hint_y=None, height=40) textinput.bind(on_text_validate=on_enter) root.add_widget(textinput) root.add_widget(sub) return root
def buildAboutUs(self, dismiss): box = BoxLayout(orientation="vertical") scrollViewLayout = ScrollView(do_scroll_x=False, scroll_y=1) childLayout = GridLayout(cols=1, size_hint_x=1, size_hint_y=None) childLayout.bind(minimum_height=childLayout.setter('height')) def longTextLabel(): _long_text = """\n\n[b]Programmers[/b]\nCarmen Bruni ([email protected]), Jia Gou ([email protected]), Christina Koch ([email protected]), Bernhard Konrad ([email protected]) and Jerome Lefebvre ([email protected])\n [b]Art[/b]\nIsabell Graf ([email protected]) \n [b]Music[/b]\nCarmen Bruni\n [b]Contact & Feedback[/b]\[email protected]""" reallyLongText = _long_text myLabel = Label(text=reallyLongText, text_size=(700,None), line_height=1.5, markup=True) myLabel.size_hint_y = None myLabel.height = 650 return myLabel childLayout.add_widget(longTextLabel()) scrollViewLayout.add_widget(childLayout) box.add_widget(scrollViewLayout) close_button = Button(text="Close", size_hint_y=0.1, on_press=dismiss) box.add_widget(close_button) return box
class deserts_screen(Screen): food_grid = ObjectProperty() def __init__(self, **kwargs): super(deserts_screen, self).__init__(**kwargs) self.deserts_grid() def deserts_grid(self): query = c.execute("SELECT * FROM Deserts") rows = query.fetchall() self.grid1 = GridLayout(cols= 1, padding=3,spacing=3,size_hint_y= None) self.grid1.bind(minimum_height=self.grid1.setter('height')) for i in rows: self.one_food = Food_BoxLayout_1() self.one_food.food_n = i[0] self.one_food.food_name.text = i[0] self.one_food.price_1.text = str(i[1]) self.grid1.add_widget(self.one_food) self.food_grid.add_widget(self.grid1)
def update(self): self.clear_widgets() layout = GridLayout( rows=1, row_force_default=True, row_default_height=50, size_hint_y=None, spacing=4, padding=4, ) layout.bind(minimum_height=layout.setter("height")) for i in range(len(self.meta.list)): image_pos = i if self.meta.list[image_pos].pgm == 'neural_style.py': _path = 'Effects/fast_neural_style/saved_models' else: _path = 'Effects' img = PencilImage(source=os.path.join( directory, _path, self.meta.list[image_pos].image), image_pos=image_pos) layout.add_widget(img) scrollview = ScrollView(do_scroll_y=False, ) scrollview.add_widget(layout) self.add_widget(scrollview)
def Start(self,uTitle,aOptions,fktCallBack): ''' starts selection ''' self.fktCallBack=fktCallBack # create the popup content = GridLayout(cols=1, spacing='5dp') scrollview = ScrollView( do_scroll_x=False, bar_width='10dp',scroll_type=['bars'] ) scrollcontent = GridLayout(cols=1, spacing='5dp', size_hint=(None, None)) scrollcontent.bind(minimum_height=scrollcontent.setter('height')) self.oPopup = popup = Popup(content=content, title=ReplaceVars(uTitle), size_hint=(0.5, 0.9), auto_dismiss=False) #we need to open the popup first to get the metrics popup.open() #Add some space on top content.add_widget(Widget(size_hint_y=None, height=dp(2))) # add all the options for option in aOptions: if hasattr(option,"Name"): name=option.Name else: name=option.Type btn = Button(text=name, size=(popup.width, dp(30)), size_hint=(None, None)) btn.bind(on_release=self.On_Value) btn.oDBRef=option scrollcontent.add_widget(btn) # finally, add a cancel button scrollview.add_widget(scrollcontent) content.add_widget(scrollview) content.add_widget(SettingSpacer()) btn = Button(text=ReplaceVars('$lvar(5009)'), size=(popup.width, dp(50)),size_hint=(0.9, None)) btn.bind(on_release=popup.dismiss) content.add_widget(btn)
def update_file_layout(self): auth_token='S2_xUq0_iNAAAAAAAAAACYNG1zf1GAzKpVWVfmLcZLA-FIiSlGxMvmxBkAtspuWQ' client = dropbox.client.DropboxClient(auth_token) self.clear_widgets() b=BoxLayout(orientation='vertical') file_system = FileSystemLocal() root_dir= App.get_running_app().user_data_dir+'/';result_dir=root_dir+'results' file_list=file_system.listdir(root_dir) # this returns a list of files in dir if os.path.exists(result_dir):file_list.extend(file_system.listdir(App.get_running_app().user_data_dir+'/'+'results'+'/')) file_list=[x for x in file_list if x[-4:]=='.csv'] b.add_widget(Label(text='Select Files to Upload',bold=True,font_size=sp(25),size_hint_y= 0.1)) file_system = FileSystemLocal() file_list=file_system.listdir(App.get_running_app().user_data_dir+'/') # this returns a list of files in dir file_list=[x for x in file_list if x[-4:]=='.csv'] s=ScrollView(size_hint_y=0.75) g=GridLayout(cols=2,size_hint_y=None) for file_1 in file_list: c=CheckBox(active=False) l=Label(bold= True,font_size=sp(20),text=file_1,size_hint_y= None,height=70) self.check_boxes[c]=file_1 g.add_widget(l);g.add_widget(c) g.bind(minimum_height=g.setter('height')) s.add_widget(g) b.add_widget(s) g_options=GridLayout(cols=2,size_hint_y= 0.1,orientation='horizontal') g_options.add_widget(Button(text="Send",on_press=self.upload,font_size=sp(25))) g_options.add_widget(Button(text="Back",on_press=self.return_back,font_size=sp(25))) b.add_widget(g_options) self.add_widget(b)
def __init__(self, **kwargs): super(IntroPanelView, self).__init__(**kwargs) self.name='introscreen' # create a default grid layout with custom width/height layout = GridLayout(cols=1, padding=10, spacing=10, size_hint=(None, None),pos_hint={'center_x': .5, 'center_y': .5}, width=500) layout.bind(minimum_height=layout.setter('height')) # create a scroll view, with a size < size of the grid scrl = ScrollView(size_hint=(None, None), size=(500, 320), pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_x=False) label = Label( text=self.introtext, size=(480, 900), text_size=(480,900), size_hint_y=None, markup=True) scrl.add_widget(label) layout.add_widget(scrl) btn = Button(text='Okay', size=(480, 40), size_hint=(None, None), on_press=self.close) layout.add_widget(btn) self.add_widget(layout)
def start_android_beta(): DEFAULT_PATH = os.path.join(os.path.dirname(__file__), 'appdata.db') conn = sqlite3.connect(DEFAULT_PATH) c = conn.cursor() c.execute("SELECT * FROM TALLY") elements = [ "Sort No", "Date", "Name", "Amount", "Category", "Payement", "Site No" ] layout = GridLayout(cols=7, spacing=10, size_hint_y=None) # Make sure the height is such that there is something to scroll. layout.bind(minimum_height=layout.setter('height')) for element in elements: btn = Label(text=str(element), size_hint_y=None, height=40) layout.add_widget(btn) x = 1 for row in c.fetchall(): but1 = Label(text=str(x), size_hint_y=None, height=40) but2 = Label(text=str(row[0]), size_hint_y=None, height=40) but3 = Label(text=str(row[1]), size_hint_y=None, height=40) but4 = Label(text=str(row[2]), size_hint_y=None, height=40) but5 = Label(text=str(row[3]), size_hint_y=None, height=40) but6 = Label(text=str(row[4]), size_hint_y=None, height=40) but7 = Label(text=str(row[5]), size_hint_y=None, height=40) x += 1 v = [but1, but2, but3, but4, but5, but6, but7] for ele in v: layout.add_widget(ele) root = ScrollView(size_hint=(1, None), size=(Window.width, Window.height)) root.add_widget(layout) runTouchApp(root)
def _create_popup(self,instance): # Create the popup and scrollview content = BoxLayout(orientation='vertical', spacing='5dp') scrollview = ScrollView(do_scroll_x=False, bar_inactive_color=[.7, .7, .7, 0.9], bar_width=4) scrollcontent = GridLayout(cols=1, spacing='5dp', size_hint=(0.95, None)) self.popup = Popup(content=content, title=self.title, size_hint=(0.25, 0.8), auto_dismiss=False, separator_color=[1,1,1,1]) # Add all the options to the ScrollView scrollcontent.bind(minimum_height=scrollcontent.setter('height')) content.add_widget(Widget(size_hint_y=None, height=dp(1))) uid = str(self.uid) for option in self.options: state = 'down' if option == self.value else 'normal' btn = ToggleButton(text=option, state=state, group=uid, height=dp(58), size_hint=(0.9, None)) btn.bind(on_release=self._set_option) scrollcontent.add_widget(btn) # Finally, add a cancel button to return on the previous panel scrollview.add_widget(scrollcontent) content.add_widget(scrollview) content.add_widget(SettingSpacer()) btn = Button(text='Cancel', height=dp(58), size_hint=(1, None)) btn.bind(on_release=self.popup.dismiss) content.add_widget(btn) self.popup.open()
class ReqTable(ScrollView): def __init__(self, **kwargs): super(ReqTable, self).__init__(**kwargs) self.size_hint = (1, None) self.grid = None def set_table(self, rows): if self.grid: self.remove_widget(self.grid) self.grid = GridLayout(cols=2, size_hint=(1, None), row_default_height=50) self.grid.bind(minimum_height=self.grid.setter('height')) self.size_hint = (1, .3) for key, value in rows: #self.grid.add_widget(TextLine('{}: {}'.format(key,value))) self.grid.add_widget( Label(text=str('{}: '.format(key)), height=35, size_hint_x=None, width=50)) l = Label(text=value, halign='left', size_hint=(None, 1)) l.bind(texture_size=l.setter('size')) self.grid.add_widget(l) self.add_widget(self.grid)
class SortedListFood(Screen): def __init__(self, **kw): super(SortedListFood, self).__init__(**kw) def on_enter(self): # Будет вызвана в момент открытия экрана self.layout = GridLayout(cols=1, spacing=10, size_hint_y=None) self.layout.bind(minimum_height=self.layout.setter('height')) back_button = Button(text='< Назад к игре', on_press=lambda x: set_screen('add_food'), size_hint_y=None, height=dp(40)) self.layout.add_widget(back_button) root = RecycleView(size_hint=(1, None), size=(Window.width, Window.height)) root.add_widget(self.layout) self.add_widget(root) dic_foods = ast.literal_eval(App.get_running_app().config.get( 'General', 'user_data')) file = 'file_words.pk' with open(file, 'rb') as fi: time = pickle.load(fi) for f, d in sorted(dic_foods.items(), key=lambda x: x[1]): fd = f.decode('u8') if time > d: pass else: btn = Button(text=fd, size_hint_y=None, height=dp(40)) self.layout.add_widget(btn) def on_leave(self): # Будет вызвана в момент закрытия экрана self.layout.clear_widgets() # очищаем список
def build(self): # create a default grid layout with custom width/height layout = GridLayout(cols=1, padding=10, spacing=10, size_hint=(None, None), width=500) # when we add children to the grid layout, its size doesn't change at # all. we need to ensure that the height will be the minimum required # to contain all the childs. (otherwise, we'll child outside the # bounding box of the childs) layout.bind(minimum_height=layout.setter('height')) # add button into that grid for i in range(30): btn = Button(text=str(i), size=(480, 40), size_hint=(None, None)) layout.add_widget(btn) # create a scroll view, with a size < size of the grid root = ScrollView(size_hint=(None, None), size=(500, 320), pos_hint={ 'center_x': .5, 'center_y': .5 }, do_scroll_x=False) root.add_widget(layout) return root
def load_chat_messsages(self, user, u_contact, m_path): """显示除自己外的所有测试用户信息""" self.user = user self.message_path = m_path self.contacts = u_contact layout = GridLayout(cols=1, spacing=10, size_hint_y=None) layout.bind(minimum_height=layout.setter('height')) self.clear_widgets() try: # 读取本地信息列表 store = JsonStore(self.message_path) b_height = store.get('block')['height'] while b_height > 0: msg_hash = store[str(b_height - 1)]['hash'] msg_data = json.loads(store[msg_hash]['message']) message = MMMessage(msg_data) # 验证接收地址是自己的信息 if self.user.is_mine(message) and verify_message(message): if message.sender in self.contacts: s_name = self.contacts[message.sender]['name'] elif message.sender == self.user.address: s_name = self.user.user_name else: s_name = None s_address = message.sender s_content = self.user.decode_message(message) msg_widget = MessageWidget(s_name, s_address, s_content) msg_widget.update() layout.add_widget(msg_widget) b_height -= 1 self.size_hint = (1, 1) self.add_widget(layout) except Exception as e: print('Error: ', str(e))
def __init__(self,getData,**kwargs): super(ProfileActivity,self).__init__(**kwargs) infoBlock = GridLayout(cols = 1,spacing = 10) imagePlace = FloatLayout(size_hint = [1,None], height = 150) imagePlace.add_widget(AsyncImage(pos_hint = {"center_x":.5,"center_y":.5}, source = getData["avatar"])) infoBlock.add_widget(imagePlace) infoBlock.add_widget(Label(text = getData["login"], color = COLOR["LIGHT"]["MAIN_COLOR"],size_hint_y = None, height = 10)) infoBlock.add_widget(InfoPlate(str(getData["reputation"]))) infoBlock.add_widget(InfoPlate(str(getData["helpNum"]))) list = ScrollView() layoutList = GridLayout(cols = 1, size_hint_y = None) layoutList.bind(minimum_height = layoutList.setter('height')) layoutList.add_widget(infoBlock) list.add_widget(layoutList) self.add_widget(list)
def load_contacts(self, u_name, c_path): """显示除自己外的所有测试用户信息""" self.user_name = u_name self.contact_path = c_path self.contacts.clear() layout = GridLayout(cols=1, spacing=10, size_hint_y=None) layout.bind(minimum_height=layout.setter('height')) self.clear_widgets() try: store = JsonStore(self.contact_path) for name in demo_user_names: if name == self.user_name: continue address = store.get(name)['address'] pubkey = store.get(name)['rsa_pubkey'] c = ContactLayout(u_name=name, u_address=address, u_pubkey=pubkey) self.contacts[address] = {'name': name, 'pubkey': pubkey, 'control': c} # (name, pubkey, c) c.update() layout.add_widget(c) except Exception as e: print(str(e)) self.size_hint = (1, 1) self.add_widget(layout)
class MessageBox(BoxLayout): def __init__(self, userid, *args, **kwargs): self.userid = userid super(MessageBox, self).__init__(*args, **kwargs) # create a grid for the scroll view to contain things self.layout = GridLayout(cols=1, padding=(10, 15), spacing=8, size_hint=(1, None)) self.layout.bind(minimum_height=self.layout.setter('height')) self.ids.scroller.add_widget(self.layout) self.ids.message_input.bind(on_enter=self.send_message) def send_message(self, instance): text = self.ids.message_input.text.rstrip('\r\n') if text: app = App.get_running_app() app.root_box.chat_client.send_chat(self.userid, text) self.add_message(text) self.ids.message_input.text = '' def add_message(self, text, msg_from=None): if not msg_from: msg_from = 'me' from_color = 'ff0000' else: from_color = '0000ff' text = '[color=%s]%s: [/color]%s' % (from_color, msg_from, text) label = TextBoxLabel(text=text) self.layout.add_widget(label) self.ids.scroller.scroll_y = 0
def __init__( self, **kwargs ): super( SimpleProgramsScreen, self ).__init__( **kwargs ) v_layout = BoxLayout( orientation = 'vertical', spacing = 20 ) label = Label( text = 'Select a program:', size_hint_y = 0.1 ) v_layout.add_widget( label ) programs_grid = GridLayout( cols = 1, spacing = 5, size_hint_y = None ) dict_of_simple_programs = \ App.get_running_app().dict_of_simple_programs for k, v in dict_of_simple_programs.items(): self.add_simple_program_widget( programs_grid, v ) programs_grid.bind( minimum_height = programs_grid.setter('height') ) scroll_for_programs = ScrollView( size_hint_y = 0.6 ) scroll_for_programs.add_widget( programs_grid ) v_layout.add_widget( scroll_for_programs ) create_custom_program = Button( text = 'Create custom program (not implemented)', size_hint_y = 0.15 ) v_layout.add_widget( create_custom_program ) back_button = Button( text = 'Back', size_hint_y = 0.15 ) back_button.on_press = self.goto_programs_screen v_layout.add_widget( back_button ) self.add_widget( v_layout )
class NotificationDemo(BoxLayout): def __init__(self, **kwargs): super(BoxLayout, self).__init__( **kwargs) self.scroller = self.children[-1] self.grid = GridLayout(cols=1, spacing=1, size_hint_y=None) self.scroller.add_widget(self.grid) self.grid.bind(minimum_height=self.grid.setter('height')) osc.init() oscid = osc.listen(ipAddr='127.0.0.1', port=3002) osc.bind(oscid, self.add_more, '/some_api') Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.3) def add_more(self,message,*args): Label = MultiLineLabel(text=message[2]) self.grid.add_widget(Label) def play(self): osc.sendMsg('/some_api', ['Play'], port=3001) def pause(self): osc.sendMsg('/some_api', ['Pause'], port=3001) def quit(self): global service service.stop()
class AppList(StackLayout): def __init__(self, app): super(AppList, self).__init__(spacing=2, size_hint=(None, None)) self.app = app self.title = Label(text="No title yet", height=30) self.add_widget(self.title) self.add_buttons() scroll = ScrollView(size_hint_y=None, height=600 - self.height) self.add_widget(scroll) self.layout = GridLayout(cols=1, size_hint_y=None) self.layout.bind(minimum_height=self.layout.setter('height')) scroll.add_widget(self.layout) def add_buttons(self): pass def clear_list(self): self.layout.clear_widgets() def add_item(self, item): item.size_hint_y = None item.height = 40 self.layout.add_widget(item) return item
def build(self): # carousel = Carousel(anim_type='out_expo') gallery = ImageCollector() # for image in gallery.get_images_from_folder(0): # carousel.add_widget(PhotoFrame(image_path=image)) img = gallery.get_random_img() l = Scatter(do_rotation=False) l.add_widget(FramedImage(source=img)) ############### layout = GridLayout(orientation='horizontal', rows=1, size_hint_x=None) # Make sure the height is such that there is something to scroll. layout.bind(minimum_width=layout.setter('width')) for i in gallery.get_images_from_folder(0): im = CustomImage(source=i, size_hint_x=None) layout.add_widget(im) root = ScrollView() root.add_widget(layout) box = BoxLayout() box.add_widget(root) ################ return box
class FiltredListScreen(Screen): def __init__(self, **kw): super(FiltredListScreen, self).__init__(**kw) def on_enter(self): # Будет вызвана в момент открытия экрана self.layout = GridLayout(cols=1, spacing=10, size_hint_y=None) self.layout.bind(minimum_height=self.layout.setter('height')) back_button = Button(text='< Назад в главное меню', on_press=lambda x: set_screen('main'), size_hint_y=None, height=dp(40)) self.layout.add_widget(back_button) root = RecycleView(size_hint=(1, None), size=(Window.width, Window.height)) root.add_widget(self.layout) self.add_widget(root) # for f, d in sorted(dic_foods.items(), key=lambda x: x[1]): # fd = f.decode('u8') + ' ' + (datetime.fromtimestamp(d).strftime('%Y-%m-%d')) # btn = Button(text=fd, size_hint_y=None, height=dp(40)) # self.layout.add_widget(btn) def on_leave(self): # Будет вызвана в момент закрытия экрана self.layout.clear_widgets() # очищаем список
class SortedListFood(Screen): def __init__(self, **kw): super(SortedListFood, self).__init__(**kw) def on_enter(self): # Будет вызвана в момент открытия экрана self.layout = GridLayout(cols=1, spacing=10, size_hint_y=None) self.layout.bind(minimum_height=self.layout.setter('height')) back_button = Button(text='< Go BAck', on_press=lambda x: set_screen('menu'), size_hint_y=None, height=dp(40)) self.layout.add_widget(back_button) root = RecycleView(size_hint=(1, None), size=(Window.width, Window.height)) root.add_widget(self.layout) self.add_widget(root) dic_foods = ast.literal_eval( App.get_running_app().config.get('General', 'user_data')) for f, d in sorted(dic_foods.items(), key=lambda x: x[1]): fd = f.decode('u8') + ' ' + (datetime.fromtimestamp(d).strftime('%Y-%m-%d')) btn = Button(text=fd, size_hint_y=None, height=dp(40)) self.layout.add_widget(btn) def on_leave(self): # Будет вызвана в момент закрытия экрана self.layout.clear_widgets() # очищаем список
def library(self,instance): print "Show library" k = instance.parent.parent.parent.children[0] k.clear_widgets() s = GridLayout(cols = 1, spacing = 3, size_hint_y = None) s.bind(minimum_height = s.setter('height')) os.chdir(self.music_path) for i in os.listdir(u'.'): if '.mp3' in i: i = i.encode('utf-8') print type(i), i s.add_widget(Button( text = i[:-4], color = (1,1,1,1), size_hint_y = None, height = 70, on_press = self.playSong, background_color = self.song_color, background_normal = '' )) g = ScrollView(size_hint = (1,0.5), pos_hint = {'x': 0, 'y': 0}) g.add_widget(s) d = StackLayout(size_hint = (1,0.3),pos_hint = {'center_x': 0.5, 'y': 0.5}, orientation = 'lr-tb') d.add_widget(Button(text = self.current_song,color = (0,0,0,1),size_hint = (1,0.5),pos_hint = {'x': 0,'y':0.5}, background_normal = '', background_color = (1,1,1,1))) d.add_widget(Button(text = "STOP",size_hint = (0.5,0.5), on_press = self.playSong, background_normal = '', background_color = (0.9,0.1,0.1,1))) d.add_widget(Button(text = "PAUSE",size_hint = (0.5,0.5), on_press = self.playSong, background_normal = '', background_color = (0.9,0.7,0.1,1))) k.add_widget(g) k.add_widget(d)
def __init__(self, dataList): self.name = "editabletable" super(ROTable, self).__init__() parent_layout = StackLayout() scroll_layout = ScrollView(size_hint=(1, None), size=(Window.width, Window.height)) table_layout = GridLayout(cols=6, size_hint_y=None, spacing=5) table_layout.bind(minimum_height=table_layout.setter('height')) length = len(dataList[0]) sizes = [0] * length # for record in dataList: # # for p, column in enumerate(record): # if len(str(column)) > sizes[p]: # sizes[p] = len(str(column)) + 3 for row_n, row_data in enumerate(dataList): for i, row in enumerate(row_data.reverse()): if i <= len(row_data) - 2: t = Label(hint_text=row, size_hint_y=None, height=40, font_size='20sp') table_layout.add_widget(t, index=i) else: btn = Button(text="Update", size_hint_y=None, height=40) table_layout.add_widget(btn, index=i) scroll_layout.add_widget(table_layout) self.add_widget(parent_layout) self.add_widget(scroll_layout)
def view_packages(instance): p = getPackages() Box = BoxLayout(orientation="vertical", spacing=10) msg = GridLayout(cols=1, spacing=0, size_hint_y=None) btn_layout = GridLayout(cols=1) btn = Button(text="Done") btn_layout.add_widget(btn) msg.bind(minimum_height=msg.setter('height')) for x in p: lbl = (Label(text='%s' % x, font_size=10, size_hint_y=None, height=40)) msg.add_widget(lbl) root = ScrollView(size_hint=(None, None), size=(375, 290), do_scroll_x=False) root.add_widget(msg) Box.add_widget(root) Box.add_widget(btn_layout) popup = Popup(background='atlas://images/eds/pop', title='Needed packages', content=Box, auto_dismiss=True, size_hint=(None, None), size=(400, 400)) btn.bind(on_release=popup.dismiss) popup.open()
def load_custom_ker(self): Box = BoxLayout(orientation="vertical", spacing=10) panel = SettingsPanel(title="Custom HTC Kernels", settings=self) msg = GridLayout(cols=1, size_hint=(None, 0.8), width=700) btn_layout = GridLayout(cols=1) done = Button(text="Done") easy = Button(text='Show Stock Kernels',size_hint_y=(None), height=25) btn_layout.add_widget(done) msg.bind(minimum_height=msg.setter('height')) try: for name in kernels: item = SettingItem(panel = panel, title = "%s" % name, disabled=False, desc = "https://github.com/wes342/%s" % name) item_btn = CustomButton(text="Clone: %s" % name ,size_hint=(None, None),width=250, height=40) item.add_widget(item_btn) msg.add_widget(item) item_btn.bind(on_release=get_kernel) root = ScrollView(size_hint=(None, None), size=(675, 350), do_scroll_x=False) root.add_widget(msg) Box.add_widget(easy) Box.add_widget(root) Box.add_widget(btn_layout) easy.bind(on_release=load_ker) popup = Popup(background='atlas://images/eds/pop', title='Custom HTC Kernels',content=Box, auto_dismiss=True, size_hint=(None, None), size=(700, 500)) done.bind(on_release=popup.dismiss) easy.bind(on_release=popup.dismiss) popup.open() except: EdsNotify().run("'system/app Directory Not Found", 'Cant Find:\n' + SystemApp)
class CaterpillarList(ScrollView): def __init__(self, **kwargs): super(CaterpillarList, self).__init__(**kwargs) self.caterpillars = [] self.bind(size=self.draw) self.box = GridLayout(orientation="vertical", cols=2, size_hint_y=None, spacing=10) self.box.bind(minimum_height=self.box.setter('height')) self.add_widget(self.box) def reset(self): self.caterpillars = [] self.draw() def add(self, caterpillar): if caterpillar in self.caterpillars: self.caterpillars.remove(caterpillar) self.caterpillars = [caterpillar] + self.caterpillars self.draw() def draw(self, *args): self.box.clear_widgets() x, y = self.size if x > y: cols = 2 else: cols = 1 self.box.cols = cols for guess in self.caterpillars: self.box.add_widget( Caterpillar(chain=guess, size_hint_y=None, size=(x, x / 7 / cols))) self.scroll_y = 1
def more_info(self,x,t): k=GridLayout(rows=len(x)*2+10, size_hint_y=None,spacing=60,padding=30) k.bind(minimum_height=k.setter('height')) r=ScrollView(do_scroll_x=False) j=0 x1=x[-1:][0] x.remove(x1) k.add_widget(Label(text=' [b]More Details[/b]',size_hint=[1,0.5],markup=True,color=[1,0,0,1])) for i in x: sp=MDSeparator(height= dp(1)) k.add_widget(sp) b=BoxLayout(padding=-50) l1=Label(text=str(j*6)+' months',color=[1,0,0,1]) l2=TextInput(text=str(i),size_hint=[1,None],readonly=True) b.add_widget(l1) b.add_widget(l2) k.add_widget(b) j+=1 sp=MDSeparator(height= dp(1)) k.add_widget(sp) b=BoxLayout(padding=-50) l1=Label(text=str(t)+' months',color=[1,0,0,1]) l2=TextInput(text=str(x1),size_hint=[1,None],readonly=True) b.add_widget(l1) b.add_widget(l2) k.add_widget(b) x.append(x1) r.add_widget(k) g=BoxLayout(orientation='vertical') g.add_widget(r) g.add_widget(Label(text=' ',size_hint=[1,0.5])) self.b=MDBottomSheet() self.b.gl_content.add_widget(g) Clock.schedule_once(self.resize_content_layout, 0) self.b.open()
class StationList(ScrollView): layout = None collection = None def __init__(self, **kwargs): super(StationList, self).__init__(**kwargs) self.layout = GridLayout(cols=1, size_hint=(None, None)) self.layout.bind(minimum_height=self.layout.setter('height')) self.add_widget(self.layout) def update_list(self, collection): if collection == self.collection: return self.collection = collection self.layout.clear_widgets() for station in collection: item = StationListingItem(station, self.layout, self.on_station_select, size=(self.width, 225), text_size=(self.width*.9, 255)) self.layout.add_widget(item) def add_station_selection_listener(self, callback): self.callback = callback def on_station_select(self, station): self.callback(station)
class CaterpillarList(ScrollView): def __init__(self,**kwargs): super(CaterpillarList, self).__init__(**kwargs) self.caterpillars=[] self.bind(size=self.draw) self.box=GridLayout(orientation="vertical",cols=2,size_hint_y=None,spacing=10) self.box.bind(minimum_height=self.box.setter('height')) self.add_widget(self.box) def reset(self): self.caterpillars=[] self.draw() def add(self,caterpillar): if caterpillar in self.caterpillars: self.caterpillars.remove(caterpillar) self.caterpillars=[caterpillar]+self.caterpillars self.draw() def draw(self,*args): self.box.clear_widgets() x,y=self.size if x>y: cols = 2 else: cols =1 self.box.cols=cols for guess in self.caterpillars: self.box.add_widget(Caterpillar(chain=guess,size_hint_y=None,size=(x,x/7/cols))) self.scroll_y=1
def build(self): layout = GridLayout(cols=1, padding=10, spacing=5, size_hint=(None, None), width=500) #Now adding movement to allow user to 'scroll' layout.bind(minimum_height=layout.setter('height')) #putting the numbers in 20 for i in range(21): buttons = Button( text=str(i), #this will loop over 20 times size_hint=(None, None), size=(500, 40), ) layout.add_widget( buttons) #this connects to buttons=Button(etc,etc,etc) root = ScrollView( size_hint=(None, None), size=(500, 333), pos_hint={ 'center_x': .5, 'center_y': .5 }, ) root.add_widget(layout) return root
def viewGames(self): sview = ScrollView(size_hint=(.9, .8), pos_hint={'center_x':.5, 'center_y':.5}) layout = GridLayout(cols=1, spacing=10, size_hint_y=None) # Make sure the height is such that there is something to scroll. layout.bind(minimum_height=layout.setter('height')) # Run sql query to get all available games availableGames = retrieve("SELECT * FROM Games") if availableGames == "": popup = Popup(title='No Games', content=Label(text='There are currently no available games'), size_hint=(None, None), size=(400, 100)) popup.open() elif availableGames == 0: popup = Popup(title='Connection', content=Label(text='Could not connect to the database'), size_hint=(None, None), size=(400, 100)) popup.open() else: for tpl in availableGames: uid, name, location, creator, status = tpl print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n" print name print "\n\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n" btn = Button(id=name, text=name, size_hint_y=None, height=200) btn.bind(on_press=self.seeInfo) layout.add_widget(btn) sview.add_widget(layout) self.add_widget(sview)
def capture_player(name): event_player = name.text popup_player_list.dismiss() # Select event and publish def capture_event(name): event_name = name.text event_log = (str(currentTime).zfill(2) + ' ' + event_name + ' (' + event_player +')') print(event_log) self.root.ids.commentary.text += '\n' + event_log popup_event_list.dismiss() # Build event list modal layout_event_list = GridLayout(cols=1, spacing=5, size_hint_y=None) layout_event_list.bind(minimum_height=layout_event_list.setter('height')) list_of_events = ["Goal scored", "Goal conceded", "Yellow card", "Red card"] layout_event_list.my_buttons = [] # if you want to keep an "easy" reference to your buttons to do something with them later # kivy doesnt crashes because it creates the property automatically for event in list_of_events: button = Button(text=event, size_hint_y=None, height=50) button.bind(on_press=capture_event) layout_event_list.my_buttons.append(button) layout_event_list.add_widget(button) root = ScrollView(size_hint=(1, None), size=(Window.width * 1, Window.height * .9)) root.add_widget(layout_event_list) # Open event modal popup_event_list = Popup(title='Select event:', content=root, size_hint=(1, 1)) popup_event_list.open()
def show_view_list_path(self, *args, **kwargs): self.clear_widgets() color = ColorLayout() boxl = BoxLayout(orientation= 'vertical',anchor_y= "top") grid = GridLayout(cols=1, size_hint_y=None) grid.bind(minimum_height=grid.setter('height')) scroll = ScrollView(size_hint=(None, None)) scroll.size = (Window.width, Window.height) scroll.center = Window.center #2 Space added but button go back ocuppies space and first value hidden. l_space = MultiLineLabel(text='',font_size="16dp", background_color=(255,255,255,255), markup=True) grid.add_widget(l_space) l_space = MultiLineLabel(text='',font_size="16dp", background_color=(255,255,255,255), markup=True) grid.add_widget(l_space) for i in args[0]: text = '[color=333333]'+' '+i['text'] + '[/color]'+' ' #~ l = MultiLineLabel(text=text,font_size="16dp",markup=True) l = MultiLineLabel(text=text,font_size="16dp", background_color=(255,255,255,255), markup=True) i['stations'] and l.bind(on_press = partial(self.show_list_stations, i['stations'],args[0])) grid.add_widget(l) button_back = Button(text="Go Back", auto_dismiss=False, size_hint=(None, None), pos_hint= {'center_x':.5, 'center_y':.7}) button_back.height="50dp" button_back.width="100dp" button_back.bind(on_press = lambda widget: self.show_option_view()) scroll.add_widget(grid) boxl.add_widget(scroll) boxl.add_widget(button_back) color.add_widget(boxl) self.add_widget(color)
def get_layouts(): layout = GridLayout(cols=1, spacing=10, size_hint_y=None) # layout.bind(minimum_height=layout.setter('height')) layout.bind(minimum_height=layout.setter('height')) root = ScrollView(size_hint=(1, 4)) root.add_widget(layout) return root, layout
def __init__(self, issue: Issue = None, contact=None, **kwargs): super().__init__(**kwargs) self.issue = issue self.contact = contact self.kc = KivyConfig() self.title = "What was the outcome of your call?" self.title_align = 'center' self.size_hint = 0.8, 0.25 self.background = 'images/modalview-background.png' self.title_color = 0, 0, 0, 1 self.separator_color = 1, 1, 1, 1 self.title_size = sp(self.kc.font_size) self.auto_dismiss = False button_layout = GridLayout(cols=2, size_hint_y=None, spacing=[sp(10), sp(10)]) button_layout.bind(minimum_height=button_layout.setter('height')) for model in issue.outcomeModels: b = OutcomeButton(text=model['label'].title(), ) b.bind(on_release=self.button_callback) button_layout.add_widget(b) self.content = button_layout
def __init__(self, **kwargs): super().__init__(**kwargs) self.package = [['Number', 'B', 'S', '4A', '3A', '3ABC'], ['Number', '4A', '4B', '4C', '4D', '4E'], ['Box', 'B', 'S', '', '', ''], ['iBox', 'B', 'S', '', '', ''], ['PK', 'B', 'S', '', '', ''], ['PB', 'B', 'S', '', '', ''], ['HT', 'B', 'S', '', '', ''], ['Number', '3A', '3B', '3C', '3D', '3E'], ['Number', '2A', '2B', '2C', '2D', '2E']] self.package_status = 0 # Initial package is choose (first package) self.update_package( self.package[self.package_status]) # initialize the package self.textbox_instance = None # initial object is None (object haven't created) self.bind_textbox() # To bind the textbox input for the package #print(self.ids['display_screen'].width) #print(self.ids['display_screen'].height) self.keyboard_mode = 'managed' layout = GridLayout(cols=2, spacing='1dp', size_hint_y=None) # Make sure the height is such that there is something to scroll. layout.bind(minimum_height=layout.setter('height')) for i in range(100): #btn = Button(text=str(i), size_hint_y=None, height='35dp') layout.add_widget(self.add_button(i)) root = ScrollView(size_hint=(1, 1)) root.add_widget(layout) self.ids['display_screen'].add_widget(root)
class DrinkersListWidget(ScrollView): def __init__(self, db, **kwargs): """ :param Db db: """ # https://kivy.org/doc/stable/api-kivy.uix.scrollview.html # Window resize recursion error while using ScrollView? https://github.com/kivy/kivy/issues/5638 # size_hint=(1, None) correct? size_hint=(1, 1) is default. # self.parent.bind(size=self.setter("size")), once the parent assigned? super(DrinkersListWidget, self).__init__(**kwargs) self.db = db self.layout = GridLayout(cols=1, spacing=2, size_hint_y=None) # Make sure the height is such that there is something to scroll. self.layout.bind(minimum_height=self.layout.setter('height')) self.add_widget(self.layout) self.update_all() @run_in_mainthread_blocking() def update_all(self): self.layout.clear_widgets() for drinker_name in sorted(self.db.get_drinker_names()): self.layout.add_widget(DrinkerWidget(db=self.db, name=drinker_name, size_hint_y=None, height=30)) @run_in_mainthread_blocking() def update_drinker(self, drinker_name): """ :param str drinker_name: """ for widget in self.layout.children: assert isinstance(widget, DrinkerWidget) if widget.name == drinker_name: widget.update() return raise Exception("Unknown drinker: %r" % (drinker_name,))
def build(self): box = BoxLayout(orientation='vertical') # create a default grid layout with custom width/height layout = GridLayout(cols=1, padding=10, spacing=10, size_hint=(None, None), width=500) # when we add children to the grid layout, its size doesn't change at # all. we need to ensure that the height will be the minimum required to # contain all the childs. (otherwise, we'll child outside the bounding # box of the childs) layout.bind(minimum_height=layout.setter('height')) # add button into that grid for i in range(30): btn = Button(text=str(i), size=(480, 40), size_hint=(None, None)) layout.add_widget(btn) # create a scroll view, with a size < size of the grid root = ScrollView( pos_hint={'top': 1.0, 'left': 1.0}) root.add_widget(layout) b = Button(text='gyumkiu', size=(480, 40), size_hint=(None, None) ) box.add_widget(b) box.add_widget(root) return box