def calculationResultLayout(self): calculationResultsLayout = GridLayout() calculationResultsLayout.cols = 2 dataValues = self.getDataValues() familyNetLabel = Label(text='Sissetulek (€)') familyNetResult = Label(text=str(self.getFamilySum())) motherNetLabel = Label(text='* ema neto (€)', color=(1,0,0,1)) motherNetResult = Label(text=str(dataValues['mother']['netIncome'])) fatherNetLabel = Label(text='* isa neto (€)', color=(0,1,0,1)) fatherNetResult = Label(text=str(dataValues['father']['netIncome'])) childSupportLabel = Label(text='* lastetoetus neto (€)', color=(1,1,0,1)) childSupportResult = Label(text=str(dataValues['childSupport']['netIncome'])) def doCalculation(obj): print('xxx') self.getNewValuesFromInputFields() self.startDrawing() childSupportResult.bind( on_press=doCalculation) calculationResultsLayout.add_widget( familyNetLabel ) calculationResultsLayout.add_widget( familyNetResult ) calculationResultsLayout.add_widget( motherNetLabel ) calculationResultsLayout.add_widget( motherNetResult ) calculationResultsLayout.add_widget( fatherNetLabel ) calculationResultsLayout.add_widget( fatherNetResult ) calculationResultsLayout.add_widget( childSupportLabel ) calculationResultsLayout.add_widget( childSupportResult ) return calculationResultsLayout
def aviso(self, txt): the_content = Label(text = txt) the_content.color = (1,1,1,1) popup = Popup(title='PIM', content=the_content, size_hint_y=.25, title_align='center') #content = the_content, size_hint=(None, None), size=(350, 150)) popup.open()
def generate_score_label(self, *args): label = Label( text=str(self.get_record()), color=get_color_from_hex('5BBEE5'), font_size=30) label.curve = 25 return label
def generate_medal_label(self, *args): label = Label( color=get_color_from_hex('5BBEE5'), font_size=30, size_hint=(.7, 1)) label.curve = 25 label.image.source = 'assets/images/medal.png' return label
def check_update(self, *args): release_link = "https://github.com/RedXBeard/kivy-1010/releases/latest" try: resp = urlopen(release_link) current_version = int("".join(resp.url.split("/")[-1].split("."))) lbl = Label( text="Already in Newest Version", shorten=True, strip=True, font_size=14, color=(0, 0, 0, 1)) if current_version > int("".join(__version__.split('.'))): lbl.text = ("Newer Version Released please check\n" "[color=3148F5][i][ref=https://github" ".com/RedXBeard/kivy-1010]Kivy1010" "[/ref][/i][/color]") lbl.bind(on_ref_press=self.open_page) layout = GridLayout( cols=1, rows=1, spacing=(10, 10), padding=(3, 6, 3, 6)) layout.add_widget(lbl) self.info_popup = Popup( content=layout, size_hint=(None, None), size=(300, 200), title='Kivy 1010', title_color=(0, 0, 0, 1), border=(0, 0, 0, 0), auto_dismiss=True, separator_color=get_color_from_hex('7B8ED4')) self.info_popup.open() except URLError: pass
def enterSubset(self, ctx): super(Listener, self).enterSubset(ctx) self.subsetstack.append(self.lastoperand) self.laystack.append(self.lastlay) vlay = BoxLayout() vlay.orientation = 'vertical' hlay = BoxLayout() hlay.orientation = 'horizontal' vlay.add_widget(hlay) hlay = BoxLayout() hlay.orientation = 'horizontal' vlay.add_widget(hlay) self.lastvlay = vlay self.lastlay.add_widget(vlay) self.lastlay = vlay.children[0] self.currentformat.push() self.currentformat.clearemphasise() self.currentformat.cleartype() if ctx.VARIABLE() or ctx.NUMBER(): if ctx.VARIABLE(): value = self.variablecontexttounicode(ctx.VARIABLE().getText()) lbl = Label(text=value) lbl.font_name = self.currentformat.getfont() self.lastlay.add_widget(lbl) if ctx.NUMBER(): self.lastlay.add_widget(Label(text=str(ctx.NUMBER().getText()))) if self.debug: name = '' if ctx.VARIABLE(): name += ctx.VARIABLE().getText() + ';' if ctx.NUMBER(): name += ctx.NUMBER().getText() print 'Entered: subset: ' + name
def on_start(self): ''' This is the start point of the kivy ui ''' import time Logger.info('Time to on_start: {} <<<<<<<<'.format(time.clock())) Logger.info("dpi: {} {}".format(metrics.dpi, metrics.dpi_rounded)) win = Window win.bind(size=self.on_size, on_keyboard=self.on_keyboard) win.bind(on_key_down=self.on_key_down) # Register fonts without this you won't be able to use bold/italic... # inside markup. from kivy.core.text import Label Label.register('Roboto', 'gui/kivy/data/fonts/Roboto.ttf', 'gui/kivy/data/fonts/Roboto.ttf', 'gui/kivy/data/fonts/Roboto-Bold.ttf', 'gui/kivy/data/fonts/Roboto-Bold.ttf') win.softinput_mode = 'below_target' self.on_size(win, win.size) self.init_ui() self.load_wallet_by_name(self.electrum_config.get_wallet_path()) # init plugins run_hook('init_kivy', self) # were we sent a url? self.uri = self.electrum_config.get('url') # default tab self.switch_to('send' if self.uri else 'history')
def build(self): label = Label(text="Testing going on.") atlas = Atlas("player_sheet.atlas") image1 = Image(allow_stretch=True) image1.texture = atlas["walkleft4"] label.add_widget(image1) return label
def test_walk_single(self): from kivy.uix.label import Label label = Label() self.assertListEqual([n for n in label.walk(loopback=True)], [label]) self.assertListEqual([n for n in label.walk_reverse(loopback=True)], [label])
def __init__(self, **kwargs): Label.__init__(self) for x in kwargs.items(): setattr(self, x[0], x[1]) if not hasattr(self, "text_color"): self.text_color = (1, 1, 1, 1) if not hasattr(self, "back_color"): self.back_color = (0, int("4a",16)/255, int("64",16)/255, .8) if not hasattr(self, "text"): self.text = "Hello World" if not hasattr(self, "duration"): self.duration = 4 if not hasattr(self, "pad_x"): self.pad_x = 15 if not hasattr(self, "pad_y"): self.pad_y = 5 self.pos = (0,0) self.opacity = 0 self.color = self.text_color self.rect = InstructionGroup() self.rect.add(Color(*self.back_color)) self.rect.add(Rectangle(pos_hint=self.pos_hint, pos=(self.center_x-self.texture_size[0]/2, self.center_y-self.texture_size[1]/2), size=(self.texture_size[0]+10, self.texture_size[1]))) self.canvas.before.add(self.rect) self.bind(texture_size=self.draw_rect) self.anim = {'fade_in':Animation(opacity=1, duration=.4), 'fade_out':Animation(opacity=0)} self.clock_fade_in = Clock.create_trigger(self.fade_in) self.clock_fade_out = Clock.create_trigger(self.fade_out, self.duration)
def __init__(self, title, choices, key, callback, keep_choice_order=False): Factory.Popup.__init__(self) print(choices, type(choices)) if keep_choice_order: orig_index = {choice: i for (i, choice) in enumerate(choices)} sort_key = lambda x: orig_index[x[0]] else: sort_key = lambda x: x if type(choices) is list: choices = dict(map(lambda x: (x,x), choices)) layout = self.ids.choices layout.bind(minimum_height=layout.setter('height')) for k, v in sorted(choices.items(), key=sort_key): l = Label(text=v) l.height = '48dp' l.size_hint_x = 4 cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' cb.size_hint_x = 1 def f(cb, x): if x: self.value = cb.value cb.bind(active=f) if k == key: cb.active = True layout.add_widget(l) layout.add_widget(cb) layout.add_widget(Widget(size_hint_y=1)) self.callback = callback self.title = title self.value = key
def readme_pop(self): """ Readme """ popup = Popup(title='README') b=BoxLayout(orientation='vertical') s = ScrollView() global tslabel tslabel=Label(size_hint_y=None,line_height=1.5,valign="top", text= "Copyright (C) 2015 Revathy Narayanan\n" + "The TimeTracker is a Python application \n that will keep"+ " track of time spent\n in day-to-day activities.\n\n"+ "The Application will have features \n"+ "* Start/Stop watch \n * Log Task\n * Add Comments\n"+ "* Generate & View Timesheet\n * Mail Timesheet\n\n "+ "The code is licensed under MIT License(MIT).\n "+ "Please see the file license in this distribution\n for license terms in the link below :\n"+ "https://github.com/rev20/Time-Tracker/blob/master/LICENSE \n\n"+ "Following is the link for the repository: \n"+ "https://github.com/rev20/Time-Tracker/") tslabel.bind(texture_size=tslabel.setter('size')) btn1=Button(text='CLOSE',size_hint=(1,.06)) s.add_widget(tslabel) b.add_widget(s) b.add_widget(btn1) popup.content=b popup.open() btn1.bind(on_press=popup.dismiss)
def on_start(self): """ This is the start point of the kivy ui """ Logger.info("dpi: {} {}".format(metrics.dpi, metrics.dpi_rounded)) win = Window win.bind(size=self.on_size, on_keyboard=self.on_keyboard) win.bind(on_key_down=self.on_key_down) # Register fonts without this you won't be able to use bold/italic... # inside markup. from kivy.core.text import Label Label.register( "Roboto", "data/fonts/Roboto.ttf", "data/fonts/Roboto.ttf", "data/fonts/Roboto-Bold.ttf", "data/fonts/Roboto-Bold.ttf", ) if platform == "android": # bind to keyboard height so we can get the window contents to # behave the way we want when the keyboard appears. win.bind(keyboard_height=self.on_keyboard_height) self.on_size(win, win.size) self.init_ui() self.load_wallet_by_name(self.electrum_config.get_wallet_path())
class ScrollableLabel(ScrollView): def __init__(self, text, ref_callback=None, font_size=13, font_name='DroidSans', *args, **kwargs): super(ScrollableLabel, self).__init__(*args, **kwargs) with self.canvas.before: Color(0.7, .02, 0.91, mode="hsv") # Color(.69, .93, .93) self.background = Rectangle(size_hint=(1,1)) self.label = Label(text=text, font_size=font_size, font_name=font_name, size_hint_y=None, pos_hint={'x':0.1, 'y':0.1}) self.label.bind(texture_size=self._set_summary_height, on_ref_press=ref_callback) # self.label.text=text self.label.markup=True self.add_widget(self.label) self.bind(pos=self.change_position) self.bind(size=self.change_size) def _set_summary_height(self, instance, size): instance.height = size[1] def change_position(self, instance, position): self.background.pos = position def change_size(self, instance, size): self.background.size = size self.label.text_size = (size[0]-50, None)
def timesheet_pop(self): """Popup to display the Timesheet""" popup = Popup(title='Timesheet') b=BoxLayout(orientation='vertical') s = ScrollView() global tslabel tslabel=Label(size_hint_y=None,line_height=1.5,valign="top", text="|_ID_|______DATE______|___TIME_SPENT____|_____TASK_________|") tslabel.bind(texture_size=tslabel.setter('size')) btn1=Button(text='CLOSE',size_hint=(1,.06)) s.add_widget(tslabel) b.add_widget(s) b.add_widget(btn1) popup.content=b popup.open() btn1.bind(on_press=popup.dismiss) con=lite.connect('TimeTracker.db') with con: cur=con.cursor() cur.execute("SELECT ID, TASK_DATE, TIME, TASK FROM Timesheet") rows = cur.fetchall() for row in rows: tslabel.text=tslabel.text+"\n " tslabel.text+=str(row[0]).center(4)+" "+str(row[1]) tslabel.text+=" "+str(row[2]).center(34)+" "+str(row[3]) if con: con.close()
def build(self): root_widget = Label( font_size=100, italic=True, markup=True) root_widget.text = '[color=#ff0000]Hello[/color] [color=#00ff00]world![/color]' return root_widget
def __init__(self, title, choices, key, callback): Factory.Popup.__init__(self) if type(choices) is list: choices = dict(map(lambda x: (x,x), choices)) layout = self.ids.choices layout.bind(minimum_height=layout.setter('height')) for k, v in sorted(choices.items()): l = Label(text=v) l.height = '48dp' l.size_hint_x = 4 cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' cb.size_hint_x = 1 def f(cb, x): if x: self.value = cb.value cb.bind(active=f) if k == key: cb.active = True layout.add_widget(l) layout.add_widget(cb) layout.add_widget(Widget(size_hint_y=1)) self.callback = callback self.title = title self.value = key
def build(self): lb_error = Label(text='Corrupted PPMT File\nCreate new PPMT File, type in terminal:\n' '\n[i]pampamt-create[/i]') lb_error.markup = True return lb_error # project = ProjectPPMT() # project.project = 'Borborema' # project.path_file_ppmt = '/home/patrick/.PampaMT/teste' # # project.save( # arq = '/home/patrick/z16/z16.ppmt' # # # project = read_ppmt_file(arq) # print(project.name) # print(project.path_file_ppmt) # lis_site = project.sites # # print(lis_site[1].name) # # lis_asc = lis_site[1].files_asc # # file = lis_asc[1] # print(file.name) # print(file.processingZ) #make_file_band_asc(bor602a)
def get_text_size(self, text): """ Helper method, weighs the size of the text. """ lab = Label(text=text, font_size=30, padding_x=5) lab.texture_update() return lab.texture_size
def build(self): f = FloatLayout() b = Button(pos_hint={'x': 0.5, 'center_y': .5},text='Hello world', font_size=14) s = Scatter() l = Label(text="Hello!",font_size=150) def select_to(*args): try: print args[1][0] except: pass fi = FileChooserIconView() f.add_widget(s) s.add_widget(l) l.add_widget(b) def callback(instance): print('The button <%s> is being pressed' % instance.text) f.add_widget(fi) b.bind(on_press=callback) fi.bind(on_selection=select_to) return f
class TinyButton(Widget): font_size = NumericProperty(20) def __init__(self, path, screen, radius, midpoint, font_size, word, **kwargs): super(TinyButton, self).__init__(**kwargs) self.texture = Image(source=path, mipmap=True).texture self.font_size = font_size self.radius = radius self.screen = screen self.midpoint = midpoint self.x = self.midpoint[0] self.y = self.midpoint[1] self.corner_pos = (self.x - self.radius, self.y - self.radius) self.word = word self.label = Label(x=self.midpoint[0], center_y=self.midpoint[1], font_size=self.font_size, text=self.word) self.label.bind(size=self.label.setter('text_size')) with self.canvas: Ellipse(texture=self.texture, pos=self.corner_pos, size=(self.radius * 2, self.radius * 2)) self.add_widget(self.label) def on_touch_down(self, touch): global click_sound click_sound.play() if self.corner_pos[1] < touch.y < self.y + self.radius: sm.current = self.screen
def __init__(self, **kvargs): super(ADialog, self).__init__(**kvargs) content = self.ids.content box_content = self.ids.box_content height, avatar_size_hint = (self.dp(60), (.05, .9)) self.ids.logo.size_hint = avatar_size_hint self.ids.box_logo_and_title.height = height # Текстовая информация. for info_string in self.info_program: if info_string == '': content.add_widget(SettingSpacer()) continue info_string = \ Label(text=info_string, size_hint_y=None, font_size=self.dp(self.base_font_size), markup=True, on_ref_press=self.events_callback) info_string.bind(size=lambda *args: self._update_label_size(args)) content.add_widget(info_string) self.content = box_content self.size_hint = (self.user_size_hint[0], self.user_size_hint[1]) self.open()
class ScrollableLabel(ScrollView): ''' use it thisly -> scrollablelabel = ScrollableLabel().build("put your big bunch of text right here") or ScrollableLabel().build() <- thusly with no argument to just get a very big bunch of text as a demo scrolls x and y default ''' def build(self,textinput,size): self.summary_label = Label(text="",text_size=(size,None), size_hint_y=None,size_hint_x=None) self.summary_label.bind(texture_size=self._set_summary_height) # remove the above bind self.summary_label.text = str(textinput) #and try setting height in the following line self.sv = ScrollView(do_scroll_x=False) # it does not scroll the scroll view. self.sv.add_widget(self.summary_label) return self.sv def _set_summary_height(self, instance, size): instance.height = size[1] instance.width = size[0]
def on_start(self): ''' This is the start point of the kivy ui ''' import time; print 'python time to on_start:', time.clock(), '<<<<<<<<<' Logger.info("dpi: {} {}".format(metrics.dpi, metrics.dpi_rounded)) win = Window win.bind(size=self.on_size, on_keyboard=self.on_keyboard) win.bind(on_key_down=self.on_key_down) # Register fonts without this you won't be able to use bold/italic... # inside markup. from kivy.core.text import Label Label.register('Roboto', 'gui/kivy/data/fonts/Roboto.ttf', 'gui/kivy/data/fonts/Roboto.ttf', 'gui/kivy/data/fonts/Roboto-Bold.ttf', 'gui/kivy/data/fonts/Roboto-Bold.ttf') win.softinput_mode = 'below_target' self.on_size(win, win.size) self.init_ui() self.load_wallet_by_name(self.electrum_config.get_wallet_path()) run_hook('init_kivy', self)
def pack(self, text_list): '''sizes popup appropiately and packs with right number of weights''' spacing = 10. cols_within_frame = 3 die_size = len(text_list) col_width = int(self.parent_obj.width / cols_within_frame) add_drag = False cols = ((die_size)//10 +1) if cols > cols_within_frame: cols = ((die_size+2)//10 +1) add_drag = True drag_it = Label(text='DRAG\n====>', bold=True) height = int(self.parent_obj.height* 0.9) sz_hint = ((col_width - spacing)/(cols*col_width), 0.1 * (height-spacing)/height) self.size = (min(1.1 * cols*col_width, self.parent_obj.width), self.parent_obj.height) contents = self.ids['contents'] contents.clear_widgets() contents.size = (cols*col_width*0.88, height) contents.spacing = spacing if add_drag: drag_it.size_hint = sz_hint contents.add_widget(drag_it) contents.add_widget(Button(on_press=self.record_weights, text='record\nweights', size_hint=sz_hint)) for text in text_list: weighter = NumberSelect(0, 10, size_hint=sz_hint) weighter.set_text(text, 1) contents.add_widget(weighter) contents.add_widget(Button(on_press=self.record_weights, text='record\nweights', size_hint=sz_hint))
def taskMenu_inner(_=None): self.clear_widgets() taskMenuLayout = GridLayout(cols=1, spacing=10, size_hint_y=None) taskMenuLayout.bind(minimum_height=taskMenuLayout.setter('height')) self.scroll_y = 1 self.add_widget(taskMenuLayout) backButton = Button(text=getTaskName(tid), size_hint_y=None, height=100) statusLabel = Label(font_size='12sp', valign = 'top', halign='left') if isRunning(tid, True): backButton.background_color = (0.8,1,0.8,1) statusLabel.text = localisation.get(language, "end") + " " + getDateString(getLastDeadline(tid)) elif isComplete(tid): backButton.background_color = (1,0.8,0.8,1) statusLabel.text = localisation.get(language, "cooldown") + " " + getDateString(getCompletionExpirationDate(tid)) else: statusLabel.text = localisation.get(language, "limbo") + " " + getDateString(getCompletionExpirationDate(tid)) backButton.bind(on_press=self.buildMainScreen) taskMenuLayout.add_widget(backButton) taskMenuLayout.add_widget(statusLabel) for milestone in getMilestones(tid): taskMenuLayout.add_widget(self.makeMilestoneLayout(tid, milestone, oldScore if milestone == getNextMilestone(tid) else None)) newMilestoneButton = Button(text=localisation.get(language,"newdate"), bold=True, size_hint_y=None, height=100) taskMenuLayout.add_widget(newMilestoneButton) newMilestoneButton.bind(on_press=self.mileStonePopup(tid)) delConfirmSwitch = Switch() delConfirmPopup = Popup(title=localisation.get(language, "sure"), content=delConfirmSwitch, size_hint=(None, None), size=(200, 200)) delConfirmPopup.bind(on_dismiss=self.deleteTask(tid, delConfirmSwitch)) delButton = Button(text=localisation.get(language,"deltask"), bold=True, size_hint_y=None, height=100) delButton.bind(on_press=delConfirmPopup.open) taskMenuLayout.add_widget(delButton)
class FontChooser(BoxLayout): font = StringProperty("") text = font def __init__(self, **kwargs): super(FontChooser, self).__init__(**kwargs) self.orientation = "vertical" self.fonts = sorted(map(str, fonts.get_fonts())) data = [{'text': str(i), 'is_selected': i == self.font} for i in self.fonts] args_converter = lambda row_index, rec: {'text': rec['text'], 'size_hint_y': None, 'height': 25} self.list_adapter = ListAdapter(data=data, args_converter=args_converter, cls=ListItemButton, selection_mode='single', allow_empty_selection=False) self.list_view = ListView(adapter=self.list_adapter) self.list_adapter.bind(selection=self.on_font_select) self.label = Label(text="The quick brown fox jumps over the brown lazy dog. 0123456789", font_size="30dp", halign="center", size_hint_y=None) self.label.font_name = fonts.match_font(self.list_adapter.selection[0].text) self.label.bind(size=self.label.setter("text_size")) self.font = self.list_adapter.selection[0].text self.add_widget(self.list_view) self.add_widget(self.label) def on_font_select(self, instance, value): self.font = value[0].text self.label.font_name = fonts.match_font(value[0].text)
def _get_body(self): from kivy.lang import Builder import textwrap self.browser = Builder.load_string(textwrap.dedent('''\ FileChooser: FileChooserIconLayout FileChooserListLayout ''')) self.browser.path = self.path self.browser.multiselect = self.multiselect self.browser.dirselect = self.dirselect self.browser.bind(path=self.setter('path'), selection=self.setter('selection')) self.bind(view_mode=self.browser.setter('view_mode'), multiselect=self.browser.setter('multiselect'), dirselect=self.browser.setter('dirselect')) lbl_path = LabelEx(text=self.browser.path, valign='top', halign='left', size_hint_y=None, height=metrics.dp(25)) self.browser.bind(path=lbl_path.setter('text')) layout = BoxLayout(orientation='vertical') layout.add_widget(self._ctrls_init()) layout.add_widget(lbl_path) layout.add_widget(self.browser) return layout
def build(self): self._view = BoxLayout() self._board = BoardWidget(self._container) self._view.add_widget(self._board) self._resources = BoxLayout(orientation='vertical') self._resources.size_hint_x = .3 if self._my_bool is True: self._turn_display = Label() self._turn_display.text = "White's turn" self._turn_display.size_hint_y = .1 self._resources.add_widget(self._turn_display) restart = Button() restart.text = "Restart" restart.bind(on_press=self.restart) restart.size_hint_y = .25 self._resources.add_widget(restart) self._view.add_widget(self._resources, 0) label = Label() label.text = "Move history here" self._resources.add_widget(label) undo = Button() undo.text = "Undo" undo.bind(on_press=self.undo) undo.size_hint_y = .25 self._resources.add_widget(undo) redo = Button() redo.text = "Redo" redo.bind(on_press=self.redo) redo.size_hint_y = .25 self._resources.add_widget(redo) self._my_bool = True return self._view
def __init__(self, **kwargs): self.color = kwargs.pop('shadowcolor', (0, 0, 0, 1) ) self.shadowcolor = kwargs.pop('color', (1, 1, 1, 1) ) self.text = kwargs.pop('text', '') self.font_size = kwargs.pop('font_size', 16) self.texthalign = kwargs.pop('texthalign', 'center') kwargs.pop('pos', '') kwargs.pop('color', '') self.label = Label(text=self.text, font_size=self.font_size, color=self.color, **kwargs) self.shadow = Label(text=self.text, font_size=self.font_size, color=self.shadowcolor, **kwargs) super(LabelShadow, self).__init__(**kwargs) self.add_widget(self.label) self.add_widget(self.shadow) #self.label.pos[0] = -1000 if self.texthalign == 'left': self.label.bind(size=self.fixLabelText ) self.shadow.bind(size=self.fixLabelText )
def build(self): return Label(text='Hello World!')
def build(self): def las_givarna(dt): global sort, givarna_tot, givarna, givarna_old, add_tot, btntime, btnadd, btnsort, nolla_givarna, relaytid, stoprelay if givarna_tot == None: givarna_tot = 0.0 #if givarna - givarna_tot < 0 and givarna < 0: # givarna_tot + givarna_tot + 2 # LÄS GIVARNA givarna_old = givarna try: f = open("/dev/shm/givarna", "r") givarna = f.read() givarna = float(givarna) * 0.00001 except: givarna = givarna_old # CHECK IF FILE WAS READ OK r = givarna - givarna_old if -50.0 <= r <= 50.00 or r == 0.0: givarna_old = givarna else: givarna = givarna_old # LÄS TRÄ SORTER #sort = sort_input.text tra_lista = tra_data_lista(tra_data) # SVÄRD if GPIO.input(3) == False and givarna_tot != givarna: GPIO.output(2, GPIO.LOW) if add_tot == True: tra_data_totlangd_add(tra_data, sort, givarna - givarna_tot) givarna_tot = givarna stoprelay = True #print(givarna_tot) # NOLLA if nolla_givarna == True: stoprelay = True givarna_tot = givarna nolla_givarna = False # TA TID PÅ KNAPPEN ADD if GPIO.input(17) == False: if btnadd == False: btntime = time.time() btnadd = True # ADD #print(time.time() - btntime) elif time.time() - btntime > 0.3: if btnsort == False: btnsort = True if add_tot == True: add_tot = False adding_label.text = 'NOPE' langd_display.color = [1, 0, 0, 1] langd_selected.color = [1, 0, 0, 1] langd_tot.color = [1, 0, 0, 1] else: add_tot = True adding_label.text = 'ADDING' langd_display.color = [0, 1, 0, 1] langd_selected.color = [0, 1, 0, 1] langd_tot.color = [0, 1, 0, 1] #tra_data_totlangd_add(tra_data, sort, givarna - givarna_tot) # VÄLJ TRÄ SLAG MED SNABB TRYCKNING if GPIO.input(17) == True: if btnadd == True: if (time.time() - btntime) < 0.3: sort = tra_data_next(tra_data, sort) print(sort) print(tra_data) btnadd = False btnsort = False if sort in tra_lista: totlangd = tra_data_totlangd(tra_data, sort) langd = tra_data_langd(tra_data, sort) langd = float(langd) else: totlangd = 0.0 langd = 0.0 # RELAY PÅ / AV if (givarna - givarna_tot) >= (langd - 23) and stoprelay == True: relaytid = time.time() stoprelay = False GPIO.output(2, GPIO.HIGH) elif (givarna - givarna_tot) < (langd - 23) and stoprelay == False: stoprelay = True elif (givarna - givarna_tot) >= ( langd - 23) and time.time() - relaytid < 1.5: GPIO.output(2, GPIO.HIGH) else: GPIO.output(2, GPIO.LOW) # DISPLAY langd_sort.text = sort langd_display.text = str(round(givarna - givarna_tot)) + ' cm' langd_selected.text = str(round(langd)) + ' cm' langd_tot.text = 'tot. ' + str(round(totlangd * 0.01, 1)) + ' m' Clock.schedule_interval(las_givarna, 0.05) root_widget = BoxLayout(orientation='vertical') # namn_button | Ny | Ladda # ------------------------------------------------------------------------ # langd_display | Sort | Mått läsare | inställd längd | totala längden # ------------------------------------------------------------------------ # edit_button_grid | edit sort | edit längd | exit | Remove | Add # ------------------------------------------------------------------------ # tra_button_grid | Björk | Gran | Tall | Asp | Ved | # ------------------------------------------------------------------------ def count_tra_slag(): for tra in tra_data: tra_button_grid.add_widget( Button(text=tra['slag'], font_size=23, halign="center")) def update_buttons(): for button in tra_button_grid.children: button.bind(on_press=tra_button_action) def edit_tra_slag(instance): global stoprelay stoprelay = True tra_data_edit_langd(tra_data, sort_input.text, langd_input.text) def add_tra_slag(instance): global stoprelay tra_data_add(tra_data, sort_input.text, langd_input.text, 0) tra_button_grid.add_widget(Button(text=sort_input.text)) stoprelay = True update_buttons() def nolla(instance): global nolla_givarna nolla_givarna = True def off(instance): os.system('shutdown -h now') def remove_tra_slag(instance): def yes(instance): tra_data_remove(tra_data, sort_input.text) for i in tra_button_grid.children: print(i) print(i.text) if i.text == sort_input.text: tra_button_grid.remove_widget(i) update_buttons() popup.dismiss() yes_button = Button(text='Joo') no_button = Button(text='Nää') popup_widget = BoxLayout(orientation='vertical') popup_widget.add_widget(Label(text='E du nu rikit sääkär?')) popup_widget.add_widget(no_button) popup_widget.add_widget(yes_button) popup = Popup(title='Radera ' + sort_input.text, content=popup_widget, size_hint=(0.5, 0.5)) yes_button.bind(on_press=yes) no_button.bind(on_press=popup.dismiss) popup.open() def tra_button_action(instance): global stoprelay stoprelay = True sort_input.text = instance.text langd_input.text = tra_data_langd(tra_data, instance.text) def nollatot(instance): def yes(instance): tra_data_totlangd_add(tra_data, sort_input.text, 'nolla') popup.dismiss() yes_button = Button(text='Joo') no_button = Button(text='Nää') popup_widget = BoxLayout(orientation='vertical') popup_widget.add_widget(Label(text='E du nu rikit sääkär?')) popup_widget.add_widget(no_button) popup_widget.add_widget(yes_button) popup = Popup(title='Nolla totala längden', content=popup_widget, size_hint=(0.5, 0.5)) yes_button.bind(on_press=yes) no_button.bind(on_press=popup.dismiss) popup.open() def exit(instance): App.get_running_app().stop() upper_button_grid = GridLayout(cols=6, size_hint_y=0.6) screen_grid = GridLayout(cols=2, size_hint_y=2) langd_display = Label(font_size=100) langd_tot_grid = GridLayout(cols=1, size_hint_x=0.5) langd_selected = Label(font_size=60, size_hint_y=2, halign="left", valign="bottom") langd_sort = Label(font_size=60) langd_tot = Label(font_size=30, halign="left", valign="top") langd_sort.color = [1, 0, 0, 1] langd_display.color = [1, 0, 0, 1] langd_selected.color = [1, 0, 0, 1] langd_tot.color = [1, 0, 0, 1] edit_button_grid = GridLayout(cols=6, size_hint_y=1) tra_button_grid = GridLayout(cols=10, size_hint_y=1) count_tra_slag() sort_input = TextInput(text='sort', halign='center', multiline=False, font_size=35) langd_input = TextInput(text='langd', halign='center', multiline=False, font_size=35) apply_button = Button(text='Apply') apply_button.bind(on_press=edit_tra_slag) nolla_button = Button(text='Nolla') nolla_button.bind(on_press=nolla) add_button = Button(text='Add') add_button.bind(on_press=add_tra_slag) remove_button = Button(text='Remove', size_hint_x=0.5) remove_button.bind(on_press=remove_tra_slag) nollatot_button = Button(text='Nolla tot.') nollatot_button.bind(on_press=nollatot) exit_button = Button(text='Quit') exit_button.bind(on_press=exit) shutdown_button = Button(text='OFF') shutdown_button.bind(on_press=off) name_label = Label(text=vername + ' ~ ' + version, halign='center', font_size=25, size_hint_x=4) madeby_label = Label(text=madeby, halign='center', font_size=12, size_hint_x=4) adding_label = Label(text='NOPE', halign='center', font_size=12) upper_button_grid.add_widget(name_label) upper_button_grid.add_widget(madeby_label) upper_button_grid.add_widget(adding_label) upper_button_grid.add_widget(nollatot_button) upper_button_grid.add_widget(exit_button) upper_button_grid.add_widget(shutdown_button) screen_grid.add_widget(langd_display) screen_grid.add_widget(langd_tot_grid) langd_tot_grid.add_widget(langd_sort) langd_tot_grid.add_widget(langd_selected) langd_tot_grid.add_widget(langd_tot) edit_button_grid.add_widget(sort_input) edit_button_grid.add_widget(langd_input) edit_button_grid.add_widget(apply_button) edit_button_grid.add_widget(nolla_button) edit_button_grid.add_widget(add_button) edit_button_grid.add_widget(remove_button) root_widget.add_widget(upper_button_grid) root_widget.add_widget(screen_grid) root_widget.add_widget(edit_button_grid) root_widget.add_widget(tra_button_grid) update_buttons() def edit_button_action(instance): if instance.text == 'Add': pass for button in edit_button_grid.children: button.bind(on_press=edit_button_action) return root_widget
def __init__(self): super(CategoriesLayout, self).__init__() root = self grid = GridLayout(cols=3, size_hint=(0.5, 0.5), pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) root.bind(size=self._update_rect, pos=self._update_rect) self.bar_str = '' self.qty_str = '' # title label label_qty = Label(text='Categories', color=(0, 0, 0, 0.25), font_size=20, pos_hint={ 'center_x': 0.1, 'top': 0.9 }) root.add_widget(label_qty) # company name self.company = Button(text='<- KAKABOKA', color=(0, 0, 0, 1), background_color=(0, 0, 0, 0), font_size=30, pos_hint={ 'center_x': 0.15, 'center_y': 0.95 }) root.add_widget(self.company) # add employee button self.add_employee = Button(text='Add employee', size_hint=(0.2, 0.15), pos_hint={ 'center_x': 0.8, 'center_y': 0.1 }) root.add_widget(self.add_employee) #Sales button self.button_sales = Button(text='Sales', size_hint=(0.2, 0.15)) grid.add_widget(self.button_sales) #Non Sales button self.button_nonsales = Button(text='Non Sales', size_hint=(0.2, 0.15)) grid.add_widget(self.button_nonsales) # services button self.button_services = Button(text='Services', size_hint=(0.2, 0.15)) grid.add_widget(self.button_services) root.add_widget(grid) with root.canvas.before: base_folder = os.path.dirname(__file__) image_path = os.path.join(base_folder, 'background.png') self.rect = Rectangle(source=image_path, size=root.size, pos=root.pos)
def build_interface(self): self.show_hide_button = RealToggleButton( './media/icons/up.png', './media/icons/down.png', self.show_hide, pos_hint={'x': 0, 'y': 0}, size_hint=(None, None), size=(self.iconsize, self.iconsize), source='./media/icons/up.png', always_release=True ) self.add_sun_button = RealMenuToggleButton( './media/icons/sunmode.png', './media/icons/sunmode_pressed.png', 'add_sun', pos_hint={'x': 0.25, 'y': 0}, size_hint=(None, None), size=(self.iconsize, self.iconsize), source='./media/icons/sunmode.png', group='menu', allow_no_selection=True ) self.add_planet_button = RealMenuToggleButton( './media/icons/add_planet.png', './media/icons/addplanet_pressed.png', 'add_planet', size_hint=(None, None), size=(self.iconsize, self.iconsize), pos_hint={'x': 0.5, 'y': 0}, group='menu', source='./media/icons/add_planet.png', allow_no_selection=True ) self.multi_button = RealMenuToggleButton( './media/icons/multipass.png', './media/icons/multipass_pressed.png', 'multi', size_hint=(None, None), size=(self.iconsize, self.iconsize), pos_hint={'x': 0.75, 'y': 0}, group='menu', source='./media/icons/multipass.png', allow_no_selection=True ) self.add_widget(self.add_planet_button) self.add_widget(self.add_sun_button) self.add_widget(self.multi_button) self.add_widget(self.show_hide_button) self.value_slider = Slider( min=5, max=50, value=10, step=1, orientation='horizontal', pos_hint={'x': 1, 'y': 0}, size_hint=(1, 1) ) self.value_label = Label( text='Some value: 9999', size_hint=(1, 1), pos_hint={'x': 2, 'y': 0}, halign='left' ) self.value_slider.bind(value=self.value_slider_change) self.hide_items = [ self.value_slider, self.value_label, self.add_planet_button, self.add_sun_button, self.multi_button ]
def invalidForm(): pop = Popup(title='Invalid Form', content=Label(text='Please fill in all inputs with valid information.'), size_hint=(None, None), size=(400, 400)) pop.open()
def aboutBtn(self): aboutPopup = Popup(title='About this software', content=Label(text=str(os.popen("cat about").read())), size_hint=(None, None), size=(550, 400)) aboutPopup.open()
except: return False def compute_size(maxs, imgw, imgh): if imgw > imgh: return maxs, maxs*imgh/imgw else: return maxs *imgw/imgh, maxs if __name__ == "__main__": from kivy.base import runTouchApp from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label box = BoxLayout(orientation="vertical") fileChooser = FileChooserThumbView(thumbsize=128) label = Label(markup=True, size_hint=(1, 0.05)) fileChooser.mylabel = label box.add_widget(fileChooser) box.add_widget(label) def setlabel(instance, value): instance.mylabel.text = "[b]Selected:[/b] {0}".format(value) fileChooser.bind(selection=setlabel) runTouchApp(box)
def build(self): return Label(text="Hey There")
def create_labels(self): for name in self.names: temp_label = Label(text=name) self.root.ids.entries_box.add_widget(temp_label)
def build(self): return Label(text="Hello World")
def build(self): return Label(text='Hello world')
Cache.register('electrum_widgets', timeout=0) from kivy.uix.screenmanager import Screen from kivy.uix.tabbedpanel import TabbedPanel from kivy.uix.label import Label from kivy.uix.checkbox import CheckBox from kivy.uix.switch import Switch from kivy.core.clipboard import Clipboard Factory.register('TabbedCarousel', module='electrum_gui.kivy.uix.screens') # Register fonts without this you won't be able to use bold/italic... # inside markup. from kivy.core.text import Label Label.register('Roboto', 'gui/kivy/data/fonts/Roboto.ttf', 'gui/kivy/data/fonts/Roboto.ttf', 'gui/kivy/data/fonts/Roboto-Bold.ttf', 'gui/kivy/data/fonts/Roboto-Bold.ttf') from electrum.util import base_units class ElectrumWindow(App): electrum_config = ObjectProperty(None) language = StringProperty('en') def set_URI(self, uri): self.switch_to('send') self.send_screen.set_URI(uri)
def main(self): ir.maybe_download_and_extract() img = (ir.FLAGS.image_file if ir.FLAGS.image_file else ir.os.path.join('image/', 'IMG.png')) string = ir.run_inference_on_image(img) self.add_widget(Label(text=string, text_size=(600, None), line_height=1.5))
def start_tiles(self): self.add_widget(self.back_btn) self.tile_list = [] self.btn_y = 0 self.btn_width = Window.width / 4 self.btn_x = [ self.btn_width * 0, self.btn_width * 1, self.btn_width * 2, self.btn_width * 3 ] global box_slide box_slide = BoxLayout(orientation='vertical', pos=(-Window.width, 0)) with box_slide.canvas: Color(.2, .5, 1, .7) box_slide.rect1 = Rectangle(pos=(box_slide.pos), size=(Window.size)) self.restart_btn = Button(text='Restart', size_hint=(None, None), pos_hint={ 'center_x': .5, 'center_y': .4 }) self.restart_btn.bind(on_press=self.game_over1) box_slide.add_widget( Label(text='Game Over', font_size=40, pos_hint={ 'center_x': .5, 'center_y': .7 })) box_slide.add_widget(self.restart_btn) global slide_anim slide_anim = Animation(pos=(0, 0), d=1) for i in range(50): self.btn = btn(size_hint=(None, None), size=(self.btn_width, Window.height / 4), pos=(random.choice(self.btn_x), Window.height + self.btn_y)) self.btn_y += self.btn.height ## self.btn.bind(on_press=self.play_sound) self.add_widget(self.btn) self.btn.bind(on_press=self._state) self.add_widget(box_slide) self.add_widget(self.score) for child in self.children: if child != box_slide and child != self.back_btn and child != self.score: self.time = (child.y + Window.height / 4) / 200 global anim anim = Animation(y=-(Window.height / 4), d=self.time) self.tile_list.append(child) anim.start(child) anim.fbind('on_complete', self.delete_btn) else: pass
def _build_associated_status_popup(self): return Popup(title='Associate your Lamp', content=Label(text='Msg here', font_size='30sp'), size_hint=(1, 1), auto_dismiss=False)
def build(self): Window.bind(size=self._resize_) self.label = Label(text='Greetings Earthlings') self.set_background_color() return self.label
def alertPopup(data): popup = Popup(title='Error Occoured', content=Label(text='hello'), size_hint=(None, None), size=(dp(600), dp(200))) popup.open()
def _build_network_status_popup(self): return Popup(title='Network Status', content=Label(text='IP ADDRESS WILL GO HERE'), size_hint=(1, 1), auto_dismiss=False)
def build(self): return Label(text='一二三', font_name=p)
def __init__(self, **kwargs): super().__init__(**kwargs) self.cols = 1 self.add_widget(Label(text='Fancy stuff here to come!!!', font_size=30))
def load(self, path, filename): LoadSaveDialog.file_to_load = filename #with open(os.path.join(path, filename[0])) as stream: #LoadSaveDialog.string= stream.read() ext = filename[0].split('.')[-1] opt = 'rb' if ext == 'enc' else 'r' file = open(filename[0], opt) LoadSaveDialog.string = file.read() file.close() TextEditor.choose_lexer(LoadSaveDialog.file_to_load[0]) print(path, filename) # ask the user for organisation name and password if (cache['organisation'] != None): # the user is logged in to an org organisation = cache['organisation'] password = cache['password'] print(filename) fs = FileSystem() ext = filename[0].split('.')[-1] if ext != 'enc': # the file needs to be encrypted first print('here3') fs.updateFile(filename[0] + '.enc', LoadSaveDialog.string, organisation, password) TextEditor.updateCodeInput(LoadSaveDialog.string) TextEditor.currentFile = filename[0] + '.enc' else: try: print(fs.readFile(filename[0], organisation, password)) TextEditor.codeinput.text = fs.readFile( filename[0], organisation, password) TextEditor.currentFile = filename[0] except ValueError: # decryption failed popup_msg = "Credentials invalid for the selected file!" layout = BoxLayout(orientation='vertical') popup_title = "Error" label1 = Label(text=popup_title) label = Label(text=popup_msg) button = Button(text='Dismiss') layout.add_widget(label1) layout.add_widget(label) layout.add_widget(button) popup = Popup(title=popup_title, content=layout, size_hint=(0.6, 0.6)) popup.open() button.bind(on_press=popup.dismiss) else: # the user needs to be prompted to login first popup_msg = "Please login to an organisation first!" layout = BoxLayout(orientation='vertical') popup_title = "Error" label1 = Label(text=popup_title) label = Label(text=popup_msg) button = Button(text='Dismiss') layout.add_widget(label1) layout.add_widget(label) layout.add_widget(button) popup = Popup(title=popup_title, content=layout, size_hint=(0.6, 0.6)) popup.open() button.bind(on_press=popup.dismiss) self.dismiss_popup()
def build_screen(self, *args): self.screen = VotingScreen() # Find button definition files files = glob.glob('buttons/*.conf') # For each file, add a button to the interface index = 0 for file in files: with open(file, 'r', encoding='utf8') as f: text = '' text_font_size = 50 text_font_name = 'Roboto-Bold.ttf' text_font_color = (0,0,0,1) label = '' label_font_size = 30 label_font_name = 'Roboto-Regular.ttf' label_font_color = (1,1,1,1) background_normal = '' background_down = '' for line in f: # Parse the definition file for keywords if line[0:5].lower() == 'text:': text = line[5:].strip().replace('\\n', '\n') if line[0:6].lower() == 'label:': label = line[6:].strip().replace('\\n', '\n') if line[0:15].lower() == 'text_font_size:': text_font_size = float(line[15:].strip()) if line[0:16].lower() == 'text_font_size:': label_font_size = float(line[16:].strip()) if line[0:15].lower() == 'text_font_name:': text_font_name = line[15:].strip() if line[0:16].lower() == 'label_font_name:': label_font_name = line[16:].strip() if line[0:18].lower() == 'background_normal:': background_normal = line[18:].strip() if line[0:19].lower() == 'background_pressed:': background_down = line[19:].strip() pack = BoxLayout(orientation='vertical') but = Button(text=text, font_size=text_font_size, size_hint=(1,0.85), markup=True, font_name=text_font_name, color = text_font_color, halign='center', on_release=partial(self.add_vote, index), background_normal=background_normal, background_down=background_down) lab = Label(text=label, font_size=label_font_size, size_hint=(1,0.15), markup=True, font_name=label_font_name, halign='center', color = label_font_color) pack.add_widget(but) pack.add_widget(lab) self.screen.button_container.add_widget(pack) index += 1 # This assigns the next button to the next entry in vote_array self.vote_array = zeros(len(files)) self.add_widget(self.screen)
def get_stock_data(row_text, dt): sym = row_text[9:-7] if not sym.isalpha(): print('%s not a symbol' % sym) return nse = Nse() print('getting nse price for stock ', sym) q = nse.get_quote(sym) popup = Popup() popup.title = 'Live data for ' + sym popup.size_hint = (.7, .6) popup.pos_hint = {'center_x': .5, 'center_y': .5} if q is not None: ltp = q['lastPrice'] low = q['dayLow'] high = q['dayHigh'] high52 = q['high52'] low52 = q['low52'] prevClose = q['previousClose'] pChange = q['pChange'] val = get_ltp_string(sym, ltp, prevClose, pChange) c1 = Label(text='Symbol') c2 = Label(text=sym) c3 = Label(text='PrevClose') c4 = Label(text=str(prevClose)) c5 = Label(text='Last Price') c6 = Label(text=val, markup=True) c7 = Label(text='Day Low') c8 = Label(text=str(low)) c9 = Label(text='Day High') c10 = Label(text=str(high)) c11 = Label(text='52 week Low') c12 = Label(text=str(low52)) c13 = Label(text='52 week High') c14 = Label(text=str(high52)) # add the data gridlayout = GridLayout(cols=2) gridlayout.add_widget(c1) gridlayout.add_widget(c2) gridlayout.add_widget(c3) gridlayout.add_widget(c4) gridlayout.add_widget(c5) gridlayout.add_widget(c6) gridlayout.add_widget(c7) gridlayout.add_widget(c8) gridlayout.add_widget(c9) gridlayout.add_widget(c10) gridlayout.add_widget(c11) gridlayout.add_widget(c12) gridlayout.add_widget(c13) gridlayout.add_widget(c14) content = gridlayout else: content = Label(text='No data available for symbol ' + sym) popup.content = content popup.open() MDApp.get_running_app().stock_fetch = False
def create_widgets(self): for name in self.names: temp_label = Label(text=name) print(name) self.root.ids.name_area.add_widget(temp_label)
def cautionPopup(): caution = Popup(title='CAUTION', content=Label(text=str(os.popen("cat caution").read())), size_hint=(None, None), size=(550, 450)) caution.open()
def build_interface(self): self.ticks_ahead_label = Label( text='Ticks ahead', size_hint=(0.5, 1), pos_hint={'x': 1, 'y': 0}, halign='left' ) self.ticks_ahead_slider = Slider( min=100, max=1000, value=self.logic.settings['ticks_ahead'], step=1, orientation='horizontal', pos_hint={'x': 1.5, 'y': 0}, size_hint=(0.5, 1) ) self.timeratio_label = Label( text='Timeratio', size_hint=(0.5, 1), pos_hint={'x': 1, 'y': 1}, halign='left' ) self.timeratio_slider = Slider( min=0, max=2, value=self.logic.tick_ratio, step=.1, orientation='horizontal', pos_hint={'x': 1.5, 'y': 1}, size_hint=(0.5, 1) ) self.show_hide_button = RealToggleButton( './media/icons/timer_panel.png', './media/icons/timer_panel.png', self.show_hide, pos_hint={'x': 4.0/5, 'y': -1}, size_hint=(None, None), size=(self.iconsize, self.iconsize), source='./media/icons/timer_panel.png', always_release=True ) self.add_widget(self.show_hide_button) self.ticks_ahead_slider.bind(value=self.ticks_ahead_change) self.timeratio_slider.bind(value=self.timeratio_change) self.add_widget(self.ticks_ahead_label) self.add_widget(self.ticks_ahead_slider) self.add_widget(self.timeratio_label) self.add_widget(self.timeratio_slider) self.hide_labels = [ self.ticks_ahead_slider, self.timeratio_slider, ] self.hide_sliders = [ self.timeratio_label, self.ticks_ahead_label, ]
def __init__(self, did , modif , cnt , **kwargs): super().__init__(**kwargs) #storing parameter from previous class self.deviceid = did self.modf = modif self.cnt = cnt f = open(f"devices\{self.deviceid}.json") #unmodified json data self.data = json.load(f) #new dictionary to store modified values self.newData = {"mapType" : {"capability":[], "resourceType":[],"resourceHref":[]} , "mapData" : {}} #layout design self.orientation = "vertical" self.padding = [20,20,20,20] #title box content = BoxLayout(orientation = 'horizontal', size_hint_y = .2 ) content.add_widget(Label(text='OCF Resource Tool' , font_size = 30)) self.add_widget(content) #second title box content = BoxLayout(orientation = 'horizontal' , size_hint_y = .1) content.add_widget(Label(text='Customize Selected Resource type for ' + self.deviceid , font_size = 20)) self.add_widget(content) #####################scrollbox for customizing items######################## scroll = ScrollView() content = GridLayout(cols = 1 , padding = (10,10) , spacing = (10,10) ,size_hint_y = None , row_default_height = 35) content.bind(minimum_height=content.setter('height')) #dictionary to store updated command self.updatedCommand = {} #dictionary for checkbox to check if command is selected self.checkbox = {} cnt = 0 for i in range(len(self.data['mapType']['resourceType'])): resourceType = self.data['mapType']['resourceType'][i][0] capability = self.data['mapType']['capability'][i][0] #only include resources that were previuosly selected if self.modf[i][0] == True : #store updated values in new dictionary self.newData["mapType"]["capability"].append([capability]) self.newData["mapType"]["resourceType"].append([resourceType]) self.newData["mapType"]["resourceHref"].append(self.modf[i][1]) self.newData["mapData"][capability] = self.data["mapData"][capability] if "valueMap" in self.data['mapData'][capability] : cnt = cnt + 1 #creating layout for commands that need to be customized minContent = BoxLayout(orientation="horizontal") minContent.add_widget(Label(text = resourceType + " " + self.modf[i][1] ,font_size = 18 )) content.add_widget(minContent) #add the capability in updatedCommand and checkbox self.updatedCommand[capability] = [] self.checkbox[capability] = [] #data of map Values arr1 = self.data['mapData'][capability]["valueMap"][0]["STValue"] arr2 = self.data['mapData'][capability]["valueMap"][0]["OCFValue"] for j in range(len(arr1)): #layout for each command minContent = BoxLayout(orientation="horizontal") #adding checkbox self.checkbox[capability].append( CheckBox(size_hint_x = .2) ) minContent.add_widget(self.checkbox[capability][j]) #adding required mapping labels minContent.add_widget(Label(text=arr1[j])) minContent.add_widget(Label(text = "OIC Resource Mapping value")) #adding boxes self.updatedCommand[capability].append(TextInput(text = str(arr2[j]) )) minContent.add_widget(self.updatedCommand[capability][j]) content.add_widget(minContent) else : cnt += 1 minContent = BoxLayout(orientation="horizontal") minContent.add_widget(Label(text = resourceType + " " + self.modf[i][1] + " :- " + "No customization required",font_size = 18 )) content.add_widget(minContent) if cnt == 0 : content.add_widget(Label(text = "You have not selected any resources",font_size = 30)) content.add_widget(Label(text = "click on generate button to produce required JSON file")) scroll.add_widget(content) self.add_widget(scroll) ############################################################################ #Generate button and back button content = FloatLayout(size_hint_y = .2) back = Button(text = "Back" , size_hint = (.2,.4) , pos_hint = {'x':.3 , 'y' : .4}) back.bind(on_release =lambda x:self.goBack()) content.add_widget(back) generate = Button(text = "Generate" , size_hint = (.2,.4) , pos_hint = {'x':.5 , 'y' : .4}) generate.bind(on_release = lambda x:self.generateJSON()) content.add_widget(generate) self.add_widget(content)
def build(self): def update_rect(instance, value): instance.rect.pos = instance.pos instance.rect.size = instance.size def init_display(self): kwargs = self.retrieve_params() draw_button(self.path_current_img, **kwargs) color = kwargs['color'] with self.display_layout.canvas.before: Color(rgba=(color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 255)) self.display_layout.rect = Rectangle( size=self.display_layout.size, pos=self.display_layout.size) # config : right side of window # pressed or not self.label_checkbox_pressed = Label(text="Button pressed") self.checkbox_pressed = CheckBox() self.checkbox_pressed.bind(active=lambda x, y: self.update_display()) # size # self.label_size = Label(text='Size configuration') # self.label_size.font_size = '25dp' self.label_size_horizontal = Label(text='Size horizontal') self.slider_size_horizontal = Slider(min=50, max=800, value=200) self.slider_size_horizontal.bind( value=lambda x, y: self.update_display()) self.label_size_vertical = Label(text='Size vertical') self.slider_size_vertical = Slider(min=50, max=800, value=200) self.slider_size_vertical.bind( value=lambda x, y: self.update_display()) # color self.label_color_red = Label(text="Red") self.slider_color_red = Slider(min=0, max=255, value=65) self.slider_color_red.bind(value=lambda x, y: self.update_display()) self.label_color_green = Label(text="Green") self.slider_color_green = Slider(min=0, max=255, value=65) self.slider_color_green.bind(value=lambda x, y: self.update_display()) self.label_color_blue = Label(text="Blue") self.slider_color_blue = Slider(min=0, max=255, value=65) self.slider_color_blue.bind(value=lambda x, y: self.update_display()) # diff color self.label_color_diff_light = Label(text="Difference with light color") self.slider_color_diff_light = Slider(min=0, max=255, value=65) self.slider_color_diff_light.bind( value=lambda x, y: self.update_display()) self.label_color_diff_dark = Label(text="Difference with dark color") self.slider_color_diff_dark = Slider(min=0, max=255, value=65) self.slider_color_diff_dark.bind( value=lambda x, y: self.update_display()) # dist self.label_distance = Label(text="Distance") self.slider_distance = Slider(min=0, max=100, value=15) self.slider_distance.bind(value=lambda x, y: self.update_display()) # radius self.label_corner_radius = Label(text="Corner radius") self.slider_corner_radius = Slider(min=0, max=400, value=30) self.slider_corner_radius.bind( value=lambda x, y: self.update_display()) self.label_gaussian_radius = Label(text="Gaussian radius") self.slider_gaussian_radius = Slider(min=0, max=30, value=10) self.slider_gaussian_radius.bind( value=lambda x, y: self.update_display()) self.config_layout = BoxLayout(orientation='vertical') self.config_layout.add_widget(self.label_checkbox_pressed) self.config_layout.add_widget(self.checkbox_pressed) # self.config_layout.add_widget(self.label_size) self.config_layout.add_widget(self.label_size_horizontal) self.config_layout.add_widget(self.slider_size_horizontal) self.config_layout.add_widget(self.label_size_vertical) self.config_layout.add_widget(self.slider_size_vertical) self.config_layout.add_widget(self.label_color_red) self.config_layout.add_widget(self.slider_color_red) self.config_layout.add_widget(self.label_color_green) self.config_layout.add_widget(self.slider_color_green) self.config_layout.add_widget(self.label_color_blue) self.config_layout.add_widget(self.slider_color_blue) self.config_layout.add_widget(self.label_color_diff_light) self.config_layout.add_widget(self.slider_color_diff_light) self.config_layout.add_widget(self.label_color_diff_dark) self.config_layout.add_widget(self.slider_color_diff_dark) self.config_layout.add_widget(self.label_distance) self.config_layout.add_widget(self.slider_distance) self.config_layout.add_widget(self.label_corner_radius) self.config_layout.add_widget(self.slider_corner_radius) self.config_layout.add_widget(self.label_gaussian_radius) self.config_layout.add_widget(self.slider_gaussian_radius) # display : left side of window self.display_layout = BoxLayout() init_display(self) self.display_layout.bind(pos=update_rect, size=update_rect) self.image_display = ImageDisplay(source=self.path_current_img) self.display_layout.add_widget(self.image_display) # main layout self.main_layout = GridLayout(cols=2) self.main_layout.add_widget(self.display_layout) self.main_layout.add_widget(self.config_layout) return self.main_layout
def showdetails(self, dict): self.img = AsyncImage(source=dict.get("icon"), size_hint_x=.5) self.smallbox.add_widget(self.img) self.verbox = BoxLayout(orientation="vertical") self.smallbox.add_widget(self.verbox) self.name = Label(text=dict.get("title") + "\n\n" + dict.get("developer"), font_name="NotoSansJP") self.verbox.add_widget(self.name) # self.devname = Label(text=dict.get("developer")) # self.verbox.add_widget(self.devname) # self.dtls = {} # self.url = "https://rapidapi.p.rapidapi.com/reviews" # self.querystr = {"store":"google","id":dict.get("id"),"language":"en"} # self.headers = { # 'x-rapidapi-host': "app-stores.p.rapidapi.com", # 'x-rapidapi-key': "YOUR-API-KEY" # } # self.response = requests.request("GET", self.url, headers=self.headers, params=self.querystr) # print(self.response.text) self.result, continuation_token = reviews(dict.get("app_id"), lang="en", country="my", sort=Sort.MOST_RELEVANT, count=200, filter_score_with=None) # self.dtls = json.loads(self.response.text) # review_list = self.data_scrape() self.client = language.LanguageServiceClient() string_val = "" for i in range(0, len(self.result) - 1): string_val += self.result[i].get("content") doc = language.types.Document(content=string_val, type='PLAIN_TEXT') response = self.client.analyze_sentiment(document=doc, encoding_type='UTF32') sentiment = response.document_sentiment # print(sentiment.score) # print(sentiment.magnitude) self.score_title = Label(text="Rating Score", font_name="Sonorous", halign="center") self.box.add_widget(self.score_title) self.score = dict.get("score") + " / 5 stars" self.lblscore = Label(text=self.score, font_name="NotoSansJP", halign="center") self.box.add_widget(self.lblscore) self.category = "" if sentiment.score == 1: self.category = "Perfect!" elif sentiment.score >= 0.5 and sentiment.score < 1: self.category = "Very positive" elif sentiment.score > 0 and sentiment.score < 0.5: self.category = "Positive" elif sentiment.score == 0: self.category = "Neutral" elif sentiment.score > -0.5 and sentiment.score < 0: self.category = "Negative" elif sentiment.score > -1 and sentiment.score < -0.5: self.category = "Very negative" elif sentiment.score == -1: self.category = "You might want to choose another app..." self.react = Label(text="Overall sentiment", font_name="Sonorous", halign="center") self.box.add_widget(self.react) self.lblreact = Label(text=self.category, font_name="NotoSansJP", halign="center") self.box.add_widget(self.lblreact) self.lst = [] self.wordcount = {} # str = re.sub(r'\b\w{1,2}\b', '', str) for each in string_val.lower().split(): new_each = each.replace("<br/>", "") new_each = new_each.replace("&", "") new_each = new_each.replace(",", "") new_each = new_each.replace(".", "") new_each = new_each.replace("*", "") new_each = new_each.replace("!", "") new_each = new_each.replace(":P", "") new_each = new_each.replace(":p", "") new_each = new_each.replace("XD", "") new_each = new_each.replace("xD", "") new_each = new_each.replace("xd", "") new_each = new_each.replace("xp", "") new_each = new_each.replace(":)", "") new_each = new_each.replace(":D", "") new_each = new_each.replace(":d", "") new_each = new_each.replace(":", "") new_each = new_each.replace("\"", "") new_each = new_each.replace("“", "") new_each = new_each.replace("â€~", "") self.lst.append(new_each) # for each in range(len(self.lst)): # if len(self.lst[each]) < 3: # self.lst.remove(self.lst[each]) self.stop_words = stopwords.words('english') # self.lst = [] # for each in range(len(self.worddict)): # self.lst.append(self.worddict) self.df = pd.DataFrame(self.lst, columns=['Word']) # self.lemmatizer = WordNetLemmatizer() # self.new_lst = [] # for each in range(len(self.lst)): # self.new_lst.append(self.lemmatizer.lemmatize(self.lst[each])) # df = pd.DataFrame(self.new_lst, columns=['Word']) # df['Word'] = df['Word'].apply(lambda x: [w for w in x.split() if len(w) > 2]) self.review = [self.remove_stop(r.split()) for r in self.df['Word']] print(self.review) # for each in range(len(self.review)): # if each == '': # self.review.remove(each) self.counter = collections.Counter(self.review) self.worddict = self.counter.most_common(11) self.new_df = pd.DataFrame(self.worddict, columns=['Word', 'Count']) # print(self.new_df.iloc[1:12]) self.new_df = self.new_df.drop([0], axis=0) # self.new_df = self.new_df.iloc[1:12] self.rev_word = self.new_df['Word'].tolist() self.rev_count = self.new_df['Count'].tolist() self.rev_percent = [] self.percent = 0 self.string_value = "" self.table_title = Label(text="Top Most Common Word", font_name="Sonorous", halign="center") self.box.add_widget(self.table_title) self.percent = self.rev_count[0] / len(self.review) * 100 self.string_value = str(round(self.percent, 2)) self.table_content = Label(text=self.rev_word[0] + " with " + self.string_value + "% occurence", font_name="NotoSansJP", halign="center") self.box.add_widget(self.table_content)
def loginBtn(self): #if db.validate(self.email.text, self.password.text): import mysql.connector def Loop3(var1, var2, var3, var4): global mydb mydb = mysql.connector.connect(host="eu-cdbr-west-03.cleardb.net", user=var1, passwd=var2, database=var3) global mycursor mycursor = mydb.cursor() global groep2 groep2 = var4 #replace_line("Personal.txt",6,groep2+"\n") #loginscreen() r1 = "!22@3##$3343@234!22@3##$3343@234" r2 = "!22@3##$3343@234!22@3##$3343@234" r3 = "!22@3##$3343@234!22@3##$3343@234" r4 = "!22@3##$3343@234!22@3##$3343@234" r5 = "!22@3##$3343@234!22@3##$3343@234" r6 = "!22@3##$3343@234!22@3##$3343@234" r7 = "!22@3##$3343@234!22@3##$3343@234" r8 = "!22@3##$3343@234!22@3##$3343@234" r9 = "!22@3##$3343@234!22@3##$3343@234" r10 = "!22@3##$3343@234!22@3##$3343@234" r11 = "!22@3##$3343@234!22@3##$3343@234" r12 = "!22@3##$3343@234!22@3##$3343@234" global loginname loginname = self.email.text sql = f"SELECT wachtwoord FROM {groep2} WHERE naam = '{self.email.text}'" mycursor.execute(sql) myresult = mycursor.fetchall() for result in myresult: r1 = result[0] #sql = f"SELECT gebruiker FROM {groep2} WHERE naam = '{self.email.text}'" #mycursor.execute(sql) #myresult = mycursor.fetchall() #for result in myresult: # r2 = result[0] if r1 == self.password.text and r1 != "!22@3##$3343@234!22@3##$3343@234": MainWindow.current = self.email.text self.reset() sm.current = "main" import threading import time def background(): while True: mydb.commit() time.sleep(45) def foreground(): pass b = threading.Thread(name='background', target=background) f = threading.Thread(name='foreground', target=foreground) b.start() f.start() if self.group.text == "Bevers ochtend" or self.group.text == "bevers ochtend" or self.group.text == "beversochtend": Loop3("b73badccc28509", "46e7ba9f", "heroku_b6ccf5347f986b7", "beversochtend") elif self.group.text == "Bevers middag" or self.group.text == "bevers middag": Loop3("b8a6ec5dd4f831", "26d0c1e2", "heroku_f9c9ff2287354ae", "beversmiddag") elif self.group.text == "Sionihorde" or self.group.text == "sionihorde": Loop3("bd261e04c4f7ac", "2646f655", "heroku_6ddc7ca4fb6c487", "sionihorde") elif self.group.text == "Shantihorde" or self.group.text == "shantihorde": Loop3("bcf0fc9752adca", "4433dfb8", "heroku_3e38dc503c384ed", "shantihorde") elif self.group.text == "Mowglihorde" or self.group.text == "mowglihorde": Loop3("b53a91493bfae6", "b0c77f1c", "heroku_043cac3778e37ef", "mowglihorde") elif self.group.text == "Ekerstroep" or self.group.text == "ekerstroep": Loop3("b20d36b9e64e9a", "592a9017", "heroku_72bce5d900dc0c4", "ekerstroep") elif self.group.text == "Pmttroep" or self.group.text == "PMT" or self.group.text == "pmt" or self.group.text == "Pmt": Loop3("bbb1086e05f46c", "305a5102", "heroku_936cbdf524a261e", "pmtgroep") elif self.group.text == "Gaaientroep" or self.group.text == "gaaientroep": Loop3("b0c7dad8c663d1", "111e5841", "heroku_53e06e5ae9e9597", "gaaientroep") elif self.group.text == "Ea757" or self.group.text == "ea757": Loop3("b9af828f2f4586", "64cb70a1", "heroku_1cb03cce5ef2216", "ea757") elif self.group.text == "Ea595" or self.group.text == "ea595": Loop3("bfbf8c292bd780", "408b12a0", "heroku_4f770db4c2019e5", "ea595") elif self.group.text == "Stam1" or self.group.text == "stam1": Loop3("b4e6692218c8bb", "55c5369c", "heroku_4e519908e65abd9", "stam1") elif self.group.text == "Stam2" or self.group.text == "stam2": Loop3("be0d90306e78fd", "dd2610aa", "heroku_1112b001d39794d", "stam2") else: pop = Popup(title='Invalid Login', content=Label(text='Groep is niet juist'), size_hint=(None, None), size=(400, 400)) pop.open()