def userLogin(self):
content = LoginScreen(root_self = self)
##
self.popup = Popup(
title = 'User Login',
content = content,
auto_dismiss = False,
size_hint = (None, None),
size = (400, 170)
)
# open the popup
self.popup.open()
###
python类Popup()的实例源码
def __init__(self, **kvargs):
super(FileChooser, self).__init__(**kvargs)
box = BoxLayout(orientation="vertical", spacing=10)
filechooser = FileChooserListView()
filechooser.bind(selection=self.select_callback)
box.add_widget(filechooser)
if self.filter == "folder":
box.add_widget(SettingSpacer())
box.add_widget(Button(text=self.text_button_select,
size_hint=(1, .1),
on_press=self.select_callback))
filechooser.filters = [self.is_dir]
elif self.filter == "files":
filechooser.filters = [self.is_file]
self.body = Popup(title=self.title, content=box, size_hint=self.size,
auto_dismiss=self.auto_dismiss,
background=self.background_image)
self.body.bind(on_dismiss=self.dismiss_callback)
self.body.open()
def __init__(self, **kvargs):
super(KDialog, self).__init__(**kvargs)
self.orientation = "vertical"
self.param = None
# ???? ??? ?????? ?????? "??-???-??????".
self.box_buttons_select = BoxLayout(orientation="horizontal",
size_hint_y=None, height=40)
self.scroll = ScrollView()
self.box_content = GridLayout(cols=2, size_hint_y=None)
self.box_content.bind(minimum_height=self.box_content.setter("height"))
self.body = Popup(title_align=self.title_align,
background=self.background_image,
on_dismiss=self.dismiss_callback)
# ??? ???? ?????????.
with self.box_content.canvas:
Color(0.16, 0.16, 0.16)
self.canvas_for_box_content = \
Rectangle(pos=(5, 5), size=(self.box_content.width,
self.box_content.height))
self.box_content.bind(size=self._update_canvas_size,
pos=self._update_canvas_size)
self.scroll.add_widget(self.box_content)
def _update_canvas_size(self, instance, value):
"""?????????? ??? ????????? ??????? ?????? ??????????.
type instance: instance <kivy.uix.gridlayout.GridLayout object'>;
type value: list;
param value: ??????? ?????? instance;
"""
self.canvas_for_box_content.pos = instance.pos
self.canvas_for_box_content.size = instance.size
# ????????? ?????? ???? Popup - ???? ?????????.
self.body_message.height = self.canvas_for_box_content.size[1] + 150
if self.body_message.height > Window.size[1]:
self.body_message.height = Window.size[1] - 10
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()
def _update_canvas_size(self, instance, value):
"""?????????? ??? ????????? ??????? ?????? ??????????.
type instance: instance <kivy.uix.gridlayout.GridLayout object'>;
type value: list;
param value: ??????? ?????? instance;
"""
self.canvas_for_box_content.pos = instance.pos
self.canvas_for_box_content.size = instance.size
# ????????? ?????? ???? Popup.
self.body.height = self.canvas_for_box_content.size[1] + 70
self.body.width = int(Window.size[0] / self.size_hint_x)
if self.body.height > Window.size[1]:
self.body.height = Window.size[1] - 10
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 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 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 onGoTo(self):
if self.loaded == 'Yes':
popup = BoxLayout(
orientation='vertical',
size=self.size,
pos=self.pos)
self.goto_popup = Popup(title='Go To' +
' (1~' +
str(len(self.data_view)) +
')', content=popup, size_hint=(0.9, 0.25), auto_dismiss=False)
self.goto_textinput = TextInput()
cancel = Button(text='Cancel', on_release=self.dismiss_goto_popup)
ok = Button(text='Ok', on_release=self.goto_ok)
buttons = BoxLayout(size_hint_y=None, height=self.height / 20)
buttons.add_widget(cancel)
buttons.add_widget(ok)
popup.add_widget(self.goto_textinput)
popup.add_widget(buttons)
self.goto_popup.open()
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 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 read(self,*largs):
content = FloatLayout()
scroll = ScrollView()
mdlist = MDList()
content.add_widget(scroll)
scroll.add_widget(mdlist)
title = "Testimonies"
pop = Popup(title= title,content= content,)
pop.open()
try:
for message in Testify.select():
time.sleep(0.50)
mdlist.add_widget(PopList(text=str(message.name),secondary_text=str(message.message)))
print('reading testimonies')
except peewee.OperationalError:
self.login_failure('Check Network Connection')
# mdlist.add_widget(PopList(text=str('Error'), secondary_text=str('Please Check Internet Connection')))
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 __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 show(self):
self.body = Popup(title="Test progress:", content=self,
auto_dismiss=False, size_hint=(.7, .5),
on_dismiss=self.dismiss_callback)
self.body.open()
self.thread = threading.Thread(target=self.retrieve_callback,
args=(self._tick,))
self.thread.start()
def __init__(self, **kwargs):
super(ImageViewer, self).__init__(**kwargs)
self.orientation = "vertical"
# ???? ??? ?????? ?????? "??-???-??????".
self.box_buttons_select = \
BoxLayout(orientation="horizontal", size_hint_y=None, height=40)
self.body = Popup(title=self.title, title_align=self.title_align,
background=self.background_image,
on_dismiss=self.dismiss_callback,
auto_dismiss=self.auto_dismiss,
size_hint=self.size_hint)
self.flag = False
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 userLogout(self, obj):
content = LogoutScreen(root_self = self)
self.popup = Popup(
title = 'User Logout',
content = content,
auto_dismiss = False,
size_hint = (None, None),
size = (400, 170)
)
# open the popup
self.popup.open()
###
def show_load(self, inout):
self.inorout = inout
content = LoadDialog(load=self.load, cancel=self.dismiss_popup)
self._popup = Popup(title="Load file", content=content,
size_hint=(0.9, 0.9))
self._popup.open()
def show_save(self):
content = SaveDialog(save=self.save, cancel=self.dismiss_popup)
self._popup = Popup(title="Save file", content=content,
size_hint=(0.9, 0.9))
self._popup.open()
10.finalApp_Hacking_UI_and_shell_root_access.py 文件源码
项目:Python_For_Android_Hacking
作者: priyankgada
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
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()
10.finalApp_Hacking_UI_and_shell_root_access.py 文件源码
项目:Python_For_Android_Hacking
作者: priyankgada
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
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
10.finalApp_Hacking_UI_and_shell_root_access.py 文件源码
项目:Python_For_Android_Hacking
作者: priyankgada
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
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()