def titlebar(self): layout=BoxLayout(padding='2sp',size_hint=(1,None),height='65sp') layout.orientation='horizontal' #credentials = self.accept_credentials() self.submit_popup = Popup(title='Enter credentials',content=self.accept_credentials(),size_hint=(0.6, 0.35)) #credentials.children[1].bind(on_press=self.submit_popup.dismiss) submit = Button(text='Submit',size_hint=(0.4,1)) if self.element.read_token(self): submit.bind(on_press=partial(self.submit_assignment)) else: submit.bind(on_press=self.submit_popup.open) run = Button(text='Run',size_hint=(0.4,1)) run.bind(on_press=self.run) ex_dropdown = Spinner(text=self.current_ex,size_hint=(1,1)) ex_dropdown.values = os.listdir('./res/') ex_dropdown.bind(text=self.updateExercise) layout.add_widget(run) layout.add_widget(ex_dropdown) layout.add_widget(submit) return layout
def titlebar(self): layout = BoxLayout(padding='2sp', size_hint=(1, None), height='65sp') layout.orientation = 'horizontal' #credentials = self.accept_credentials() self.submit_popup = Popup(title='Enter credentials', content=self.accept_credentials(), size_hint=(0.6, 0.35)) #credentials.children[1].bind(on_press=self.submit_popup.dismiss) submit = Button(text='Submit', size_hint=(0.4, 1)) if self.element.read_token(self): submit.bind(on_press=partial(self.submit_assignment)) else: submit.bind(on_press=self.submit_popup.open) run = Button(text='Run', size_hint=(0.4, 1)) run.bind(on_press=self.run) ex_dropdown = Spinner(text=self.current_ex, size_hint=(1, 1)) ex_dropdown.values = os.listdir('./res/') ex_dropdown.bind(text=self.updateExercise) layout.add_widget(run) layout.add_widget(ex_dropdown) layout.add_widget(submit) return layout
def getUI(self): """get the ui element""" if 'enum' in self._typeInfo: result = Spinner() result.values = self._typeInfo['enum'] elif self._typeInfo['type'].lower() == 'boolean': result = Spinner() result.values = ['true', 'false'] else: result = TextInput() if self.value: result.text = self.value.lower() skin = sm.getSkin('text', self.asset) result.size = sm.getControlSize(skin, self.asset) self.uiEl = result self.prepareUiElement() result.bind(text=self.value_changed) return result
def buildMenu(mediator: Mediator, size_hint=None): menuDict = { 'Jouw hand': lambda: mediator.showSpecification(), 'Biedingen': lambda: mediator.showBiddingChooser(), 'Over BidBud': lambda: mediator.showCredits() } widgetSizeHint = (1.0, 1.0) if size_hint == None else size_hint widget = Spinner(text='Menu', size_hint=widgetSizeHint) widget.values = list(menuDict.keys()) widget.bind(text=lambda i, v: menuDict[v]()) def resizeMenu(i, isOpen): if isOpen: widget.size_hint_x = None widget.width = Window.width / 2 else: widget.size_hint = widgetSizeHint widget.bind(is_open=resizeMenu) return widget
def change_rules(self, instance): def all_unique(inp_list): seen = set() return not any(i in seen or seen.add(i) for i in inp_list) def finished(instance): try: survive_list = list(survive_input.text) create_list = list(create_input.text) survive_list = map(int, survive_list) create_list = map(int, create_list) if saved_selections.text == 'Manual Input': if self.cell_grid.game_id == 1: new_gen = int(generation_input.text) if 0 < new_gen < 14: self.cell_grid.game_grid.generations = new_gen if any(i > 8 or i < 0 for i in survive_list) or not all_unique(survive_list): pass else: self.cell_grid.game_grid.survive_list = survive_list if any(i > 8 or i < 0 for i in create_list) or not all_unique(create_list): pass else: self.cell_grid.game_grid.birth_list = create_list else: if self.cell_grid.game_id == 0: if saved_selections.text == 'Conway\'s Life': self.cell_grid.game_grid.survive_list = [2, 3] self.cell_grid.game_grid.birth_list = [3] elif saved_selections.text == '34 Life': self.cell_grid.game_grid.survive_list = [3, 4] self.cell_grid.game_grid.birth_list = [3, 4] elif saved_selections.text == '2x2 Life': self.cell_grid.game_grid.survive_list = [1, 2, 5] self.cell_grid.game_grid.birth_list = [3, 6] elif saved_selections.text == 'Gnarl': self.cell_grid.game_grid.survive_list = [1] self.cell_grid.game_grid.birth_list = [1] elif saved_selections.text == 'HighLife': self.cell_grid.game_grid.survive_list = [2, 3] self.cell_grid.game_grid.birth_list = [3, 6] elif saved_selections.text == 'Maze': self.cell_grid.game_grid.survive_list = [ 1, 2, 3, 4, 5 ] self.cell_grid.game_grid.birth_list = [3] elif saved_selections.text == 'Psuedo Life': self.cell_grid.game_grid.survive_list = [2, 3, 8] self.cell_grid.game_grid.birth_list = [3, 5, 7] elif saved_selections.text == 'Serviettes': self.cell_grid.game_grid.survive_list = [] self.cell_grid.game_grid.birth_list = [2, 3, 4] elif saved_selections.text == 'Cities': self.cell_grid.game_grid.survive_list = [ 2, 3, 4, 5 ] self.cell_grid.game_grid.birth_list = [ 4, 5, 6, 7, 8 ] elif saved_selections.text == 'Mazectric': self.cell_grid.game_grid.survive_list = [ 1, 2, 3, 4 ] self.cell_grid.game_grid.birth_list = [3] except ValueError: pass popup.dismiss() content = BoxLayout(orientation='vertical') content_manual = BoxLayout(orientation='horizontal') survive_input = TextInput(size_hint=(1, 1)) create_input = TextInput(size_hint=(1, 1)) close_button = Button(text='OK', size_hint=(None, 1), size=(50, 100)) content_manual.add_widget(survive_input) content_manual.add_widget(create_input) if self.cell_grid.game_id == 1: generation_input = TextInput(size_hint=(1, 1)) content_manual.add_widget(generation_input) content_manual.add_widget(close_button) close_button.bind(on_press=finished) saved_selections = Spinner(text='Manual Input') if self.cell_grid.game_id == 1: title = 'Enter New Generation Rules' size = (320, 130) saved_selections.values = ('Manual Input') elif self.cell_grid.game_id == 0: title = 'Enter New Survive and Create Rules' size = (300, 130) saved_selections.values = ('Manual Input', 'Conway\'s Life', '34 Life', '2x2 Life', 'Gnarl', 'HighLife', 'Maze', 'Mazectric', 'Psuedo Life', 'Serviettes', 'Cities') content.add_widget(saved_selections) content.add_widget(content_manual) popup = Popup(title=title, content=content, size=size, size_hint=(None, None)) popup.open()