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
python类Popup()的实例源码
10.finalApp_Hacking_UI_and_shell_root_access.py 文件源码
项目:Python_For_Android_Hacking
作者: priyankgada
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
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 on_release(self):
if not self.popup:
self.popup = Popup(size_hint=(0.8, 0.6), title_color=(0, 0, 0, 1),
background='', background_color=(0.2, 0.2, 0.2, 0.9))
self.popup.title = 'Set Notification id'
self.popup.content = Numpad()
self.popup.content.callback = self.numpad_select_callback
self.popup.open()
def on_release(self):
if not self.popup:
self.popup = Popup(size_hint=(0.8, 0.3), title_color=(0, 0, 0, 1),
background='', background_color=(0.2, 0.2, 0.2, 0.9))
self.popup.title = 'Set Notification activity'
self.popup.content = ActivityNumpad()
self.popup.content.callback = self.numpad_select_callback
self.popup.open()
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 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()
def show_load(self):
content = LoadDialog(load=self.load, cancel=self.dismiss_popup)
self._popup = Popup(title='Load file', content=content,
size_hint=(0.75, 0.75))
self._popup.open()
def display_log(self):
popup = Popup(title='Network Log',
content=Label(text = 'Log is not implemented yet.'),
size_hint = (0.3, 0.3))
popup.open()
def __init__(self,stuff):
close=Label(text=stuff)
popup=Popup(title="Meetings",size_hint=(None, None), size=(500, 400))
root=ScrollView(size_hint=(1, None), size=(Window.width, Window.height))
popup.add_widget(close)
root.add_widget(popup)
popup.open()
def _key_handler(self, instance, KEY, *args): # Reakce na stisk systémové klávesy OS Android
print "Key: {0}".format(KEY)
if KEY == 1001:
if self.sm.current not in ('MainMenuScreen', 'GameScreen'):
if self.sm.current == "SettingsScreen":
self.sm.get_screen("SettingsScreen").dropdown.dismiss()
self.sm.current_screen.prev()
else:
if self.sm.current == 'MainMenuScreen':
text = self.L.STR_POPUP_EXIT
title = self.L.STR_POPUP_EXIT_TITLE
yes_callback = self.popupStop
else:
text = self.L.STR_POPUP_DISCONNECT
title = self.L.STR_POPUP_DISCONNECT_TITLE
yes_callback = self.popupDisconnect
content = BoxLayout(orientation='vertical')
content.add_widget(Label(text=text, font_name='font/Roboto-Regular.ttf', font_size='14dp'))
buttons = GridLayout(cols=2, rows=1, spacing=10, size_hint=(1, .3))
yes = Button(text=self.L.STR_YES)
yes.bind(on_press=yes_callback)
no = Button(text=self.L.STR_NO)
buttons.add_widget(yes)
buttons.add_widget(no)
content.add_widget(buttons)
self.popupExit = Popup(title=title, size_hint=(.7,.3), content=content, auto_dismiss=False)
no.bind(on_press=self.popupExit.dismiss)
self.popupExit.open()
elif KEY == 1002:
self.dispatch('on_pause')
elif KEY == 1004:
self.dispatch('on_pause')
def __init__(self, msg=None, *args, **kwargs):
super(MsgDialog, self).__init__(*args, **kwargs)
self.popup = Popup(content=self,
size_hint=kwargs['size_hint'],
title=kwargs['title'])
self.msgtext = msg
def on_open_press(self):
# initialize filepicker instance
content = FilePicker(on_close=self.close_popup, path=self.drive_selected)
self.file_popup = Popup(title='Select your file',
content=content,
size_hint=(.8, .8))
self.file_popup.open()
def show_exception(e):
"""Show th latest exception in a pop-up dialog."""
tb = traceback.format_exc()
Logger.exception(str(e))
Logger.exception(tb)
popup = Popup(title='Python exception occured',
content=TextInput(text=str(e) + "\n\n" + tb),
size_hint=(.8, .8))
popup.open()
def on_release(self):
if self.last_touch and self.last_touch.is_double_tap:
app.game_state = GameState()
popup = Popup(title="Info",content=Label(text="Game restarted"),size_hint=(0.25,0.15)).open()
def __init__(self, **kwargs):
super(MainScreen, self).__init__(**kwargs)
self.protocol = kwargs['protocol']
self.screen_manager = kwargs['screen_manager']
self.method_chooser = MethodPanel(controller=self)
self.method_chooser_visible = False
self.popup = Popup(title='Actions',
content=Label(text=''),
size_hint=(None, None), size=(400, 400))
def __init__(self, **kwargs):
super(NodesScreen, self).__init__(**kwargs)
self.screen_manager = kwargs['screen_manager']
self.discoveries = {}
self.bookmarks = {}
self.load_link_list()
self.popup = Popup(title='Actions',
content=Label(text=''),
size_hint=(None, None), size=(400, 400))
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 build(self):
file = open("privacy_agreement.txt")
privacy_agreement = file.read()
privacy_agreement = privacy_agreement +'\nDo you agree to share data collected on your phone?'
content = PrivacyPopup(text=privacy_agreement)
content.bind(on_answer=self._on_answer)
self.popup = Popup(title="Agreement on Data Sharing",
content=content,
size_hint=(None, None),
size=(1200, 2300),
auto_dismiss=False)
self.popup.open()
def onOpen(self, *args):
self.open_popup = Popup(
title='Open file',
content=Open_Popup(
load=self.load),
background_normal='',
background_color=(0/255.0, 161/255.0, 247/255.0, 1),
color=(0/255.0, 161/255.0, 247/255.0, 1),
auto_dismiss=True)
# self.open_popup.bind(on_dismiss=self.exit_open_popup)
self.open_popup.open()