python


Problems with the screen manager of Kivy Python


I'm doing a function for a kivy app and in the first screen it's necessary to insert some data inputs. My idea is to show a popup in the case you don't do the data input correctly, but I've been testing with my app and I don't know how to do it in the right way. When a button gets pressed, before you go to the next screen, the inputs are loaded and checked (at that moment in case that they weren't correct the popup is showed). Here is the code of the function that is executed when you press the button:
# -*- coding: utf-8 -*-
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.properties import DictProperty
from kivy.properties import StringProperty
from kivy.uix.popup import Popup
Builder.load_string('''
<Root>:
Welcome:
name: 'welcome'
MainScreen:
name: 'main'
AnotherScreen:
name: 'another'
<GridLayout>
canvas.before:
Color:
rgba: 0.5, 0.5, 0.5, 0.1
BorderImage:
# BorderImage behaves like the CSS BorderImage
border: 10, 10, 10, 10
source: '../ABRIL/Presentacion/etseib.jpg'
pos: self.pos
size: self.size
<FloatLayout>
canvas.before:
Color:
rgba: 0.5, 0.5, 0.5, 0.1
BorderImage:
# BorderImage behaves like the CSS BorderImage
border: 10, 10, 10, 10
source: '../examples/widgets/sequenced_images/data/images/button_white.png'
pos: self.pos
size: self.size
<Welcome>:
FloatLayout:
Label:
text: ""
size_hint_y: 0.1
pos_hint: {'center_x':0.5,'center_y':0.6}
Label:
text: "Escriu el teu correu "
font_size: 25
size_hint: 0.2, 0.05
pos_hint: {'center_x':0.3,'center_y':0.20}
Label:
text: "Benvingut a l'aplicacio ETSEIB Calendar. Per tal d'obtenir el teu arxiu amb el calendari de practiques de laboratori del GETI, segueix els seguents passos:\\n1.Inserta el teu mail (es recomana plataforma gmail o hotmail.\\n2.Selecciona quan amb quina antelacio vols rebre la notificacio de la practica\\n3.Selecciona les assignatures a la seguent pantalla.\\n4.Inserta els grups.\\n5.Revisa el teu mail i descarrega l'arxiu."
size_hint_y: 0.5
pos_hint: {'center_x':0.5,'center_y':0.36}
Spinner:
text: 'Selecciona quan vols rebre lavis'
values:('1 hora abans','8 hores abans','24 hores abans')
pos_hint: {'center_x':0.5,'center_y':0.28}
size_hint: 0.2, 0.05
on_text: root.aff(self.text)
Button:
text: "Exit"
background_color: .7, 1, 6, 1
on_release:root.close()
size_hint: 0.4, 0.1
pos_hint: {'center_x':0.2,'center_y':0.05}
Button:
text: "Next"
font_size:
background_color: .7, .7, 1, 1
size_hint: 0.4, 0.1
pos_hint: {'center_x':0.8,'center_y':0.05}
on_release:
root.ready()
#root.parent.current='main'
#root.parent.transition.direction = 'left'
#root.parent.transition= SwapTransition
TextInput:
multiline: False
size_hint: 0.2, 0.05
pos_hint: {'center_x':0.5,'center_y':0.20}
on_text: root.add(self.text)
<MainScreen>:
GridLayout:
cols: 2
Label:
text: "Select Subjects (1/2)"
font_size: 15
Button:
text: "Main Page"
background_color: .7, 1, 6, 1
on_release:
root.parent.current='welcome'
root.parent.transition.direction = 'right'
Button:
text: "Next"
font_size:
background_color: .7, .7, 1, 1
on_release:
root.parent.current='another'
root.parent.transition.direction = 'left'
''')
class Welcome(Screen):
def __init__(self, **kw):
super(Welcome, self).__init__(**kw)
self.a = App.get_running_app()
def add(self,p): #emmagatzema els textsinputs
self.a.email=p #.encode("utf-8")
#falta enlazarlo
def aff(self,p):
self.a.temps=p[0:2]
def ready(self):
if self.a.temps=="default" or self.a.email=="":
content=Label(text='Insert Valid Data')
popup = Popup(title='Error',content=content,size_hint=(0.7, 0.5),background_color=(0, 0, 0, 0))
popup.open()
content.bind(on_press=popup.dismiss)
else:
self.parent.transition.direction = 'left'
self.parent.current='main'
def close(self):
return App.get_running_app().stop()
class MainScreen(Screen):
def __init__(self, **kw):
super(MainScreen, self).__init__(**kw)
self.a = App.get_running_app()
def ping(self, n, value): #emmagatzema les caselles marcades
self.a.big_dict[n] = value
def close(self):
return App.get_running_app().stop()
class AnotherScreen(Screen):
def on_pre_enter(self, *args):
#i=filtro.dic(0)
a = App.get_running_app()
t={} #dintre del diccionari t s'emmagatzemaren els inputs
keys=[] #aquesta llista permetra ordenar les caselles seleccionades per les seguents pantalles, independentment del ordre seleccionat
def change(self):
self.parent.transition.direction = 'right'
self.parent.current='second'
b2=Button(text='Run',background_color=[0,1,0,1])
self.add_widget(b2)
b2.bind(on_release=change)
class Root(ScreenManager):
pass
class SimpleKivy(App): #aquest diccionari permet emmagatzemar les caselles marcades(inicialment totes desmarcades==FALSE)
big_dict = DictProperty({'240161': False, '240061': False, '240171': False, '240151': False, '240063': False, '240073': False, '240072': False, '240031': False, '240033': False, '240054': False, '240053': False, '240052': False, '240172': False}
)
email=StringProperty("")
temps=StringProperty("default")
def build(self):
return Root()
SimpleKivy().run()
The problem I'm concerned that might be in the change of screen, because I've done in the same way that kivy language. Thanks.


