def show_color_select_popup(self, title, content): popup = Popup(title="Warning Color", content=content, size_hint=(0.4, 0.6)) popup.bind(on_dismiss=self.popup_dismissed) popup.open() self._popup = popup
def mod_sc(self, btn, path, ids, state): for x in range(0, len(Active.scanList)): if path is Active.scanList[x].path: tmp = Active.scanList[x] break if ids is 'is_temp': Active.scanList[x].is_temp = 1 if state is 'down' else 0 Active.scanList[x].options['CL_TEMP'] = 1 if state is 'down' else '0' else: Active.scanList[x].options[ids] = '1' if state is 'down' else '0' if ids is 'BACKUP' and state is 'down': Active.scanList[x].options['DEL_F_SIZE'] = '0' elif ids is 'DEL_F_SIZE' and state is 'down': Active.scanList[x].options['BACKUP'] = '0' elif ids is 'BACKUP_OLD' and state is 'down': Active.scanList[x].options['DEL_F_OLD'] = '0' elif ids is 'DEL_F_OLD' and state is 'down': Active.scanList[x].options['BACKUP_OLD'] = '0' try: Active.scan_task.mod_from_scan(Active.client, path, Active.scanList[x].get_options(), Active.scanList[x].is_temp) except ScanException as se: popup = Popup(size_hint=(None, None), size=(500, 150)) popup.add_widget(Label(text=se.value)) popup.bind(on_press=popup.dismiss) popup.title = se.title popup.open() btn.state = 'normal' if state is 'down' else 'down' Active.scanList[x] = tmp return
def my_popup(self): """ Функция для определения поведения и внешнего вида всплывающих окон. """ global tasks word = random.choice(tasks) popup = Popup(title='Задание', content=Label(text=word, text_size=(200, None), shorten_from='right'), size_hint=(0.8, 0.7), separator_color=[0.96, 0.56, 0, 1], title_color=[0.36, 0.54, 0.66, 1]) def my_callback2(instance): """ Функция для определения поведения всплывающего окна при его закрытии. """ view = ModalView() view.dismiss(force=True) self.logic() return False popup.bind(on_dismiss=my_callback2) popup.open()
def doGiveDrink(self, drink, intervaltime): root = BoxLayout(orientation='vertical') content = Label(text='Take a break\nYour \n' + self.drinkOnScreen[drink]["name"] + '\nwill be mixed.', font_size='40sp') root.add_widget(content) popup = Popup( title='Life, the Universe, and Everything. There is an answer.', content=root, auto_dismiss=False) def makeDrink(parentwindow): drinks = self.drinkOnScreen[drink] hector = HectorHardware(config) for ingridient in drinks["recipe"]: hector.valve_dose(pumpList[ingridient[0]], ingridient[1]) time.sleep(.1) print("IndexPumpe: ", pumpList[ingridient[0]]) print("Ingredient: ", ingridient[0]) print("Output in ml: ", ingridient[1]) self.db.countUpIngredient(ingridient[0], ingridient[1]) time.sleep(1) self.db.countUpDrink(drinks["name"]) hector.finger(1) hector.ping(3) hector.finger(0) print(drinks["name"]) parentwindow.dismiss() popup.bind(on_open=makeDrink) popup.open()
class MyWidget(Widget): progress_bar = ObjectProperty() def __init__(self, **kwa): super(MyWidget, self).__init__(**kwa) self.progress_bar = ProgressBar() self.popup = Popup(title='Download', content=self.progress_bar) self.popup.bind(on_open=self.puopen) self.add_widget(Button(text='Download', on_release=self.pop)) # the function which works when you clicj = k the button def pop(self, instance): self.progress_bar.value = 1 self.popup.open() # To continuesly increasing the value of pb. def next(self, dt): if self.progress_bar.value >= 100: return False self.progress_bar.value += 1 # def puopen(self, instance): Clock.schedule_interval(self.next, 1 / 25)
class Add_debris_select(BoxLayout): debris_id = ObjectProperty(None) get_debris_id = ObjectProperty(None) debris_type = ObjectProperty(None) get_debris_type = ObjectProperty(None) debris_weight = ObjectProperty(None) get_debris_weight = ObjectProperty(None) debris_lat = ObjectProperty(None) get_debris_lat = ObjectProperty(None) debris_long = ObjectProperty(None) get_debris_long = ObjectProperty(None) add_debris_to_db = ObjectProperty(None) def __init__(self,**kwargs): super(Add_debris_select,self).__init__(**kwargs) def on_back(self): self.parent.parent.transition.direction = 'left' self.parent.parent.current = 'display_database' def on_dismiss(self, arg): pass def not_full_info(self,event): self.popup = Popup(title= "Information", content = Info_Pop(), size_hint=(None, None), size=(self.width/2, self.height/2)) self.popup.bind(on_dismiss = self.on_dismiss) self.popup.open()
class Dates(GridLayout): now = datetime.datetime.now() def __init__(self, **kwargs): super(Dates, self).__init__(**kwargs) self.cols = 7 self.c = calendar.monthcalendar(2015, 5) for i in self.c: for j in i: if j == 0: self.add_widget( Button(on_release=self.on_release, text='{j}'.format(j=''))) else: self.add_widget( Button(on_release=self.on_release, text='{j}'.format(j=j))) def get_month(self): pass def on_dismiss(self, arg): # Do something on close of popup pass def on_release(self, event): print "date clicked :" + event.text event.background_color = 1, 0, 0, 1 self.popup = Popup(title="Set Reminder :", content=Reminder(), size_hint=(None, None), size=(self.width * 3 / 4, self.height)) self.popup.bind(on_dismiss=self.on_dismiss) self.popup.open()
def play_on_enter(self, vidname): self.vid = VideoPlayer(source=vidname, state='play', options={'allow_stretch':False, 'eos': 'loop'}) popup = Popup(title=vidname, content=self.vid) popup.bind(on_dismiss=lambda x:self.stop_video()) popup.open()
def on_edit(self): channel = self.channel popup = Popup(title = 'Edit System Channel' if channel.systemChannel else 'Edit Channel', content = ChannelEditor(channel = channel), size_hint=(None, None), size = (dp(500), dp(180))) popup.open() popup.bind(on_dismiss=self.on_edited)
class MyPopupProgressBar(Widget): # Kivy properties classes are used when you create an EventDispatcher. progress_bar = ObjectProperty() def __init__(self, **kwa): # super combines and initializes two widgets Popup and ProgressBar super(MyPopupProgressBar, self).__init__(**kwa) self.progress_bar = ProgressBar() # instance of ProgressBar created. # progress bar assigned to popup self.popup = Popup(title='Barra de progresso', content=self.progress_bar) self.popup.bind(on_open=self.puopen) # Binds super widget to on_open. # Uses clock to call progress_bar_start() (callback) one time only Clock.schedule_once(self.progress_bar_start) # Provides initial value of of progress bar and lanches popup def progress_bar_start(self, instance): self.progress_bar.value = 1 # Initial value of progress_bar self.popup.open() # starts puopen() def next(self, dt): # Updates Project Bar global exitFlag global progress if exitFlag: # Checks to see if progress_bar.value has met 100 return False # Returning False schedule is canceled and won't repeat self.progress_bar.value = progress # Updates progress_bar's progress def puopen(self, instance): # Called from bind. # Creates Clock event scheduling next() every 5-1000th of a second. Clock.schedule_interval(self.next, .0005)
class Editor(App): text = StringProperty() filename = StringProperty() def __init__(self, **kwargs): super().__init__(**kwargs) self.io = IO() self.keyboard = Window.request_keyboard(lambda *_: _, self) self.keyboard.bind(on_key_down=self.on_key) def convert(self, text): with open('__', 'w+') as f: pass result = os.system('echo | pandoc -f rst -t markdown __') print(result) def on_key(self, _, code, text, modifiers): if 'ctrl' in modifiers and text == 's': if not self.filename: self.popup = Popup(content=Factory.FileNamePopup()) self.popup.bind(on_dismiss=lambda *_: self.io.save( self.filename, self.text)) self.popup.open() return self.io.save(self.filename, self.root.ids['rst_code'].textinput.text)
def getdir(self): fc = FileChooserListView(path=self.pPath) p = Popup(title='Open Directory/Folder', content=fc, size_hint=(0.5, 0.5)) p.bind(on_dismiss=lambda x: self.setDir(fc.path)) p.open()
def popup_message(self, msg, title="Welcome!"): popup = Popup(title=title, content=Label(text=msg), size=(435, 100), size_hint=(None, None)) popup.bind(on_dismiss=self.reset_game) popup.open()
def update_list(self): try: Active.qrList = Active.qr_task.get_qr_list(Active.client) except QrException as qr: popup = Popup(size_hint=(None, None), size=(400, 150)) popup.add_widget(Label(text=qr.value)) popup.bind(on_press=popup.dismiss) popup.title = qr.title popup.open() return except EmptyListException as ee: global empty if empty is 0: empty = 1 popup = Popup(size_hint=(None, None), size=(400, 150)) popup.add_widget(Label(text=ee.value)) popup.bind(on_press=popup.dismiss) popup.title = ee.title popup.open() finally: self.qrdata.clear() for x in range(0, len(Active.qrList)): self.qrdata.append({ 'filename': Active.qrList[x].f_name, 'old_path': Active.qrList[x].o_path }) self.list_adapter.data = self.qrdata if hasattr(self.list_view, '_reset_spopulate'): self.list_view._reset_spopulate()
def download_apk(instance, answer): global popup if answer == "yes": global apk_url apk_path = os.path.join(main_utils.get_mobileinsight_path(), "update.apk") if os.path.isfile(apk_path): os.remove(apk_path) t = threading.Thread(target=download_thread, args=(apk_url, apk_path)) t.start() progress_bar = ProgressBar() progress_bar.value = 1 def download_progress(instance): def next_update(dt): if progress_bar.value >= 100: return False progress_bar.value += 1 Clock.schedule_interval(next_update, 1 / 25) progress_popup = Popup(title='Downloading MobileInsight...', content=progress_bar) progress_popup.bind(on_open=download_progress) progress_popup.open() popup.dismiss()
def update_list(self): try: Active.scanList = Active.scan_task.get_scan_list(Active.client) except ScanException as se: popup = Popup(size_hint=(None, None), size=(400, 150)) popup.add_widget(Label(text=se.value)) popup.bind(on_press=popup.dismiss) popup.title = se.title popup.open() return except EmptyListException as ee: global empty if empty is 0: empty = 1 popup = Popup(size_hint=(None, None), size=(400, 150)) popup.add_widget(Label(text=ee.value)) popup.bind(on_press=popup.dismiss) popup.title = ee.title popup.open() self.scdata.clear() for x in range(0, len(Active.scanList)): self.scdata.append({'path': Active.scanList[x].path, 'options': Active.scanList[x].options}) self.list_adapter.data = self.scdata if hasattr(self.list_view, '_reset_spopulate'): self.list_view._reset_spopulate()
def check_login_validity(self, input_login: str, input_password: str): app = App.get_running_app() if login_exists(input_login): o_info = app.diary_ctr.get_owner_info_by_login(input_login) if o_info.is_password_valid(input_password): # If valid, proceed to next level app.current_owner = app.diary_ctr.get_owner_by_login(login=o_info.login) change_screen(self, new_screen="W_DiaryPick") else: wrong_password_popup = Popup(content=Label(text="Password is not valid"), title="Login error", size_hint=(None, None), size=(200, 100) ) wrong_password_popup.open() # When popup disappear change the screen wrong_password_popup.bind(on_dismiss=lambda *args: change_screen(screen_instance=self, new_screen="W_Login")) else: wrong_login_popup = Popup(content=Label(text="Login doesn't exist"), title="Login error", size_hint=(None, None), size=(200, 100)) wrong_login_popup.open() # When popup disappear change the screen wrong_login_popup.bind(on_dismiss=lambda *args: change_screen(screen_instance=self, new_screen="W_Entry"))
class InputPopupWidget: def __init__(self, callback=None, title=None): if not all([callback, title]): raise KeyError( 'Must provide callback method as well as a title for popup') self.title = title self.popup_layout = BoxLayout(orientation='vertical') self.popup_ok_btn = Button(text='Ok', size_hint=(1.0, 0.6)) self.popup_text_input = TextInput(text='', multiline=False, size_hint=(1.0, 0.4)) self.popup_layout.add_widget(self.popup_text_input) self.popup_layout.add_widget(self.popup_ok_btn) self.popup = Popup(content=self.popup_layout, size_hint=(1.0, 0.3), auto_dismiss=False, title=self.title) self.popup_ok_btn.bind(on_press=self.popup.dismiss) self.popup.bind(on_dismiss=callback) def open(self, _=None): self.popup.open() @property def input_text(self): return self.popup_text_input.text
class MessageBox(EnergyGameApp): def __init__(self, parent, titleheader="Title", message="Message", options={"OK": ""}, size=(400, 400)): def popup_callback(instance): "callback for button press" self.retvalue = instance.text self.popup.dismiss() self.parent = parent self.retvalue = None self.titleheader = titleheader self.message = message self.options = options self.size = size box = GridLayout(orientation='vertical', cols=1) box.add_widget(Label(text=self.message, font_size=16)) b_list = [] buttonbox = BoxLayout(orientation='horizontal') for b in self.options: b_list.append(Button(text=b, size_hint=(1,.35), font_size=20)) b_list[-1].bind(on_press=popup_callback) buttonbox.add_widget(b_list[-1]) box.add_widget(buttonbox) self.popup = Popup(title=titleheader, content=box, size_hint=(None, None), size=self.size) self.popup.open() self.popup.bind(on_dismiss=self.OnClose) def OnClose(self, event): self.popup.unbind(on_dismiss=self.OnClose) self.popup.dismiss() if self.retvalue and self.options[self.retvalue] != "": command = "self.parent."+self.options[self.retvalue] exec command
class TexteEntree(TextInput): popup = ObjectProperty(None) title = StringProperty('') texte = ObjectProperty(None) def on_open(self, instance): self.texte.textinput.focus = True def on_dismiss(self, instance): self.bind(on_focus=self.on_focus) def on_focus(self, instance, value): if not self.popup: self.popup = Popup(title=self.title, size_hint=(.5, .5), pos_hint={'top': 1}) if not self.texte: self.texte = Texte(text=self.text, valider=self.on_valider, in_popup=True, multiline=self.multiline) self.popup.bind(on_open=self.on_open, on_dismiss=self.on_dismiss) if self.popup._window is not None: return self.popup.content = self.texte self.popup.open() def on_valider(self, text): self.text = text self.popup.dismiss()
class MessageBox(MessageBoxApp): def __init__(self, parent, titleheader="Title", message="Message", options={"OK": ""}, size=(400, 400)): def popup_callback(instance): "callback for button press" self.retvalue = instance.text self.popup.dismiss() self.parent = parent self.retvalue = None self.titleheader = titleheader self.message = message self.options = options self.size = size box = GridLayout(orientation='vertical', cols=1) box.add_widget(Label(text=self.message, font_size=16)) b_list = [] buttonbox = BoxLayout(orientation='horizontal') for b in self.options: b_list.append(Button(text=b, size_hint=(1,.35), font_size=20)) b_list[-1].bind(on_press=popup_callback) buttonbox.add_widget(b_list[-1]) box.add_widget(buttonbox) self.popup = Popup(title=titleheader, content=box, size_hint=(None, None), size=self.size) self.popup.open() self.popup.bind(on_dismiss=self.OnClose) def OnClose(self, event): self.popup.unbind(on_dismiss=self.OnClose) self.popup.dismiss() if self.retvalue != None and self.options[self.retvalue] != "": command = "self.parent."+self.options[self.retvalue] exec command
def on_edit(self): channel = self.channel popup = Popup(title='Edit System Channel' if channel.systemChannel else 'Edit Channel', content=ChannelEditor(channel=channel), size_hint=(None, None), size=(dp(500), dp(180))) popup.open() popup.bind(on_dismiss=self.on_edited)
class MyWidget(Widget): progress_bar = ObjectProperty() def __init__(self, **kwa): super(MyWidget, self).__init__(**kwa) self.progress_bar = ProgressBar() self.popup = Popup( title='Download', content=self.progress_bar ) self.popup.bind(on_open=self.puopen) self.add_widget(Button(text='Download', on_release=self.pop)) def pop(self, instance): self.progress_bar.value = 1 self.popup.open() def next(self, dt): if self.progress_bar.value>=100: return False self.progress_bar.value += 1 def puopen(self, instance): Clock.schedule_interval(self.next, 1/25)
def update_list(self): try: Active.qrList = Active.qr_task.get_qr_list(Active.client) except QrException as qr: popup = Popup(size_hint=(None, None), size=(400, 150)) popup.add_widget(Label(text=qr.value)) popup.bind(on_press=popup.dismiss) popup.title = qr.title popup.open() return except EmptyListException as ee: global empty if empty is 0: empty = 1 popup = Popup(size_hint=(None, None), size=(400, 150)) popup.add_widget(Label(text=ee.value)) popup.bind(on_press=popup.dismiss) popup.title = ee.title popup.open() finally: self.qrdata.clear() for x in range(0, len(Active.qrList)): self.qrdata.append({'filename': Active.qrList[x].f_name, 'old_path': Active.qrList[x].o_path}) self.list_adapter.data = self.qrdata if hasattr(self.list_view, '_reset_spopulate'): self.list_view._reset_spopulate()
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 PopupOk(text, title='', btn_text='Continue', input=None, callback=None): btnclose = Button(text=btn_text, size_hint_y=None, height='50sp') content = BoxLayout(orientation='vertical') p = Popup(title=title, content=content, size=('300dp', '300dp'), size_hint=(None, None), pos_hint={'top':.95}) content.add_widget(Label(text=text)) if input is not None: assert callback is not None ti = TextInput(height='50sp', font_size='30sp', input_type=input, multiline=False, size_hint_y = None, focus=True) content.add_widget(ti) def _callback(*args): try: ti.hide_keyboard() except AttributeError: # On a real computer, not the phone pass if ti.text == '': callback(None) else: callback(ti.text) p.bind(on_dismiss=_callback) p.is_visable = True content.add_widget(btnclose) btnclose.bind(on_release=p.dismiss) p.open() if input is not None: while not p.is_visable: EventLoop.idle() return ti.text
def _on_drink_button_click(self, drink, button): """ :param BuyItem drink: :param Button button: """ print("GUI: %s asks to drink %s." % (self.name, drink.intern_name)) popup = Popup( title='Confirm: %s: Buy %s?' % (self.name, drink.shown_name), content=Button( text='[size=35]%s[/size]\nwants to drink [b]%s[/b] for %s %s.' % ( self.name, drink.shown_name, drink.price, self.db.currency), markup=True, halign="center"), size_hint=(0.7, 0.3)) class Handlers: confirmed = False def on_confirmed(*args): # It could be that the GUI was hanging, and the user clicked multiple times on it, # and this gets executed multiple times. if not Handlers.confirmed: Handlers.confirmed = True updated_drinker = self.db.drinker_buy_item(drinker_name=self.name, item_name=drink.intern_name) self._load(updated_drinker) popup.dismiss() def on_dismissed(sself, *args): if not Handlers.confirmed: print("GUI: cancelled: %s asks to drink %s." % (self.name, drink.intern_name)) popup.content.bind(on_press=on_confirmed) popup.bind(on_dismiss=on_dismissed) popup.open()
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 Dates(GridLayout): now = datetime.datetime.now() def __init__(self,**kwargs): super(Dates,self).__init__(**kwargs) self.cols = 7 self.c = calendar.monthcalendar(2015,5) for i in self.c: for j in i: if j == 0: self.add_widget(Button(on_release = self.on_release,text = '{j}'.format(j=''))) else: self.add_widget(Button(on_release = self.on_release, text = '{j}'.format(j=j))) def get_month(self): pass def on_dismiss(self, arg): # Do something on close of popup pass def on_release(self,event): print ("date clicked :" + event.text) event.background_color = 1,0,0,1 self.popup = Popup(title= "Set Reminder :", content = Reminder(), size_hint=(None, None), size=(self.width*3/4, self.height)) self.popup.bind(on_dismiss = self.on_dismiss) self.popup.open()
def launch_alarm_popup(self, instance): widget = self.build_alarm_popup() title = 'Set ' + self.name popup = Popup(title=title, content=widget, size_hint=(0.7, 0.3), pos_hint={'y' : 35.0 / Window.height}) popup.bind(on_dismiss=self.update_alarm) popup.open()
class SelectColor(Widget): select_callback = ObjectProperty(p) dismiss_callback = ObjectProperty(p) size = ListProperty((.8, .97)) title = StringProperty("Select Color:") text_button_ok = StringProperty("Yes") default_color = StringProperty("#ffffffff") background_image = StringProperty( "atlas://data/images/defaulttheme/modalview-background") def __init__(self, **kvargs): super(SelectColor, self).__init__(**kvargs) box = BoxLayout(orientation="vertical") select_color = ColorPicker(hex_color=self.default_color) button_select = Button(text=self.text_button_ok, size_hint=(1, .1)) box.add_widget(select_color) box.add_widget(Widget(size_hint=(None, .02))) box.add_widget(SettingSpacer()) box.add_widget(Widget(size_hint=(None, .02))) box.add_widget(button_select) self.body = Popup(title=self.title, content=box, size_hint=self.size, background=self.background_image) self.body.bind(on_dismiss=self.dismiss_callback) button_select.bind(on_press=lambda color: self.select_callback( select_color.hex_color), on_release=lambda *args: self.body.dismiss()) self.body.open()
class MyPopupProgressBar(Screen, BoxLayout): progress_bar = ObjectProperty() def __init__(self, **kwa): super(MyPopupProgressBar, self).__init__(**kwa) self.progress_bar = ProgressBar() self.popup = Popup(title='Loading: {}%'.format( int(self.progress_bar.value)), content=self.progress_bar) self.popup.bind(on_open=self.puopen) Clock.schedule_once(self.pop) def jinchurki(self, dt): self.popup.title = 'Loading: {}%'.format(int(self.progress_bar.value)) def pop(self, instance): self.progress_bar.value = 1 self.popup.open() def next(self, dt): if self.progress_bar.value >= 100: self.manager.current = "login" self.popup.dismiss() return False self.progress_bar.value += 2.5 def puopen(self, instance): Clock.schedule_interval(self.next, 1 / 100) Clock.schedule_interval(self.jinchurki, 1 / 100)
class MessageBox(DownloadScreen): def __init__(self, titleheader="Title", message="Message", options={"OK": "self.ok()", "NO": "self.no()"}): def popup_callback(instance): "callback for button press" # print('Popup returns:', instance.text) self.retvalue = instance.text self.popup.dismiss() self.retvalue = None self.options = options box = BoxLayout(orientation='vertical') box.add_widget(Label(text=message, font_size=20)) b_list = [] buttonbox = BoxLayout(orientation='horizontal') for b in options: b_list.append(Button(text=b, size_hint=(1,.35), font_size=20)) b_list[-1].bind(on_press=popup_callback) buttonbox.add_widget(b_list[-1]) box.add_widget(buttonbox) self.popup = Popup(title=titleheader, content=box, size_hint=(None, None), size=(400, 400)) self.popup.open() self.popup.bind(on_dismiss=self.OnClose) def OnClose(self, event): self.popup.unbind(on_dismiss=self.OnClose) self.popup.dismiss() if self.retvalue != None: command = "super(MessageBox, self)."+self.options[self.retvalue] # print "command", command exec command
class MessageBox(KDbotApp): def __init__(self, titleheader="Title", message="Message", options={"OK": "self.ok()", "NO": "self.no()"}): def popup_callback(instance): "callback for button press" # print('Popup returns:', instance.text) self.retvalue = instance.text self.popup.dismiss() self.retvalue = None self.options = options box = BoxLayout(orientation='vertical') box.add_widget(Label(text=message, font_size=20)) b_list = [] buttonbox = BoxLayout(orientation='horizontal') for b in options: b_list.append(Button(text=b, size_hint=(1,.35), font_size=20)) b_list[-1].bind(on_press=popup_callback) buttonbox.add_widget(b_list[-1]) box.add_widget(buttonbox) self.popup = Popup(title=titleheader, content=box, size_hint=(None, None), size=(800, 400), auto_dismiss=False) self.popup.open() self.popup.bind(on_dismiss=self.OnClose) def OnClose(self, event): self.popup.unbind(on_dismiss=self.OnClose) self.popup.dismiss() if self.retvalue != None: command = "super(MessageBox, self)."+self.options[self.retvalue] # print "command", command exec (command)
def submit(self, instance): btn = Button(text='Stop') content = Label(font_size='100sp') box = BoxLayout(orientation='vertical', spacing=2) box.add_widget(content) box.add_widget(btn) popup = Popup(content=box, auto_dismiss=False) btn.bind(on_press=popup.dismiss) def update(instance): def my_callback(dt): global count workMinutes = int(self.txtWork.text) pauseMinutes = int(self.txtPause.text) cycleMinutes = int(self.txtCycles.text) l = main(workMinutes, pauseMinutes, cycleMinutes) if count == len(l): content.text = 'DONE!' return False content.text = l[count] count += 1 Clock.schedule_interval(my_callback, 1) popup.bind(on_open=update) popup.open()
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()
class ProgressBarScreen(Screen): progress_bar = ObjectProperty() def __init__(self, **kwa): super(ProgressBarScreen, self).__init__(**kwa) self.progress_bar = ProgressBar() self.popup = Popup( title='Running, Do Not Exit', content=self.progress_bar ) self.popup.bind(on_open=self.puopen) layout = BoxLayout(orientation='horizontal', size_hint=[.5, .1], pos_hint={'x':.5, 'y':0}) layout.add_widget(Button(text='Run Current Test', on_release=self.pop)) self.add_widget(layout) def pop(self, instance): self.progress_bar.value = 1 self.popup.open() def next(self, dt): self.progress_bar.value += 1 def puopen(self, instance): while self.progress_bar.value<100: Clock.schedule_once(self.next, 5) self.progress_bar.value += 1 if self.progress_bar.value>=100: self.popup.dismiss() ResultsScreen().show()
class MessageBox(App): def __init__(self, parent, titleheader="Message", message="", options={"OK": ""}, size_hint=(.8,.3), font_size=None, size=None, modal=0, edit_add = False, edit_default_text=""): #def build(self, parent, titleheader="Message", message="", options={"OK": ""}, size_hint=(.8,.2), size=(None, None)): def popup_callback(instance): self.retvalue = instance.text self.popup.dismiss() self.parent = parent self.retvalue = None self.titleheader = titleheader self.message = message self.options = options self.font_size=font_size self.edit_add=edit_add self.edit_default_text=edit_default_text if size: self.size = size else: self.size=(0,0) if size_hint: self.size_hint=size_hint #box = GridLayout(orientation='vertical', cols=1) box = GridLayout(cols=1) box.orientation='vertical' #self.add_widget(box) #box.add_widget(Label(text=self.message, font_size=self.font_size)) box.add_widget(Label(text=self.message)) if self.edit_add: self.edit=TextInput(text=self.edit_default_text) box.add_widget(self.edit) b_list = [] buttonbox = BoxLayout(orientation='horizontal',size_hint=(1, None),height=32) box.add_widget(buttonbox) for b in self.options: b_list.append(Button(text=b, on_press=popup_callback)) #b_list[-1].bind(on_press=self.popup_callback) buttonbox.add_widget(b_list[-1]) if modal: #Допилить self.popup = ModalView() self.popup.title=titleheader self.popup.size_hint=self.size_hint self.popup.size=self.size self.popup.add_widget(box) else: self.popup = Popup(title=titleheader, content=box, size_hint=self.size_hint, size=self.size) #self.popup = Popup(title=titleheader, content=box, size_hint=self.size_hint) self.popup.open() self.popup.bind(on_dismiss=self.OnClose) def OnClose(self, event): self.popup.unbind(on_dismiss=self.OnClose) self.popup.dismiss() if self.retvalue != None and self.retvalue in self.options and self.options[self.retvalue] != "": command = "self.parent."+ (self.options[self.retvalue]%self.edit.text if self.edit_add else self.options[self.retvalue]) exec(command) def dismiss(self): self.retvalue = 'dismiss' self.popup.dismiss()
def show_customize_dialog(self): content = CustomizeChannelsView(settings=self.settings, datastore=self.datastore, current_channels=self._selected_channels) content.bind(on_channels_customized=self._channels_customized) popup = Popup(title="Customize Channels", content=content, size_hint=(0.7, 0.7)) popup.bind(on_dismiss=self.popup_dismissed) popup.open() self._popup = popup
def popup_message(msg): title = "Message" popup = Popup(title=title, content=Label(text=msg), size=(435, 100), size_hint=(None, None)) popup.bind(on_dismiss=load) popup.open()
class Calendar_Buttons: """Show popup when pressing "calendar" button.""" def __init__(self, *args): """Popup calendar and dismiss actions.""" self.calendar = Popup(title="Calendrier", content=Calendar_Popup()) self.calendar.open() self.calendar.bind(on_dismiss=popup_close)
def onButtonPress(self): label = Label(text='Alarm Started !!') popup = Popup(title='Alarm Started !!', content=label, size_hint=(None, None), size=(600, 600)) popup.bind(on_dismiss=self.actual_time) popup.open()
def quit_popup(self): popup = Popup(title='Score Summary Window', size_hint=(0.7, 0.7)) l = BoxLayout(orientation='vertical') l.add_widget(Label(text='Game Over', font_size='40sp')) l.add_widget(Label(text='Total moves played: %d' % self.total_moves, font_size='25sp')) popup.add_widget(l) popup.bind(on_dismiss=self.summary_popup_dismiss) popup.open()
def edit_name(self): content = TextInput(text=self.name, font_size=self.fontSize * 0.4, multiline=False, padding=(2, 0)) popup = Popup( title="Input new name:", content=content, size_hint=(None, None), size=(self.width / 2, self.height / 5) ) popup.bind(on_dismiss=self.update_name) popup.open()
def getConnectedDevices(self, button): popup = Popup(title='Please wait..', content=Label(text='Fetching connected devices'), size_hint=(None, None), size=(400, 200), auto_dismiss=False) popup.bind(on_open=self.connectedNodesSetter) popup.open()
def showChannelConfigDialog(self): content = ChannelCustomizationView(settings=self.settings, channel=self.channel) content.bind(on_channel_customization_close=self.on_channel_customization_close) popup = Popup(title='Customize {}'.format(self.channel), content=content, size_hint=(0.6, 0.8)) popup.bind(on_dismiss=self.popup_dismissed) popup.open() self._popup = popup self._dismiss_customization_popup_trigger()
def launch_popup(self): button = Button() popup = Popup(title='Backlight', content=button, size_hint=(1.0, 1.0)) popup.bind(on_dismiss=self.backlight_on) button.bind(on_press=popup.dismiss) bl.backlight_off() popup.open()
def on_customize(self, *args): content = ChannelEditor(channel = self.channel_config) popup = Popup(title = 'Customize Channel', content = content, size_hint=(None, None), size = (dp(500), dp(220))) popup.bind(on_dismiss=self.on_edited) content.bind(on_channel_edited=lambda *args:popup.dismiss()) popup.open()
def load_preset_view(self): def popup_dismissed(*args): pass content = PresetBrowserView(self.preset_manager, 'obd2') content.bind(on_preset_selected=self._on_preset_selected) content.bind(on_preset_close=lambda *args:popup.dismiss()) popup = Popup(title='Import a preset configuration', content=content, size_hint=(0.7, 0.8)) popup.bind(on_dismiss=popup_dismissed) popup.open()
def showChannelSelectDialog(self): content = ChannelSelectView(settings=self.settings, channel=self.channel) content.bind(on_channel_selected=self.channel_selected) content.bind(on_channel_cancel=self._dismiss_popup) popup = Popup(title="Select Channel", content=content, size_hint=(0.5, 0.7)) popup.bind(on_dismiss=self.popup_dismissed) popup.open() self._popup = popup self._dismiss_customization_popup_trigger()
def show_add_stream_dialog(self): self.stream_connecting = False content = AddStreamView(settings=self._settings, datastore=self._datastore) content.bind(on_connect_stream_start=self.on_stream_connecting) content.bind(on_connect_stream_complete=self.on_stream_connected) popup = Popup(title="Add Telemetry Stream", content=content, size_hint=(0.7, 0.7)) popup.bind(on_dismiss=self.popup_dismissed) popup.open() self._popup = popup
def game_over(self, score): '''Ends the game and prints [score] ''' msg = 'Zombies have eaten you brains, your result is $%s' % score pop = Popup(title='GAME OVER', content=Label(text=msg), size_hint=(None, None), size=(self.width / 2, self.height / 2)) def exit_app(instance): raise SystemExit(0) pop.bind(on_dismiss=exit_app) pop.open()
def callback_login(self, instance): if instance.status != "OK": popup = Popup(title='ERROR!!', content=Label(text=instance.status), size_hint=(0.5, 0.3), font_size='38sp') popup.bind(on_dismiss=self.callback_error) popup.open() return app = App.get_running_app() app.root.carousel.load_slide(app.root.senderlist) return False
class ListDialogCtl(AbstractController): def set_option(self,option_id,option_text): self.option_id=option_id self.option_text=option_text self.l.btn.disabled=False def choose_option(self,titol,options,option_callback,width=400,height=500,header_widget=None,header_widget_height=10,option_sel=''): if not option_sel or option_sel == '': option_sel = options[0]['option_id'] self.option_callback=option_callback self.l=ListDialog() self.l.controller=self text_list = [x for x in options if x['option_id']==option_sel] text = (text_list and text_list[0]['option']) or '' print 'TEXT ' +str(text) self.result='ko' self.option_id=None self.option_text='' self.l.adapter=ListDialogAdapter(grid=self.l.datagrid,option_id=str(option_sel),text=text) self.l.adapter.controller=self self.l.adapter.data=options self.l.datagrid.header_height_hint=0. self.l.header_widget_height=header_widget_height if header_widget: header_widget.parent=None self.l.header_container.add_widget(header_widget) else: self.l.header_container.add_widget(Label()) self.l.header_widget_height=10 from utils.format import get_format self.popup = Popup(title_size=get_format('font14'),title=titol, content=self.l, size_hint=(None, None), size=(width, height)) self.visto = False self.l.btn.bind(on_press=self.visto_pressed) self.popup.bind(on_dismiss=self.sendOption) self.popup.open() def visto_pressed(self, sender): self.visto = True self.popup.dismiss() def refreshOptions(self,options): self.l.adapter.data=options def sendOption(self,sender): if self.result=='ko' or not self.visto: return self.option_callback(None,'') else: return self.option_callback(self.option_id,self.option_text) def createScreens(self): pass
def on_enter(self, *args): try: NetHelper.baixar_banco_bibliotecas() self.lista_bibliotecas = LibraryHelper.abrir_arquivo_banco_bibliotecas() except Exception: def dismiss(instance): self.parent.current = 'menu' popup = Popup(title='Erro', content=Label(text='Nao foi possivel se conectar ao servidor'), size_hint=(.5, .5)) popup.bind(on_dismiss=dismiss) popup.open()
def deleteItem(self, item, index): try: Active.scan_task.rm_from_scan(Active.client, item.path) except ScanException as se: popup = Popup(size_hint=(None, None), size=(400, 150)) popup.add_widget(Label(text=se.value)) popup.bind(on_press=popup.dismiss) popup.title = se.title popup.open() return Active.scanList.pop(index) global update update = 1
def collectData(self, instance): if self.currentOption != '' and self.currentActivity.isComplete(): button = Button(text='Activity successfully added') popup = Popup(title='SUCCESS!', content=button, size_hint=(None, None), height=250, width=250) button.bind(on_press=popup.dismiss) popup.bind(on_dismiss=self.closeWindow) popup.open() addActivity(self.currentActivity) else: button = Button(text='There are fields missing\nor the data is incorrect!') popup = Popup(title='ERROR!', content=button, size_hint=(None, None), height=250, width=250) button.bind(on_press=popup.dismiss) popup.open()