我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用kivy.uix.label.Label()。
def build(self): root_widget = BoxLayout(orientation='vertical') output_label = Label(size_hint_y=1) button_symbols = ('1', '2', '3', '+', '4', '5', '6', '-', '7', '8', '9', '.', '0', '*', '/', '=') button_grid = GridLayout(cols=4, size_hint_y=2) for symbol in button_symbols: button_grid.add_widget(Button(text=symbol)) clear_button = Button(text='clear', size_hint_y=None, height=100) root_widget.add_widget(output_label) root_widget.add_widget(button_grid) root_widget.add_widget(clear_button) return root_widget
def show_step_two(self, text_terms, sub_sections_files, select_sub_section): """????????? ????????? ??????? '??? ??????'.""" for sub_section_name in sub_sections_files.keys(): self.sub_sections.add_widget(Label( text="[color=#2fbfe0][ref={sub_section_name}]" "{sub_section_name}" "[/ref]".format(sub_section_name=sub_section_name), on_ref_press=select_sub_section, markup=True)) self.sub_sections.add_widget(SettingSpacer()) self.scroll_view_two.add_widget(self.sub_sections) self.step_two.add_widget(RstDocument(text=text_terms)) self.step_two.add_widget(self.scroll_view_two) self.step_two.disabled = False self.step_two.collapse = False # ????????? ?????? "??? ??????"
def game(self,instance): letters=self.letttersinput.text letters = ",".join(list(letters)) #post data mydata=[('letters', letters),('order','length'),('pos','beg'),('dic','1'),('table','dict')] #Encoding mydata=urllib.urlencode(mydata) codedPath ='''aHR0cDovL3d3dy50aGV3b3JkZmluZGVyLmNvbS9zY3JhYmJsZS5waHA=''' path=base64.b64decode(codedPath) req=urllib2.Request(path, mydata) req.add_header("Content-type", "application/x-www-form-urlencoded") page=urllib2.urlopen(req).read() # applying beautifulsoup for parsing soup = BS(page,"html.parser") # parsing the div with id res = soup.find("div", { "id" : "displayresults" }) Con= res.contents[1].contents[1] line="" for child in Con.children: line+= child.string popup = Popup(title="Result",content=Label(text=line)) popup.open()
def addToBuyList(self, obj): if(self.pos_system.getBuyList() == None): content = Label(text = 'You need to start a new list!') popup = Popup( title = 'No Buy List', content = content, size_hint = (None, None), size = (400, 100) ) # open the popup popup.open() return button = Button(text=obj.text, size_hint_y = None, height = 40) button.bind(on_press = self.removeFromBuyList) self.a_buylist.add_widget(button) self.pos_system.getBuyList().addItem(obj.item) self.updateTotalPrice() ###
def _build_detail_event_box(self, event): event_layout = BoxLayout(orientation='horizontal') label_color = rgb_to_kivy(0, 102, 0, 1) if event.evaluation else rgb_to_kivy(255, 0, 0, 1) # event_eval_text = 'Positive' if event.evaluation else 'Negative' # event_text = "{} [{}]".format(event.date.strftime("%d/%m/%y %H:%M:%S"), event_eval_text) event_text = event.date.strftime("%d/%m/%y %H:%M:%S") event_label = Label(text=event_text, font_size=70, color=label_color, size_hint=(1, 1)) event_rm_button = Button( text="-", font_size=50, size_hint=(.15, 1), background_normal='', background_color=rgb_to_kivy(255, 0, 0, 1) ) handle_rm_with_event = partial(self.handle_rm_event, event) event_rm_button.bind(on_release=handle_rm_with_event) event_layout.add_widget(event_label) event_layout.add_widget(event_rm_button) return event_layout
def on_pre_enter(self, *args): # Load relevant transactions transactions = self.network.hashgraph.get_relevant_transactions() # Create updated list def args_converter(row_index, rec): return { 'height': 60, 'markup': True, 'halign': 'center', 'text': rec['formatted'] } list_adapter = SimpleListAdapter(data=transactions, args_converter=args_converter, cls=Label) self.list_view = ListView(adapter=list_adapter, size_hint_y=8) self.ids.box_layout.add_widget(self.list_view, index=1)
def on_pre_enter(self, *args): members = self.network.hashgraph.known_members.values() members = [m for m in members if m != self.network.me] members.sort(key=lambda x: x.formatted_name) # Create updated list def args_converter(row_index, rec): return { 'height': 60, 'markup': True, 'halign': 'center', 'text': repr(members[row_index]), } list_adapter = SimpleListAdapter(data=members, args_converter=args_converter, cls=Label) self.list_view = ListView(adapter=list_adapter, size_hint_y=8) self.ids.box_layout.add_widget(self.list_view, index=1)
def __init__(self, auth_token, **kwargs): super(CloudCBScreen, self).__init__(**kwargs) self.header = {'Authorization': "Basic %s" % auth_token} self.url = SERVER_URI + 'copy-paste/' self.old_text = Clipboard.paste() self.cloud_clip = TextInput(text="Fetching...") layout = BoxLayout(orientation='vertical') layout.add_widget(Label(text='Cloud Clipboard')) layout.add_widget(Label(text='Current text on clipboard:')) layout.add_widget(self.cloud_clip) layout.add_widget(Button(text='Refresh', on_press=self.download)) layout.add_widget(Label(text='Earlier text on your clipboard:')) layout.add_widget(TextInput(text=self.old_text)) layout.add_widget(Button(text='Update Cloud Clipboard with this text', on_press=self.upload)) self.add_widget(layout) self.download()
def new_label(self): a_caption = 'Label' + '{:02d}'.format(self.count_objs) self.count_objs += 1 mypage.unilabel((40, 240, 80, 20, a_caption)) a_label = mypage.unilabels [-1] a_label.size_hint=(None,None) a_label.height = 20; if mypage.kivy: a_label.background_color = a_label.color a_label.bind(on_touch_down=self.touch_down) a_label.bind(on_touch_move=self.touch_move) else: a_label.touch_enabled = False a_label.pos = (a_label.x, a_label.y) a_label.color = a_label.background_color self.new_objs.append(a_label)
def set_info(self, data_to_write, x_hint_list, num_rows_to_add = 3): #Takes in the file data, and updates the Grid to represent #and indicate the files that are loaded with their metadata. if len(data_to_write) != self.cols: print('--Set info: Data mismatch error.') popup = Popup(title='Grid Error 02', content=Label(text = 'There was a problem in updating the grid.'), size_hint = (0.3, 0.3)) popup.open() else: threshold = 3 #If < threshold available rows left, add more if self._avail < threshold: self.create_grid(x_hint_list, num_rows_to_add) length = len(self.children) next_row = self.find_next_row() end = length - (next_row * self.cols) start = end - self.cols for i, widget in enumerate(reversed(self.children[start:end])): #strip text primarily for title and artist, so shorten #doesn't take into account the trailing whitespace widget.text = data_to_write[i].strip() self._avail -= 1
def load_audio_file(self, path): from kivy.core.audio import SoundLoader sound = SoundLoader.load(path) self._sound = sound if sound: update_bar_schedule = Clock.schedule_interval(self.update_bar, 1) self._update_bar_schedule = update_bar_schedule self.ids.p_bar.max = sound.length sound.volume = self.ids.volume_slider.value sound.play() else: print('Cannot play the file %s.' % path) error_msg = 'Cannot play the file %s.' % (path) if path else 'No file selected.' popup = Popup(title='Audio Error.', content=Label(text= error_msg), size_hint = (0.3, 0.3)) popup.open()
def build(self): floater = FloatLayout() logo = Image(source='AutoPen.png', pos_hint={'center_x': 0.5, 'center_y': .6}) spiderman = Label( text='[size=24][i]With Great Power comes Great Responsibility[/i][/size]', markup=True, pos_hint={'center_x': 0.5, 'center_y': .2}) enter = Button(text='enter', size_hint=(0.2,0.1), pos_hint={'center_x': 0.5, 'center_y': .1}) floater.add_widget(logo) floater.add_widget(spiderman) floater.add_widget(enter) return floater
def __init__(self, **kwargs): # inicializace super(PartylineScreen, self).__init__(**kwargs) self.root.insertStrings.append((self, "STR_PARTYLINE")) self.input = TextInput(size_hint=(.8, .07), pos_hint={'x':.08, 'y':.024}) self.output = Label(markup=True, font_name='font/Roboto-Regular.ttf', font_size='16dp', size_hint_y = None) self.SLayout = GridLayout(size_hint_y = None, cols=1, spacing=0) self.SLayout.bind(minimum_height=self.SLayout.setter('height')) self.scroll = ScrollView(size_hint=(1,.9), pos_hint={'center_x': .58, 'y': .125}, scroll_timeout=10000) self.scroll.do_scroll_x = False self.scroll.add_widget(self.SLayout) self.SLayout.add_widget(self.output) self.layout = RelativeLayout(size_hint=(.75, .83), pos_hint={'center_x': .437, 'y': .02}) self.send = DelButton(color=(1,1,1,0), text='SEND', size_hint=(None, .1), pos_hint={'x':.88, 'y':.022}, background_normal='crop/icons/send.png', background_down='crop/icons/send.png') self.send.bind(on_press=self.sendMsg) self.input.bind(focus=self.on_focus) self.layout.content.add_widget(self.scroll) self.layout.content.add_widget(self.input) self.layout.content.add_widget(self.send) self.add_widget(self.layout) if self.root.onAndroid(): self.LayouFocusOn = Animation(size_hint_y=.5, pos_hint={'center_x': .437, 'y': .38}, duration=.2) self.LayouFocusOut = Animation(size_hint_y=.83, pos_hint={'center_x': .437, 'y': .02}, duration=.2)
def on_release(self): label = Label(size_hint_y=None,size_hint_x=None) label.bind(texture_size=label.setter('size')) fob = open("help.txt") label.text = fob.read() fob.close() content = ScrollView(size_hint=(1,1)) content.add_widget(label) popup = Popup(title="Help",content=content,size_hint=(0.6,0.6)).open()
def build(self): # Resource tree creation root = resource.CoAPResource() well_known = resource.CoAPResource() root.putChild('.well-known', well_known) core = CoreResource(root) well_known.putChild('core', core) counter = MOTDResource(self, 0) root.putChild('motd', counter) endpoint = resource.Endpoint(root) reactor.listenUDP(coap.COAP_PORT, coap.Coap(endpoint)) # Kivy screen initialization self.label = Label(text="") self.display_counter(0) self.messagebox = TextInput(size_hint_y=.1, multiline=False) self.messagebox.text = "Message of the day" self.layout = BoxLayout(orientation='vertical', padding=10) self.layout.add_widget(self.label) self.layout.add_widget(self.messagebox) return self.layout
def on_enter(self): # when we add children to the grid layout, its size doesn't change at # all. we need to ensure that the height will be the minimum required # to contain all the childs. (otherwise, we'll child outside the # bounding box of the childs) self.ids.audioSidebar.bind(minimum_height=self.ids.audioSidebar.setter('height')) progress_bar = ProgressBar( value=0, size_hint= (0.5, None)) label = Label(text = 'Waiting', size_hint= (0.32, None)) label2 = Label(text='N/A%', size_hint= (0.18, None)) self.ids.audioSidebar.add_widget(label2) self.ids.audioSidebar.add_widget(progress_bar) self.ids.audioSidebar.add_widget(label) self.app.chat_client = HQCWSClient(self.app.config) self.app.chat_client.app = self.app self.app.chat_client.config = self.app.config # self.app.chat_client.send_sync(constants.SYN) # create a scroll view, with a size < size of the grid # root = ScrollView(size_hint=(None, None), size=(310, 460), # pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_x=False) # root.add_widget(audioClipLayout) # self.ids.audioSidebar.add_widget(root)
def on_enter(self): if self.app.config.get('ChatSettings', 'role') == "PRODUCER": files = self.app.get_own_state()['requested_files'] for file in files: label = Label(text=file, size_hint=(1 / len(files), None)) self.ids.filelayout.add_widget(label) elif self.app.config.get('ChatSettings', 'role') == "ARTIST": files = self.app.get_own_state()['requested_files'] if files: header_label = Label(text="Files being sent", size_hint=(1 / len(files), None), color=[0, 0, 0, 1]) self.ids.filelayout.add_widget(header_label) for file in files: full_path = self.app.config.get_file_name(self.app.session_name, file) self.app.chat_client.send_file(full_path) label = Label(text=file, size_hint=(1 / len(files), None), color=[0, 0, 0, 1]) self.ids.filelayout.add_widget(label) else: pass
def update_dialog(self, cur_build, upd_build): popup = Popup(title='Update', content=ScrollView(), size_hint=(0.8,None), height=cm(5)) grid = GridLayout(cols=1, spacing=0, size_hint_y=None) grid.bind(minimum_height= grid.setter('height')) con = StackLayout() grid.add_widget(con) popup.content.add_widget(grid) lbl1 = Label(text='Current build is %s' % (cur_build), size_hint_y=None, height=cm(1)) lbl2 = Label(text='Build %s available' % (upd_build), size_hint_y=None, height=cm(1)) btn1 = Button(text='Cancel', size_hint=(0.5, None), height=cm(1)) btn2 = Button(text='Update', size_hint=(0.5, None), height=cm(1)) btn1.bind(on_release=popup.dismiss) btn2.bind(on_release=lambda x: {self.update(), popup.dismiss()}) for x in (lbl1, lbl2, btn1, btn2): con.add_widget(x) popup.open()
def reg(args, n, p): if n == "Nickname.." or n == "": p = Popup(title='Login Error', content=Label(text="Digite seu apelido!", color=(1,0,0,1)),size_hint=(.6, .2)) p.open() elif p == "Password.." or p == "": p = Popup(title='Login Error', content=Label(text="Digite sua senha!", color=(1,0,0,1)),size_hint=(.6, .2)) p.open() else: # Tratando dados.. name = addslashes(n) pswd = addslashes(p) sql = "select * from users where nickname = '"+name+"'" rows = cur.execute(sql) if rows > 0: p = Popup(title='Login Error', content=Label(text="Este apelido esta em uso!", color=(1,0,0,1)),size_hint=(.6, .2)) p.open() else: sql = "insert into users (nickname, passwd, level, photo, online) values ('"+name+"', '"+pswd+"', 'Usuario', default, '0')" cur.execute(sql) con.commit() p = Popup(title='Cadastramento Concluído', content=Label(text=name+", Cadastrado com sucesso!", color=(0,1,0,1)),size_hint=(.6, .2)) p.open()
def do_login(self, loginText, passwordText): a = SnapDB() val = a.checkLogin(nickname=loginText, password=passwordText) userID = val[1] if val[1] != None: a = SnapDB() a.getUserData(userID) popup = Popup(title='Hola', content=Label(text='Hi '+localFiles.getLocalUserInfo()[2].split(" ")[0]+', happy snapchatting!'), size_hint=(None, None), size=(350, 200)) popup.open() self.manager.transition = SlideTransition(direction="left") self.manager.current = 'connected' else: popup = Popup(title='Error', content=Label(text='The password or username are incorrect. Try again.'), size_hint=(None, None), size=(350, 200)) popup.open() app = App.get_running_app() app.config.read(app.get_application_config()) app.config.write()
def checkSnapInbox(self): try: print("Looking for snaps...") a = Snap() namesFound = a.getImageName(localFiles.getLocalUserInfo()[0])[0] idsFound = a.getImageName(localFiles.getLocalUserInfo()[0])[1] if len(namesFound) == 0: popup = Popup(title='Oops!', content=Label(text='There are no new snaps for you, '+localFiles.getLocalUserInfo()[2].split(" ")[0]), size_hint=(None, None), size=(350, 200)) popup.open() else: for x in range(len(namesFound)): img = str(namesFound[x]).strip() ImageFunctions.showImg(img) a.updateSnapStatus(localFiles.getLocalUserInfo()[0]) except: print("ERROR")
def desktop_warning(self): layout = BoxLayout(orientation='vertical') layout.add_widget(Label(text='KivMob will not display ads on ' +\ 'nonmobile platforms. You must build an ' +\ 'Android project to demo ads. (iOS not yet ' +\ 'supported)', size_hint_y=1, text_size=(250, None), halign='left', valign='middle')) button_layout = BoxLayout() button1=Button(text="Open Build Steps", size_hint=(0.8, 0.2)) button1.bind(on_release = lambda x : webbrowser.open("https://www.google.com")) button_layout.add_widget(button1) button2=Button(text="Close", size_hint=(0.8, 0.2)) button2.bind(on_release = lambda x : popup.dismiss()) button_layout.add_widget(button2) layout.add_widget(button_layout) popup = Popup(title='KivMob Demo Alert', content=layout, size_hint=(0.9, 0.9)) popup.open()
def interstitial_warning(self): layout = BoxLayout(orientation='vertical') layout.add_widget(Label(text="Ad has not loaded. " +\ "Wait a few seconds and then " +\ "try again.", size_hint_y=1, text_size=(250, None), halign='left', valign='middle')) button_layout = BoxLayout() close=Button(text="Close", size_hint=(0.8, 0.2)) close.bind(on_release = lambda x : popup.dismiss()) button_layout.add_widget(close) layout.add_widget(button_layout) popup = Popup(title='KivMob Demo Alert', content=layout, size_hint=(0.9, 0.9)) popup.open()
def create_menu_buttons(self): """??????? ?????? ? ??????? ????.""" name_path_buttons_menu = { "JUNK FILES": "Data/Images/clean_cache.png", "MEMORY BOOST": "Data/Images/clean_memory.png", "APP MANAGER": "Data/Images/clean_apk.png", "SECURITY & PRIVACY": "Data/Images/clean_privacy.png"} for name_button in name_path_buttons_menu.keys(): item_box = BoxLayout(orientation="vertical") item_label = Label(text=name_button, color=[.1, .1, .1, 1]) item_button = \ ImageButton(source=name_path_buttons_menu[name_button], id=name_button, on_press=self.events_callback) item_box.add_widget(item_button) item_box.add_widget(item_label) self.ids.body_buttons_menu.add_widget(item_box)
def __init__(self, **kvargs): super(AboutDialog, self).__init__(**kvargs) if self.flag: self.background_box_content = [0.0, 0.0, 0.0, 1.0] box_content = self.ids.box_content height, avatar_size_hint = (60, (.05, .9)) if not self.flag \ else (120, (.1, 1)) 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 == "": box_content.add_widget(SettingSpacer()) continue info_string = \ Label(text=info_string, size_hint_y=None, font_size=self.base_font_size, markup=True, on_ref_press=self.events_callback) info_string.bind(size=lambda *args: self._update_label_size(args)) box_content.add_widget(info_string) if not self.flag: self.body_message = Popup( underline_color=self.underline_color, content=self, title=self.title_message, size_hint=(self.user_size_hint[0], self.user_size_hint[1]), pos_hint={"center_x": .5, "center_y": .5}, background=self.background_image, on_dismiss=self.dismiss_callback) self.body_message.open() else: refs = Label(text=self.refs, markup=True, size_hint=(1, .1)) refs.bind(on_ref_press=self.events_callback) self.add_widget(refs)
def __init__(self, **kvargs): super(ProgressLoad, self).__init__(**kvargs) self.orientation = "vertical" self.padding = 20 self.KProgress = kvargs.get("KProgress") self.label_one = Label(text="", size_hint=(1, .1), markup=True) self.label_two = Label(text="", size_hint=(1, .1), markup=True) self.progress_load = self.KProgress() self.button_cancel = \ Button(text="Cancel", on_press=self.events_callback, size_hint=(1, .2)) self.label_one.bind( size=lambda *args: self._update_text_size(args)) self.label_two.bind( size=lambda *args: self._update_text_size(args)) self.add_widget(self.label_one) self.add_widget(self.label_two) self.add_widget(Widget(size_hint=(None, .02))) self.add_widget(SettingSpacer()) self.add_widget(Widget(size_hint=(None, .02))) self.add_widget(self.progress_load) self.add_widget(Widget(size_hint=(None, .3))) self.add_widget(SettingSpacer()) self.add_widget(Widget(size_hint=(None, .02))) self.add_widget(self.button_cancel) self.progress_load.min = 0 self.progress_load.max = 100 self.progress_load.bar_value = 0 self.progress_load.spacing_widget = 2 self.progress_load.height_widget = 1 self.progress_load.color = "#ff7f32" self.progress_load.background_color = "#2fbfe0" self.progress_load.border_color = "#2fbfe0"
def build(self): return Label(text='Hello World')
def __init__(self, **kwargs): super(PopupLabel, self).__init__(**kwargs) scroller = AppScrollView() lbl = Label( size_hint_y=None, text_size=(scroller.width, None), text=self.text) scroller.bind(size=self._update_text_size) lbl.bind(texture_size=self._update_text_widget_size) scroller.add_widget(lbl) self.content, self.lbl = scroller, lbl
def __init__(self,**kwargs): super(WordUI, self).__init__(**kwargs) self.cols=2 #adding text label self.add_widget(Label(text="insert the words:")) #adding text Input self.letttersinput = TextInput(multiline=False) self.add_widget(self.letttersinput) #adding the action button self.add_widget(Button(text="Generate", on_press=self.game , pos=(50, 100)))
def __init__(self, **kwargs): super(LoginScreen, self).__init__(**kwargs) '''self.orientation = 'vertical' ### self.grid = GridLayout() self.grid.cols = 2 self.grid.add_widget(Label(text='User Name')) self.grid.username = TextInput(multiline=False) self.grid.add_widget(self.grid.username) self.grid.add_widget(Label(text='password')) self.grid.password = TextInput(multiline=False) self.grid.add_widget(self.grid.password) ### self.options = BoxLayout() self.options.size_hint_y = 0.5 self.options.bt_cancel = Button(text='Cancel') self.options.add_widget(self.options.bt_cancel) self.options.bt_login = Button(text='Login') self.options.bt_login.bind(on_press=self.bt_login_clicked) self.options.add_widget(self.options.bt_login) ### self.add_widget(self.grid) self.add_widget(self.options)''' ###
def bt_login(self): row = self.root_self.database.isValidLogin(self.username.text, self.password.text) if(row == None): content = Label(text = 'Username or Password incorrect!') popup = Popup( title = 'User Login', content = content, size_hint = (None, None), size = (400, 100) ) # open the popup popup.open() return # self.root_self.pos_system.setUserName(self.username.text) self.root_self.pos_system.setUserID(row[0]) self.root_self.database.registerLogs(self.root_self.pos_system.getUserID(), 0) # self.root_self.loadBarOptions() self.root_self.loadMainWindow() # self.root_self.a_price.label_price = Label(text = '0€') self.root_self.a_price.add_widget(self.root_self.a_price.label_price) # self.root_self.popup.dismiss() ###
def loadMainWindow(self, obj = None): self.atual_menu = 0 op_n = 1 mainOptions = [APPERTIZERS_NAME, MEAT_NAME, FISH_NAME, VEGAN_NAME, DRINKS_NAME, DESSERT_NAME] self.a_articles.clear_widgets() for op in mainOptions: button = Button(text=op) button.bind(on_press=self.openNewMenu) op_n = op_n + 1 self.a_articles.add_widget(button) for a in range(op_n-1, 9): self.a_articles.add_widget(Label(text='')) self.bt_next.enabled = False self.bt_previous.enabled = False if(self.pos_system.getBuyList() == None): self.bt_newlist.enabled = True self.bt_clearlist.enabled = False self.bt_finishlist.enabled = False self.menu_page = 0 ###
def openNewMenu(self, obj): op_n = 1 total_rows = 0 if obj != self.bt_next and obj != self.bt_previous: self.menu_type = obj.text.lower() cursor = self.database.loadArticles(self.menu_type, self.menu_page) self.a_articles.clear_widgets() for row in cursor: total_rows = total_rows + 1 if(total_rows > 9) : break button = Button(text=row[1]) button.bind(on_press=self.addToBuyList) button.item = Item(id_p = row[0], name = row[1], price = row[2], tax = 0.2) op_n = op_n + 1 self.a_articles.add_widget(button) for a in range(op_n-1, 9): self.a_articles.add_widget(Label(text='')) if(total_rows > 9): self.bt_next.enabled = True else: self.bt_next.enabled = False if(self.menu_page > 0): self.bt_previous.enabled = True else: self.bt_previous.enabled = False ###
def progbar(self): pb = ProgressBar() popup = Popup(title='Brute Forcing... Do NOT Close This Window!', content=pb, size_hint=(0.7, 0.3)) popup.open() time.sleep(2) pb.value = 25 time.sleep(4) pb.value = 50 time.sleep(6) pb.value = 75 time.sleep(8) pb.value = 100 popup = Popup(title="Password Not Found!",content=Label(text="Password Not Found in our dictionary, give it a try later"),size_hint=(0.7,0.3)) popup.open()
def do_action2(self, *args): if self.user_input2=='': # user enter no value popup = Popup(title="Profile Name Can't Be empty!",content=Label(text="Profile Name Format ie Hussam Khrais"),size_hint=(0.7,0.3)) popup.open() return threading.Thread(target=self.progbar).start() return
def progbar(self): pb = ProgressBar() popup = Popup(title='Searching in DB... Do NOT Close This Window!', content=pb, size_hint=(0.7, 0.3)) popup.open() time.sleep(2) pb.value = 25 time.sleep(4) pb.value = 50 time.sleep(6) pb.value = 75 time.sleep(8) pb.value = 100 popup = Popup(title="Password Not Found!",content=Label(text="Double check profile name OR try brute force option!"),size_hint=(0.7,0.3)) popup.open()
def do_action(self, *args): if self.user_input=='': # user enter no value popup = Popup(title="Profile Name Can't Be empty!",content=Label(text="Profile Name Format ie Hussam Khrais"),size_hint=(0.7,0.3)) popup.open() return threading.Thread(target=self.progbar).start() return
def _build_botton_box(self): botton_box = BoxLayout(orientation='vertical', spacing=10) self.total_label = Label(font_size=30, color=[0, 0, 0, 1], size_hint=(1, 1)) botton_box.add_widget(self.total_label) botton_box.add_widget(self._build_evaluation_box()) return botton_box
def _build_top_box(self): top_box = BoxLayout(orientation='vertical') self.positive_label = Label(text="0%", font_size=150, color=rgb_to_kivy(239, 93, 5, 1), size_hint=(1, 1)) top_box.add_widget(self._build_menu_and_reset()) top_box.add_widget(self.positive_label) return top_box
def display_BG(self, value): popup = Popup(title='BG', content=Label(text=value,font_size=25), size_hint=(None, None), size=(125, 125)) popup.bind(on_dismiss=self.dismiss_both) popup.open()
def __init__(self, **kwargs): super(LoginScreen, self).__init__(**kwargs) self.username_w = TextInput(multiline=False) self.password_w = TextInput(password=True, multiline=False) self.login_btn = Button(text='Login') self.login_btn.bind(on_press=self.login) layout = GridLayout() layout.cols = 2 layout.add_widget(Label(text='Username')) layout.add_widget(self.username_w) layout.add_widget(Label(text='Password')) layout.add_widget(self.password_w) layout.add_widget(self.login_btn) self.add_widget(layout)
def show_failure(self, req, res): if req.resp_status / 100 == 4: self.add_widget(Label(text='Invalid username/password. See readme to register.'))
def newFoodIns(self,delta): t = date.today() - timedelta(delta) try: realKcal = float(self.kcalInp.text)*float(self.portionInp.text) c.execute("INSERT INTO foods(name,date,kcal,portion) VALUES(?,?,?,?);", (self.foodInp.text,t,realKcal,int(self.portionInp.text))) db.commit() CalApp.updateJournal(delta) CalApp.sm.current = 'Root' except ValueError: invalid = Popup(title='Invalid entries', content=Label(text='Check your data and try again.'), size_hint=(None, None),size=('250dp','150dp')) invalid.open()
def setup2(self): try: CalApp.inp = [self.nameInp.text.strip(' \t\n\r'), float(self.heightInp.text), float(self.weightInp.text),int(self.yearsInp.text), self.genderChoice] CalApp.sm.current='Profile2' except (TypeError,ValueError) as e: invalid = Popup(title='Invalid entries', content=Label(text='Check your data and try again.'), size_hint=(None, None),size=('250dp','150dp')) invalid.open()
def unilabel(self, params): self.unilabels.append([]) if self.kivy: from kivy.uix.label import Label self.unilabels[len(self.unilabels) - 1] = Label(pos = \ (params[0] * self.xratio, params[1] * self.yratio), \ size_hint=(1.0,1.0), halign="left", \ valign="bottom", text = params[4]) self.unilabels[len(self.unilabels) - 1].font_size = 17.5 * \ self.yratio self.unilabels[len(self.unilabels) - 1].bind(size= \ self.unilabels[len(self.unilabels) - 1].setter('text_size')) self.root.add_widget(self.unilabels[len(self.unilabels) - 1]) else: import ui self.unilabels[len(self.unilabels) - 1] = ui.Label(frame= \ (params[0] * self.xratio, (600 - params[1] - params[3]) * \ self.yratio, params[2] * self.xratio, params[3] * self.yratio)) self.unilabels[len(self.unilabels) - 1].text = params[4] self.unilabels[len(self.unilabels) - 1].text_color = 'white' self.unilabels[len(self.unilabels) - 1].alignment = \ ALIGN_LEFT = True self.unilabels[len(self.unilabels) - 1].font = ('<system>', 18 * \ self.xratio) self.root.add_subview(self.unilabels[len(self.unilabels) - 1])
def unilabel(self, params): self.unilabels.append([]) if self.kivy: from kivy.uix.label import Label self.unilabels[len(self.unilabels) - 1] = Label(pos = \ (params[0] * self.xratio, params[1] * self.yratio), \ size_hint=(1.0,1.0), halign="left", \ valign="bottom", text = params[4]) self.unilabels[len(self.unilabels) - 1].font_size = 17.5 * \ self.yratio self.unilabels[len(self.unilabels) - 1].bind(size= \ self.unilabels[len(self.unilabels) - 1].setter('text_size')) self.root.add_widget(self.unilabels[len(self.unilabels) - 1]) else: import ui self.unilabels[len(self.unilabels) - 1] = ui.Label(frame= \ (params[0] * self.xratio, (600 - params[1] - params[3]) * \ self.yratio, params[2] * self.xratio, params[3] * self.yratio)) self.unilabels[len(self.unilabels) - 1].text = params[4] self.unilabels[len(self.unilabels) - 1].text_color = 'white' self.unilabels[len(self.unilabels) - 1].alignment = \ ui.ALIGN_LEFT self.unilabels[len(self.unilabels) - 1].font = ('<system>', 18 * \ self.yratio) self.root.add_subview(self.unilabels[len(self.unilabels) - 1])
def edit_row(self, index, data_to_write): if len(data_to_write) != self.cols: print('--Edit Row: Data mismatch error.') popup = Popup(title='Grid Error 01', content=Label(text = 'There was a problem in updating the grid.'), size_hint = (0.3, 0.3)) popup.open() else: end = len(self.children) - (index * self.cols) start = end - self.cols #Update the selected file's info too. if self.children[start].text == self._sel_file: self._sel_file = data_to_write[-1] for i, widget in enumerate(reversed(self.children[start:end])): widget.text = data_to_write[i].strip()