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

Unable to find virtualenv or django after installing with pip
Dynamically naming tuples for redis
Django - accessing foreignkey's attribute
How can I use \r to make Python print on the same line?
Python to search a string for the first occurrence of any item in a list
Fetch and write CLOB type values from oracle to a file
Pandas calculate days elapsed and percent change
Installing lower version of GLIBC and running pyinstaller
Django-Parsley Not Displaying Errors
Django : uploading images
Querying a list in mongoengine; contains vs in
Python - Store a value in an array inside one for loop
Chop a list into a list of lists [duplicate]
Adding Event functions outside PyQt/PySide Generated Code
Regex in Python: “\d+” and "[0-9]+ do NOT only recognize numbers&Digits but also Operators?
in networkX reading a gml file getting ParseException: Expected “]”

Categories

HOME
caching
cil
websphere
sed
scipy
ipython
youtube-livestreaming-api
google-sheets-api
mapbox-gl-js
csvhelper
propertygrid
oclint
image-recognition
symfony2-easyadmin
cloudflare
ida
grub2
chocolatey
ios10.3
uiautomator
rails-activerecord
jquery-form-validator
profile
unpack
ggmap
bitcoin-testnet
pygooglechart
gpib
strophe
percentage
pdflatex
viewstate
openpgp
boilerplate
sonarqube-scan
restful-url
react-native-router-flux
jrules
powermta
upsert
bids
sapui
mcrypt
fedora20
gce
addin-express
redux-router
iron.io
atlassian-crowd
typhoon
backstop.js
rmongodb
mailcatcher
kendo-combobox
selecteditem
picking
enyo
mirrorlink
sourcegear-vault
response-headers
programming-paradigms
bridge
uos
subversion-edge
virus
obfuscar
inputaccessoryview
activity-streams
sysctl
vcl
em
formvalidation-plugin
humanizer
bsp
valence
sgml
bsod
image-zoom
windows-update
justgage
shiva3d
fileconveyor
qt4.6
pstree
maven-ant-tasks
flexicious
selectmanycheckbox
chatroom
msn
hardware-acceleration
camtasia
iphone-sdk-3.2
asp.net-mvc-controller
opcodes
project-lifecycle
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