class ConnectionScreen(Screen): def __init__(self, **kwargs): super(ConnectionScreen, self).__init__(**kwargs) self.root = Accordion() roleItem = AccordionItem(title='Role') self.root.add_widget(roleItem) serverItem = AccordionItem(title='Server') self.root.add_widget(serverItem) self.dmBtn = ToggleButton(text="DM", group="role") self.pcBtn = ToggleButton(text="Player", group="role", state="down") self.textinput = TextInput(text='John-LAPTOP', multiline=False) self.textinput.bind(on_text_validate=self.on_confirm) roleItem.add_widget(self.dmBtn) roleItem.add_widget(self.pcBtn) serverItem.add_widget(self.textinput) self.add_widget(self.root) def on_confirm(self, instance): global Combatants if self.dmBtn.state == "down": Combatants = Roster() t = threading.Thread(target = self.startServer) t.start() global isDM isDM = True elif self.pcBtn.state == "down": nameserver = Pyro4.locateNS(host=self.textinput.text) Combatants = Pyro4.Proxy("PYRONAME:Combatants") SS = SelectionScreen(name="Selection Screen") sm.add_widget(SS) self.manager.current = 'Selection Screen' def startServer(self): Pyro4.Daemon.serveSimple({Combatants: "Combatants"}, host=socket.gethostname(), ns=True)
def build(self): root = Accordion() for x in range(2): item = AccordionItem(title='Title %d' % x) item.add_widget(Builder.load_string(kv)) root.add_widget(item) return root
def __init__(self, username, userid, name): """ """ self.name = name self.username = username self.userid = userid super(LevelSelect, self).__init__() conn = sqlite3.connect(filehome + 'database.db') # Opens the connection to the database. c = conn.cursor() levels = c.execute('''SELECT levelid, levelname, leveldesc FROM level''') # Gets the levels from the database box = BoxLayout(orientation = 'vertical') box.add_widget(Banner(False, 2, self.userid)) # Adds the top banner, as this is the main menu we need a logout button and not a back button. lvlAccordion = Accordion(orientation = 'vertical', min_space = dp(25), anim_duration = 1) for i in levels: item = AccordionItem(title = i[1], min_space = dp(25), background_normal='images/blue32025.png', background_selected='images/orange32025.png') boxa = BoxLayout(orientation = 'vertical') lbl = Label(text = i[2], text_size = (300, None)) boxa.add_widget(lbl) btn = Button(text = 'Go', id = str(i[0])+','+i[1], on_press = self.selectlevel, background_normal = 'images/orange32030.png', background_down = 'images/blue32025.png', size_hint_y = None, height = dp(30)) boxa.add_widget(btn) item.add_widget(boxa) lvlAccordion.add_widget(item) box.add_widget(lvlAccordion) # Adds the Accordion to the box self.add_widget(box) # Adds the box widget to the screen conn.close()
def build(self): root =Accordion() for x in range(5): item = AccordionItem(title='Title %d' %x , min_space=60) item.add_widget(Label(text='Hello Youssef \n' *5)) root.add_widget(item) return root
def build(self): root = Accordion() for x in xrange(5): item = AccordionItem(title='Title %d' % x) item.add_widget(Label(text='Very big content\n' * 10)) root.add_widget(item) return root
def __init__(self, *args, **kwargs): Accordion.__init__(self, *args, **kwargs) self.open_mapping = None #self.on_select(self.on_blah) self.mapping_lists = [] ## TODO rename self.mapping_buttons = {}
class InterfaceManager(BoxLayout): def __init__(self, **kwargs): super(InterfaceManager, self).__init__(**kwargs) self.first = Login() self.second = Accordion() self.second = Accordion(orientation='vertical') options = ['My profile', 'New Object', 'Find Objects'] for key in options: item = AccordionItem(title='%s' % key) if key == 'New Object': item.add_widget(NewObject()) if key == 'Find Objects': item.add_widget(FindObjects()) self.second.add_widget(item) self.final = Label(text="Hello World") self.add_widget(self.first) def show_second(self, usr, pss): self.clear_widgets() print 'show_second!!!' print usr print pss self.add_widget(self.second) def show_final(self, button): self.clear_widgets() self.add_widget(self.final)
def show_accordion(self): root = Accordion() for x in xrange(5): item = AccordionItem(title='Title %d' % x) item.add_widget(Label(text='Very big content\n' * 10)) root.add_widget(item) col = AnchorLayout() col.add_widget(root) return col
def build(self): root = Accordion(orientation='vertical') for x in xrange(5): item= AccordionItem(title='Image %d' %x) src = "images/%d.jpg" % x image = Image(source=src,pos=(400, 100), size=(400, 400)) item.add_widget(image) root.add_widget(item) return root
def build(self): root_acc = Accordion(orientation='vertical') for player in players_list: item = AccordionItem(title=player) btn = Button(text=player, background_color=grey) item.add_widget(btn) item = self.create_layout(player) root_acc.add_widget(item) return root_acc
def build(self): root = Accordion() for x in range(5): item = AccordionItem( title='Title %d' % x, min_space=50) #involve the value of x instead of d item.add_widget(Label(text='Hello World\n' * 5)) root.add_widget(item) return root
def build(self): for device in Device.objects.order_by('pin'): GPIO.setup(device.pin, GPIO.OUT) screen = Accordion() for category in Category.objects.order_by('order'): item = AccordionItem(title=category.label) screen.add_widget(item) item.add_widget(self.buildCategory(category)) return screen
def build(self): scroller = ScrollView(size_hint=(1, None), size=(Window.width, Window.height)) root = Accordion(orientation='vertical',size_hint_y=None,height=50*27) chart = self.create_gantt() for title in chart: item = AccordionItem(title=title) item.add_widget(Image(source=title)) root.add_widget(item) scroller.add_widget(root) return scroller
def __init__(self, **kwargs): super(TransitDisplayWidget, self).__init__(**kwargs) accord = Accordion() self._InboundScreen = TransitDisplayScreenWidget(title = "Inbound") accord.add_widget(self._InboundScreen) self._OutboundScreen = TransitDisplayScreenWidget(title = "Outbound") accord.add_widget(self._OutboundScreen) self.add_widget(accord)
def build(self): lista = Accordion() for x in range(7): item = AccordionItem(title='Item{0}'.format(x + 1)) item.add_widget( Label(text='''Além do horizonte deve ter Algum lugar bonito pra viver em paz Onde eu possa encontrar a natureza Alegria e felicidade com certeza''')) lista.add_widget(item) return lista
def build(self): self.root = Accordion(min_space=30) self.overviewItem = AccordionItem(title=unichr(252) + 'bersicht') self.overview = Overview() self.overviewItem.add_widget(self.overview) #self.closeButton = Button(text = 'Beenden', size=(100, 50), size_hint=(None, None), background_color=[1,0,0,1]) #self.closeButton.bind(on_press=self.closeApp) #self.overviewItem.add_widget(self.closeButton) self.root.add_widget(self.overviewItem) self.scheduleItem = AccordionItem(title='Stundenplan') self.schedule = Schedule() self.scheduleItem.add_widget(self.schedule) self.root.add_widget(self.scheduleItem) self.appointmentsItem = AccordionItem(title='Termine') self.appointments = Appointments() self.appointmentsItem.add_widget(self.appointments) self.root.add_widget(self.appointmentsItem) self.todoListItem = AccordionItem(title='Haushalts-Abenteuer') self.todoList = TodoList() self.todoListItem.add_widget(self.todoList) self.root.add_widget(self.todoListItem) self.newsItem = AccordionItem(title='Nachrichten') self.news = Feeds() self.newsItem.add_widget(self.news) self.root.add_widget(self.newsItem) self.pictureItem = AccordionItem(title='Bilder') self.pictureFrame = PictureFrame() self.pictureItem.add_widget(self.pictureFrame) self.root.add_widget(self.pictureItem) self.scheduleItem.collapse = False self.ledClock = LedMatrix() # initial weather data self.overview.updateWeather() # continuous updates EACH_SECOND = 1 ONE_MINUTE = 60 FOUR_HOURS = 14400 Clock.schedule_interval(self.__updateLedClock, EACH_SECOND) Clock.schedule_interval(self.__updateItems, ONE_MINUTE) Clock.schedule_interval(self.__updateWeather, FOUR_HOURS) return self.root
def build(self): num_page = 2 root = Accordion() pages = list() for page in range(num_page): item = AccordionItem(title=f'Title{page}') grid = GridLayout(cols=3, spacing=20, padding=10) # with grid.canvas: # Color(0.5,0.6,0.7,0.8) # Rectangle(size=grid.size,pos=grid.pos) item.add_widget(grid) root.add_widget(item) pages.append(grid) #!!! this must be get from serial port !!!# Buttons_text = list(map(lambda num: 'Button ' + str(num), range(1, 6))) Buttons_status0 = [ 'open', 'close', 'deactive', 'open', 'close', 'deactive' ] Buttons_status = dict() for name, status in zip(Buttons_text, Buttons_status0): Buttons_status[name] = status # predefined constants Buttons_color = { 'open': [random(), random(), random(), 0.9], 'close': [1, 0, 0, 0.9], 'deactive': [0.5, 0.5, 0.5, 0.9] } # add Buttons to page 0 Buttons = list( map( lambda name: Button(text=name, background_color=Buttons_color[ Buttons_status[name]]), Buttons_text)) # Clock.schedule_interval(Buttons[0]., 1.0 / 60.0) # Buttons[0].bind(on_press=print('hello world')) _ = list(map(lambda button: pages[0].add_widget(button), Buttons)) # add Gauges to page 1 Gauges = list( map(lambda gauge: Gauge(value=50, size_gauge=200, size_text=19), Buttons_text)) _ = list(map(lambda gauge: pages[1].add_widget(gauge), Gauges)) ### defines events _ = list( map( lambda button: button.bind(on_press=lambda button: self. ErrorWindow()), Buttons)) return root
def build(self): lista = Accordion() item = AccordionItem( title='Amor', background_normal='cores.jpg', background_selected= 'um-video-super-legal-com-imagens-do-por-do-sol-muito-lindo.jpg') item.add_widget( Label(text=''' Bom o que sinto as vezes, tenho medo de sentir, sera que eu sou a pessoa certa?, tenho muitas insertezas, dizem que quando a gente gosta não que saber e que a pessoa pra si, mas eu agora não sei se só estou gostando será, eu mudei quero ter uma familia a pessoa que eu estou gostando ela tem seu receios. Não sei se isso é o certo, acredito que esse sentimento seja amor apaixonado tenho que esperar. Um dia tive uma crise de paixão logo outro dia me recuperei meio que não sentia mais que gosta, acredito que deva esperar. ''')) item1 = AccordionItem(title='B') item2 = AccordionItem(title='C') item1.add_widget(Label(text='Pão')) item2.add_widget(Label(text='Oleo')) lista.add_widget(item2) lista.add_widget(item) lista.add_widget(item1) return lista
def __init__(self, **kwargs): super(SelectionScreen, self).__init__(**kwargs) global Combatants self.root = Accordion() charItem = AccordionItem(title='Characters') self.root.add_widget(charItem) enItem = AccordionItem(title='Enemies') self.root.add_widget(enItem) confirmItem = AccordionItem(title='Done') self.root.add_widget(confirmItem) self.CharButtons = [] self.EnemyButtons = [] self.enemyIter = 0 self.quantity = 0 self.content = TextInput(text='1', multiline=False) self.content.bind(on_text_validate=self.setQuantity) i = 0 while i < Combatants.getNumChars(): btn = ToggleButton(text=Combatants.getCharName(i)) charItem.add_widget(btn) self.CharButtons.append(btn) i = i+ 1 i = 0 while i < Combatants.getNumEn(): btn = ToggleButton(text=Combatants.getEnName(i)) enItem.add_widget(btn) self.EnemyButtons.append(btn) i = i + 1 B = Button(text='Go!') B.bind(on_press=self.showCombatants) confirmItem.add_widget(B) self.add_widget(self.root)
def __init__(self, *args, **kwargs): super(Settings, self).__init__(**kwargs) self.orientation = "vertical" self.accordion = Accordion(orientation="vertical") for x in [General, Themes, About]: item = AccordionItem(title=str(x.__name__), title_template="Panel") item.box = x(orientation="vertical") item.add_widget(item.box) self.accordion.add_widget(item) for x in self.accordion.children: x.collapse = False if type(x.box).__name__ == "General" else True self.add_widget(self.accordion) self.save_buttons = SaveButtons(size_hint_y=0.1) self.add_widget(self.save_buttons)
def __init__(self, **kwargs): super(BaseMultiChannelConfigView, self).__init__(**kwargs) self.register_event_type('on_config_updated') accordion = Accordion(orientation='vertical', size_hint=(1.0, None)) sv = ScrollContainer(size_hint=(1.0,1.0), do_scroll_x=False) sv.add_widget(accordion) self._accordion = accordion self.add_widget(sv)
def build(self): root = Accordion(orientation="vertical") for x in range(4): item = AccordionItem(title='Screen %d' % x) item.add_widget(Button(text='Vis TimeLapse\n', size_hint=(0.25,0.25), pos=(100, 100))) item.add_widget(Button(text='IR TimeLapse\n', size_hint=(0.25,0.25), pos=(100, 100))) item.add_widget(Button(text='Vis Live\n', size_hint=(0.25,0.25), pos=(100, 100))) item.add_widget(Button(text='IR Live\n', size_hint=(0.25,0.25), pos=(100, 100))) root.add_widget(item) return root
class ActionMenu(Screen): def __init__(self, **kwargs): super(ActionMenu, self).__init__(**kwargs) self.root = Accordion(orientation='vertical') self.targItem = AccordionItem(title='Target') self.root.add_widget(self.targItem) self.conItem = AccordionItem(title='Confirm') self.root.add_widget(self.conItem) B = Button(text='Confirm') B2 = Button(text='Cancel') B.bind(on_press=self.confirmTarget) B2.bind(on_press=self.cancel) self.conItem.add_widget(B) self.conItem.add_widget(B2) self.add_widget(self.root) def populate(self): self.ComButtons = [] for c in Combatants.retList(): btn = ToggleButton(text=c.name, group='targets') self.targItem.add_widget(btn) self.ComButtons.append(btn) def confirmTarget(self, obj): hasTarget = False i = 0 for b in self.ComButtons: if b.state == 'down': hasTarget = True Screens[2].Target = Combatants.get(i) i += 1 if hasTarget == True: hasTarget = False self.targItem.clear_widgets(children=self.ComButtons) self.ComButtons.clear() Combatants.get(0).hasActed = True Screens[2].AttackButton.disabled = True self.manager.current = 'Battle Screen' Screens[2].Attack() def cancel(self, obj): self.targItem.clear_widgets(children=self.ComButtons) self.ComButtons.clear() self.manager.current = 'Battle Screen'
def __init__(self, **kwargs): super(SessionBrowser, self).__init__(**kwargs) self.register_event_type('on_lap_selection') accordion = Accordion(orientation='vertical', size_hint=(1.0, None)) sv = ScrollContainer(size_hint=(1.0, 1.0), do_scroll_x=False) self.selected_laps = {} self.current_laps = {} sv.add_widget(accordion) self._accordion = accordion self.add_widget(sv)
class ViewQuestion(Screen, BoxLayout): def __init__(self, **kwargs): super(ViewQuestion, self).__init__(**kwargs) self.accordion = Accordion(orientation='vertical') self.get_question() def get_question(self): list_for_accord = [] list_for_sub_item = [] for i in list_of_subject: store = JsonStore('{}.json'.format(i.strip('').upper())) list_for_accord.append(i) accord_item = AccordionItem(title=i, orientation='horizontal') for key in store.keys(): p = Popup(title=key, size_hint=(.5, .5), auto_dismiss=True) accord_sub_item = OneLineListItem(text=str(key)) accord_sub_item.bind(on_press=p.open) accord_item.add_widget(accord_sub_item) grid = GridLayout(cols=1) l1 = Button(text=store[key]['question']) l2 = Button(text=store[key]['option1']) l3 = Button(text=store[key]['option2']) l4 = Button(text=store[key]['option3']) l5 = Button(text=store[key]['option4']) l7 = TextInput(text='') l6 = Button(text='see answer') l6.bind(on_release=lambda x: setattr(l7, 'text', store[p.title] ['answer'])) grid.add_widget(l1) grid.add_widget(l2) grid.add_widget(l3) grid.add_widget(l4) grid.add_widget(l5) grid.add_widget(l6) grid.add_widget(l7) p.add_widget(grid) self.accordion.add_widget(accord_item) self.add_widget(self.accordion)
def __init__(self, **kwargs): super(InterfaceManager, self).__init__(**kwargs) self.first = Login() self.second = Accordion() self.second = Accordion(orientation='vertical') options = ['My profile', 'New Object', 'Find Objects'] for key in options: item = AccordionItem(title='%s' % key) if key == 'New Object': item.add_widget(NewObject()) if key == 'Find Objects': item.add_widget(FindObjects()) self.second.add_widget(item) self.final = Label(text="Hello World") self.add_widget(self.first)
def __init__(self, username, userid, level, levelname, name): self.name = name self.username = username self.userid = userid self.level = level self.levelname = levelname super(LevelListScreen, self).__init__() # Get level sections from database. conn = sqlite3.connect(filehome + 'database.db') c = conn.cursor() levelsections = c.execute('''SELECT levelsectionid, levelsectionname, levelsectionimage FROM levelsection WHERE levelid = ?''', (level,)) box = BoxLayout(orientation = 'vertical') box.add_widget(Banner(self.levelname, 1, self.userid)) topAccordion = Accordion(orientation = 'vertical', min_space = dp(25), anim_duration = 1) # Adding an accordion item for each of the levelsections for i in levelsections: item = AccordionItem(title = i[1], min_space = dp(25), background_normal='images/blue32025.png', background_selected = 'images/orange32025.png') boxa = BoxLayout(orientation = 'vertical') boxa.add_widget(AsyncImage(source = i[2])) # Get topics for the current level section from the database. c1 = conn.cursor() levelsectiontopics = c1.execute('''SELECT topicid, topicname, topicpage FROM topics WHERE levelsectionid = ?''', (i[0],)) # Add a button for each topic within the section for j in levelsectiontopics: boxa.add_widget(Button(text=j[1], id= j[1] + ',' + j[2], on_press = self.selecttopic, background_normal = 'images/orange32030.png', background_down = 'images/blue32025.png', size_hint_y = None, height = dp(30))) item.add_widget(boxa) topAccordion.add_widget(item) quizitem = AccordionItem(title = 'Quiz', min_space = dp(25), background_normal = 'images/blue32025.png', background_selected = 'images/orange32025.png') boxb = BoxLayout(orientation = 'vertical') boxb.add_widget(Label(text = 'Want to test your knowledge for this level?')) boxb.add_widget(Button(text = 'Quiz here', on_press = self.quiz, id = level, background_normal = 'images/orange32030.png', background_down = 'images/blue32025.png', size_hint_y = None, height = dp(30))) quizitem.add_widget(boxb) topAccordion.add_widget(quizitem) box.add_widget(topAccordion) self.add_widget(box) conn.close()
def build(self): root = Accordion(orientation='vertical') item = AccordionItem(title='Gate Transactions') item.add_widget(Label(text=\ """1) Login to Port of Virginia 2) Fill in these fields 3) Click "Get URL" and paste the URL into the browser 4) Copy all text (Command or Control+A) on this page 5) Click this button to create the CSV""")) page = BoxLayout(orientation='vertical') subpage = BoxLayout(orientation='vertical') input1 = BoxLayout(orientation='horizontal') input2 = BoxLayout(orientation='horizontal') input3 = BoxLayout(orientation='horizontal') input1.add_widget(Label(text='Start Date (yyyy-mm-dd):')) self.start_date = TextInput(text=datetime.now().strftime("%Y-%m-01")) input1.add_widget(self.start_date) input2.add_widget(Label(text='End Date (yyyy-mm-dd):')) self.end_date = TextInput(text=datetime.now().strftime("%Y-%m-%d")) input2.add_widget(self.end_date) input3.add_widget(Label(text='License Plate:')) self.license_plate = TextInput(text="UN11316,UN11316,UN11316") input3.add_widget(self.license_plate) buttons = GridLayout(cols=1) button = Button(text="Get URL", font_size=24) button.bind(on_press=self.get_url) buttons.add_widget(button) button = Button(text="JSON to CSV", font_size=24) button.bind(on_press=self.json_to_csv) buttons.add_widget(button) button = Button(text="List of Licenses to CSV", font_size=24) button.bind(on_press=self.get_urls_and_json_to_csv) buttons.add_widget(button) page.add_widget(subpage) subpage.add_widget(input1) subpage.add_widget(input2) subpage.add_widget(input3) page.add_widget(buttons) item.add_widget(page) root.add_widget(item) return root
def build(self): self.title = "HP4156C Parameter Analyser" ## Main screen has a title and two accordions root = BoxLayout(orientation='vertical') ## Add a title header to the window header = Label(text="HP4156C Parameter Analyser", font_size=20, size_hint_y=None, height=25) root.add_widget(header) ## The main Accordion menu menu = Accordion() ## The first accordion tab has three buttons item = AccordionItem(title='Configuration') item.add_widget(Configuration()) menu.add_widget(item) #the above section can be repeated to add more accordion items ## Add the accordion to the main screen root.add_widget(menu) return root
def build(self): root = Accordion() root = Accordion(min_space=60) # Providing the orentation root = Accordion(orientation='vertical') # Adding text to each Accordion for x in range(5): item = AccordionItem(title='Title % d' % x) item.add_widget( Label(text='GFG is Good Website foe CSE Students\n' * 5)) root.add_widget(item) # Reurn the root return root
class IspApp(App): def __init__(self, url, classes): super(IspApp, self).__init__() self.url = url self.accordion = Accordion() self.pnlCalendar = CalendarPanel(classes) def build(self): Window.size = (1400, 800) bltAll = AllLayout() bltCenter = BoxLayout() aciInf = AccordionItem(title='ISP Selection') aciInf.add_widget(InferencePanel(self.url, self)) aciCal = AccordionItem(title='Calendar') aciCal.add_widget(self.pnlCalendar) self.accordion.add_widget(aciInf) self.accordion.add_widget(aciCal) bltCenter.add_widget(self.accordion) bltAll.add_widget(bltCenter) return bltAll def update(self, courses): self.pnlCalendar.update_selected_courses(courses)
def __init__(self, **kwargs): super(ActionMenu, self).__init__(**kwargs) self.root = Accordion(orientation='vertical') self.targItem = AccordionItem(title='Target') self.root.add_widget(self.targItem) self.conItem = AccordionItem(title='Confirm') self.root.add_widget(self.conItem) B = Button(text='Confirm') B2 = Button(text='Cancel') B.bind(on_press=self.confirmTarget) B2.bind(on_press=self.cancel) self.conItem.add_widget(B) self.conItem.add_widget(B2) self.add_widget(self.root)
def __init__(self, **kwargs): super(ConnectionScreen, self).__init__(**kwargs) self.root = Accordion() roleItem = AccordionItem(title='Role') self.root.add_widget(roleItem) serverItem = AccordionItem(title='Server') self.root.add_widget(serverItem) self.dmBtn = ToggleButton(text="DM", group="role") self.pcBtn = ToggleButton(text="Player", group="role", state="down") self.textinput = TextInput(text='John-LAPTOP', multiline=False) self.textinput.bind(on_text_validate=self.on_confirm) roleItem.add_widget(self.dmBtn) roleItem.add_widget(self.pcBtn) serverItem.add_widget(self.textinput) self.add_widget(self.root)
def __init__(self, **kwargs): super(SessionListView, self).__init__(**kwargs) self.register_event_type('on_lap_selection') self.register_event_type('on_session_updated') self.register_event_type('on_sessions_loaded') accordion = Accordion(orientation='vertical', size_hint=(1.0, None)) sv = ScrollContainer(size_hint=(1.0, 1.0), do_scroll_x=False) self.selected_laps = {} self.current_laps = {} sv.add_widget(accordion) self._accordion = accordion self.add_widget(sv) self.sessions = [] self.datastore = None self.settings = None self._save_timeout = None self._session_accordion_items = []
def build(self): self.title = "HP4156C Parameter Analyser" ## Main screen has a title and two accordions root = BoxLayout(orientation='vertical') ## Add a title header to the window header = Label(text="HP4156C Parameter Analyser", font_size=20, size_hint_y=None, height=25) root.add_widget(header) ## The main Accordion menu menu = Accordion() ## The first accordion tab has three buttons item = AccordionItem(title='Configuration') item.add_widget(Label(text='Very big content\n' * 10)) menu.add_widget(item) ## The second accordion tab graphs data and saves to excel item = AccordionItem(title='Results') item.add_widget(Label(text='Very big content\n' * 10)) menu.add_widget(item) ## Add the accordion to the main screen root.add_widget(menu) return root
def __init__(self, mainwi, data_id, **kwars): super(detallestorneo, self).__init__() self.mainwi = mainwi self.data_id = data_id self.ids.container2.clear_widgets() #eti= Label(text="Navega por el contenido") #self.ids.container2.add_widget(eti) root = Accordion(orientation="vertical", anim_duration=2.5) item1 = AccordionItem(title="Reglas") item2 = AccordionItem(title="Fixture") item3 = AccordionItem(title="Premios") conn = mysql.connector.connect(host="167.250.49.138", user="******", passwd="civ6525639", port="3306", database="laliga") cursor = conn.cursor() q = "SELECT Reglas, Premio FROM torneos WHERE ID=" cursor.execute(q + self.data_id) for x in cursor: print(x) item1.add_widget( Label(text=x[0], text_size=(300, None), valign="top")) item2.add_widget(Label(text='%s' % x[0], text_size=(300, None))) item3.add_widget( Label(text=x[1], text_size=(300, None), halign="center", valign="top")) root.add_widget(item1) root.add_widget(item2) root.add_widget(item3) self.ids.container2.add_widget(root) conn.close()
def build(self): root = BoxLayout(orientation='vertical') self.accordion = Accordion(orientation='vertical') root.add_widget(self.accordion) self.add_rule() return root
return (timedelta(days=index) + unixepoch).astimezone(self.tz) def index_of(self, dt): '''return a global index corresponding to a datetime. ''' secs = (dt - unixepoch).total_seconds() global_idx = secs / TimeTick.scale_factor_dict['second'] return global_idx def pos_of_time(self, time): return self.index2pos(self.index_of(time)) def timedelta2dist(self, td): return td.days * self.scale def center_on_timeframe(self, start, end): self.index_0 = self.index_of(start) self.index_1 = self.index_of(end) if __name__ == '__main__': acc = Accordion(orientation='vertical') simple = AccordionItem(title='simple') simple.add_widget(Timeline()) complex_ = AccordionItem(title='complex') complex_.add_widget( Timeline(backward=True, orientation='horizontal', ticks=selected_time_ticks() + [TimeTick(valign='top', mode='12 hours'), TimeTick(valign='line_bottom', mode='2 hours')], line_offset=dp(130) )) acc.add_widget(simple) acc.add_widget(complex_) runTouchApp(acc)
class SelectionScreen(Screen): def __init__(self, **kwargs): super(SelectionScreen, self).__init__(**kwargs) global Combatants self.root = Accordion() charItem = AccordionItem(title='Characters') self.root.add_widget(charItem) enItem = AccordionItem(title='Enemies') self.root.add_widget(enItem) confirmItem = AccordionItem(title='Done') self.root.add_widget(confirmItem) self.CharButtons = [] self.EnemyButtons = [] self.enemyIter = 0 self.quantity = 0 self.content = TextInput(text='1', multiline=False) self.content.bind(on_text_validate=self.setQuantity) i = 0 while i < Combatants.getNumChars(): btn = ToggleButton(text=Combatants.getCharName(i)) charItem.add_widget(btn) self.CharButtons.append(btn) i = i+ 1 i = 0 while i < Combatants.getNumEn(): btn = ToggleButton(text=Combatants.getEnName(i)) enItem.add_widget(btn) self.EnemyButtons.append(btn) i = i + 1 B = Button(text='Go!') B.bind(on_press=self.showCombatants) confirmItem.add_widget(B) self.add_widget(self.root) def showCombatants(self, obj): i = 0 NoEnemies = True for c in self.CharButtons: if c.state == 'down': Combatants.add(i, True) i += 1 i = 0 for e in self.EnemyButtons: if e.state == 'down': labStr = "How many " + e.text + "?" NoEnemies = False self.popup = Popup(title=labStr, content=self.content) self.popup.open() self.enemyIter = i i += 1 if NoEnemies == True: self.beginBattle() def setQuantity(self, instance): self.quantity = self.content.text j = 0 while j < int(self.quantity): Combatants.add(self.enemyIter, False) j += 1 if int(self.quantity) > 1: Combatants.getLast().name = Combatants.getLast().name + " " + str(j) self.popup.dismiss() self.beginBattle() def beginBattle(self): if isDM == True: Combatants.isWaiting = False BS = BattleScreen(name="Battle Screen") sm.add_widget(BS) Screens.append(BS) self.manager.current = 'Battle Screen' else: WS = WaitScreen(name="Wait Screen") sm.add_widget(WS) self.manager.current = 'Wait Screen'
def __init__(self, **kvargs): super(PageSendMail, self).__init__(**kvargs) self.orientation = "vertical" self.add_widget(Label(text=self.message_to, markup=True, size_hint=(1, .1))) accordion = Accordion(orientation="vertical") # Панель смайлов. self.smiles = \ AccordionItem(title=self.accordion_panel_smiles_title, background_selected=self.background_selected, background_normal=self.background_normal) smiles_box = StackLayout() if os.path.exists(self.path_to_folder_images_smiles): for name_image in os.listdir(self.path_to_folder_images_smiles): smile = \ ImageButton( source="{}/{}".format( self.path_to_folder_images_smiles, name_image), id=":{}:".format(name_image.split(".")[0]), size_hint=(.09, .12)) smile.bind(on_press=self.events_callback) smiles_box.add_widget(smile) self.smiles.add_widget(smiles_box) accordion.add_widget(self.smiles) # Панель форматирования и поле ввода. text = AccordionItem(title=self.accordion_panel_text_title, background_selected=self.background_selected, background_normal=self.background_normal) content = BoxLayout(orientation="vertical") # TODO: Слишком маленькие иконки на панели форматирования текста. # Сделать иконки в два ряда. if platform == "android": size_hint = (1, .12) else: size_hint = (1, .06) formats_panel = BoxLayout(size_hint=size_hint) # Иконки форматирования. for name_image in self.list_images_for_format_text: format_button = \ ImageButton(id=os.path.split(name_image)[1].split(".")[0], source=name_image) format_button.bind(on_press=self.events_callback) formats_panel.add_widget(format_button) self.text_input = TextInput(hint_text=self.hint_text, size_hint=(1, .4), auto_indent=True) if self.default_text != "": self.text_input.text = self.default_text content.add_widget(formats_panel) content.add_widget(self.text_input) text.add_widget(content) accordion.add_widget(text) # Подписи и чекбоксы. message_to = GridLayout(cols=2, size_hint=(1, .22), spacing=5) if self.forum == "mail": message_to.add_widget(Label(text=self.label_priority, markup=True)) message_to.add_widget(Widget()) message_to.add_widget(Label(text=self.priority_low)) self.low_check = \ CheckBox(background_radio_down=self.background_radio_down, background_radio_normal=self.background_radio_normal, id="low", group="priority") self.low_check.bind(active=self.events_callback) message_to.add_widget(self.low_check) message_to.add_widget(Label(text=self.priority_normal)) self.normal_check = \ CheckBox(background_radio_down=self.background_radio_down, background_radio_normal=self.background_radio_normal, active=True, id="normal", group="priority") self.normal_check.bind(active=self.events_callback) message_to.add_widget(self.normal_check) message_to.add_widget(Label(text=self.priority_tall)) self.tall_check = \ CheckBox(background_radio_down=self.background_radio_down, background_radio_normal=self.background_radio_normal, id="tall", group="priority") self.tall_check.bind(active=self.events_callback) message_to.add_widget(self.tall_check) additional = GridLayout(cols=2, size_hint=(1, .22), spacing=5) if self.forum == "mail": additional.add_widget(Label(text=self.label_report, markup=True)) additional.add_widget(Widget()) additional.add_widget(Label(text=self.save_in_sent)) self.save_in_sent_check = \ CheckBox( background_checkbox_down=self.background_checkbox_down, background_checkbox_normal=self.background_checkbox_normal, active=True, id="save in sent") self.save_in_sent_check.bind(active=self.events_callback) additional.add_widget(self.save_in_sent_check) additional.add_widget(Label(text=self.read_report)) self.read_report_check = \ CheckBox( background_checkbox_down=self.background_checkbox_down, background_checkbox_normal=self.background_checkbox_normal, id="read report") self.read_report_check.bind(active=self.events_callback) additional.add_widget(self.read_report_check) self.add_files_label = Label(text=self.add_files) additional.add_widget(self.add_files_label) self.add_files_check = \ CheckBox( background_checkbox_down=self.background_checkbox_down, background_checkbox_normal=self.background_checkbox_normal, id="add files",) self.add_files_check.bind(active=self.events_callback) additional.add_widget(self.add_files_check) # Кнопки выбора. button_panel = BoxLayout(size_hint=(1, .15)) for name_button in [self.text_button_ok, self.text_button_cancel]: select_button = Button(text=name_button, size_hint=(1, 1), id=name_button) select_button.bind(on_press=self.events_callback) button_panel.add_widget(select_button) self.add_widget(accordion) self.add_widget(Widget(size_hint=(None, .02))) if self.forum == "mail": self.add_widget(message_to) self.add_widget(Widget(size_hint=(None, .02))) self.add_widget(SettingSpacer()) self.add_widget(additional) self.add_widget(Widget(size_hint=(None, .02))) self.add_widget(SettingSpacer()) self.add_widget(Widget(size_hint=(None, .02))) self.add_widget(button_panel) self.body = Popup(title=self.title, content=self, size_hint=(.9, .99), background=self.background_image) self.body.open()
def __init__(self, url, classes): super(IspApp, self).__init__() self.url = url self.accordion = Accordion() self.pnlCalendar = CalendarPanel(classes)
from kivy.base import runTouchApp from kivy.uix.accordion import Accordion from kivy.factory import Factory Builder.load_string(""" <Bucket@AccordionItem>: AnchorLayout: id: the_table canvas.before: Color: rgba: 0, 0, 0, 1 Rectangle: pos: self.pos size: self.size """) acc = Accordion() staticpage = Factory.Bucket(title='Static') header1 = ['Col'+str(x+1) for x in xrange(5)] staticpage.ids.the_table.add_widget(DataTable(name='static', data=data, header_column='Col1', header_row=header1)) editpage = Factory.Bucket(title='Editable') header2 = ['Col'+str(5-x) for x in xrange(5)] editpage.ids.the_table.add_widget(DataTable(name='edit', data=data, header_column='Col5', header_row=header2, editable=True)) acc.add_widget(staticpage) acc.add_widget(editpage)
global_idx = secs / TimeTick.scale_factor_dict['second'] return global_idx def pos_of_time(self, time): return self.index2pos(self.index_of(time)) def timedelta2dist(self, td): return td.days * self.scale def center_on_timeframe(self, start, end): self.index_0 = self.index_of(start) self.index_1 = self.index_of(end) if __name__ == '__main__': acc = Accordion(orientation='vertical') simple = AccordionItem(title='simple') simple.add_widget(Timeline()) complex_ = AccordionItem(title='complex') complex_.add_widget( Timeline(backward=True, orientation='horizontal', ticks=selected_time_ticks() + [ TimeTick(valign='top', mode='12 hours'), TimeTick(valign='line_bottom', mode='2 hours') ], line_offset=dp(130))) acc.add_widget(simple) acc.add_widget(complex_) runTouchApp(acc)
def main_menu(): #Window.fullscreen=True Window.clearcolor=(1,140.0/255,15.0/255,0) Menu=BoxLayout(orientation='vertical') title = Label( text='Trages', markup=True, bold=True, color=(79.0/255,15.0/255,204.0/255,0), font_name='RAVIE.ttf', font_size='100dp', y=Window.height/2-25, x=-Window.width/2+100, size_hint=(1,0.3) ) Menu.add_widget(title) root=Accordion(orientation='vertical') ButtonChildren=Button(text='Press here for children education',size_hint=(1,0.3)) ButtonChildren.bind(on_press=go_children) s1='This version of software\n is a new method of \nteaching children.\n It allows one to make \nlearning process \nmore interactive and \nsimple due to gaming form.' LabelChildren=Label(text=s1, font_name='RAVIE.ttf',font_size='20dp',max_lines=4,shorten=True,color=(113.0/255,17.0/255,150.0/255,1)) BoxLayoutChildren=BoxLayout(orientation='horizontal') BoxLayoutChildren2=BoxLayout(orientation='vertical') BoxLayoutChildren2.add_widget(LabelChildren) BoxLayoutChildren2.add_widget(ButtonChildren) ImageChildren=Image(source='childeduc.bmp') BoxLayoutChildren.add_widget(ImageChildren) BoxLayoutChildren.add_widget(BoxLayoutChildren2) children=AccordionItem(title='Children Education') children.add_widget(BoxLayoutChildren) ### ButtonGame=Button(text='Press here for testing',size_hint=(1,.3)) ButtonGame.bind(on_press=go_game) s2='This version of software\n is a new method of \ntesting children.\n It allows one to make \ntesting process \nmore interactive and \nsimple due to gaming form.' LabelGame=Label(text=s2, font_name='RAVIE.ttf',font_size='20dp',max_lines=4,shorten=True,color=(113.0/255,17.0/255,150.0/255,1)) BoxLayoutGame=BoxLayout(orientation='horizontal') BoxLayoutGame2=BoxLayout(orientation='vertical') BoxLayoutGame2.add_widget(LabelGame) BoxLayoutGame2.add_widget(ButtonGame) ImageGame=Image(source='forgame.bmp') BoxLayoutGame.add_widget(ImageGame) BoxLayoutGame.add_widget(BoxLayoutGame2) game=AccordionItem(title='Game!') game.add_widget(BoxLayoutGame) ### BoxLayoutInfo=BoxLayout(orientation='horizontal') ImageInfo=Image(source='command.jpg') BoxLayoutInfo.add_widget(ImageInfo) LabelInfo=Label(text='We are command from \nN.Novgorod,Russia.\nWe are Max and Anna.\nWe want to help \ndeaf-mute people,\nso we created\n this application.',font_size='25dp',font_name='RAVIE.ttf',color=(113.0/255,17.0/255,150.0/255,1)) BoxLayoutInfo.add_widget(LabelInfo) info=AccordionItem(title='About us') info.add_widget(BoxLayoutInfo) ButtonExit=Button(text='Exit') ButtonExit.bind(on_press=go_exit) ButtonExit.size_hint=(1,.1) #rexit=AccordionItem(title='Exit') #rexit.add_widget(ButtonExit) root.add_widget(children) root.add_widget(game) root.add_widget(info) #root.add_widget(rexit) root.current=children Menu.add_widget(root) Menu.add_widget(ButtonExit) return Menu
def __init__(self, **kvargs): super(UploadFiles, self).__init__(**kvargs) self.__data = { "zip": False, # упаковывать ли файл в zip "name": "", # имя файла "version": "", # версия файла "description": "", # описание файла "file": "", # путь к файлу "screenshot": "" # путь к изображению скриншота } self.cols = 1 self.spacing = 17 self.label_form = Label(text=self.title_step, font_size=20, size_hint=(1, .05), markup=True) accordion = Accordion(orientation="vertical") # --------------------STEP-ONE---------------------- self.step_one = \ AccordionItem(title=self.panel_step_one_text, background_selected=self.background_selected, background_normal=self.background_normal) scroll_view_one = ScrollView() sections = GridLayout(cols=1, spacing=17, size_hint_y=None) sections.bind(minimum_height=sections.setter("height")) sections.add_widget(SettingSpacer()) for section_name in self.sections_files.keys(): sections.add_widget( Label(text="[color=#2fbfe0][ref={section_name}]{section_name}" "[/ref][/color]".format(section_name=section_name), on_ref_press=self.event_callback, markup=True)) sections.add_widget(SettingSpacer()) scroll_view_one.add_widget(sections) self.step_one.add_widget(RstDocument(text=self.text_terms)) self.step_one.add_widget(scroll_view_one) # --------------------STEP-TWO---------------------- self.step_two = \ AccordionItem(title=self.panel_step_two_text, background_selected=self.background_selected, background_normal=self.background_normal) self.scroll_view_two = ScrollView() self.sub_sections = GridLayout(cols=1, spacing=17, size_hint_y=None) self.sub_sections.bind( minimum_height=self.sub_sections.setter("height")) self.sub_sections.add_widget(SettingSpacer()) self.step_two.disabled = True # --------------------STEP-THREE---------------------- self.step_three = \ AccordionItem(title=self.panel_step_three_text, background_selected=self.background_selected, background_normal=self.background_normal) self.scroll_view_three = ScrollView() self.select_file = GridLayout(cols=1, spacing=17, size_hint_y=None) self.select_file.bind(minimum_height=self.select_file.setter("height")) self.select_file.add_widget(SettingSpacer()) self.step_three.disabled = True # ---------------------------------------------------- accordion.add_widget(self.step_one) accordion.add_widget(self.step_two) accordion.add_widget(self.step_three) self.add_widget(self.label_form) self.add_widget(accordion) self.body = Popup(title=self.title, content=self, size_hint=(.9, .99), background=self.background_image) self.body.open() # Открываем панель "Шаг Первый". self.step_one.collapse = False
def main_menu(): #Window.fullscreen=True Window.clearcolor = (1, 140.0 / 255, 15.0 / 255, 0) Menu = BoxLayout(orientation='vertical') title = Label(text='Trages', markup=True, bold=True, color=(79.0 / 255, 15.0 / 255, 204.0 / 255, 0), font_name='RAVIE.ttf', font_size='100dp', y=Window.height / 2 - 25, x=-Window.width / 2 + 100, size_hint=(1, 0.3)) Menu.add_widget(title) root = Accordion(orientation='vertical') ButtonChildren = Button(text='Press here for children education', size_hint=(1, 0.3)) ButtonChildren.bind(on_press=go_children) s1 = 'This version of software\n is a new method of \nteaching children.\n It allows one to make \nlearning process \nmore interactive and \nsimple due to gaming form.' LabelChildren = Label(text=s1, font_name='RAVIE.ttf', font_size='20dp', max_lines=4, shorten=True, color=(113.0 / 255, 17.0 / 255, 150.0 / 255, 1)) BoxLayoutChildren = BoxLayout(orientation='horizontal') BoxLayoutChildren2 = BoxLayout(orientation='vertical') BoxLayoutChildren2.add_widget(LabelChildren) BoxLayoutChildren2.add_widget(ButtonChildren) ImageChildren = Image(source='childeduc.bmp') BoxLayoutChildren.add_widget(ImageChildren) BoxLayoutChildren.add_widget(BoxLayoutChildren2) children = AccordionItem(title='Children Education') children.add_widget(BoxLayoutChildren) ### ButtonGame = Button(text='Press here for testing', size_hint=(1, .3)) ButtonGame.bind(on_press=go_game) s2 = 'This version of software\n is a new method of \ntesting children.\n It allows one to make \ntesting process \nmore interactive and \nsimple due to gaming form.' LabelGame = Label(text=s2, font_name='RAVIE.ttf', font_size='20dp', max_lines=4, shorten=True, color=(113.0 / 255, 17.0 / 255, 150.0 / 255, 1)) BoxLayoutGame = BoxLayout(orientation='horizontal') BoxLayoutGame2 = BoxLayout(orientation='vertical') BoxLayoutGame2.add_widget(LabelGame) BoxLayoutGame2.add_widget(ButtonGame) ImageGame = Image(source='forgame.bmp') BoxLayoutGame.add_widget(ImageGame) BoxLayoutGame.add_widget(BoxLayoutGame2) game = AccordionItem(title='Game!') game.add_widget(BoxLayoutGame) ### BoxLayoutInfo = BoxLayout(orientation='horizontal') ImageInfo = Image(source='command.jpg') BoxLayoutInfo.add_widget(ImageInfo) LabelInfo = Label( text= 'We are command from \nN.Novgorod,Russia.\nWe are Max and Anna.\nWe want to help \ndeaf-mute people,\nso we created\n this application.', font_size='25dp', font_name='RAVIE.ttf', color=(113.0 / 255, 17.0 / 255, 150.0 / 255, 1)) BoxLayoutInfo.add_widget(LabelInfo) info = AccordionItem(title='About us') info.add_widget(BoxLayoutInfo) ButtonExit = Button(text='Exit') ButtonExit.bind(on_press=go_exit) ButtonExit.size_hint = (1, .1) #rexit=AccordionItem(title='Exit') #rexit.add_widget(ButtonExit) root.add_widget(children) root.add_widget(game) root.add_widget(info) #root.add_widget(rexit) root.current = children Menu.add_widget(root) Menu.add_widget(ButtonExit) return Menu
def __init__(self, **kwargs): super(ViewQuestion, self).__init__(**kwargs) self.accordion = Accordion(orientation='vertical') self.get_question()
class bippyApp(App): """ Main Application Class required for Kivy """ def getCur(self, instance, value=False): """ From the currency longName returned by the UI return the Abbreviation understood by the rest of the application """ if value == '----------Currencies below are not currently available at woodwallets.io----------': instance.text = self.selectedCurrencyLongName return for cur in currencies: if cur['longName'] == value: self.selectedCurrency = str(cur['currency']) self.selectedCurrencyLongName = str(cur['longName']) return def checkPrivK(self, instance, value=False): """ Perform various checks on the private key data and act accordingly This is called whenever the Private Key entry box looses focus """ if value: return testKey = instance.text self.PasswordEnter.text = '' self.entropyImage.unbind(on_touch_move=self.draw) self.prog.value = 0 self.entropyImage.canvas.remove_group('ellipses') #Test if it is an electrum seed if key.isElectrumSeed(testKey): self.MainLabel.text = 'It looks like you entered an Electrum seed.\n\nEnter a Passphrase to encrypt it.' self.PrivKLabel.text = 'Electrum Seed' self.PassLabel.text = 'Enter\nPassphrase' return #Test if it is an encrypted electrum Seed if key.isEncElectrumSeed(testKey): self.MainLabel.text = 'It looks like you\'ve entered an encrypted Electrum Seed.\n\nEnter your Passphrase to decrypt it.' self.PrivKLabel.text = 'Encrypted\nElectrum Seed' self.PassLabel.text = 'Enter Passphrase' return #Test if its a BIP encrypted Key if key.isBip(testKey, self.selectedCurrency): self.MainLabel.text = 'It looks like you entered a BIP0038 encrypted Private Key.\n\nEnter your Passphrase to decrypt it.' self.PrivKLabel.text = 'Encrypted Key' self.PassLabel.text = 'Encryption\nPassphrase' return #Test if it's a Private key if key.isWif(testKey, self.selectedCurrency) or key.isHex(testKey) or key.isBase64(testKey) or key.isBase6(testKey): self.MainLabel.text = 'You\'ve entered a Private Key.\n\nEnter a Passphrase to encrypt it.' self.PrivKLabel.text = 'Private Key' self.PassLabel.text = 'Enter\nPassphrase' return #reset to standard if the box is empty if testKey == '': self.MainLabel.text = '[b]Welcome to bippy[/b]\n\nTo get started choose a currency and enter an encryption passphrase.\n\nIf you already have a private key you would like to encrypt or decrypt,\n\nenter it in the \'Private Key\' box below' self.PrivKLabel.text = 'Private Key\n(optional)' self.PassLabel.text = 'Passphrase' return #otherwise let the user know that they haven't entered a recognised Private Key self.MainLabel.text = 'bippy can\'t recognise what you entered as a private key.\n\nAcceptable formats are:\nCompressed WIF, HEX, Base64, Base6, BIP Encrypted' self.PrivKLabel.text = 'Private Key\n(optional)' self.PassLabel.text = 'Passphrase' return def checkPassword(self, instance, value=False): """ This is called whenever the password field looses focus perform checks and validation on the password field and initiate encryption/decryption if data is correct """ if value: return self.Password = instance.text if gen.verifyPassword(self.Password) is False: self.MainLabel.text = 'Passphrases must be 7 characters or longer' self.entropyImage.unbind(on_touch_move=self.draw) self.prog.value = 0 self.entropyImage.canvas.remove_group('ellipses') return #need to have some sort of password length and complexity check here self.PrivateKey = self.PrivK.text #it could be a BIP key in which case we show the Decrypt button if key.isBip(self.PrivateKey, self.selectedCurrency): self.MainLabel.text = 'Hit the \'Decrypt\' button to start the decryption.' self.rightBox.remove_widget(self.prog) self.rightBox.add_widget(self.decButton) return #It could be an Electrum Seed in which case we show the Electrum encrypt button if key.isElectrumSeed(self.PrivateKey): self.MainLabel.text = 'Hit the \'Encrypt\' button to start the encryption of your Electrum Seed' self.rightBox.remove_widget(self.prog) self.rightBox.add_widget(self.encElectrumButton) return #It could be an encrypted Electrum seed in which case weshow the Electrum Decrypt button if key.isEncElectrumSeed(self.PrivateKey): self.MainLabel.text = 'Hit the \'Decrypt\' button to decrypt your Electrum Seed' self.rightBox.remove_widget(self.prog) self.rightBox.add_widget(self.decElectrumButton) return #otherwise check that the entry isn't a WIF, HEX B64 or B6 key #if there is no valid privatekey we ask for entropy to be entered #This then generates a new key pair if not key.isWif(self.PrivateKey, self.selectedCurrency) and not key.isHex(self.PrivateKey) and not key.isBase64(self.PrivateKey) and not key.isBase6(self.PrivateKey): self.PrivK.text = '' self.PrivateKey = None self.MainLabel.text = 'To generate a BIP0038 encrypted key you need to generate some randomness.\n\nHold your left mouse button down and move it about on the image to the right to do this and fill up the bar.' self.entropy = [] self.entropyImage.bind(on_touch_move=self.draw) return #otherwise there is a user supplied private key so we offer to generate a BIP key self.MainLabel.text = 'Hit the \'Encrypt\' button to start the encryption of your private key' self.rightBox.remove_widget(self.prog) self.rightBox.add_widget(self.encButton) return def draw(self, instance, value): """ This function is enabled when only a password has been entered. It allows the user to draw on the image shown to the right of the UI This is the method by which entropy is gathered for generation of key pairs """ with self.entropyImage.canvas: Color(0, 0.86667, 1) d = 5. if self.entropyImage.collide_point(value.x, value.y): Ellipse(pos=(value.x - d / 2, value.y - d / 2), size=(d, d), group='ellipses') self.entropy.append((int(value.x),int(value.y))) self.prog.value += 1 if self.prog.value == 550: self.entropyImage.unbind(on_touch_move=self.draw) self.prog.value = 0 self.entropyImage.canvas.remove_group('ellipses') #got everything we need. replace the progress bar with a generate button self.rightBox.remove_widget(self.prog) self.rightBox.add_widget(self.encButton) self.MainLabel.text='You have generated enough Randomness.\n\nHit the \'Encrypt\' button to start the encryption.\n\n(bippy may become unresponsive for ~10 seconds while encryption takes place)' return def generateBIP(self, instance, value=False): """ Generate the BIP Private Key """ self.MainLabel.text='Starting BIP0038 Encryption' #use clock to delay the start of the encryption otherwise the message above is never shown Clock.schedule_once(self.genBIP, 0.5) return def genBIP(self, dt): """ This is the second part of the generate BIP method. It's split into two like this as otherwise the UI doesn't update to show that encryption has started """ if self.PrivateKey is None: BIP, Address = gen.genBIPKey(self.selectedCurrency, self.Password, self.entropy) else: BIP, Address = gen.encBIPKey(self.PrivateKey, self.selectedCurrency, self.Password) self.setBIP(BIP, Address) return def decryptBIP(self, instance, value=False): """ Decrypt the BIP key """ self.MainLabel.text='Starting BIP0038 Decryption' #use clock to delay the start of the encryption otherwise the message above is never shown Clock.schedule_once(self.decBIP, 0.5) return def decBIP(self, dt): """ Second part of the decryption routine to allow UI to update """ PrivateKey, PublicAddress = gen.decBIPKey(self.PrivateKey, self.Password, self.selectedCurrency) if PrivateKey is False: self.MainLabel.text = 'BIP0038 Decryption was unsuccessful.\n\nAre you sure the passphrase was correct?' self.rightBox.remove_widget(self.prog) self.rightBox.remove_widget(self.decButton) self.rightBox.add_widget(self.resetButton) return self.MainLabel.text = 'BIP0038 Decryption was successful.\n\nSee below for your private key and address.' self.PrivKLabel.text = 'Decrypted\nPrivate Key' self.PassLabel.text = 'Address' self.PasswordEnter.password = False self.PrivK.text = PrivateKey self.PasswordEnter.text = PublicAddress #unbind the private key and password entry boxes so that the user can copy out the key and address self.PrivK.unbind(focus=self.checkPrivK) self.PasswordEnter.unbind(focus=self.checkPassword) self.rightBox.remove_widget(self.prog) self.rightBox.remove_widget(self.decButton) self.rightBox.add_widget(self.resetButton) return def setBIP(self, BIP, Address): """ This method updates the UI with the output of encryption """ #re-shuffle the visible widgets so that the links become available self.leftBox.remove_widget(self.MainLabel) self.leftBox.remove_widget(self.entryPane) self.leftBox.add_widget(self.LinksTab) self.leftBox.add_widget(self.entryPane) self.PrivKLabel.text = 'BIP0038 Key' self.PassLabel.text = 'Address' self.DoubleLink.text = 'https://woodwallets.io/product/woodwallet-private-key-and-public-address?dbl_addr=' + Address + '&dbl_pvtkey=' + BIP + '&dbl_coin=' + self.selectedCurrency + '&orig=bippy' self.PrivateLink.text = 'https://woodwallets.io/product/one-side-private-key-only?pvt_pvtkey=' + BIP + '&pvt_coin=' + self.selectedCurrency + '&orig=bippy' self.PublicLink.text = 'https://woodwallets.io/product/woodwallet-public-address?pub_addr=' + Address + '&pub_coin=' + self.selectedCurrency + '&orig=bippy' self.PasswordEnter.password = False self.PrivK.text = BIP self.PasswordEnter.text = Address #unbind the private key and password enty boxes so that the user can copy out the key and address self.PrivK.unbind(focus=self.checkPrivK) self.PasswordEnter.unbind(focus=self.checkPassword) self.rightBox.remove_widget(self.prog) self.rightBox.remove_widget(self.encButton) self.rightBox.add_widget(self.resetButton) return def resetUI(self, instance, value=False): """ This is called when the reset button is pressed. The UI is restored to its initial state """ self.leftBox.remove_widget(self.LinksTab) self.leftBox.remove_widget(self.MainLabel) self.leftBox.remove_widget(self.entryPane) self.leftBox.add_widget(self.MainLabel) self.leftBox.add_widget(self.entryPane) self.MainLabel.text='[b]Welcome to bippy[/b]\n\nTo get started choose a currency and enter an encryption passphrase.\n\nIf you already have a private key you would like to encrypt or decrypt,\n\nenter it in the \'Private Key\' box below' self.PrivKLabel.text='Private Key\n(optional)' self.PrivK.text = '' self.PassLabel.text='Passphrase' self.PasswordEnter.password = True self.PasswordEnter.text = '' #rebind the private key and password entry boxes self.PrivK.bind(focus=self.checkPrivK) self.PasswordEnter.bind(focus=self.checkPassword) self.rightBox.remove_widget(self.resetButton) self.rightBox.remove_widget(self.encButton) self.rightBox.remove_widget(self.decButton) self.rightBox.add_widget(self.prog) return def encryptElectrum(self, instance, value=False): """ Encrypt the Electrum Seed """ self.MainLabel.text='Starting Encryption of Electrum Seed' #use clock to delay the start of the encryption otherwise the message above is never shown self.PrivK.text = '' Clock.schedule_once(self.encElectrum, 0.5) return def encElectrum(self, dt): """ Begin encryption of the supplied Electrum Seed """ encryptedSeed = electrum.encrypt(self.PrivateKey, self.Password) self.MainLabel.text = 'Encryption was successful.\n\nSee below for your encrypted seed' self.PrivKLabel.text = 'Encrypted\nElectrum Seed' self.PassLabel.text = '' self.PrivK.text = encryptedSeed self.PasswordEnter.text = '' #unbind the private key and password entry boxes so that the user can copy out the key and address self.PrivK.unbind(focus=self.checkPrivK) self.PasswordEnter.unbind(focus=self.checkPassword) self.rightBox.remove_widget(self.prog) self.rightBox.remove_widget(self.encElectrumButton) self.rightBox.add_widget(self.resetButton) return def decryptElectrum(self, instance, value=False): """ Start the decryption of the Electrum Seed """ self.MainLabel.text='Starting the Decryption of your Electrum seed' #use clock to delay the start of the decryption otherwise the message above is never shown self.PrivK.text = '' self.PasswordEnter.text = '' Clock.schedule_once(self.decElectrum, 0.5) return def decElectrum(self, dt): """ Perform the actual decryption of the Electrum Seed """ decryptedSeed = electrum.decrypt(self.PrivateKey, self.Password) if decryptedSeed is False: self.MainLabel.text = 'Decryption was not successful.\n\nAre you sure you entered the correct passphrase?\n\nReset to try again' self.rightBox.remove_widget(self.prog) self.rightBox.remove_widget(self.decElectrumButton) self.rightBox.add_widget(self.resetButton) return self.MainLabel.text = 'Decryption was successful.\n\nSee below for your Electrum Seed.' self.PrivKLabel.text = 'Decrypted\nElectrum Seed' self.PassLabel.text = '' self.PasswordEnter.password = False self.PrivK.text = decryptedSeed self.PasswordEnter.text = '' #unbind the private key and password entry boxes so that the user can copy out the key and address self.PrivK.unbind(focus=self.checkPrivK) self.PasswordEnter.unbind(focus=self.checkPassword) self.rightBox.remove_widget(self.prog) self.rightBox.remove_widget(self.decElectrumButton) self.rightBox.add_widget(self.resetButton) return def build(self): """ Build the UI """ #root layout is a horizontal box layout self.root = BoxLayout(spacing=10, padding=[5,5,5,5]) #the right box has another BoxLayout. self.rightBox = BoxLayout(orientation='vertical', size_hint=(.25, 1)) #the image goes in the top part self.entropyImage = AsyncImage(source='woodFORbippy.png', size_hint=(1, .9), allow_stretch=True, keep_ratio=True) self.rightBox.add_widget(self.entropyImage) #the progress bar in the bottom self.prog = ProgressBar(max=550, size_hint=(.9,.1), pos_hint={'right':.95}) self.rightBox.add_widget(self.prog) #the encrypt button. #this isn't added to the UI until Entropy has been collected #the first version is for BIP 38 keys. The second is for Electrum Seeds self.encButton = Button(text='Encrypt', size_hint=(.9,.1), pos_hint={'right':.95}) self.encButton.bind(on_press=self.generateBIP) self.encElectrumButton = Button(text='Encrypt', size_hint=(.9,.1), pos_hint={'right':.95}) self.encElectrumButton.bind(on_press=self.encryptElectrum) #the decrypt button. #this isn't added to the UI until decryption possibilities have been noticed self.decButton = Button(text='Decrypt', size_hint=(.9,.1), pos_hint={'right':.95}) self.decButton.bind(on_press=self.decryptBIP) self.decElectrumButton = Button(text='Decrypt', size_hint=(.9,.1), pos_hint={'right':.95}) self.decElectrumButton.bind(on_press=self.decryptElectrum) #the reset button. #this isn't added to the UI until Encryption has taken place self.resetButton = Button(text='Reset', size_hint=(.9,.1), pos_hint={'right':.95}) self.resetButton.bind(on_press=self.resetUI) #within the left hand box we split into a vertical box layout self.leftBox = BoxLayout(orientation='vertical', size_hint=(.7,1)) #the top of the left hand box is a label self.MainLabel = Label(text_size=(720,150), font_size=15, shorten=True, halign='center', valign='middle', markup=True, text='[b]Welcome to bippy[/b]\n\nTo get started choose a currency and enter an encryption passphrase.\n\nIf you already have a private key you would like to encrypt or decrypt,\n\nenter it in the \'Private Key\' box below', size_hint=(1, .4)) self.leftBox.add_widget(self.MainLabel) #for displaying the links we have an accordion layout #build it here even though it is only attached after encryption has taken place self.LinksTab = Accordion(size_hint=(1, .4)) self.Links = AccordionItem(title='Links', ) self.LinksGrid = GridLayout(cols=2, padding=(10, 10, 10, 10), spacing=(10, 20)) self.LinksGrid.add_widget(Label(text='Double Sided', font_size=11, size_hint=(.3,1), text_size=(100,50), halign='center', valign='middle')) self.DoubleLink = TextInput(multiline=False, size_hint_y=None, height=30) self.LinksGrid.add_widget(self.DoubleLink) self.LinksGrid.add_widget(Label(text='Single Sided Private Key', font_size=11, size_hint=(.3,1), text_size=(100,50), halign='center', valign='middle')) self.PrivateLink = TextInput(multiline=False, size_hint_y=None, height=30) self.LinksGrid.add_widget(self.PrivateLink) self.LinksGrid.add_widget(Label(text='Single Sided Public Address', font_size=11, size_hint=(.3,1), text_size=(100,50), halign='center', valign='middle')) self.PublicLink = TextInput(multiline=False, size_hint_y=None, height=30) self.LinksGrid.add_widget(self.PublicLink) self.Links.add_widget(self.LinksGrid) self.Message = AccordionItem(title='Complete', ) self.MessageLabel = Label(halign='center', valign='middle', text='BIP0038 encryption is complete\n\nSee below for your encrypted private key and address\n\nSee the \'Links\' tab to the left for direct links to purchase Wood Wallets') self.Message.add_widget(self.MessageLabel) #add the two 'tabs' to the main accordion widget self.LinksTab.add_widget(self.Links) self.LinksTab.add_widget(self.Message) #the bottom of the left hand pane is a grid layout self.entryPane = GridLayout(cols=2, size_hint=(1, .6), padding=(10, 40, 10, 40), spacing=(10, 40)) #within this pane we have the Text Input boxes and labels #Currency self.entryPane.add_widget(Label(text='Currency', size_hint_x=None, width=100)) self.Currency = Spinner(text='Bitcoin', values=currencyLongNamesList, size_hint_x=None, size_hint_y=None, height=40, width=50) self.Currency.bind(text=self.getCur) self.selectedCurrency = 'BTC' self.selectedCurrencyLongName = 'Bitcoin' self.entryPane.add_widget(self.Currency) #Private Key self.PrivKLabel = Label(text='Private Key\n(optional)', size_hint_x=None, width=100) self.entryPane.add_widget(self.PrivKLabel) self.PrivK = TextInput(size_hint_y=None, height=30, multiline=False) self.PrivK.bind(focus=self.checkPrivK) self.entryPane.add_widget(self.PrivK) #Password self.PassLabel = Label(text='Passphrase', size_hint_x=None, width=100) self.entryPane.add_widget(self.PassLabel) self.PasswordEnter = TextInput(size_hint_y=None, height=30, multiline=False, password=True) self.PasswordEnter.bind(focus=self.checkPassword) self.entryPane.add_widget(self.PasswordEnter) #add the entry pane to the left box self.leftBox.add_widget(self.entryPane) #add the left box to the root widget self.root.add_widget(self.leftBox) #add the rightbox to the root widget self.root.add_widget(self.rightBox) return self.root
def build(self): """ Build the UI """ #root layout is a horizontal box layout self.root = BoxLayout(spacing=10, padding=[5,5,5,5]) #the right box has another BoxLayout. self.rightBox = BoxLayout(orientation='vertical', size_hint=(.25, 1)) #the image goes in the top part self.entropyImage = AsyncImage(source='woodFORbippy.png', size_hint=(1, .9), allow_stretch=True, keep_ratio=True) self.rightBox.add_widget(self.entropyImage) #the progress bar in the bottom self.prog = ProgressBar(max=550, size_hint=(.9,.1), pos_hint={'right':.95}) self.rightBox.add_widget(self.prog) #the encrypt button. #this isn't added to the UI until Entropy has been collected #the first version is for BIP 38 keys. The second is for Electrum Seeds self.encButton = Button(text='Encrypt', size_hint=(.9,.1), pos_hint={'right':.95}) self.encButton.bind(on_press=self.generateBIP) self.encElectrumButton = Button(text='Encrypt', size_hint=(.9,.1), pos_hint={'right':.95}) self.encElectrumButton.bind(on_press=self.encryptElectrum) #the decrypt button. #this isn't added to the UI until decryption possibilities have been noticed self.decButton = Button(text='Decrypt', size_hint=(.9,.1), pos_hint={'right':.95}) self.decButton.bind(on_press=self.decryptBIP) self.decElectrumButton = Button(text='Decrypt', size_hint=(.9,.1), pos_hint={'right':.95}) self.decElectrumButton.bind(on_press=self.decryptElectrum) #the reset button. #this isn't added to the UI until Encryption has taken place self.resetButton = Button(text='Reset', size_hint=(.9,.1), pos_hint={'right':.95}) self.resetButton.bind(on_press=self.resetUI) #within the left hand box we split into a vertical box layout self.leftBox = BoxLayout(orientation='vertical', size_hint=(.7,1)) #the top of the left hand box is a label self.MainLabel = Label(text_size=(720,150), font_size=15, shorten=True, halign='center', valign='middle', markup=True, text='[b]Welcome to bippy[/b]\n\nTo get started choose a currency and enter an encryption passphrase.\n\nIf you already have a private key you would like to encrypt or decrypt,\n\nenter it in the \'Private Key\' box below', size_hint=(1, .4)) self.leftBox.add_widget(self.MainLabel) #for displaying the links we have an accordion layout #build it here even though it is only attached after encryption has taken place self.LinksTab = Accordion(size_hint=(1, .4)) self.Links = AccordionItem(title='Links', ) self.LinksGrid = GridLayout(cols=2, padding=(10, 10, 10, 10), spacing=(10, 20)) self.LinksGrid.add_widget(Label(text='Double Sided', font_size=11, size_hint=(.3,1), text_size=(100,50), halign='center', valign='middle')) self.DoubleLink = TextInput(multiline=False, size_hint_y=None, height=30) self.LinksGrid.add_widget(self.DoubleLink) self.LinksGrid.add_widget(Label(text='Single Sided Private Key', font_size=11, size_hint=(.3,1), text_size=(100,50), halign='center', valign='middle')) self.PrivateLink = TextInput(multiline=False, size_hint_y=None, height=30) self.LinksGrid.add_widget(self.PrivateLink) self.LinksGrid.add_widget(Label(text='Single Sided Public Address', font_size=11, size_hint=(.3,1), text_size=(100,50), halign='center', valign='middle')) self.PublicLink = TextInput(multiline=False, size_hint_y=None, height=30) self.LinksGrid.add_widget(self.PublicLink) self.Links.add_widget(self.LinksGrid) self.Message = AccordionItem(title='Complete', ) self.MessageLabel = Label(halign='center', valign='middle', text='BIP0038 encryption is complete\n\nSee below for your encrypted private key and address\n\nSee the \'Links\' tab to the left for direct links to purchase Wood Wallets') self.Message.add_widget(self.MessageLabel) #add the two 'tabs' to the main accordion widget self.LinksTab.add_widget(self.Links) self.LinksTab.add_widget(self.Message) #the bottom of the left hand pane is a grid layout self.entryPane = GridLayout(cols=2, size_hint=(1, .6), padding=(10, 40, 10, 40), spacing=(10, 40)) #within this pane we have the Text Input boxes and labels #Currency self.entryPane.add_widget(Label(text='Currency', size_hint_x=None, width=100)) self.Currency = Spinner(text='Bitcoin', values=currencyLongNamesList, size_hint_x=None, size_hint_y=None, height=40, width=50) self.Currency.bind(text=self.getCur) self.selectedCurrency = 'BTC' self.selectedCurrencyLongName = 'Bitcoin' self.entryPane.add_widget(self.Currency) #Private Key self.PrivKLabel = Label(text='Private Key\n(optional)', size_hint_x=None, width=100) self.entryPane.add_widget(self.PrivKLabel) self.PrivK = TextInput(size_hint_y=None, height=30, multiline=False) self.PrivK.bind(focus=self.checkPrivK) self.entryPane.add_widget(self.PrivK) #Password self.PassLabel = Label(text='Passphrase', size_hint_x=None, width=100) self.entryPane.add_widget(self.PassLabel) self.PasswordEnter = TextInput(size_hint_y=None, height=30, multiline=False, password=True) self.PasswordEnter.bind(focus=self.checkPassword) self.entryPane.add_widget(self.PasswordEnter) #add the entry pane to the left box self.leftBox.add_widget(self.entryPane) #add the left box to the root widget self.root.add_widget(self.leftBox) #add the rightbox to the root widget self.root.add_widget(self.rightBox) return self.root
class AbilityMenu(Screen): def __init__(self, **kwargs): super(AbilityMenu, self).__init__(**kwargs) self.root = Accordion(orientation='vertical') self.invItem = AccordionItem(title='Item') self.root.add_widget(self.invItem) self.targItem = AccordionItem(title='Target') self.root.add_widget(self.targItem) self.conItem = AccordionItem(title='Confirm') self.root.add_widget(self.conItem) B = Button(text='Confirm') B2 = Button(text='Cancel') B.bind(on_press=self.confirmTarget) B2.bind(on_press=self.cancel) self.conItem.add_widget(B) self.conItem.add_widget(B2) self.add_widget(self.root) def populateItems(self): self.ItemButtons = [] for item in Combatants.get(0).inventory: if item.quantity > 0: btn = ToggleButton(text=item.name, group='items') self.invItem.add_widget(btn) self.ItemButtons.append(btn) def populateTargs(self): self.ComButtons = [] for c in Combatants.retList(): btn = ToggleButton(text=c.name, group='targets') self.targItem.add_widget(btn) self.ComButtons.append(btn) def confirmTarget(self, obj): hasTarget = False hasItem = False itemNum = None i = 0 for a in self.ItemButtons: if a.state == 'down': hasItem = True itemNum = i i += 1 i = 0 for b in self.ComButtons: if b.state == 'down': hasTarget = True Screens[2].Target = Combatants.get(i) i += 1 if hasTarget == True and hasItem == True: hasTarget = False hasItem = False self.targItem.clear_widgets(children=self.ComButtons) self.ComButtons.clear() self.invItem.clear_widgets(children=self.ItemButtons) self.ItemButtons.clear() Combatants.get(0).abilitiesUsed = Combatants.get(0).abilitiesUsed + 1 Screens[2].AbilityButton.disabled = True self.manager.current = 'Battle Screen' Screens[2].UseItem(itemNum) def cancel(self, obj): self.targItem.clear_widgets(children=self.ComButtons) self.ComButtons.clear() self.invItem.clear_widgets(children=self.ItemButtons) self.ItemButtons.clear() self.manager.current = 'Battle Screen'