I'm trying to build an app using kivy and python. When I implement screen manager I get a black screen though. As you can see in my code I have two screens: ApppScreen and AllitemsScreen. I'd like to have my ApppScreen to come up first as 'homescreen'. What is going wrong? Thanks in advance!
kv file:
<ApppScreen>:
Label:
text: 'hoi'
BoxLayout:
size: root.width, root.height
orientation: 'vertical'
Label:
text: 'hey'
size_hint: 1, .1
ScrollView:
size_hint: 1, .3
GridLayout:
size_hint: 1,None
height: self.minimum_height
cols: 1
MyLabel:
text: ' items'
GridLayout:
id: container
cols: 2
size_hint_y: None
height: self.minimum_height
row_force_default: True
row_default_height: dp(260)
TextInput:
title: 'NewItem'
id: input
multiline: False
size_hint: 1, .1
Button:
text: 'add new item'
size_hint: 1, .1
on_press: app.add_a_row()
Button:
text: 'All items'
size_hint: 1, .1
on_press: root.manager.current = 'allitems'
<AllitemsScreen>:
BoxLayout:
size: root.width, root.height
orientation: 'vertical'
Label:
text: 'hey'
size_hint: 1, .1
ScrollView:
size_hint: 1, .3
GridLayout:
size_hint: 1,None
height: self.minimum_height
cols: 1
MyLabel:
text: 'All items'
GridLayout:
size_hint: 1,None
height: self.minimum_height
cols: 2
rows: 25
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
MyLabel:
text: 'Filler'
TextInput:
title: 'NewItem'
id: input
multiline: False
size_hint: 1, .1
Button:
text: 'add new item'
size_hint: 1, .1
on_press: root.newitem(input.text)
Button:
text: 'items2'
size_hint: 1, .1
on_press: root.manager.current = 'appp'
<TextInp>:
title: 'NewItem'
id: test1
auto_dismiss: False
TextInput:
multiline: False
id: input
hint_text:'Enter the items url'
on_text: app.NewItem()
<Row>:
orientation: "horizontal"
Image:
source: app.image_source
width: 100
main.py file
import kivy
kivy.require('1.9.0')
from kivy.uix.gridlayout import GridLayout
from kivy.uix.scrollview import ScrollView
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.button import Button
from kivy.lang import Builder
from kivy.uix import image
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.textinput import TextInput
from kivy.uix.widget import Widget
from price import ExtractPrice
from pythonmain import Item
from image import ExtractImage
import requests
from urllib.request import urlopen
from PIL import Image
from datetime import date
class ApppScreen(Screen):
def newitem(self, link):
item_list.append(Item(link))
print(item_list[0].store, item_list[0].original_price)
class AllitemsScreen(Screen):
pass
sm = ScreenManager()
sm.add_widget(ApppScreen(name='appp'))
sm.add_widget(AllitemsScreen(name='allitems'))
class Row(BoxLayout):
pass
class notifier(App):
image_source = item1.image
print(image_source)
def build(self):
return sm
def add_a_row(self):
self.root.ids.container.add_widget(Row())
if __name__ == '__main__':
notifier().run()
You create your widgets before loading the kv. Create them in the build method instead.
Related
With Kivy, I want a layout that is different when the window size is portrait or landscape (a grid of buttons, and for exemple the buttons on a row are shown in a column).
I tried first to hide some widgets, but that doesn't work well (even at a size of 0, some text appears, and this doesn't work with spacing)
So I wanted to delete a row directly, it worked, but...
The space for the raw remains with, like this
I tried to delete the second row, but there is now a gap.
Here is the code for that example
test3.kv file
<MDBoxLayout>:
spacing:5
<MyLayout>:
MDBoxLayout:
orientation: "vertical"
size: root.width, root.height
id: vbox
# Texte
MDLabel:
size_hint: 1,0.4
text: "Text"
halign: 'left'
valign: 'bottom'
font_size: 48
id: label
# Ligne 1
MDBoxLayout:
orientation: "horizontal"
size_hint: 1,0.15
id: ligne1
MDFillRoundFlatButton:
size_hint: 0.25,1
text: "A"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"B"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"C"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"D"
# Ligne 2
MDBoxLayout:
orientation: "horizontal"
size_hint: 1,0.15
id: ligne2
MDFillRoundFlatButton:
size_hint: 0.25,1
text: "1"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"2"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"3"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"4"
# Ligne 3
MDBoxLayout:
orientation: "horizontal"
size_hint: 1,0.15
MDFillRoundFlatButton:
size_hint: 0.25,1
text: "E"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"F"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"G"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"H"
# Ligne 4
MDBoxLayout:
orientation: "horizontal"
size_hint: 1,0.15
MDFillRoundFlatButton:
size_hint: 0.25,1
text: "I"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"J"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"K"
MDFillRoundFlatButton:
size_hint: 0.25,1
text:"L"
test3.py file
import kivy
kivy.require('1.1.1')
from kivymd.app import MDApp
from kivy.uix.widget import Widget
from kivy.lang import Builder
from kivymd.uix.boxlayout import MDBoxLayout
Builder.load_file('test3.kv')
class MyLayout(Widget):
def on_size(self, *args):
self.ids.label.text = 'on_size'
if self.width > self.height:
self.ids.label.text = self.ids.label.text + f' horizontal {self.ids.ligne2}'
# orientation : horizontal
if isinstance(self.ids.ligne2, MDBoxLayout):
self.ids.label.text = self.ids.label.text + ' ligne 2 existe: supprimée'
self.ids.ligne2.clear_widgets()
self.remove_widget(self.ids.ligne2)
self.ids.ligne2 = None
class app(MDApp):
def build(self):
return MyLayout()
if __name__ == '__main__':
app().run()
Is this something missing in my code, or should I try another method to change dynamically the layout?
how do i add buttons to my paintScreen class without the on_touch_down/move interfering and making it so that i draw within a BoxLayout canvas and separate the buttons in a different box so that it wont draw over the buttons? This is the current problem i am having. Also if that problem is fixed then would i be able to save that drawing as an img if i use export_to_png
from kivy.app import App
from kivy.graphics.context_instructions import Color
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.properties import ObjectProperty
from kivy.uix.textinput import TextInput
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.dropdown import DropDown
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.spinner import Spinner
from kivy.uix.checkbox import CheckBox
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang.builder import Builder
from kivy.uix.recycleview import RecycleView
from kivy.uix.scrollview import ScrollView
from kivy.graphics import Line, Rectangle, Ellipse, Triangle
Builder.load_string("""
<firstScreen>
BoxLayout:
orientation: "vertical"
ScrollView:
size: root.size
GridLayout:
orientation: "vertical"
size_hint_y: None
height: self.minimum_height #<<<<<<<<<<<<<<<<<<<<
row_default_height: 90
cols: 2
Label:
text: "Name: "
TextInput:
multiline: False
Label:
text: "Address: "
TextInput:
multiline: False
Label:
text: "Contact: "
TextInput:
multiline: False
Label:
text: "Telephone: "
TextInput:
multiline: False
Label:
text: "Order Number: "
TextInput:
multiline: False
Label:
text: "Transporter's Name: "
TextInput:
multiline: False
Label:
text: "Vehicle Reg. No.: "
TextInput:
multiline: False
Label:
text: "Driver's Name: "
TextInput:
multiline: False
Label:
text:"Hazchem Requirements: "
Spinner:
id: spinner_1
text: "< Select >"
values: root.pick_opt
Spinner:
id: spinner_2
text: "Waste Details"
values: root.pick_classification
GridLayout:
size_hint: 1, None
rows:2
Label:
text: "Non-Hazardous"
Label:
text: "Hazardous"
CheckBox:
on_active: root.chk_tick
CheckBox:
on_active: root.chk_tick
Spinner:
id: spinner_3
text: "Service Details"
values: root.sog
TextInput:
multiline: False
hint_text: "Enter Volume/Weight"
Spinner:
id: spinner_4
text: "Service Details"
values: root.sog
TextInput:
multiline: False
hint_text: "Enter Volume/Weight"
Spinner:
id: spinner_5
text: "Service Details"
values: root.sog
TextInput:
multiline: False
hint_text: "Enter Volume/Weight"
Spinner:
id: spinner_6
text: "Service Details"
values: root.sog
TextInput:
multiline: False
hint_text: "Enter Volume/Weight"
Button:
text: "Next Screen"
size_hint: 1,.1
on_press: root.manager.current = "screen_2"
<secondScreen>
BoxLayout:
orientation: "horizontal"
ScrollView:
size: root.size
GridLayout:
orientation: "vertical"
size_hint_y: None
height: self.minimum_height #<<<<<<<<<<<<<<<<<<<<
row_default_height: 120
cols: 1
BoxLayout:
orientation: 'vertical'
Spinner:
id: spinner_7
text: "details"
width: self.parent.width * 2
values: root.pick_dets
Spinner:
id: spinner_8
text: "details"
values: root.pick_dets
Spinner:
id: spinner_9
text: "details"
values: root.pick_dets
GridLayout:
cols: 2
rows: 3
Label:
text: "Start Time"
Label:
text: "End Time"
TextInput:
multiline: False
TextInput:
multiline: False
GridLayout:
cols: 2
Label:
text: 'Special Instructions/Remarks'
TextInput:
hint_text: 'Enter Remarks'
Button:
id: signature
text: 'Signature'
on_press: root.manager.current = "screen_signature"
BoxLayout:
orientation: 'vertical'
Button:
text: "Previous Screen"
size_hint: 1,.1
on_press: root.manager.current = "screen_1"
Button:
text: "Next Screen"
size_hint: 1,.1
on_press: root.manager.current = "screen_2"
<paintScreen>
""")
class paintScreen(Screen):
# On mouse press how Paint_brush behave
def on_touch_down(self, touch):
color = (1, 1, 1)
with self.canvas:
Color(*color, mode='hsv')
d = 30.
Line(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))
touch.ud['line'] = Line(points=(touch.x, touch.y))
# On mouse movement how Paint_brush behave
def on_touch_move(self, touch):
touch.ud['line'].points += [touch.x, touch.y]
pass
class firstScreen(Screen):
def __init__(self, **kwargs):
self.pick_opt = ["yes", "no"]
self.pick_classification = ["Classification (SANAS 10228)", "HR (1,2,3,4 - Minimum Requirements)",
"Emergency Response Guide Reference"]
self.sog = ['Oil', "Effluent", "Sludge", "Other"]
super(firstScreen, self).__init__(**kwargs)
def chk_tick(self, instance, value):
if value:
print("ticked")
else:
print('unticked')
pass
class secondScreen(Screen):
def __init__(self, **kwargs):
self.pick_dets = ["HP Cleaning", "Chemicals", "Soil Treatment",
"Minor Civils & Plumbing", "Effluent Treatment", "Other"]
super(secondScreen, self).__init__(**kwargs)
pass
class MyScreenManager(ScreenManager, RecycleView):
pass
screen_manager: ScreenManager = ScreenManager()
screen_manager.add_widget(firstScreen(name="screen_1"))
screen_manager.add_widget(secondScreen(name="screen_2"))
screen_manager.add_widget(paintScreen(name="screen_signature"))
class Myapp(App):
def build(self):
return screen_manager
def clear_canvas(self, obj):
self.painter.canvas.clear()
if __name__ == "__main__":
Myapp().run()
Pop up and EXE issue
Hi guys I've got problem, whenever I open my Kivy Program via Python, a popup is actually showing up
But when I convert it via Pyinstaller, it gives me an error:
How can I possibly fix this?
Python Code:
import os
os.environ["KIVY_IMAGE"] = "pil, sdl2"
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.popup import Popup
Builder.load_file("kivy.kv")
class Rusure(Popup):
pass
class Menu(Screen):
def quit(self):
Rusure().open()
class Settings(Screen):
def bright (self,*args):
self.brightness.text = "Brightness: {}".format(str(int(args[1])))
class Play(Screen):
pass
class Sm(ScreenManager):
def __init__(self):
super().__init__()
self.add_widget(Menu(name="menu"))
self.add_widget(Settings(name="settings"))
self.add_widget(Play(name="play"))
class GoodApp(App):
def build(self):
return Sm()
GoodApp().run()
Kivy Code:
#: import rit kivy.uix.screenmanager.RiseInTransition
#: import st kivy.uix.screenmanager.SlideTransition
#: import fot kivy.uix.screenmanager.FallOutTransition
#: import Factory kivy.factory.Factory
<Menu>:
BoxLayout:
padding: 100,100,100,100
orientation: "vertical"
Label:
text: "Menu"
BoxLayout:
orientation: "horizontal"
Button:
text: "Play"
background_normal: "Image.jpg"
background_down: "ImageRel.jpg"
color: 1,1,1,1
on_press:
root.manager.transition = rit()
root.manager.current = "play"
Button:
text: "Settings"
background_color: 0.9,1,1,1
on_press:
root.manager.transition = st()
root.manager.current = "settings"
root.manager.transition.direction = "up"
Button:
text: "Quit"
background_color: 1,0.7,0,1
on_press:
root.quit()
<Settings>:
brightness: brght
BoxLayout:
padding: 100,100,100,100
orientation: "vertical"
Label:
text: "Settings"
GridLayout:
cols: 3
Label:
text: "Brightness"
Slider:
min: 0
max: 10
value: 5
on_value: root.bright(*args)
Label:
id: brght
text: "Change Value"
Button:
text: "Back"
on_press:
root.manager.transition = st()
root.manager.current = "menu"
root.manager.transition.direction = "down"
<Play>:
BoxLayout:
Label:
text: "Welcome to the game!"
Button:
text: "Back"
on_press:
root.manager.transition = fot()
root.manager.current = "menu"
<Rusure>:
title: "Are you sure?"
size_hint: 0.5,0.5
auto_dismiss: False
BoxLayout:
orientation: "vertical"
Label:
text: "Your progress will be lost"
GridLayout:
cols: 2
Button:
text: "Oh shit man!"
on_press: root.dismiss()
Button:
text: "Cancel"
on_press: root.dismiss()
I tried searching solution on the internet, but after 3 hours of searching I couldn't come up whith any answer.
I am trying to make a GUI in python using kivy and TabeedPanel . some problems are coming for putting on exact location of label, TextInput , button. I'm unable to put multiple label, TextInput altogether. That's why I commented in the code. I tried GridLayout also, but Unable to arrange exactly.
Can you help me? Thanks in advance.
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem
from kivy.lang import Builder
from kivy.uix.checkbox import CheckBox
from kivy.uix.button import Button
from kivy.app import App
from kivy.uix.textinput import TextInput
import json
Builder.load_string("""
<Test>:
do_default_tab: False
TabbedPanelItem:
text: 'page1'
BoxLayout:
Label:
text: 'label'
TextInput:
text: 'TextInput'
CheckBox:
text: 'CheckBox'
Button:
text: 'save'
#BoxLayout:
# orientation: 'vertical'
# BoxLayout:
# orientation: 'horizontal'
# Label:
# text: 'label'
TabbedPanelItem:
text: 'page2'
BoxLayout:
Label:
text: 'number1'
#TextInput:
# text: 'TextInput'
Label:
text: 'number2'
# TextInput:
# text: 'TextInput'
Button:
text: 'button'
""")
class Test(TabbedPanel):
pass
class MyApp(App):
def build(self):
test = Test()
return test
if __name__ == '__main__':
MyApp().run()
Following your example, you can use BoxLayouts but you need to nest them correctly:
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.lang import Builder
Builder.load_string("""
<Test>:
do_default_tab: False
TabbedPanelItem:
text: 'page1'
BoxLayout:
padding: 50, 50, 50, 50
orientation: 'horizontal'
BoxLayout:
spacing: 50
orientation: 'vertical'
size_hint_x: 1
Label:
text: 'label'
Label:
text: 'label'
Label:
text: 'label'
BoxLayout:
spacing: 50
orientation: 'vertical'
TextInput:
text: 'TextInput'
TextInput:
text: 'TextInput'
TextInput:
text: 'TextInput'
BoxLayout:
spacing: 50
orientation: 'vertical'
size_hint_x: 0.40
CheckBox:
text: 'CheckBox'
CheckBox:
text: 'CheckBox'
CheckBox:
text: 'CheckBox'
BoxLayout:
spacing: 50
orientation: 'vertical'
size_hint_x: 0.60
Button:
text: 'save'
Button:
text: 'save'
Button:
text: 'save'
TabbedPanelItem:
text: 'page2'
BoxLayout:
padding: 50, 50, 50, 50
orientation: 'horizontal'
BoxLayout:
spacing: 50
orientation: 'vertical'
Label:
text: 'label'
Label:
text: 'label'
Label:
BoxLayout:
spacing: 50
orientation: 'vertical'
TextInput:
text: 'TextInput'
TextInput:
text: 'TextInput'
Button:
spacing: 100
text: 'button'
""")
class Test(TabbedPanel):
pass
class MyApp(App):
def build(self):
test = Test()
return test
if __name__ == '__main__':
MyApp().run()
Output:
Here's an example using GridLayout that I made a reference to in your other question. FYI, there are many ways you could go about this. I personally like using gridlayout with forms because it's easy to put then ScrollViews if need be.
Read up on the kv language here to help keep things DRY and other things. If a widget is defined in kv, then you don't need to import them at the top of your file.
Example:
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.lang import Builder
Builder.load_string("""
<MyLabel#Label>:
size_hint: (None, None)
size: (400, 100)
<MyTextInput#TextInput>:
size_hint: (None, None)
size: (600, 100)
<MyButton#Button>:
size_hint: (None, None)
size: (400, 100)
<MyCheckBox#AnchorLayout>:
# I'm nesting the checkbox here b/c it is hard to see if the background is not lightened.
size_hint: (None, None)
size: (100, 100)
anchor_x: "center"
anchor_y: "center"
canvas.before:
Color:
rgba: [0.7, 0.7, 0.7, 1]
Rectangle:
pos: self.pos
size: self.size
CheckBox:
<Test>:
do_default_tab: False
TabbedPanelItem:
text: 'page1'
GridLayout:
rows: 3
cols: 4
padding: [10, 100]
spacing: [10, 50]
MyLabel:
text: "Label 1"
MyTextInput:
MyCheckBox:
MyButton:
text: "Button 1"
MyLabel:
text: "Label 3"
MyTextInput:
MyCheckBox:
MyButton:
text: "Button 2"
MyLabel:
text: "Label 3"
MyTextInput:
MyCheckBox:
MyButton:
text: "Button 3"
TabbedPanelItem:
text: 'page2'
GridLayout:
rows: 3
cols: 2
padding: [10, 100]
spacing: [10, 50]
MyLabel:
text: "Label 1"
MyTextInput:
MyLabel:
text: "Label 2"
MyTextInput:
# blank spacer widget
Widget:
size_hint: (None, None)
size: (400, 100)
MyButton:
text: "Button"
""")
class Test(TabbedPanel):
pass
class MyApp(App):
def build(self):
return Test()
if __name__ == '__main__':
MyApp().run()
My application is simple, the ScreenTwo is showing a form 'Parametreur' with various options to be entered.
What I'm trying to do is to set a 'save' button at the end of this form that will register into a list called 'resultat' all the options furfilled so far leaving '0' in the empty inputs.
The global variable 'resultat' would look like this ['blabla','15/06/2018','31/12/1999','6'].
File.py
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager, Screen, WipeTransition
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.properties import ObjectProperty
from kivy.lang import Builder
Builder.load_file("HadrianRunningApp.kv")
class ScreenMenu(Screen):
pass
class ScreenOne(Screen):
pass
class ScreenTwo(Screen):
pass
class Parametreur(FloatLayout):
def build(self):
pass
def submit_input(self):
# Get the student name from the TextInputs
label_name = self.label_text_input.text
resultat.insert(0,label_name)
def submit_input2(self):
date_debut_name = self.date_debut_input.text
resultat.insert(1,date_debut_name)
def submit_input3(self):
date_fin_name = self.date_fin_input.text
resultat.insert(2,date_fin_name)
def submit_input4(self):
var_duree_estimation = self.duree_estimation_input.text
resultat.insert(3,var_duree_estimation)
def save_input(self):
print(resultat)
class Manager(ScreenManager):
screen_menu = ObjectProperty(None)
screen_one = ObjectProperty(None)
screen_two = ObjectProperty(None)
class ScreensApp(App):
def build(self):
m = Manager(transition=WipeTransition())
return m
if __name__=='__main__':
ScreensApp().run()
The Kivy file .kv:
#:kivy 1.9.0
<ScreenMenu>:
BoxLayout:
orientation:'vertical'
size: root.size
padding: "20dp"
Button:
text: "go to Screen 1"
on_press: root.manager.current = 'screen1'
Button:
text: "go to Screen 2"
on_press: root.manager.current = 'Parametreur'
<ScreenOne>:
BoxLayout:
spacing: 20
padding: 20
Button:
text: "go to Screen 2"
on_press: root.manager.current = 'Parametreur'
Button:
text: "go to Menu"
on_press: root.manager.current = 'screen0'
<ScreenTwo>:
Parametreur
<Parametreur>:
label_text_input: label_text
date_debut_input: date_debut
date_fin_input: date_fin
duree_estimation_input: duree_estimation
resultat: resultat
RelativeLayout:
orientation: 'vertical'
GridLayout:
size_hint: (1., 0.11)
pos_hint: {'right': 1, 'center_y': 0.91}
padding: 6
spacing: "4dp"
cols:2
rows:1
Button:
text: "go to Screen 1"
on_press: root.manager.current = 'screen1'
Button:
text: "go to Menu"
on_press: root.manager.current = 'screen0'
GridLayout:
size_hint: (1., 0.8)
pos_hint: {'right': 1, 'center_y': 0.45}
padding: "7dp"
spacing: 5
cols:2
rows:7
Button:
text: "Liste Actif"
Label:
text: " "
BoxLayout:
Label:
text: "Date du début"
BoxLayout:
orientation: "vertical"
Button:
text: "Submit"
on_press: root.submit_input2()
TextInput:
id: date_debut
text: 'dd/mm/YYYY'
BoxLayout:
Label:
text: "Date de fin"
BoxLayout:
orientation: "vertical"
Button:
text: "Submit"
on_press: root.submit_input3()
TextInput:
id: date_fin
text: 'dd/mm/YYYY'
Label:
text: "Pourcentage de séparation \n de la base (validation/test)"
Button:
text: "Open to Close"
Button:
text: "Close to Close"
Button:
text: "les 3 (6 en tout) frontières des VSs"
BoxLayout:
Label:
text: "Durée pour la réestimation \n des modèles (en jours)"
BoxLayout:
orientation: "vertical"
Button:
text: "Submit"
on_press: root.submit_input4()
TextInput:
id: duree_estimation
text: 'dd/mm/YYYY'
Label:
text: "variable selection NMF/Entropy"
Label:
text: "Kernel/damiers/buntcher/\n neurone/XGBoost/Gradient boosting"
# We create the widgets
BoxLayout:
spacing: "0dp"
Label:
id: label_text
text: "0"
font_size: "30dp"
BoxLayout:
orientation: "vertical"
spacing: "3dp"
Button:
text: "Add"
on_release: label_text.text = str(int(label_text.text) + 1)
Button:
text: "Subtract"
on_release: label_text.text = str(int(label_text.text) - 1)
Button:
text: "Submit"
size_hint_x: None
on_press: root.submit_input()
BoxLayout:
padding: "2dp"
spacing: "2dp"
size_hint: (1., 0.50)
pos_hint: {'right': 1, 'center_y': 0.09}
Button:
id: resultat
text:"Save"
size_hint_x: None
on_press: root.save_input()
<Manager>:
id: screen_manager
screen_menu: screen_menu
screen_one: screen_one
screen_two: screen_two
ScreenMenu:
id: screen_menu
name: 'screen0'
manager: screen_manager
ScreenOne:
id: screen_one
name: 'screen1'
manager: screen_manager
ScreenTwo:
id: screen_two
name: 'Parametreur'
manager: screen_manager
Where and How should I set my global variable 'resultat' (which is a list)?
I've solved my problem but I still don't understand how does it work. Setting a variable is Kivy doesn't need to set it in the Python code. But how do Kivy and Python know about its type? Right now, it works as a list without me defining it such as (I intended it to be a list anyway).
How could I set a variable as tuple for example?