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

How do I specify the root module directory in python?
Python, xml.dom, and parsing
Find all string positions in file
Python use request to login
how to delete a tempfile later
How do I flatten nested lists of lists in python?
How can I get a string(Mix of digit and char) up to last digit using regex in python?
Plotting python object attribute and objects are stored in list
Tkinter animation will not work
Establishing Root Widget / accessing it as app.root?
python mysqldb query with where
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() python
Python changing arrays (numpy) using the map command
Iterate function changing parameter after each run
How to access name of a specific vertex in graph (python-igraph)
gdal_merge overlaying pngs over one another

Categories

HOME
sidekiq
crate
nlp
checkbox
xamarin.android
rotation
windows-7
visual-studio-2013
ocaml
thunderbird-addon
automated-tests
webdav
ll
codeblocks
structuremap
dropbear
rapidjson
phpbb
ms-access-2007
zend-framework-mvc
memsql
tfs2013
iis-10
samsung-mobile
version-numbering
edge-detection
referenceerror
encase
getjson
m2e
hotmail
hawtio
modelandview
nunit-3.0
codesys
strstr
mongoexport
installshield-2012
lftp
fqdn
azure-availability-set
taskmanager
jags
windows-95
rpostgresql
quintus
httplib2
libtiff.net
inject
windows-azure-pack
linkageerror
ng2-material
remoteapp
twgl.js
fill
zuora
uialertview
sevenzipsharp
subresource-integrity
playscape
rx-groovy
coypu
cpu-cores
git-checkout
virus
searchkick
pl-i
sthttprequest
valence
cppdepend
ifft
wic
jqmobi
iconv
fortran77
zend-lucene
sunspot-rails
plone-funnelweb
redirectstandardoutput
wcf-web-api
hibernate3
applicationcontext
text-services-framework
rubycas
dcpu-16
scalaxb
smooth
pivotal-crm
pureftpd
quick-search
file-encodings
lazy-c++
weborb
database-diagramming
rd

Resources

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
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App