def makeLocalServiceEditPage(self): screen = Screen(name='EditLocalService') self.servicesScreen = screen layout = BoxLayout(orientation='vertical', spacing=10) screen.add_widget(layout) self.localServiceEditorName = Label(size_hint=(1, None), halign="center", text="??????????") layout.add_widget(self.makeBackButton()) self.localServiceEditPanelScroll = ScrollView(size_hint=(1, 1)) self.localServiceEditPanel = BoxLayout(orientation='vertical', size_hint=(1, None)) self.localServiceEditPanel.bind( minimum_height=self.localServiceEditPanel.setter('height')) self.localServiceEditPanelScroll.add_widget(self.localServiceEditPanel) layout.add_widget(self.localServiceEditPanelScroll) return screen
def makeDiscoveryPage(self): # Discovery Page screen = Screen(name='Discovery') self.discoveryScreen = screen layout = BoxLayout(orientation='vertical', spacing=10) screen.add_widget(layout) label = Label( size_hint=(1, None), halign="center", text= 'Browsing your local network.\nWarning: anyone on your network\ncan advertise a site with any title they want.' ) layout.add_widget(self.makeBackButton()) layout.add_widget(label) self.discoveryScroll = ScrollView(size_hint=(1, 1)) self.discoveryListbox = BoxLayout(orientation='vertical', size_hint=(1, None)) self.discoveryListbox.bind( minimum_height=self.discoveryListbox.setter('height')) self.discoveryScroll.add_widget(self.discoveryListbox) layout.add_widget(self.discoveryScroll) return screen
def __init__(self, camara, soundwave, **kwargs): super(UserInputBox, self).__init__(**kwargs) with self.canvas.before: Color(subdivisionColor[0], subdivisionColor[1], subdivisionColor[2]) self.rect = Rectangle(size=self.size, pos=self.pos) # listen to size and position changes self.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) self.orientation = "horizontal" rightbox = BoxLayout(orientation='vertical', size_hint=(0.3, 1)) rightupbox = BoxLayout(orientation='horizontal') # rightupbox.add_widget(Image(source="assets/Camara.png", size_hint=(0.1, None), pos_hint={'top': 1})) rightupbox.add_widget(camara) rightbox.add_widget(rightupbox) self.poselabel = WidgetCreator.newlabel("Brazos: NULL", size_hint=(1.0, None)) rightbox.add_widget(self.poselabel) self.add_widget(rightbox) leftbox = BoxLayout(orientation='vertical') leftupbox = BoxLayout(orientation='horizontal') # leftupbox.add_widget(Image(source="assets/Camara.png", size_hint=(0.1, 0.1))) leftupbox.add_widget(soundwave) leftbox.add_widget(leftupbox) leftdownbox = BoxLayout(orientation='horizontal') self.rostroimage = Image(source=SelectorDeIconos.iconoderostro(Rostro.SERIO), size_hint=(0.1, 1)) leftdownbox.add_widget(self.rostroimage) self.rostrolabel = WidgetCreator.newlabel("SERIO", size_hint=(1.0, None)) leftdownbox.add_widget(self.rostrolabel) leftbox.add_widget(leftdownbox) self.add_widget(leftbox)
def __init__(self, simulacion, **kwargs): super(ResultadoScreenLayout, self).__init__(**kwargs) self.orientation = 'vertical' boxtitular = BoxLayout(size_hint=(1.0, None), height=40) boxtitular.orientation = 'horizontal' boxtitular.add_widget( Label(text="Resultado General:", size_hint=(1.0, None), height=20, color=textcolor)) boxtitular.barraderesultado = BoxLayout() boxtitular.barraderesultado.orientation = 'vertical' boxtitular.barraderesultado.add_widget( Label(text="Barra", size_hint=(1.0, None), height=20)) boxtitular.barraderesultado.add_widget( Label(text="Porcentaje", size_hint=(1.0, None), height=20)) boxtitular.add_widget(boxtitular.barraderesultado) boxtitular.add_widget( Label(text="Usuario", size_hint=(1.0, 1.0), height=20)) self.add_widget(boxtitular) self.add_widget(TabbedPanelResultados(simulacion)) btn = WidgetCreator.newbutton("Volver") btn.bind(on_press=self.callback_volver) self.add_widget(btn) self.guardarsimulacionalsalir = True
def __init__(self): super().__init__() self.orientation = "vertical" self.toolbar = MDToolbar(title="Setting") self.toolbar.left_action_items = [["arrow-left", self.back]] self.add_widget(self.toolbar) self.container = BoxLayout() label = MDLabel(text="", halign="center") self.container.add_widget(label) self.add_widget(self.container)
class SettingsPage(BoxLayout): def __init__(self): super().__init__() self.orientation = "vertical" self.toolbar = MDToolbar(title="Setting") self.toolbar.left_action_items = [["arrow-left", self.back]] self.add_widget(self.toolbar) self.container = BoxLayout() label = MDLabel(text="", halign="center") self.container.add_widget(label) self.add_widget(self.container) def back(self, instance): app.screen_manager.current = "listpage"
class PlayingPage(BoxLayout): def __init__(self): super().__init__() self.pointer = 0 self.state_ = { "isPlaying": True, "title": "Test Title", "artist": "J. Cole", "lenght": 100.0 } self.orientation = "vertical" self.toolbar = MDToolbar(title="Now Playing") self.toolbar.left_action_items = [["arrow-left", self.back]] self.add_widget(self.toolbar) self.upper_container = BoxLayout() self.upper_container.orientation = "vertical" self.title = MDLabel(text=self.state_['title'] + '\n' + self.state_['artist'], halign="center", font_style="H5") self.upper_container.add_widget(self.title) self.lower_container = BoxLayout() self.lower_container.orientation = "horizontal" self.lower_container.halign = "center" self.lower_container.size_hint_max_y = 0.2 self.slider_time_line = BoxLayout() self.slider_time_line.orientation = "horizontal" self.play_btn = MDIconButton(icon="pause") self.play_btn.on_press = self.pause_ self.next_Btn = MDIconButton(icon="skip-forward") self.slider = MDSlider(min=0, max=self.state_['lenght']) self.prev_Btn = MDIconButton(icon="skip-backward") self.lower_container.add_widget(self.prev_Btn) self.lower_container.add_widget(self.play_btn) self.lower_container.add_widget(self.next_Btn) self.slider_time_line.add_widget(self.slider) self.add_widget(self.upper_container) self.add_widget(self.slider_time_line) self.add_widget(self.lower_container) def init_config(self, title, artist, lenght): if not artist: artist = "" self.title.text = str(title) + "\n" + str(artist) self.slider.max = lenght def pause_(self): self.state_['isPlaying'] = not self.state_['isPlaying'] self.slider.max = self.state_['lenght'] if self.state_['isPlaying']: self.play_btn.icon = "pause" app.playing.play() else: self.play_btn.icon = "play" app.playing.stop() def back(self, instance): app.screen_manager.current = "listpage"
def makeLocalServicesPage(self): screen = Screen(name='LocalServices') self.servicesScreen = screen layout = BoxLayout(orientation='vertical', spacing=10) screen.add_widget(layout) label = Label( size_hint=(1, None), halign="center", text= 'WARNING: Running a local service may use a lot of data and battery.\nChanges may require service restart.' ) labelw = Label( size_hint=(1, None), halign="center", text= 'WARNING 2: This app currently prefers the external SD card for almost everything including the keys.' ) layout.add_widget(self.makeBackButton()) layout.add_widget(label) layout.add_widget(labelw) btn2 = Button(text='Create a service') btn2.bind(on_press=self.promptAddService) layout.add_widget(btn2) self.localServicesListBoxScroll = ScrollView(size_hint=(1, 1)) self.localServicesListBox = BoxLayout(orientation='vertical', size_hint=(1, None), spacing=10) self.localServicesListBox.bind( minimum_height=self.localServicesListBox.setter('height')) self.localServicesListBoxScroll.add_widget(self.localServicesListBox) layout.add_widget(self.localServicesListBoxScroll) return screen
def makeMainScreen(self): mainScreen = Screen(name='Main') mainscroll = ScrollView(size_hint=(1, 1)) self.mainScreenlayout = BoxLayout(orientation='vertical', spacing=10, size_hint=(1, 1),adaptive_height=True) mainscroll.add_widget(self.mainScreenlayout) mainScreen.add_widget(mainscroll) return mainScreen
def makeGlobalSettingsPage(self): screen = Screen(name='GlobalSettings') layout = BoxLayout(orientation='vertical', spacing=10) screen.add_widget(layout) layout.add_widget(self.makeBackButton()) self.localSettingsScroll = ScrollView(size_hint=(1, 1)) self.localSettingsBox = BoxLayout(orientation='vertical', size_hint=(1, None), spacing=10) self.localSettingsBox.bind( minimum_height=self.localSettingsBox.setter('height')) self.localSettingsScroll.add_widget(self.localSettingsBox) layout.add_widget(self.localSettingsScroll) return screen
def color_chooser(self): if uiApp.current_selected_widget == None: toast("select a wire first") return content = Button(text='Close me!', size_hint_y=0.1) popup = Popup(title="Theme color") box = BoxLayout(orientation='vertical') clr_picker = ColorPicker() def on_color(instance, value): # self.current_selected_widget.clr.color=instance.color for i in (uiApp.current_selected_widget.parent.parent).children: for j in i.children: if isinstance(j, DraggableWire): child = j.children[0] child.canvas.before.children[0].rgba = instance.color # child = self.current_selected_widget.children[0] # child.canvas.before.children[0].rgba = instance.color clr_picker.bind(color=on_color) box.add_widget(clr_picker) content.bind(on_press=popup.dismiss) box.add_widget(content) popup.add_widget(box) popup.open()
def build(self): Window.size=(350,180) screen = MDScreen() layout = BoxLayout(orientation="vertical") self.b_9=MDRaisedButton(text="9",on_press=self.insert_text) self.b_8=MDRaisedButton(text="8",on_press=self.insert_text) self.b_7=MDRaisedButton(text="7",on_press=self.insert_text) self.b_6=MDRaisedButton(text="6",on_press=self.insert_text) self.b_5=MDRaisedButton(text="5",on_press=self.insert_text) self.b_4=MDRaisedButton(text="4",on_press=self.insert_text) self.b_3=MDRaisedButton(text="3",on_press=self.insert_text) self.b_2=MDRaisedButton(text="2",on_press=self.insert_text) self.b_1=MDRaisedButton(text="1",on_press=self.insert_text) self.b_zero=MDRaisedButton(text="0",on_press=self.insert_text) self.b_equals=MDRaisedButton(text="=",on_press=self.equals) self.b_CLR=MDRaisedButton(text="CLR",on_press=self.clear_text) self.b_plus=MDRaisedButton(text="+",on_press=self.addition) self.b_minus=MDRaisedButton(text="-",on_press=self.sub) self.b_mul=MDRaisedButton(text="*",on_press=self.mul) self.b_Div=MDRaisedButton(text="/",on_press=self.div) self.text_field = MDTextFieldRect(text="",size_hint=(1, None),height="30dp",pos_hint={'centr_x':0,'center_y':0.96}) gl = GridLayout(cols=4) layout.add_widget(self.text_field) lis=[self.b_9,self.b_8,self.b_7,self.b_plus,self.b_6,self.b_5,self.b_4,self.b_minus,self.b_3,self.b_2,self.b_1,self.b_mul,self.b_CLR,self.b_zero,self.b_equals,self.b_Div] for k in lis: gl.add_widget(k) layout.add_widget(gl) return layout
def makeSettingsPage(self): page = Screen(name='Settings') layout = BoxLayout(orientation='vertical') page.add_widget(layout) label = MDToolbar(title="Settings and Tools") layout.add_widget(label) layout.add_widget(self.makeBackButton()) log = Button(text='System Logs') btn1 = Button(text='Local Services') label1 = Label(halign="center", text='Share a local webservice with the world') log.bind(on_release=self.gotoLogs) btn1.bind(on_press=self.goToLocalServices) layout.add_widget(log) layout.add_widget(btn1) layout.add_widget(label1) btn = Button(text='Global Settings') btn.bind(on_press=self.goToGlobalSettings) layout.add_widget(btn) # Start/Stop btn3 = Button(text='Stop') btn3.bind(on_press=self.stop_service) label3 = Label( size_hint=(1, None), halign="center", text= 'Stop the background process. It must be running to acess hardline sites. Starting may take a few seconds.' ) layout.add_widget(btn3) layout.add_widget(label3) btn4 = Button(text='Start or Restart.') btn4.bind(on_press=self.start_service) label4 = Label( size_hint=(1, None), halign="center", text='Restart the process. It will show in your notifications.') layout.add_widget(btn4) layout.add_widget(label4) layout.add_widget(Widget()) return page
def __init__(self, **kwargs): super(ChatBox, self).__init__(**kwargs) self.do_scroll_x = False self.do_scroll_y = True new_box = BoxLayout(size_hint_y=None, orientation='vertical', padding=chatboxpadding, spacing=10) new_box.bind(minimum_height=new_box.setter('height')) with self.canvas.before: Color(subdivisionColor[0], subdivisionColor[1], subdivisionColor[2]) self.rect = RoundedRectangle(size=self.size, pos=self.pos, radius=[10]) # listen to size and position changes self.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) self.content = new_box self.add_widget(self.content)
def makeLogsPage(self): screen = Screen(name='Logs') self.servicesScreen = screen layout = BoxLayout(orientation='vertical', spacing=10) screen.add_widget(layout) layout.add_widget(MDToolbar(title="System Logs")) layout.add_widget(self.makeBackButton()) self.logsListBoxScroll = ScrollView(size_hint=(1, 1)) self.logsListBox = BoxLayout(orientation='vertical', size_hint=(1, None), spacing=10) self.logsListBox.bind(minimum_height=self.logsListBox.setter('height')) self.logsListBoxScroll.add_widget(self.logsListBox) layout.add_widget(self.logsListBoxScroll) return screen
def __init__(self, **kwargs): super(SimulacionScreenLayout, self).__init__(**kwargs) self.padding = [10, 10, 10, 10] self.orientation = 'vertical' self.faselabel = WidgetCreator.newlabel("Nombre de Fase", size_hint=(1.0, None)) self.add_widget(self.faselabel) chat = BoxLayout(orientation="horizontal", size_hint=(1, 1), spacing=10) chat.add_widget(WidgetCreator.newimage('assets/BotFace.jpg')) self.chatbox = ChatBox(size_hint=(1, 1)) chat.add_widget(self.chatbox) self.add_widget(chat) self.camara = Image(size_hint=(1, 1), pos_hint={'top': 1}) self.soundwave = FigureCanvasKivyAgg(AudioController().fig) self.userinputbox = UserInputBox(self.camara, self.soundwave, padding=[10, 10, 10, 10], spacing=10) self.add_widget(self.userinputbox) Clock.schedule_interval(self.update, 1.0 / 30.0)
def makeStreamEditPage(self): "Prettu much just an empty page filled in by the specific goto functions" screen = Screen(name='EditStream') self.servicesScreen = screen self.streamEditPanelScroll = ScrollView(size_hint=(1, 1)) self.streamEditPanel = BoxLayout(orientation='vertical', adaptive_height=True, spacing=5, size_hint=(1, None)) self.streamEditPanel.bind( minimum_height=self.streamEditPanel.setter('height')) self.streamEditPanelScroll.add_widget(self.streamEditPanel) screen.add_widget(self.streamEditPanelScroll) return screen
def makeRowWidget(self, stream, post): def f(*a): self.currentPageNewRecordHandler = None self.gotoStreamRow(stream, post['id']) l = BoxLayout(adaptive_height=True, orientation='vertical') l.add_widget(Button(text=post.get('name', "?????"), on_release=f)) tlen = 0 t = [] for i in post: if i.startswith('row.') and not post[i] in (0, ''): x = i[4:] + ": " + str( post[i])[:16] + ("..." if len(str(post[i])) > 16 else "") if tlen + len(x) > 120: continue t.append(x) tlen += len(x) t = "\r\n".join(textwrap.wrap(", ".join(t), 48)) l.add_widget(self.saneLabel(t, l)) return l
def __init__(self): super().__init__() self.pointer = 0 self.state_ = { "isPlaying": True, "title": "Test Title", "artist": "J. Cole", "lenght": 100.0 } self.orientation = "vertical" self.toolbar = MDToolbar(title="Now Playing") self.toolbar.left_action_items = [["arrow-left", self.back]] self.add_widget(self.toolbar) self.upper_container = BoxLayout() self.upper_container.orientation = "vertical" self.title = MDLabel(text=self.state_['title'] + '\n' + self.state_['artist'], halign="center", font_style="H5") self.upper_container.add_widget(self.title) self.lower_container = BoxLayout() self.lower_container.orientation = "horizontal" self.lower_container.halign = "center" self.lower_container.size_hint_max_y = 0.2 self.slider_time_line = BoxLayout() self.slider_time_line.orientation = "horizontal" self.play_btn = MDIconButton(icon="pause") self.play_btn.on_press = self.pause_ self.next_Btn = MDIconButton(icon="skip-forward") self.slider = MDSlider(min=0, max=self.state_['lenght']) self.prev_Btn = MDIconButton(icon="skip-backward") self.lower_container.add_widget(self.prev_Btn) self.lower_container.add_widget(self.play_btn) self.lower_container.add_widget(self.next_Btn) self.slider_time_line.add_widget(self.slider) self.add_widget(self.upper_container) self.add_widget(self.slider_time_line) self.add_widget(self.lower_container)
def makeZbarPage(self): sc = Screen(name="zbarcam") self.zparpagelayout = lo = BoxLayout(orientation="vertical") sc.add_widget(lo) return sc
def newmdicon(iconname, **kwargs): image = BoxLayout(padding=5, size_hint=(0.1, 0.1)) image.add_widget(MDIcon(icon=iconname, **kwargs)) return image
def newicon(source) -> Image: image = BoxLayout(padding=5, size_hint=(0.1, 0.1)) image.add_widget(Image(source=source)) return image
def newimage(source, size=(0.4, 1)) -> Image: image = BoxLayout(size_hint=size) image.add_widget(Image(source=source)) return image
def gotoTableView(self, stream, parent='', search=''): "Data records can be attatched to a post." self.currentPageNewRecordHandler = None self.streamEditPanel.clear_widgets() s = daemonconfig.userDatabases[stream] parentDoc = daemonconfig.userDatabases[stream].getDocumentByID( parent, allowOrphans=True) if not parentDoc: logging.error("nonexistent parent document") return themeColor = getColor(parentDoc) self.streamEditPanel.add_widget(self.makeBackButton()) postWidget = self.makePostWidget(stream, parentDoc, indexAssumption=False) self.streamEditPanel.add_widget(postWidget) t = (MDToolbar(title="Data Table View")) if themeColor: t.md_bg_color = themeColor t.specific_text_color = getFGForColor(themeColor) self.streamEditPanel.add_widget(t) topbar = BoxLayout(orientation="horizontal", spacing=10, adaptive_height=True) searchBar = BoxLayout(orientation="horizontal", spacing=10, adaptive_height=True) searchQuery = MDTextField(size_hint=(0.68, None), multiline=False, text=search) searchButton = MDRoundFlatButton(text="Search") searchBar.add_widget(searchQuery) searchBar.add_widget(searchButton) def doSearch(*a): self.currentPageNewRecordHandler = None self.gotoTableView(stream, parent, searchQuery.text.strip()) searchButton.bind(on_release=doSearch) def goHere(): self.currentPageNewRecordHandler = None self.gotoTableView(stream, parent, search) self.backStack.append(goHere) self.backStack = self.backStack[-50:] newEntryBar = BoxLayout(orientation="horizontal", spacing=10, adaptive_height=True) newRowName = MDTextField(size_hint=(0.68, None), multiline=False, text=search) def write(*a): for i in newRowName.text: if i in "[]{}:,./\\": return if newRowName.text.strip(): id = uuid.uuid5( uuid.UUID(parent), newRowName.text.strip().lower().replace(' ', "")) #That name already exists, jump to it if daemonconfig.userDatabases[stream].getDocumentByID( id, allowOrphans=True): self.currentPageNewRecordHandler = None self.gotoStreamRow(stream, id) return else: id = str(uuid.uuid4()) x = daemonconfig.userDatabases[stream].getDocumentsByType( "row.template", parent=parent, limit=1, allowOrphans=True) newDoc = { 'parent': parent, 'id': id, 'name': newRowName.text.strip() or id, 'type': 'row', 'leafNode': True } #Use the previously created or modified row as the template for i in x: for j in i: if j.startswith('row.'): newDoc[j] = '' self.currentPageNewRecordHandler = None self.gotoStreamRow(stream, id, newDoc) btn1 = Button(text='New Entry') btn1.bind(on_press=write) newEntryBar.add_widget(newRowName) newEntryBar.add_widget(btn1) if s.writePassword: topbar.add_widget(newEntryBar) self.streamEditPanel.add_widget(topbar) if not search: p = s.getDocumentsByType("row", limit=1000, parent=parent, allowOrphans=True) else: p = s.searchDocuments(search, "row", limit=1000, parent=parent) t = MDToolbar(title="Data Rows") if themeColor: t.md_bg_color = themeColor t.specific_text_color = getFGForColor(themeColor) self.streamEditPanel.add_widget(t) self.streamEditPanel.add_widget(searchBar) for i in p: self.streamEditPanel.add_widget(self.makeRowWidget(stream, i)) self.screenManager.current = "EditStream" def onNewRecord(db, r, sig): if db is daemonconfig.userDatabases[stream]: if r.get('parent', '') == parentDoc.get( 'parent', '') and r['type'] == "post": if not self.unsavedDataCallback: self.gotoStreamPost(stream, postID, noBack=True) elif parentDoc['id'] in r.get("parent", ''): postWidget.body.text = renderPostTemplate( daemonconfig.userDatabases[stream], parentDoc['id'], parentDoc.get("body", ''))[0] self.currentPageNewRecordHandler = onNewRecord
def gotoStreamRow(self, stream, postID, document=None, noBack=False, template=None): "Editor/viewer for ONE specific row" self.streamEditPanel.clear_widgets() self.streamEditPanel.add_widget( MDToolbar(title="Table Row in " + stream)) self.streamEditPanel.add_widget(self.makeBackButton()) if not noBack: def goHere(): self.gotoStreamRow(stream, postID) self.backStack.append(goHere) self.backStack = self.backStack[-50:] document = document or daemonconfig.userDatabases[ stream].getDocumentByID(postID, allowOrphans=True) if 'type' in document and not document['type'] == 'row': raise RuntimeError("Document is not a row") document['type'] = 'row' title = Label(text=document.get("name", ''), font_size='22sp') #Our default template if none exists #Give it a name because eventually we may want to have multiple templates. #Give it an ID so it can override any existing children of that template. #Use only the direct ID of the parent record in cade we want to move it eventually. oldTemplate = { 'type': "row.template", 'leafNode': True, 'parent': document['parent'], 'name': 'default', 'id': uuid.uuid5(uuid.UUID(document['parent'].split("/")[-1]), ".rowtemplate.default") } for i in daemonconfig.userDatabases[stream].getDocumentsByType( "row.template", parent=document['parent'], limit=1, allowOrphans=True): oldTemplate = i template = template or oldTemplate def post(*a): with daemonconfig.userDatabases[stream]: #Make sure system knows this is not an old document try: del document['time'] except: pass daemonconfig.userDatabases[stream].setDocument(document) #If the template has changed, that is how we know we need to save template changes at the same time as data changes if not template.get('time', 0) == oldTemplate.get('time', 1): daemonconfig.userDatabases[stream].setDocument(template) daemonconfig.userDatabases[stream].commit() self.unsavedDataCallback = None self.goBack() btn1 = Button(text='Save Changes') btn1.bind(on_release=post) self.streamEditPanel.add_widget(title) buttons = BoxLayout(orientation="horizontal", spacing=10, adaptive_height=True) if daemonconfig.userDatabases[stream].writePassword: self.streamEditPanel.add_widget(buttons) buttons.add_widget(btn1) def delete(*a): def reallyDelete(v): if v == postID: with daemonconfig.userDatabases[stream]: daemonconfig.userDatabases[stream].setDocument({ 'type': 'null', 'id': postID }) daemonconfig.userDatabases[stream].commit() self.gotoStreamPosts(stream) self.askQuestion("Delete table row permanently on all nodes?", postID, reallyDelete) btn1 = Button(text='Delete') btn1.bind(on_release=delete) if daemonconfig.userDatabases[stream].writePassword: buttons.add_widget(btn1) names = {} self.streamEditPanel.add_widget(MDToolbar(title="Data Columns:")) for i in template: if i.startswith('row.'): names[i] = '' for i in document: if i.startswith('row.'): if i in template: names[i] = '' else: #In the document but not the template, it is an old/obsolete column, show that to user. names[i] = '(removed)' for i in names: self.streamEditPanel.add_widget(Button(text=i[4:])) d = document.get(i, '') try: d = float(d) except: pass x = MDTextField(text=str(d) + names[i], mode='fill', multiline=False, font_size='22sp') def oc(*a, i=i, x=x): d = x.text.strip() if isinstance(d, str): d = d.strip() try: d = float(d or 0) except: pass document[i] = d x.bind(text=oc) self.streamEditPanel.add_widget(x) if isinstance(d, float) or not d.strip(): l = BoxLayout(orientation="horizontal", spacing=10, adaptive_height=True) b = MDRoundFlatButton(text="--") def f(*a, i=i, x=x): d = document.get(i, '') if isinstance(d, str): d = d.strip() try: d = float(d or 0) except: return document[i] = d - 1 x.text = str(d - 1) b.bind(on_release=f) b2 = MDRoundFlatButton(text="++") def f(*a, i=i, x=x): d = document.get(i, '') if isinstance(d, str): d = d.strip() try: d = float(d or 0) except: return document[i] = d + 1 x.text = str(document[i]) b2.bind(on_release=f) l.add_widget(b) l.add_widget(b2) self.streamEditPanel.add_widget(l) b = MDRoundFlatButton(text="Add Column") def f(*a): def f2(r): if r: template['row.' + r] = '' #Remove time field which marks it as a new record that will get a new timestamp rather than #being ignored when we go to save it, for being old. template.pop('time', None) #Redraw the whole page, it is lightweight, no DB operation needed. self.gotoStreamRow(stream, postID, document=document, noBack=True, template=template) self.askQuestion("Name of new column?", cb=f2) b.bind(on_release=f) self.streamEditPanel.add_widget(b) b = MDRoundFlatButton(text="Del Column") def f(*a): def f2(r): if r: try: del template['row.' + r] template.pop('time', None) except: pass #Redraw the whole page, it is lightweight, no DB operation needed. self.gotoStreamRow(stream, postID, document=document, noBack=True, template=template) self.askQuestion("Column to delete?", cb=f2) b.bind(on_release=f) self.streamEditPanel.add_widget(b) self.screenManager.current = "EditStream"
def gotoMainScreen(self): self.mainScreenlayout.clear_widgets() layout=self.mainScreenlayout label = MDToolbar(title="Drayer Journal") label.icon=os.path.join(os.path.dirname(os.path.abspath("__file__")),'assets','icons',"Craftpix.net",'medival','cart.jpg') layout.add_widget(label) stack = StackLayout(size_hint=(1,None),adaptive_height=True,spacing=5) l = self.saneLabel("Notice: streams may be stored on the SD card. Some other apps may be able to read them",layout) layout.add_widget(l) btn1 = Button(text='My Streams') stack.add_widget(btn1) btn1.bind(on_press=self.goToStreams) btn1 = Button(text='Discover Services') btn1.bind(on_press=self.goToDiscovery) stack.add_widget(btn1) btn5 = Button(text='Settings+Tools') btn5.bind(on_press=self.goToSettings) stack.add_widget(btn5) btn6 = Button(text='Help') btn6.bind(on_press=self.goToHelp) stack.add_widget(btn6) layout.add_widget(stack) label = MDToolbar(title="Bookmarks") layout.add_widget(label) for i in sorted(list(daemonconfig.getBookmarks().keys())): bw =BoxLayout(orientation='horizontal', spacing=10, size_hint=(1, None),adaptive_height=True) b = Button(text=i[:32]) bd = Button(text="Del") def dlbm(*a,i=i): def f(a): if a: daemonconfig.setBookmark(a,None,None) self.gotoMainScreen() self.askQuestion("Delete Bookmark?",i,f) bd.bind(on_press=dlbm) def bm(*a,i=i): self.gotoBookmark(i) b.bind(on_press=bm) bw.add_widget(b) bw.add_widget(bd) layout.add_widget(bw) self.screenManager.current = "Main"
def hocr_dialog(self, instance, *args): from kivy.uix.image import Image from PIL.Image import open # texture.get_region seems to be buggy if not self.pil_image: self.pil_image = open(self.image.source) snippet = self.pil_image.crop(instance.bbox) image = Image() self._update_image(image, snippet) from kivymd.uix.boxlayout import BoxLayout from kivymd.uix.textfield import TextInput, MDTextField layout = BoxLayout(orientation="vertical", size=(500, 200), size_hint=(None, None)) bboxlayout = BoxLayout(orientation="vertical") bboxvaluelayout = BoxLayout(orientation="horizontal") bboxlayout.add_widget(OneLineListItem(text="BBOX")) for bbox in instance.bbox: bboxvaluelayout.add_widget(MDTextField(text=str(bbox))) bboxlayout.add_widget(bboxvaluelayout) layout.add_widget(bboxlayout) layout.add_widget(image) layout.add_widget(TextInput(text=instance.text,font_name=get_font())) dialog = MDDialog(title="Snippets", type='custom', auto_dismiss=False, text=instance.text, content_cls=layout, size=(500, 800), size_hint=(None, None), buttons=[ MDFlatButton( text="UPDATE BBOX", on_release=partial(self.update_bbox, instance) ), MDFlatButton( text="SAVE", on_release=partial(self.update_text, instance) ), MDFlatButton( text="DISCARD", on_release=partial(self.close_dialog) ), ], ) dialog.open()
def goToStreams(self, *a): "Go to a page wherein we can list user-modifiable services." self.streamsEditPanel.clear_widgets() layout = self.streamsEditPanel bar = BoxLayout(spacing=10, adaptive_height=True, size_hint=(1, None)) stack = StackLayout(spacing=10, adaptive_height=True, size_hint=(1, None)) layout.add_widget(bar) layout.add_widget(MDToolbar(title="My Streams")) layout.add_widget(stack) def upOne(*a): self.gotoMainScreen() btn1 = Button(text='Up') btn1.bind(on_press=upOne) bar.add_widget(btn1) bar.add_widget(self.makeBackButton()) btn2 = Button(text='Create a Stream') btn2.bind(on_press=self.promptAddStream) stack.add_widget(btn2) def f(selection): if selection: dn = 'file:' + os.path.basename(selection) while dn in daemonconfig.userDatabases: dn = dn + '2' try: daemonconfig.loadUserDatabase(selection, dn) self.editStream(dn) except: logging.exception(dn) self.openFM.close() #This lets us view notebook files that aren't installed. def promptOpen(*a): try: #Needed for android self.getPermission('files') except: logging.exception("cant ask permission") from .kivymdfmfork import MDFileManager from . import directories self.openFM = MDFileManager(select_path=f) if os.path.exists("/storage/emulated/0/Documents") and os.access( "/storage/emulated/0/Documents", os.W_OK): self.openFM.show("/storage/emulated/0/Documents") elif os.path.exists( os.path.expanduser("~/Documents")) and os.access( os.path.expanduser("~/Documents"), os.W_OK): self.openFM.show(os.path.expanduser("~/Documents")) else: self.openFM.show(directories.externalStorageDir or directories.settings_path) btn1 = Button(text='Open Book File') btn1.bind(on_press=promptOpen) stack.add_widget(btn1) def goHere(): self.screenManager.current = "Streams" self.backStack.append(goHere) self.backStack = self.backStack[-50:] layout.add_widget(MDToolbar(title="Open Streams:")) try: s = daemonconfig.userDatabases time.sleep(0.5) for i in s: layout.add_widget(self.makeButtonForStream(i)) try: for j in daemonconfig.userDatabases[i].connectedServers: if daemonconfig.userDatabases[i].connectedServers[ j] > (time.time() - (10 * 60)): w = 'online' else: w = 'idle/offline' layout.add_widget( self.saneLabel(j[:28] + ": " + w, layout)) except: logging.exception("Error showing node status") except Exception: logging.info(traceback.format_exc()) self.screenManager.current = "Streams"
def editStream(self, name): if not name in daemonconfig.userDatabases: self.goToStreams() db = daemonconfig.userDatabases[name] c = db.config try: c.add_section("Service") except: pass try: c.add_section("Info") except: pass self.streamEditPanel.clear_widgets() topbar = BoxLayout(size_hint=(1, None), adaptive_height=True, spacing=5) stack = StackLayout(size_hint=(1, None), adaptive_height=True, spacing=5) def upOne(*a): self.goToStreams() btn1 = Button(text='Up') btn1.bind(on_press=upOne) topbar.add_widget(btn1) topbar.add_widget(self.makeBackButton()) self.streamEditPanel.add_widget(topbar) self.streamEditPanel.add_widget(MDToolbar(title=name)) def goHere(): self.editStream(name) self.backStack.append(goHere) self.backStack = self.backStack[-50:] btn2 = Button(text='Notebook View') def goPosts(*a): self.gotoStreamPosts(name) btn2.bind(on_press=goPosts) stack.add_widget(btn2) btn2 = Button(text='Feed View') def goPosts(*a): self.gotoStreamPosts(name, parent=None) btn2.bind(on_press=goPosts) stack.add_widget(btn2) btn2 = Button(text='Stream Settings') def goSettings(*a): self.editStreamSettings(name) btn2.bind(on_press=goSettings) stack.add_widget(btn2) if name.startswith('file:'): btn2 = Button(text='Close Stream') def close(*a): daemonconfig.closeUserDatabase(name) self.goToStreams() btn2.bind(on_press=close) stack.add_widget(btn2) importData = Button(text="Import Data File") def promptSet(*a): try: #Needed for android self.getPermission('files') except: logging.exception("cant ask permission") def f(selection): if selection: def f2(x): if x: with daemonconfig.userDatabases[name]: with open(selection) as f: daemonconfig.userDatabases[ name].importFromToml(f.read()) daemonconfig.userDatabases[name].commit() self.askQuestion("Really import?", "yes", cb=f2) self.openFM.close() from .kivymdfmfork import MDFileManager from . import directories self.openFM = MDFileManager(select_path=f) if os.path.exists("/storage/emulated/0/Documents") and os.access( "/storage/emulated/0/Documents", os.W_OK): self.openFM.show("/storage/emulated/0/Documents") elif os.path.exists( os.path.expanduser("~/Documents")) and os.access( os.path.expanduser("~/Documents"), os.W_OK): self.openFM.show(os.path.expanduser("~/Documents")) else: self.openFM.show(directories.externalStorageDir or directories.settings_path) importData.bind(on_release=promptSet) stack.add_widget(importData) export = Button(text="Export All Posts") def promptSet(*a): from .kivymdfmfork import MDFileManager from .. import directories try: #Needed for android self.getPermission('files') except: logging.exception("cant ask permission") def f(selection): if selection: if not selection.endswith(".toml"): selection = selection + ".toml" def g(a): if a == 'yes': r = daemonconfig.userDatabases[ name].getDocumentsByType('post', parent='') data = daemonconfig.userDatabases[ name].exportRecordSetToTOML( [i['id'] for i in r]) logging.info("Exporting data to:" + selection) with open(selection, 'w') as f: f.write(data) self.openFM.close() if os.path.exists(selection): self.askQuestion("Overwrite?", 'yes', g) else: g('yes') #Autocorrect had some fun with the kivymd devs self.openFM = MDFileManager(select_path=f, save_mode=(name + '.toml')) if os.path.exists("/storage/emulated/0/Documents") and os.access( "/storage/emulated/0/Documents", os.W_OK): self.openFM.show("/storage/emulated/0/Documents") elif os.path.exists( os.path.expanduser("~/Documents")) and os.access( os.path.expanduser("~/Documents"), os.W_OK): self.openFM.show(os.path.expanduser("~/Documents")) else: self.openFM.show(directories.externalStorageDir or directories.settings_path) export.bind(on_release=promptSet) stack.add_widget(export) self.streamEditPanel.add_widget(stack) #Show recent changes no matter where they are in the tree. #TODO needs to be hideable for anti-spoiler purposes in fiction. self.streamEditPanel.add_widget(MDToolbar(title="Recent Changes:")) for i in daemonconfig.userDatabases[name].getDocumentsByType( 'post', orderBy='arrival DESC', limit=5): x = self.makePostWidget(name, i, includeParent=True) self.streamEditPanel.add_widget(x) self.screenManager.current = "EditStream"
def __init__(self, resultado: LineaResultado, fase, nrodefase: Fase, **kwargs): super(TabbedPanelItemResultados, self).__init__(**kwargs) self.text = f"Fase {nrodefase}" content = BoxLayout(padding=gridpadding) # content = BoxLayout(halign='left', valign="middle") content.orientation = 'vertical' content.add_widget( Label(text=f"{fase.nombre}", size_hint=(1.0, None), height=20)) content.add_widget( Label(text="Captura de usuario:", size_hint=(1.0, None), height=20)) grid = GridLayout( cols=2, row_force_default=True, row_default_height=40, size_hint=(1.0, None), height=240, spacing=5, padding=gridpadding, ) label = Label(text="Rostro", size_hint=(None, 1), width=100) with label.canvas.before: Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2]) label.rect = Rectangle(size=self.size, pos=self.pos) label.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(label) rostro = BoxLayout(orientation='horizontal') rostro.add_widget(Label(text=resultado.captura.rostro.name)) rostro.add_widget( Image(size_hint=(None, 0.9), width=40, source=SelectorDeIconos.iconoderostro( resultado.captura.rostro))) with rostro.canvas.before: Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2]) rostro.rect = Rectangle(size=self.size, pos=self.pos) rostro.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(rostro) label = Label(text="Mirada", size_hint=(None, 1), width=100) with label.canvas.before: Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2]) label.rect = Rectangle(size=self.size, pos=self.pos) label.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(label) mirada = BoxLayout(orientation='horizontal') mirada.add_widget(Label(text=resultado.captura.mirada.name)) mirada.add_widget( Image(size_hint=(None, 0.9), width=40, source=SelectorDeIconos.iconodemirada( resultado.captura.mirada))) with mirada.canvas.before: Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2]) mirada.rect = Rectangle(size=self.size, pos=self.pos) mirada.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(mirada) label = Label(text="Cabeza", size_hint=(None, 1), width=100) with label.canvas.before: Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2]) label.rect = Rectangle(size=self.size, pos=self.pos) label.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(label) cabeza = BoxLayout(orientation='horizontal') cabeza.add_widget(Label(text=resultado.captura.cabeza.name)) cabeza.add_widget( Image(size_hint=(None, 0.9), width=40, source=SelectorDeIconos.iconodecabeza( resultado.captura.cabeza))) with cabeza.canvas.before: Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2]) cabeza.rect = Rectangle(size=self.size, pos=self.pos) cabeza.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(cabeza) label = Label(text="Brazos", size_hint=(None, 1), width=100) with label.canvas.before: Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2]) label.rect = Rectangle(size=self.size, pos=self.pos) label.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(label) brazos = BoxLayout(orientation='horizontal') brazos.add_widget(Label(text=resultado.captura.posicionbrazos.name)) brazos.add_widget( Image(size_hint=(None, 0.9), width=40, source=SelectorDeIconos.iconodebrazos( resultado.captura.posicionbrazos))) with brazos.canvas.before: Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2]) brazos.rect = Rectangle(size=self.size, pos=self.pos) brazos.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(brazos) label = Label(text="Volumen de Voz", size_hint=(None, 1), width=100) with label.canvas.before: Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2]) label.rect = Rectangle(size=self.size, pos=self.pos) label.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(label) volumen = BoxLayout(orientation='horizontal') volumen.add_widget(Label(text=str(resultado.captura.volumendevoz))) volumen.add_widget( Image(size_hint=(None, 0.9), width=40, source=SelectorDeIconos.iconodevolumen( resultado.captura.volumendevoz))) with volumen.canvas.before: Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2]) volumen.rect = Rectangle(size=self.size, pos=self.pos) volumen.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(volumen) label = Label(text="Palabras por minuto", size_hint=(None, 1), width=100) with label.canvas.before: Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2]) label.rect = Rectangle(size=self.size, pos=self.pos) label.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(label) velocidad = BoxLayout(orientation='horizontal') velocidad.add_widget( Label(text=str(resultado.captura.palabrasporsegundo))) velocidad.add_widget( Image(size_hint=(None, 0.9), width=40, source=SelectorDeIconos.iconodevelocidad( resultado.captura.palabrasporsegundo))) with velocidad.canvas.before: Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2]) velocidad.rect = Rectangle(size=self.size, pos=self.pos) velocidad.bind(pos=WidgetCreator.update_rect, size=WidgetCreator.update_rect) grid.add_widget(velocidad) content.add_widget(grid) box = BoxLayout() box.add_widget( Label(text=f"Interpretación: {resultado.interpretacion.lectura}", size_hint=(1.0, None), height=20)) content.add_widget(box) scrollableInfo = ScrollView(size_hint=(1.0, 1.0)) scrollableInfo.add_widget( Label(text=f"{resultado.interpretacion.masinfo}")) content.add_widget(scrollableInfo) self.add_widget(content)