def on_long_press(self): files = os.listdir( os.path.join(os.getcwd(), load_config()["device_path"])) if any([x.endswith('tmp') for x in files]): print('COFAM') day = self.parent.parent.ids.date.dp.text.split(',')[1][1:] data = Data(filename=datename(day)) with open(data.tmp_path, 'r') as f: lines = json.load(f) if len(lines) > 1: with open(data.tmp_path, 'w') as f: json.dump(lines[:-1], f) else: os.remove(data.tmp_path) pop = Popup() pop.title = 'Komunikat' pop.separator_height = 0 pop.size_hint = (.5, .4) pop.content = Button(text='Operacja cofnięta') pop.content.bind(on_press=pop.dismiss) pop.open() else: pop = Popup() pop.title = 'Komunikat' pop.separator_height = 0 pop.size_hint = (.6, .2) pop.content = Button(text='Brak nowych wpisów') pop.content.bind(on_press=pop.dismiss) pop.open()
def locked_pop_up(self): #A LOT OF LITERAL from kivy.uix.label import Label myBox=BoxLayout() myBox.orientation='vertical' myLabel=Label() myLabel.text='Clear previous stage\nto unlock this level' myLabel.valign='middle' myLabel.halign='center' button=Button() button.text='Dismiss' button.size_hint_y=0.3 myBox.add_widget(myLabel) myBox.add_widget(button) popUp=Popup() popUp.title='Level locked' popUp.content=myBox popUp.size_hint=(0.7,0.5) button.bind(on_release=popUp.dismiss) return popUp
def PopupAudit(audit_obj, key): def on_close(*args): def _on_close(*args): Window.rotation = 0 Clock.schedule_once(_on_close, .25) assert isinstance(audit_obj, AuditResult) or audit_obj is None if audit_obj is None: text = "No audit attribute found for %s" % key else: text = str(audit_obj) btnclose = Button(text='Continue', size_hint_y=None, height='50sp') content = BoxLayout(orientation='vertical') ## lbl = TextInput(text=text, font_size='12sp', auto_indent=True, ## readonly=True, disabled=True, ## font_name='fonts'+os.sep+'DroidSansMono.ttf') lbl = ScrollableText(text=text) content.add_widget(lbl) content.add_widget(btnclose) p = Popup(title='Audit of "%s"' % key, content=content, #size=('300dp', '300dp'), size_hint=(.95, .75)) btnclose.bind(on_release=p.dismiss) p.bind(on_open=lbl.go_top) # See if this is a pretty long audit, so we will display long ways if max([len(a) for a in text.split('\n')]) > 30: p.bind(on_dismiss=on_close) and None p.size_hint = (.95, .95) Window.rotation = 90 p.open()
def expand_query_search(self): # Get expanded query query_str = self.ids['search_query_input'].text query_expanded = expand_query(query_str, self.model_selected) query = self.vsm_models[self.corpus_selected].to_vector( query_str) if self.model_selected == 'vsm' else query_str # Buttons for options yes_btn = Button(text='Expanded', on_press=partial(self.search, query_expanded, query_str)) no_btn = Button(text='Original', on_press=partial(self.search, query, query_str)) # Popup box_layout = BoxLayout(orientation='horizontal') box_layout.add_widget(yes_btn) box_layout.add_widget(no_btn) query_expansion_popup = Popup() query_expansion_popup.add_widget(box_layout) query_expansion_popup.title = str(query_expanded) query_expansion_popup.title_align = "center" query_expansion_popup.size_hint = None, None query_expansion_popup.size = 800, 400 query_expansion_popup.open() return
def open_not_implemented(self, log, pop_width, pop_height): pop = Popup(title=lang['Not_yet_implemented']) pop.size_hint = None, None pop.width = pop_width pop.height = pop_height pop.content = Label(text=logNot[log]) pop.open()
def achievement_popUp(self): #MUST BE CALLED AFTER CALLING self.achievement_update() above myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() myLabel.text = self.achievement_update() myLabel.size_hint_y = len(ArtInfo.fanpage_url) * 0.07 myScroll = ScrollView() myScroll.add_widget(myLabel) button = Button() button.text = 'Dismiss' button.size_hint_y = 0.15 myBox.add_widget(myScroll) myBox.add_widget(button) popUp = Popup() popUp.title = 'Highest scores' popUp.content = myBox popUp.size_hint = (0.9, 0.8) button.bind(on_release=popUp.dismiss) popUp.open()
def are_you_sure_exit(self): myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() myLabel.text = 'Are you sure\nyou wanna exit the game?' button = Button() button.text = 'No' button.size_hint_y = 0.2 button1 = Button() button1.text = 'Yes' button1.size_hint_y = 0.2 bar = Widget() bar.size_hint_y = 0.02 myBox.add_widget(myLabel) myBox.add_widget(button1) myBox.add_widget(bar) myBox.add_widget(button) popUp = Popup() popUp.title = 'Exiting the game' popUp.content = myBox popUp.size_hint = (0.8, 0.8) button.bind(on_release=popUp.dismiss) button1.bind(on_release=self.exit_application) return popUp
def unvailable_feature_popUp_creator(self): #I WILL MAKE THE FEATURES SIMPLE UNAVAILABLE FOR NOW myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() myLabel.text = 'This feature will be\navailable in future version' button = Button() button.text = 'Dismiss' button.size_hint_y = 0.3 myBox.add_widget(myLabel) myBox.add_widget(button) popUp = Popup() popUp.title = 'Feature not yet available' popUp.content = myBox popUp.size_hint = (0.8, 0.5) button.bind(on_release=popUp.dismiss) return popUp
def disrupt_game_popUp(self): myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() myLabel.text = 'This will quit the current game.\nAre you sure?' button1 = Button() button1.text = 'Yes' button1.size_hint_y = 0.2 button2 = Button() button2.text = 'No' button2.size_hint_y = 0.2 bar = Widget() bar.size_hint_y = 0.02 myBox.add_widget(myLabel) myBox.add_widget(button1) myBox.add_widget(bar) myBox.add_widget(button2) popUp = Popup() popUp.title = 'Stop the game?' popUp.content = myBox popUp.size_hint = (0.9, 0.8) popUp.auto_dismiss = False #button.bind(on_release=popUp.dismiss) button1.bind(on_release=self.disrupt_yes) button2.bind(on_release=self.disrupt_no) return popUp
def state_goal_popUp(self): myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() if ArtInfo.max_score[self.puzzle_index] != None: myLabel.text = 'Reach score of ' + str( self.goal) + '\nto unlock next stage.\n\ Maximum score: ' + str(ArtInfo.max_score[self.puzzle_index]) else: myLabel.text = 'Reach score of ' + str( self.goal) + '\nto unlock next stage.\n\ Maximum score: unlimtied' button = Button() button.text = 'Ok!' button.size_hint_y = 0.3 myBox.add_widget(myLabel) myBox.add_widget(button) popUp = Popup() popUp.title = 'Mission' popUp.content = myBox popUp.size_hint = (0.8, 0.5) popUp.auto_dismiss = False button.bind(on_release=self.start_timing_press) return popUp
def game_over_popUp(self): myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() myLabel.text = 'Your score: ' + str( self.score) + '\nHighest score: ' + str(self.highest_score) if self.critical: myLabel.text = myLabel.text + '\nYou must score at least ' + str( self.goal) + '\nto unlock next level' button = Button() button.text = 'Ok' button.size_hint_y = 0.3 myBox.add_widget(myLabel) myBox.add_widget(button) popUp = Popup() popUp.title = 'Result: Level ' + str(self.puzzle_index + 1) popUp.content = myBox popUp.size_hint = (0.8, 0.5) popUp.auto_dismiss = False button.bind(on_release=self.reset_timer) self.game_over_message_popUp = popUp self.game_over_message_popUp.open()
def artist_unavailable_popUp(self): #MOVE THESE TO SOMEWHERE BETTER myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() myLabel.text = 'Artist fanpage is\nunavailable at this time' button = Button() button.text = 'Dismiss' button.size_hint_y = 0.3 myBox.add_widget(myLabel) myBox.add_widget(button) popUp = Popup() popUp.title = 'Level locked' popUp.content = myBox popUp.size_hint = (0.5, 0.5) popUp.auto_dismiss = False button.bind(on_release=popUp.dismiss) popUp.open()
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_popup(popup_title, size_x, size_y, layout, title_size): popup = Popup(title=popup_title) popup.size_hint = (size_x, size_y) popup.content = layout popup.title_size = title_size popup.title_align = 'center' popup.auto_dismiss = False return popup
def save(self, instance): if filepath == "": p = Popup(title="Warning") p.size_hint = 0.5,0.5 lay = BoxLayout(orientation=VERTICAL) lay.add_widget(Label(text="Please Open A file first!")) lay.add_widget(Button(text="Ok", on_press=lambda instance: p.dismiss())) p.add_widget(lay) p.open() else: code = l.text with open(filepath,"w") as fp: fp.write(code) p = Popup(title="Success") p.size_hint = 0.5,0.5 lay = BoxLayout(orientation=VERTICAL) lay.add_widget(Label(text="File Saved!")) lay.add_widget(Button(text="Ok", on_press=lambda instance: p.dismiss())) p.add_widget(lay) p.open()
def open_popup_new_dir(self, path): poupup = Popup(content=PopupNewDir(make_new_dir=self.make_new_dir)) poupup.title = lang['New_Folder'] poupup.title_size = 16 poupup.size_hint = None, None poupup.height = 120 poupup.width = 250 poupup.id = 'pop_new_dir' self.ids['pop_new_dir'] = poupup global path_new_dir self.path_new_dir = path poupup.open()
def open_popup_new_dir(self,path): poupup = Popup(content=PopupNewDir(make_new_dir=self.make_new_dir)) poupup.title = lang['New_Folder'] poupup.title_size = 16 poupup.size_hint = None, None poupup.height = 120 poupup.width = 250 poupup.id = 'pop_new_dir' self.ids['pop_new_dir'] = poupup global path_new_dir self.path_new_dir = path poupup.open()
def view_art_popUp(self): myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() if self.critical: myLabel.text = 'You have completed the puzzle!\n\nNote: You must win with timer\nto unlock next level' else: myLabel.text = 'You have completed the puzzle!' if self.artist != None and self.artist != 'flickr': button = Button() button.text = 'More arts by ' + self.artist button.size_hint_y = 0.2 button.bind(on_release=self.open_fanpage) button1 = Button() button1.text = 'View full image' button1.size_hint_y = 0.2 button2 = Button() button2.text = 'Replay' button2.size_hint_y = 0.2 bar = Widget() bar.size_hint_y = 0.02 bar2 = Widget(size_hint_y=0.02) myBox.add_widget(myLabel) myBox.add_widget(button1) myBox.add_widget(bar) if self.artist != None and self.artist != 'flickr': myBox.add_widget(button) myBox.add_widget(bar2) myBox.add_widget(button2) popUp = Popup() popUp.title = 'You won!' popUp.content = myBox popUp.size_hint = (0.9, 0.8) popUp.auto_dismiss = False #button.bind(on_release=popUp.dismiss) button1.bind(on_release=self.view_image) button2.bind(on_release=self.re_play) return popUp
def no_data_popup(self): pop = Popup(title='Data status', auto_dismiss=False) lbl = Label() lbl.text = 'No Data!. Add some transactions' btn = MDIconButton() lbl.pos_hint = {'center_x': .5, 'center_y': .5} btn.icon = 'home' btn.bind(on_press=self.go_home) btn.md_bg_color = (1, 1, 1, 1) btn.pos_hint = {'center_x': .5, 'center_y': 0.1} layout = FloatLayout() layout.add_widget(lbl) layout.add_widget(btn) pop.content = layout pop.size_hint = .8, .6 return pop
def get_popup(self): pop = Popup(title='Transaction status', auto_dismiss=False) lbl = Label() lbl.text = 'Update successful' btn = MDIconButton() lbl.pos_hint = {'center_x': .5, 'center_y': .5} btn.icon = 'home' btn.bind(on_press=self.go_home) btn.md_bg_color = (1, 1, 1, 1) btn.pos_hint = {'center_x': .5, 'center_y': 0.1} from kivy.uix.floatlayout import FloatLayout layout = FloatLayout() layout.add_widget(lbl) layout.add_widget(btn) pop.content = layout pop.size_hint = .6, .6 return pop
def showAssetSelector(self): """renders the root grounds in the treeview.""" try: popup = Popup(title="select asset") popup.size_hint = (0.8, 0.8) tv = TreeView(root_options=dict(text='Tree One'), hide_root=True, indent_level=4) tv.size_hint = 1, None tv.bind(minimum_height=tv.setter('height')) tv.load_func = self.populateTreeNode tv.bind(selected_node=self.on_assetChanged) root = ScrollView(pos=(0, 0)) root.add_widget(tv) popup.add_widget(root) popup.open() except Exception as e: showError(e)
def createParentTask(self,name,description,duration, deadline): self.task.name = name self.task.description = description self.task.duration = int(duration) self.task.deadline = deadline Task.updateTask(self.task) self.clear_widgets() print('app is running') popup = Popup(title='You have created a new task!',auto_dismiss=False) popup.size_hint = 0.25,0.25 content = Button(text='Close me!',size_hint_y = .10) popup.add_widget(content) # bind the on_press event of the button to the dismiss function content.bind(on_press=popup.dismiss) popup.open()
def Network_PlayerInit(self, data): self.player_id = data['id'] connection.Send({"action": "loby_list"}) def confirm(name, p): connection.Send({"action": "nickname", "nickname": name}) self.nickname = name p.dismiss() p = Popup(auto_dismiss=False) p.size_hint = (None, None) p.size = (420 / density_ratio, 180 / density_ratio) p.title = "Choose a nickname" box = BoxLayout(size_hint_y=None, height=60 / density_ratio) nickname_input = TextInput(multiline=False) confirm_btn = ThemedButton(text="Confirm", on_press=lambda btn: confirm(nickname_input.text, p), size_hint_x=None, width=120 / density_ratio) box.add_widget(nickname_input) box.add_widget(confirm_btn) p.add_widget(box) p.open()
def export_data(self, *args, **kwargs): data_dict = self.asistance data = self.transform_data_dict(data_dict) data.sort() today = datetime.now() export_dir = self._app_dir() string_today = today.strftime("%d_%m_%y_%X") outfile = open(f"{export_dir}/download/asistance{string_today}.csv", "w", newline="") writer = csv.writer(outfile) writer.writerows(map(lambda x: [x], data)) outfile.close() box = BoxLayout(orientation='vertical') box.add_widget( Label(text=f"""Tu archivo se encuentra en {export_dir}/download """)) popup = Popup(auto_dismiss=True, content=box) popup.title = "Exportación correcta" popup.size_hint = (.8, 0.2) popup.open()
def max_score_reached_popUp(self): myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() myLabel.text = 'Maximum score possible reached\nUnlimited score is allowed in\nhigh level stages' button = Button() button.text = 'Dismiss' button.size_hint_y = 0.3 myBox.add_widget(myLabel) myBox.add_widget(button) popUp = Popup() popUp.title = 'Max score for level reached' popUp.content = myBox popUp.size_hint = (0.9, 0.5) popUp.auto_dismiss = False button.bind(on_release=self.handle_max_reached) return popUp
def get_content(): global popup p = Popup() label = Label() text = ''' BSE prices are not available now. Possibly b/c it is a holiday. Or may beb/c you are running this app for the first time on a market holiday If your holdings have BSE only stocks, the NAV will be off. This will resolve itself after 17:00 hrs on the next trading day ''' label.text = text p.content = label p.size_hint = (0.8, 0.8) popup = p
def show_search_result_popup(self, instance) -> None: """ Open a popup for clicked on search result to show entire search result body """ docID = instance.text.split("-")[0].strip() if self.corpus_selected == "reuters": docID = int(docID) doc = get_corpus_texts(self.corpus_selected, [docID]).iloc[0] title = doc["title"] body = doc["body"] # Popup search_result_popup = Popup() search_result_popup.title = f"{docID} - {title}" search_result_popup.title_align = "center" search_result_popup.size_hint = None, None search_result_popup.size = 1400, 800 label = Label(text=textwrap.fill(body, 170)) # label_scroll = ScrollableLabel() # label_scroll.text = body # label_scroll.size_hint_y = None # label_scroll.height = 500 # label_scroll.text_size = 200, None # search_result_popup = Popup( # title=f"{docID} - {title}", # content=label_scroll, # size_hint=(None, None), # size=(600, 600) # ) search_result_popup.add_widget(label) search_result_popup.open() return
def hataGoster(self, hata): icerik = Label(text=hata, markup=True) popup = Popup(title='Yapamadım !', content=icerik) popup.size_hint = (0.7, 0.7) icerik.bind(on_touch_down=popup.dismiss) popup.open()
def open_command_popup(self): box = BoxLayout(orientation='vertical') box.add_widget(Button(text='MOVE', on_press=partial(self.define_button, CommandMove))) popup = Popup(title='Commands', content=box) popup.size_hint = (0.2, 0.8) popup.open()
txt_valor = TextInput() txt_valor.multiline = False txt_valor.hint_text = 'Valor (exemplo: 1,99)' bt_pop = Button(text='Ok') pop_layout.add_widget(txt_nome) pop_layout.add_widget(txt_cidade) pop_layout.add_widget(txt_numpedido) pop_layout.add_widget(txt_pedido) pop_layout.add_widget(txt_valor) pop_layout.add_widget(bt_pop) pop = Popup() pop.size_hint = 0.8, 0.7 pop.title = 'Novo registro' pop.content = pop_layout #========================================================= # addWidgets dos box box_label.add_widget(label) box_resumo.add_widget(lb_resumo) box_resumo.add_widget(lb_cidade) box_resumo.add_widget(lb_nuped) box_resumo.add_widget(lb_data) box_resumo.add_widget(lb_valor) box_meio.add_widget(box_check) box_check.add_widget(ch_plastico)
def GameOver(): ''' This function is called when the clock ran out and the game ends. The user is Propmted for their name, and it's entered in the high score file and list if it is among the top 5 scores. The top five scores are displayed. Highscores are written to a file named high_scores.txt, if there doesn't exist one one is created. ''' try: # check that data is initialized GameOver.input_text except AttributeError: # initialize data GameOver.input_text = None GameOver.score_list = [] # update board status and animations _Board._highlighted.clear() Clock.unschedule(_Board.game_timer.tile_drop) _Board.game_timer.cover_timer = -1 _Board.tile_cover.pos = -5000, -5000 _Board.manager.transition = RiseInTransition(duration=.5) _Board.manager.current = 'menu' # create the popup prompt for user name box = BoxLayout() text_in = TextInput(multiline = False, font_size = 40) box.add_widget(text_in) popup = Popup(title='Enter Your Name') popup.content = box popup.auto_dismiss = False popup.size_hint = (None, None) popup.size=(550, 120) # go to last screen when user presses 'enter' text_in.on_text_validate = LastScreen GameOver.input_text = text_in GameOver.input_text.popup = popup # Read in highscore file of 5 highest scores must end with newline try: file = open('high_scores.txt', 'r') for line in file: line = line.strip().split(",") line[1] = ' '.join(line[1].split()) try: GameOver.score_list.append((line[0],line[1])) except: # if blank line do nothing continue file.close() except: # Do nothing if no file or empty line pass # THIS SHOULDN'T HAPPEN, but if the highscore file ended up # with more than 5 things in it, we will rewrite the new one to have 5 # by removing lowest scores while(len(GameOver.score_list)>5): GameOver.score_list.pop(0) # IF LIST LESS THAN 5 RECORDS LONG THEN FILL IT WITH EMPTIES while(len(GameOver.score_list)<5): GameOver.score_list = [(0, 'No Record Yet')] + GameOver.score_list popup.open()
def showError(self, text): content=Label(text=text, markup=True) popup = Popup(title=_('Warning !'), content=content) popup.size_hint = (0.7,0.7) popup.open()
code = l.text with open(filepath,"w") as fp: fp.write(code) p = Popup(title="Success") p.size_hint = 0.5,0.5 lay = BoxLayout(orientation=VERTICAL) lay.add_widget(Label(text="File Saved!")) lay.add_widget(Button(text="Ok", on_press=lambda instance: p.dismiss())) p.add_widget(lay) p.open() def runP(self, instance): """if you want to use python to execute code!""" if filepath == "lol": p = Popup(title="Warning") p.size_hint = 0.5,0.5 lay = BoxLayout(orientation=VERTICAL) lay.add_widget(Label(text="Please Open A file first!")) lay.add_widget(Button(text="Ok", on_press=lambda instance: p.dismiss())) p.add_widget(lay) p.open() else: path = filepath try: result = os.popen(f"py {path}") except Exception as e: result = repr(e) codeout.text = result def change(self,x): self.wm.current = x
def hataGoster(self, hata): icerik=Label(text=hata, markup=True) popup = Popup(title='Yapamadım !', content=icerik) popup.size_hint = (0.7,0.7) icerik.bind(on_touch_down=popup.dismiss) popup.open()