Related Links

file hashing by identifying files by first 4 bytes
Using Linux or any other language to read stdout and stdout from python scripts.
numpy fails to resize large matrix
python selenium how to copy text of site?
Unexpected max number but correct min number
Sum of positive numbers results in a negative number
Why is contours changing slightly alltough the object is still? OpenCV
Right matrix division in Scipy/NumPy? [duplicate]
Remove rows where a specific column has a blank entry
How to accept multiple strings from user at same time and store them in list in python?
Python Tkinter Canvas does not appear
Linear Search - Python
python dataframe boolean values with if statement
Pandas mean() for multiindex
Getting quote_from_bytes() expected bytes when updating couchdb document
Using multithreading API in Python when my target function in another .py file

Categories

HOME
laravel-5
meshlab
boost-thread
travis-ci
jscript
checksum
webdav
httpclient
contact-form-7
flexbox
hosts
iso
gatsby
spinnaker
finite-group-theory
flann
rebol2
scala-native
internet-explorer-8
prestodb
jogl
ejbca
plupload
uiautomator
autolayout
thingsboard
facebook4j
binutils
rworldmap
go-cd
codelite
cgal
bxslider
red-black-tree
protobuf-net
clockwork
oracle-xml-db
nunit-3.0
oscommerce
text-files
pmwiki
sonarqube-scan
sql-like
image-compression
brute-force
wsadmin
ssh.net
excel-interop
lftp
finite-element-analysis
appstore-approval
paas
ingres
createobject
objloader
libtiff.net
alter
xib
bacnet
zurb-foundation-apps
uiprogressview
linkageerror
pagekit
soda
faraday
fill
interactive-brokers
cctray
java.util.calendar
optionbutton
xjc
divide-by-zero
callstack
es2015
hana-xs
c++-actor-framework
named-ranges
scala-2.11
node-inspector
proxies
phpdocx
sanitization
real-time-updates
bignum
image-zoom
dynamic-binding
justgage
grunt-contrib-compass
snapjs
linkedhashset
hashalgorithm
electronic-signature
opengl-es-lighting
windows-live-id
getresource
task-management
jquery-ui-button
soft-keyboard
configurable





Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm