I'm currently building a small program that converts an Excel sheet into a JSON format. I want that every time a change or update is made, the excel file gets updated with a Login and Date information of the person who made the change.
I have created Two screens using KivyMD, one for the login data and another one for the excel functionality. My current issue is that I want to acquire the login information from the previous screen, but I'm having a hard time understanding how to get the data.
I have tried to create a "login" variable within my "Update" screen referencing the id from the "Log" screen by using this line I found on a previous post: "login = self.manager.screens[1].ids.login.text"
But that line is giving me the following error : "
login = self.manager.screens[1].ids.login.text
File "kivy\properties.pyx", line 863, in kivy.properties.ObservableDict.getattr
AttributeError: 'super' object has no attribute 'getattr'
"
I'm very new to KivyMD and I'm pretty sure that there is something over here that I'm not seeing or just missing. I would appreciate any help given.
Here is my .py file:
import os.path
from kivymd.app import MDApp
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.lang import Builder
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
from helpers import screen_helper_2
from kivy.core.window import Window
from datetime import datetime
import json
import functions as function
Window.size = (400, 500)
# AlbacoreLog Screen Fully Functional
class AlbacoreLogScreen(Screen):
def show_login(self, *args):
close_button = MDFlatButton(text='Close', on_release=self.close_dialog)
if self.ids.login.text is "":
check_string = 'Please enter Login or Name'
self.dialog = MDDialog(text=check_string,
size_hint=(0.7, 1),
buttons=[close_button])
self.dialog.open()
else:
self.manager.current = 'function'
def close_dialog(self, obj):
self.dialog.dismiss()
class AutoUpdateScreen(Screen):
def albacorize_update(self, *args):
def close_ext(*args):
dialog_ext.dismiss()
def close_ext_2(*args):
dialog_5.dismiss()
def close_update(*args):
dialog_update.dismiss()
close_button_ext_2 = MDFlatButton(text='Close', on_release=close_ext_2)
close_button_ext = MDFlatButton(text='Close', on_release=close_ext)
close_button_update = MDFlatButton(text='Close', on_release=close_update)
if self.ids.change.text is "":
dialog_update = MDDialog(text='Also, make sure to add your update',
size_hint=(0.7, 1),
buttons=[close_button_update])
dialog_update.open()
self.back_to_update()
if self.ids.ms.text is "":
dialog_ext = MDDialog(text='Please enter Master Sheet name and extension',
size_hint=(0.7, 1),
buttons=[close_button_ext])
dialog_ext.open()
self.back_to_update()
elif type(self.ids.ms.text) is str:
ms = self.ids.ms.text
update = self.ids.change.text
if os.path.isfile(ms):
login = self.manager.screens[1].ids.login.text
now = datetime.now()
time_date = now.strftime("%d/%m/%Y %H:%M:%S")
print("File exist")
q_and_a_section = function.question_answer_build(ms)
node_section = function.section_build(ms)
function.updates(ms, login, time_date, update) ##I want to pass the login data to a different module on my program in order to build the new excel sheet.
else:
print("File not exist")
dialog_5 = MDDialog(text='MS does not have extension or is not in current root folder',
size_hint=(0.7, 1),
buttons=[close_button_ext_2])
dialog_5.open()
self.manager.current = 'msautomap'
def back_to_function(self, *args):
self.manager.current = 'function'
def back_to_update(self, *args):
self.manager.current = 'msautoupdate'
sm = ScreenManager()
sm.add_widget(AlbacoreLogScreen(name='log'))
sm.add_widget(AutoUpdateScreen(name='msautoupdate'))
class AlbacorizerApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Yellow"
self.theme_cls.primary_hue = "A700"
self.theme_cls.theme_style = "Dark"
screen = Builder.load_string(screen_helper_2)
return screen
AlbacorizerApp().run()
And here is my .kv file:
screen_helper_2 = """
Screen:
NavigationLayout:
ScreenManager:
AlbacoreLogScreen:
AutoUpdateScreen:
<AlbacoreLogScreen>:
name: 'log'
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: 'Albacorizer Log'
left_action_items: [["lighthouse", lambda x: nav_drawer.toggle_nav_drawer()]]
elevation: 10
Widget:
MDTextField:
id: login
hint_text: "Enter login"
helper_text: "or enter name"
helper_text_mode: "on_focus"
icon_right: "lighthouse-on"
icon_right_color: app.theme_cls.primary_color
pos_hint:{'center_x':0.5, 'center_y':0.7}
size_hint_x: None
size_hint_y: None
width: 300
MDRectangleFlatButton:
text: 'Go !'
pos_hint: {'center_x':0.5,'center_y':0.4}
on_release:
root.show_login()
Widget:
<AutoUpdateScreen>:
name: 'msautoupdate'
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: 'MS Automap Update'
left_action_items: [["lighthouse", lambda x: nav_drawer.toggle_nav_drawer()]]
elevation: 10
Widget:
MDTextField:
id: ms
hint_text: "What is the MS name and extension?"
helper_text: "don't forget the extension"
helper_text_mode: "on_focus"
icon_right: "lighthouse-on"
icon_right_color: app.theme_cls.primary_color
pos_hint:{'center_x': 0.5, 'center_y': 0.5}
size_hint_x: None
width: 300
MDTextFieldRect:
id: change
hint_text: "Summary of changes to MS"
mode: "rectangle"
pos_hint:{'center_x': 0.5, 'center_y': 0.5}
size_hint_x: None
width: 200
height: "100dp"
Widget:
MDRectangleFlatButton:
text: 'Albacorize !'
pos_hint: {'center_x':0.5,'center_y':0.2}
on_release:
root.albacorize_update()
Widget:
MDRectangleFlatButton:
text: 'Back'
pos_hint: {'center_x':0.5,'center_y':0.3}
on_release:
root.back_to_function()
root.manager.transition.direction = 'right'
Widget:
"""
Try changing:
login = self.manager.screens[1].ids.login.text
to:
login = self.manager.get_screen('log').ids.login.text
Using self.manager.screens[1] makes your code depend on the order of Screens in the screens list (and [1] is the wrong one). Using get_screen('log') makes your code independent of the order of the Screens (and gets the correct one).
Related
in my login system I want to create a popup box that will be displayed when there is an error in the username, password, or verification password. Can someone help me in how to make the popup show with different labels everytime an error happens
here is the code for main file:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
class LoginWindow(Screen):
def signIn(self):
pass
def signUp(self):
# db=open('QuizData.txt','r')
username=self.ids.uname.text
password=self.ids.passw.text
repassword=self.ids.repassw.text
if password!=repassword:
pass #i want a popup box to appear if this is true
def popup(self):
pass
class QuizWindow(Screen):
pass
class QuizScreenManager(ScreenManager):
pass
kv = Builder.load_file('loginLayoutCSS.kv')
class Login(App):
def build(self):
return kv
if __name__=='__main__':
Login().run()
here is the code for .kv file
#:kivy 2.1.0
#:import utils kivy.utils
#:import Factory kivy.factory.Factory
<MyPopup#Popup>
auto_dismiss: True
size_hint:0.6,0.3
pos_hint:{'center_x':0.5}
title: 'Error'
Button:
text:'close'
fonr_size: 20
on_release: root.dismiss()
<MyTextInput#TextInput>
font_size:25
# size_
background_normal:''
background_color: utils.get_color_from_hex('#8c8c8c')
QuizScreenManager:
LoginWindow:
QuizWindow:
<LoginWindow>:
name:'login'
BoxLayout:
orientation:'vertical'
size: root.width,root.height
spacing: 20
padding: 20
Label:
id:heading
text:'Welcome back, sign in'
font_size:32
MyTextInput:
id:uname
text:'username'
MyTextInput:
id:passw
text:'password'
MyTextInput:
id:repassw
text:'re-enter Password'
multiline:False
size_hint_y: None
height:0
opacity:0
Button:
text:'Sign In'
id:signin
size_hint_y:0.6
on_release:
app.root.current='quizwindow'
root.manager.transition.direction='up'
Button:
text:'New here? Sign up Now! click here'
id:signup
on_press:
# signin.size_hint_y = None
repassw.size_hint_y = 0.6
repassw.opacity = 1
repassw.background_color = utils.get_color_from_hex('#8c8c8c')
root.signUp()
root.popup()
signup.text = 'Sign Up'
signin.opacity = 0
<QuizWindow>:
name:'quizwindow'
Button:
text:'go back'
on_release:
app.root.current='login'
root.manager.transition.direction='down'
You can add an id to the MyPopup class to allow you to access a Label that can contain your message. Here is a modified version of that portion of your kv file:
<MyPopup#Popup>
auto_dismiss: True
size_hint:0.6,0.3
pos_hint:{'center_x':0.5}
title: 'Error'
BoxLayout:
orientation: 'vertical'
Label:
id: message
Button:
text:'close'
fonr_size: 20
size_hint: None, None
size: self.texture_size
on_release: root.dismiss()
Then you can access that Label in your python code like this:
def signUp(self):
# db=open('QuizData.txt','r')
username = self.ids.uname.text
password = self.ids.passw.text
repassword = self.ids.repassw.text
if password != repassword:
popup = Factory.MyPopup()
popup.ids.message.text = 'passwords do not match'
popup.open()
I tried to store username taken from user in a .json file. But it dosen't work properly. After the user repeatedly enters the username, it is randomly stored in a json file. Please solve the problem with this code.
Sometimes the .json file is created randomly. But not
at the first time.
.kv file
screen_helper = """
ScreenManager:
SetUpWindow:
Home:
<SetUpWindow>:
name: 'settingup'
MDTextField:
id:username_text_fied
pos_hint: {'center_x':0.5,'center_y':0.45}
size_hint: (0.7,0.1)
hint_text : 'Name your Studio'
helper_text: 'Required'
helper_text_mode: 'on_focus'
icon_right: 'account'
icon_right_color: app.theme_cls.primary_light
required : True
MDRaisedButton:
id:disabled_button
disabled: True
text:"Next"
md_bg_color:app.theme_cls.primary_color
pos_hint: {'center_x':0.9,'center_y':0.08}
font_style: 'Button'
ripple_rad_default : 40
ripple_duration_out : 1
md_bg_color: app.theme_cls.primary_dark
on_press:
root.manager.current = 'home'
root.manager.transition.direction = 'left'
<Home>:
name: 'home'
"""
.py file
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import Screen, ScreenManager
from kivymd.app import MDApp
from kivy.storage.jsonstore import JsonStore
class SetUpWindow(Screen):
pass
sm = ScreenManager()
sm.add_widget(SetUpWindow(name='settingup'))
class Mode(MDApp):
def build(self):
screen = Screen()
self.screen = Builder.load_string(screen_helper)
screen.add_widget(self.screen)
self.username_text = self.screen.get_screen('settingup').ids.username_text_fied.text
return screen
self.store.put('UserInfo', name=self.username_text)
self.username_changer()
def username_changer(self):
self.screen.get_screen('home').ids.bottomappbar.title = f"Studio {self.store.get('UserInfo')['name']}"
def on_start(self):
self.store = JsonStore("std_profile.json")
try:
if self.store.get('UserInfo')['name'] != "":
self.username_changer()
self.screen.get_screen('home').manager.current = 'home'
except KeyError:
self.screen.get_screen('settingup').manager.current = 'settingup'
Mode().run()
Here is a modified version of your code that does what I think you want:
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import Screen
from kivymd.app import MDApp
from kivy.storage.jsonstore import JsonStore
screen_helper = """
ScreenManager:
SetUpWindow:
Home:
<SetUpWindow>:
name: 'settingup'
MDTextField:
id:username_text_fied
pos_hint: {'center_x':0.5,'center_y':0.45}
size_hint: (0.7,0.1)
hint_text : 'Name your Studio'
helper_text: 'Required'
helper_text_mode: 'on_focus'
icon_right: 'account'
icon_right_color: app.theme_cls.primary_light
required : True
on_text:
disabled_button.disabled = False # enable next button
MDRaisedButton:
id:disabled_button
disabled: True
text:"Next"
md_bg_color:app.theme_cls.primary_color
pos_hint: {'center_x':0.9,'center_y':0.08}
font_style: 'Button'
ripple_rad_default : 40
ripple_duration_out : 1
md_bg_color: app.theme_cls.primary_dark
on_press:
app.save_user_name() # save user name to Json
root.manager.current = 'home'
root.manager.transition.direction = 'left'
<Home>:
name: 'home'
MDBottomAppBar:
MDToolbar:
id: bottomappbar
title: "Title"
icon: "git"
type: "bottom"
left_action_items: [["menu", lambda x: x]]
mode: "free-end"
"""
class SetUpWindow(Screen):
pass
class Home(Screen):
pass
class Mode(MDApp):
def build(self):
return Builder.load_string(screen_helper)
def save_user_name(self): # added method to actually save user name to JSon
self.username_text = self.root.get_screen('settingup').ids.username_text_fied.text
self.store.put('UserInfo', name=self.username_text)
self.username_changer()
def username_changer(self):
self.root.get_screen('home').ids.bottomappbar.title = f"Studio {self.store.get('UserInfo')['name']}"
def on_start(self):
self.store = JsonStore("std_profile.json")
try:
if self.store.get('UserInfo')['name'] != "":
self.username_changer()
self.root.get_screen('home').manager.current = 'home'
except KeyError as e:
self.root.get_screen('settingup').manager.current = 'settingup'
Mode().run()
Note the change in the build() method and the elimination of the other code that was building ScreenManager and SetUpWindow. References to self.screen have been replaced with self.root. The Next button now saves the user name.
I am trying to add more than one Product's Name and their prices in a single nested list or single dictionary.
(The respective function in the following code is def add_screen(self)).
But I am not able find a way to do so.
In main.py --> class AddScreen(Screen) --> def add_screen(self) --> 'pdt' and 'amt'
I want to make a nested list or a dictionary of pdt and amt from the User input whenever the user clicks the Add More Button.
main.py
from kivymd.app import MDApp
from kivy.lang.builder import Builder
from kivy.properties import ObjectProperty
from kivy.uix.screenmanager import ScreenManager, Screen
from gui_elements import screen_helper
class NameScreen(Screen):
c_name = ObjectProperty(None)
def c_name_p(self):
customer = self.c_name.text
class AddScreen(Screen):
p_name = ObjectProperty(None)
amnt = ObjectProperty(None)
def add_screen(self):
pdt = self.p_name.text
amt = self.amnt.text
self.p_name.text = ''
self.amnt.text = ''
# Create the screen manager
sm = ScreenManager()
sm.add_widget(NameScreen(name='menu'))
sm.add_widget(AddScreen(name='profile'))
class DukanApp(MDApp):
def build(self):
screen = Builder.load_string(screen_helper)
return screen
DukanApp().run()
gui_elements.py
screen_helper = """
ScreenManager:
NameScreen:
AddScreen:
<NameScreen>:
id: name_screen
c_name: c_name
name: 'menu'
MDTextField:
id: c_name
hint_text: "Enter the Customer's Name"
helper_text: 'Ex- Mrinmoy Sarkar'
helper_text_mode: 'persistent'
pos_hint: {'center_x':0.5,'center_y':0.5}
size_hint_x: None
width: 300
icon_right: 'account'
MDRoundFlatButton:
text: 'Next'
pos_hint: {'center_x':0.5,'center_y':0.4}
on_press: root.manager.current = 'add'
on_press: root.c_name_p()
<AddScreen>:
id: add_screen
p_name: p_name
amnt: amnt
name: 'add'
MDTextField:
id: p_name
hint_text: "Name of the Product"
helper_text: 'Ex- T-Shirt , Jeans , etc.'
helper_text_mode: 'persistent'
pos_hint: {'center_x':0.3,'center_y':0.5}
size_hint_x: None
width: 300
MDTextField:
id: amnt
hint_text: "Cost of The Product"
helper_text: 'Ex- 1200 , 1000 , etc.'
helper_text_mode: 'persistent'
pos_hint: {'center_x':0.7,'center_y':0.5}
size_hint_x: None
width: 200
MDRoundFlatButton:
text: 'Continue'
pos_hint: {'center_x':0.6365,'center_y':0.4}
on_press: root.manager.current = 'add'
on_press: root.add_screen()
MDRoundFlatButton:
text: 'Add More'
pos_hint: {'center_x':0.7755,'center_y':0.4}
on_press: root.manager.current = 'add'
on_press: root.add_screen()
"""
First, you need to create the dictionary. Here, I chose to do that in your App class:
class DukanApp(MDApp):
def build(self):
self.products = {} # create the products dictionary
screen = Builder.load_string(screen_helper)
return screen
Then add items to that dictionary in the add_screen() method:
def add_screen(self):
pdt = self.p_name.text
amt = self.amnt.text
# get a reference to the products dictionary
products = MDApp.get_running_app().products
# add this product to the dictionary
products[pdt] = amt
print('products:', products)
self.p_name.text = ''
self.amnt.text = ''
I am new to python and kivymd and I am trying to develop a program for data entry. However, when I create a drop-down menu for a selection, an error occurred and I can't update the value of the text field after I select an item.
Here is the python code:
from kivymd.app import MDApp
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import ObjectProperty
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.properties import ObjectProperty
from kivymd.uix.menu import MDDropdownMenu
class AMRMenu(Screen):
def GIbutton(self):
sm.current = 'GI'
class GIWindow(Screen):
weather = ObjectProperty(None)
menu_weather_items = [{"text":"Sunny"},{"text":"Cloudy"},{"text":"Raining"}]
menu_FeedResponse_items=[{"text":"High"},{"text":"Medium"},{"text":"Low"}]
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.menu = MDDropdownMenu(
items=self.menu_weather_items,
width_mult=4,
caller = self.weather,
callback=self.set_item)
def set_item(self, instance):
def set_item(interval):
self.weather.text = instance.text
self.menu.dismiss()
Clock.schedule_once(set_item, 0.5)
class WindowManager(ScreenManager):
pass
sm = WindowManager()
class MainApp(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
kv = Builder.load_file("FR.kv")
def build(self):
screens = [AMRMenu(name = "menu"), GIWindow(name = "GI")]
for screen in screens:
sm.add_widget(screen)
sm.current = "menu"
return sm
if __name__ == "__main__":
MainApp().run()
And here is the kv. file:
<AMRMenu>:
name:"menu"
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Main Menu"
MDList:
OneLineListItem:
text: "General Information"
on_press: root.GIbutton()
OneLineListItem:
text: "Water Temperature"
OneLineListItem
text: "Feeding Amount"
OneLineListItem:
text: "Residue and Feeding response"
OneLineListItem:
text: "Dead fish"
OneLineListItem:
text: "Sell/Use"
<GIWindow>
name: "GI"
weather: weather
ScrollView:
id: screen
MDBoxLayout:
orientation: 'vertical'
adaptive_height: True
MDTextField:
id: weather
pos_hint: {'center_x': .5, 'center_y': .5}
hint_text: "Weather"
icon_right: "arrow-down-drop-circle-outline"
input_filter: lambda text, from_undo: text[:5 - len(self.text)]
on_focus: root.menu.open()
Here is the error message:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/core/window/__init__.py", line 1297, in add_widget
(widget, widget.parent)
kivy.uix.widget.WidgetException: Cannot add <kivymd.uix.menu.MDDropdownMenu object at 0x7fd2fa31a6e0> to window, it already has a parent <kivy.core.window.window_sdl2.WindowSDL object at 0x7fd2f65826e0>
I don't know why I made this happen. It helps a lot if someone figures it out. Thank you for reading this question
The problem is that your kv line:
on_focus: root.menu.open()
is opening the menu every time the focus changes. So, it tries to open the menu even when the focus becomes false. An easy fix is to just open the menu when focus is True`:
on_focus: if self.focus: root.menu.open()
I'm trying to build an App thats uses certain input Parameters and when hitting a submit button it uses a logic to generate output paramters. I managed to build the app and the input and the triggering via a submit button. Now i want to generate the output, for beginning with an easy logic. I looked up several similar solutions, but somehow they don't work for me.
For some reason my .kv file doen't get the updated value for the label text with the error: "ValueError: Label.text accept only str" Eventough everything is declared as a string in the .py. If i change it in the kv to str("...") I get some code line which i guess is the intern id of the attribute but not the assigned value i want to get.
I hope you can help. Pls don't be too harsh, I#M new to python and kivy...
main .py, shuldn't be part of the problem
Peenomat.py
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.anchorlayout import AnchorLayout
from kivy.core.text import LabelBase
Builder.load_file('Statusbar.kv')
Builder.load_file('Inputparameters.kv')
Builder.load_file('Outputparameters.kv')
#Layout
class Peenomat(AnchorLayout):
pass
class PeenomatApp(App):
def build(self):
return Peenomat()
if __name__=="__main__":
PeenomatApp().run()
.py with the classes and methods for the logic
StatusBar.py
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.properties import ObjectProperty
from kivy.properties import StringProperty
from kivy.app import App
class InputParameters(GridLayout):
verfahren = ObjectProperty(None)
def on_state(self, togglebutton):
tb = togglebutton
if tb.state == 'down':
self.verfahren = tb.text
self.verfahren = tb.text
print(self.verfahren)
return self.verfahren
class StatusBar(BoxLayout):
#InputGrößen
group_mode = False
prozess = ObjectProperty(None)
vorbehandlung = ObjectProperty(None)
material = ObjectProperty(None)
haerte = ObjectProperty(None)
rauheit = ObjectProperty(None)
#OutputGrößen
frequenz = StringProperty(None)
def btn_submit(self):
ip = App.get_running_app().root.ids._input_parameters
print("Haerte:", ip.haerte.value, "Rauheit:", ip.rauheit.value, "Material:", ip.material.text, "Vorbehandlung:", ip.vorbehandlung.text)
if ip.haerte.value < 50:
self.frequency = str(180)
elif ip.haerte.value < 60:
self.frequency = str(200)
else:
self.frequency = str(220)
#control to see if right value is taken
print(self.frequency, "Hz")
def btn_clear(self):
np = App.get_running_app().root.ids._input_parameters
np.pro1.state = "normal"
np.pro2.state = "normal"
np.pro3.state = "normal"
np.material.text = "Auswahl treffen"
np.haerte.value = 55
np.rauheit.value = 5.5
the .kv file that can't get the label text:
outputparameters.kv
#: import statusbar StatusBar
<OutputParameters#GridLayout>
#Initialisierung .py zu .kv
frequenz: _frequenz
Label:
text:'Frequenz:'
font_size:
Label:
id: _frequenz
text: root.frequenz
font_size: 20
the .kv file with the submit button, shouldn't be part of the problem either, worked perfectly fine before implementing the part ehre i try to update the text
statusbar.kv
#: import statusbar StatusBar
<StatusBar#BoxLayout>
orientation:'horizontal'
Button:
text: 'Clear'
on_press: root.btn_clear()
Button:
text: 'Submit'
on_press: root.btn_submit()
the file where i put in all the inputparameters, rather important:
Inputparameters.kv
#: import statusbar StatusBar
<InputParameters#GridLayout>
#Initialisierung .py zu .kv Ids
prozess: _prozess
pro1: _prozess1
pro2: _prozess2
pro3: _prozess3
vorbehandlung: _vorbehandlung
material: _material
haerte: _haerte
rauheit: _rauheit
#Prozess
Label:
text:'Prozess:
BoxLayout:
orientation: 'horizontal'
id: _prozess
ToggleButton:
id:_prozess1
text:'P-MOH'
group: "proc_group"
on_state: root.on_state(self)
ToggleButton:
id:_prozess2
text:'E-MOH'
group: "proc_group"
on_state: root.on_state(self)
ToggleButton:
id:_prozess3
text:'PE-MOH'
group: "proc_group"
on_state: root.on_state(self)
#Material
Label:
text: 'Material:'
Spinner:
id: _material
text: ""
values:
# Herstellschritte
Label:
text:'Fertigungsschritte:'
Spinner:
id: _vorbehandlung
text:
values:
# Haerte
Label:
text:'Haerte:'
BoxLayout:
orientation: 'vertical'
Label:
text: str(_haerte.value)
Slider:
id: _haerte
# Rauheit
Label:
text:'Rauheit:
BoxLayout:
orientation: 'vertical'
Label:
text:
Slider:
id: _rauheit
and the file where my layout is embedded (also rather necessary)
peenomat.kv
<Peenomat>
AnchorLayout:
anchor_x: 'left'
anchor_y: 'bottom'
GridLayout:
cols: 1
canvas.before:
Color:
Rectangle:
pos: self.pos
size: self.size
InputParameters:
id:_input_parameters
StatusBar:
id:_status_bar
OutputParameters:
id:_output_parameters
I really hope you can help, have been struggeling with this for a while and it should rather be easy...thanks in advance!
In your kv rule for <OutputParameters#GridLayout> you have a line:
frequenz: _frequenz
which sets frequenz to be a reference to the Label with the id of _frequenz. Then in that Label you are setting text using:
text: root.frequenz
So, you are trying to set the text of the Label to a reference to that Label
I suggest trying something like this:
<OutputParameters#GridLayout>
#Initialisierung .py zu .kv
frequenz: _frequenz
frequency: ''
And change the Label to:
Label:
id: _frequenz
text: root.frequency
font_size: 20
But to actually change the value shown in the label, you will need a reference to the instance of OutputParameters, using something like:
App.get_running_app().root.ids._output_parameters.frequency = str(500)