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

Install NLTK with IronPyton for VS2012
pip install won't install on my machine
Integrating using scipy.integrate.simps
Problems with django and virtualenv
Returning when any Future in a list finishes
Python Django - matching query does not exist when using pk
R translation to Python
Are there downsides to using Python locals() for string formatting? [duplicate]
Compiled Python writing to Program Files
How to synchronize multiple django settings to the DB?
simulate pulling marbles from a bag without replacement (efficiently)
Datetime string doesn't match after strftime() and strptime()
Pandas HDFStore Tables doesn't accept multiindex columns
Two lists, if a common match is found print another list element [closed]
Is it possible to permanently change a variable inside a Python script from the same script?
Tweepy: simple script with 'Bad Authentication data' error

Categories

HOME
sql-server
sas
cil
semantic-ui
shopify
tinyos
wsdl
transparent
is-empty
recyclerview
azureservicebus
apple-numbers
laravel-4
quill
httpclient
i2c
google-plus
spinnaker
flann
local
squarespace
rebol2
mod-pagespeed
lstm
styles
statusbar
google-maps-android-api-2
npm-install
badge
branch
bxslider
outsystems
hotmail
ios-ui-automation
geomesa
xamarin.uitest
initializer
image-compression
magiczoomplus
installshield-2012
polyfills
mediawiki-extensions
distributed-transactions
datalog
html-agility-pack
rkt
worker
estimation
seamless-immutable
multi-agent
greenhills
pluck
execl
infinite-scroll
build-process
verbose
cleditor
alter
spring-ioc
backstop.js
picasa
gitweb
console-redirect
hateoas
jenkins-scriptler
insert-into
qbfc
sevenzipsharp
pyopengl
digits
crash-dumps
rspec3
xaml-designer
epl
robocode
google-earth-plugin
tcpreplay
getimagedata
yahoo-boss-api
adaptive-compression
korma
cppdepend
zipalign
resource-files
gfs
bigint
modeshape
astyanax
surveyor-gem
resgen
magickwand
zend-framework-modules
linkedhashset
getstring
jpf
mysql-error-1045
nsindexpath
surf
sendfile
drawtext
getresource
scala-2.8
internals

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