def __init__(self, **kwargs): super(Button_Widget, self).__init__(**kwargs) btn1 = kb.Button(text='Sort By\nExtension', pos=(200, 100)) btn1.bind(on_release=self.extension) self.add_widget(btn1) btn2 = kb.Button(text='Sort By\nDay', pos=(0, 100)) btn2.bind(on_release=self.sortDay) self.add_widget(btn2) btn3 = kb.Button(text='Sort By\nMonth', pos=(100, 0)) btn3.bind(on_release=self.sortMonth) self.add_widget(btn3) btn4 = kb.Button(text='Sort By\nYear', pos=(0, 0)) btn4.bind(on_release=self.sortYear) self.add_widget(btn4) btn5 = kb.Button(text='Sort By\nAscending', pos=(100, 200)) btn5.bind(on_release=self.sortAsc) self.add_widget(btn5) btn6 = kb.Button(text='Backup', pos=(200, 0)) btn6.bind(on_release=self.backup) self.add_widget(btn6) btn7 = kb.Button(text='Extract', pos=(0, 200)) btn7.bind(on_release=self.extract) self.add_widget(btn7) btn8 = kb.Button(text='Select\nFolder\n(Do First)', pos=(100, 100), color=[0.92, 0.8, 0.75, 1]) btn8.bind(on_release=self.browse) self.add_widget(btn8) self.txt = kb2.TextInput(hint_text='Enter\nPrecision\nValue\n(Integer)', multiline=False, pos=(200, 200)) self.add_widget(self.txt) global popup1 global popup2 popup1 = kb3.Popup(title='ERROR', content=kb4.Label(text='Please Enter the\nPrecision Value for\nSort by Ascending'), auto_dismiss=False) popup2 = kb3.Popup(title='ERROR', content=kb4.Label(text='Please Select a File'), auto_dismiss=False)
def on_pre_enter(self): if not self.initialized: self.initialized = True self.widgets["title_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="center", anchor_y="top") self.widgets["title_layout"].add_widget( kv_label.Label(text='New Game', size_hint=(0.1, 0.1))) self.widgets["exit_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="left", anchor_y="bottom") self.widgets["exit_layout"].add_widget( kv_button.Button( background_normal= f'{dl_gb_utils.images_path}/arrow_left.png', background_down=f'{dl_gb_utils.images_path}/arrow_left.png', size_hint=(.2, .1), border=[1, 1, 1, 1], on_press=lambda i: self.goto_menu())) self.widgets["stories_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="center", anchor_y="center") self.widgets["stories_layout"].add_widget( kv_boxlayout.BoxLayout(orientation='vertical', size_hint=(0.5, 0.7))) self.widgets["stories_layout"].children[0].add_widget( kv_button.Button( text="Undefined Title", # ~ on_press = lambda i: self.goto_story(story1.s1))) on_press=lambda i: print("Story not defined"))) for name, widget in self.widgets.items(): self.add_widget(widget)
def make_cells(self): for cell in self.grid: pos = cell.pos terrain = cell.terrain x, y = pos w = cell.make_widget(pos=self.grid_to_window(pos)) self._grid[x][y] = w self.add_widget(w) if terrain: t = terrain.make_widget(pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) w.add_widget(t) # t.update_vertices() if cell.object: o = cell.object.make_widget(pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) w.add_widget(o) for _, content in enumerate(cell.additional_content): c = content.make_widget(pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) w.add_widget(c) w.add_widget( label.Label(text=str(pos), pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }))
def on_pre_enter(self): if not self.initialized: self.initialized = True self.widgets["title_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="center", anchor_y="top") self.widgets["title_layout"].add_widget( kv_label.Label(text='Menu', size_hint=(0.1, 0.1))) self.widgets["settings_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="right", anchor_y="top") self.widgets["settings_layout"].add_widget( kv_button.Button( background_normal=f'{dl_gb_utils.images_path}/settings.png', background_down=f'{dl_gb_utils.images_path}/settings.png', border=[1, 1, 1, 1], size_hint=(.12, .08), on_press=lambda i: self.goto_settings())) self.widgets["exit_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="left", anchor_y="bottom") self.widgets["exit_layout"].add_widget( kv_button.Button(text='Exit', size_hint=(.1, .1), on_press=lambda i: exit())) self.widgets["newgame_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="center", anchor_y="center") self.widgets["newgame_layout"].add_widget( kv_button.Button(text='New Game', size_hint=(.5, .1), on_press=lambda i: self.goto_newgame())) for name, widget in self.widgets.items(): self.add_widget(widget)
def run_paragraph(self, paragraph): self.clear_widgets() self.widgets = {} self.widgets["center_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="center", anchor_y="center", size_hint=(0.9, 0.9)) self.widgets["center_layout"].add_widget( kv_label.Label(text_size=(400, 400), text=paragraph.get_text(), halign="center", valign="center")) self.widgets["choices_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="center", anchor_y="bottom") self.widgets["choices_layout"].add_widget( kv_boxlayout.BoxLayout(orientation='vertical', size_hint=(0.5, 0.2))) for choice in paragraph.get_choices(): self.widgets["choices_layout"].children[0].add_widget( kv_button.Button(text=choice.get_text(), on_press=lambda i: self.run_paragraph( choice.get_paragraph()))) for name, widget in self.widgets.items(): self.add_widget(widget)
def on_pre_enter(self): if not self.initialized: self.initialized = False # for now everything is regenerated everytime self.widgets["title_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="center", anchor_y="top") self.widgets["title_layout"].add_widget( Label(text=self.story.get_title(), size_hint=(0.1, 0.1))) self.widgets["exit_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="left", anchor_y="bottom") self.widgets["exit_layout"].add_widget( kv_button.Button(background_normal='images/arrow_left.png', background_down='images/arrow_left.png', size_hint=(.2, .1), border=[1, 1, 1, 1], on_press=lambda i: self.goto_newgame())) self.widgets["center_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="center", anchor_y="center") self.widgets["center_layout"].add_widget( kv_boxlayout.BoxLayout(orientation='vertical', size_hint=(0.5, 0.7))) self.widgets["center_layout"].children[0].add_widget( kv_label.Label(text=self.story.get_summary())) self.widgets["center_layout"].children[0].add_widget( kv_button.Button(text="Begin Story", on_press=lambda i: self.run_chapter( self.story.get_first_chapter()))) for name, widget in self.widgets.items(): self.add_widget(widget)
def build(self): self.textInput = inp.TextInput() self.label = lbl.Label(text="Your Message") self.button = btn.Button(text="Click Me") self.button.bind(on_press = self.displayMessage) self.boxLayout = bx.BoxLayout(orientation="vertical") self.boxLayout.add_widget(self.textInput) self.boxLayout.add_widget(self.label) self.boxLayout.add_widget(self.button) return self.boxLayout
def setupCategories(self): app = App.get_running_app() ic = IntentClassifier() categories = ic.load_dataset(piece="uniqueintents") categoryScroller = app.root.ids.feedback_screen.ids.feedbackCategories categoryList = boxlayout.BoxLayout() categoryList.orientation = "vertical" categoryList.id = "categoryList" # categoryList.size_hint_y = None for i in categories: newcat = boxlayout.BoxLayout() newcat.orientation = "horizontal" newCheckBox = checkbox.CheckBox() newLabel = label.Label() newLabel.font_size = 24 newLabel.text = i newcat.add_widget(newCheckBox) newcat.add_widget(newLabel) categoryList.add_widget(newcat) # for i in range(10): # newLabel = label.Label() # newLabel.text = str(i) # newLabel.font_size = 24 # categoryList.add_widget(newLabel) newcat = boxlayout.BoxLayout() newcat.orientation = "horizontal" newCheckBox = checkbox.CheckBox() newLabel = label.Label() newLabel.font_size = 24 newLabel.text = "Other" newInput = textinput.TextInput() newInput.font_size = 24 newInput.hint_text = "Category" newcat.add_widget(newCheckBox) newcat.add_widget(newLabel) newcat.add_widget(newInput) categoryList.add_widget(newcat) categoryScroller.add_widget(categoryList)
def on_pre_enter(self): if not self.initialized: self.initialized = True self.widgets["title_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="center", anchor_y="top") self.widgets["title_layout"].add_widget( kv_label.Label(text='Settings', size_hint=(0.1, 0.1))) self.widgets["exit_layout"] = kv_anchorlayout.AnchorLayout( anchor_x="left", anchor_y="bottom") self.widgets["exit_layout"].add_widget( kv_button.Button( background_normal= f'{dl_gb_utils.images_path}/arrow_left.png', background_down=f'{dl_gb_utils.images_path}/arrow_left.png', size_hint=(.2, .1), border=[1, 1, 1, 1], on_press=self.goto_menu)) for name, widget in self.widgets.items(): self.add_widget(widget)
def build(self): self.l = False self.textInput = inp.TextInput() self.label = lbl.Label(text="") self.popText = lbl.Label(text="Make sure you are connected", font_size='25sp') self.popBtn = btn.Button(text="Close", size_hint=(1, .5), size=(400, 50)) self.box = bx.BoxLayout(orientation='vertical') self.box.add_widget(self.popText) self.box.add_widget(self.popBtn) self.popup = pup.Popup(title="Error", content=self.box, auto_dismiss=False, size_hint=(None, None), size=(400, 200)) self.popBtn.bind(on_press=self.popup.dismiss) self.button = btn.Button(text="Connect", size_hint=(1, .25)) self.button.bind(on_press=lambda x: self.conn(self.ip, self.button)) """self.button2 = btn.Button(text="up") self.button2.bind(on_press = lambda x:self.sendMessage('up')) self.button2.bind(on_release = lambda x:self.sendMessage('stop')) self.button3 = btn.Button(text="down") self.button3.bind(on_release = lambda x:self.sendMessage('stop')) self.button3.bind(on_press = lambda x:self.sendMessage('down')) self.button4 = btn.Button(text="right") self.button4.bind(on_press = lambda x:self.sendMessage('right')) self.button4.bind(on_release = lambda x:self.sendMessage('stop')) self.button5 = btn.Button(text="left") self.button5.bind(on_press = lambda x:self.sendMessage('left')) self.button5.bind(on_release = lambda x:self.sendMessage('stop'))""" self.ip = inp.TextInput(text="enter ip to connect to", size_hint=(1, .25)) self.textInput = inp.TextInput(size_hint=(1, .4)) self.send = btn.Button(text="send message", size_hint=(1, .25)) self.send.bind(on_press=lambda x: self.sendMessage(self.textInput)) self.boxLayout = bx.BoxLayout(orientation="vertical") #self.boxLayout.add_widget(self.textInput) #self.boxLayout.add_widget(self.label) self.boxLayout.add_widget(self.ip) self.boxLayout.add_widget(self.button) self.boxLayout.add_widget(self.label) self.boxLayout.add_widget(self.textInput) self.boxLayout.add_widget(self.send) #self.box1 = bx.BoxLayout(orientation = "vertical") """self.box1.add_widget(self.button2) self.box1.add_widget(self.button3) self.box2 = bx.BoxLayout(orientation = "horizontal") self.box2.add_widget(self.button5) self.box2.add_widget(self.box1) self.box2.add_widget(self.button4) self.boxLayout.add_widget(self.box2)""" return self.boxLayout