Im making a multiple choice question using kivy. I dont know how to track correct answers - kivy

I am a newbie in programming and badly needed help for our activity.
Im making a multiple choice question using kivy. I dont know how to track correct answers.
class OneQuestion(Screen):
correct = 0
mistake = 0
def checkbox_click(self, instance, value, answer):
if answer == 1:
correct = + 1
else:
mistake = + 1
global current_answer
answer= "You made " + str(correct) + " correct answers"
global current_error
error= "You made " + str(mistake) + " wrong answers"
current_answer = answer
current_error = error
def show_data(self):
self.dialog = MDDialog(title = "Result", text =current_answer,
pos_hint={'center_x': 0.5, 'center_y': 0.5},
buttons=[MDFlatButton(text='Close', on_release=self.close_dialog),
MDFlatButton(text='Return', on_release=self.close_dialog2)]
)
self.dialog.open()
def close_dialog(self, obj):
self.dialog.dismiss()
def close_dialog2(self, obj):
self.dialog.dismiss()
self.manager.current = 'exercise'
Kivy file:
<OneQuestion>
name: 'quest1'
GridLayout:
cols: 2
canvas:
MDLabel
text:"option 1"
font_size:20
CheckBox:
color: 0,0,1
on_active: root.checkbox_click(self,self.active, 0)
MDLabel
text:"option 2"
font_size:20
CheckBox:
color: 0,0,1
on_active: root.checkbox_click(self,self.active,1)
MDLabel
text:"option 3"
font_size:20
CheckBox:
color: 0,0,1
on_active: root.checkbox_click(self,self.active,0)
MDLabel
text:"option 4"
font_size:20
CheckBox:
color: 0,0,1
on_active: root.checkbox_click(self,self.active,1)
BoxLayout:
orientation: 'horizontal'
size_hint_y: 0.2
Button:
text: 'Back'
on_press: root.manager.current = 'exercise'
Button:
text: 'Submit'
on_release: root.show_data()

Related

AttributeError: object has no attribute 'ids'

I am new in kivy and I am trying to change image of float layout with a button
I tried everything I can but it didn't worked out.
I am getting the below error
AttributeError: 'Chat_Bot' object has no attribute 'ids'
May be I need to extend the class but I am not sure
Below is my main.py file
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager
from kivy.clock import Clock
from kivy.core.text import LabelBase
from kivymd.uix.label import MDLabel
from kivymd.uix.label import MDLabel
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import StringProperty,NumericProperty
from kivymd.uix.textfield import *
import lk_k
Window.keyboard_anim_args = {"d":.2,"t":"in_out_quart"}
Window.softinput_mode = ""
class Command(MDLabel):
text = StringProperty()
size_hint_x = NumericProperty()
halign = StringProperty()
font_size=26
class Response(MDLabel):
text = StringProperty()
size_hint_x = NumericProperty()
halign = StringProperty()
font_size=26
class main(MDApp):
def change_screen(self, name):
screen_manager.current = name
def build(self):
global screen_manager
screen_manager = ScreenManager()
screen_manager.add_widget(Builder.load_file("Chats.kv"))
return screen_manager
def response(self, *args):
q=lk_k.get_response(message)
if len(q)<6:
s=.22
h="center"
elif len(q)<11:
s=.32
h="center"
elif len(q) < 16:
s = .45
h = "center"
elif len(q) < 21:
s = .58
h = "center"
elif len(q) < 26:
s = .71
h = "center"
else:
s = .77
h = "center"
screen_manager.get_screen('chats').chat_list.add_widget(Response(text=q, size_hint_x=s,halign=h))
def send(self):
global message, size, halign
if screen_manager.get_screen('chats').text_input != "":
message = screen_manager.get_screen('chats').text_input.text
if len(message)<6:
size=.22
halign="center"
elif len(message)<11:
size=.32
halign="center"
elif len(message) < 16:
size = .45
halign = "center"
elif len(message) < 21:
size = .58
halign = "center"
elif len(message) < 26:
size = .71
halign = "center"
else:
size = .77
halign = "left"
screen_manager.get_screen('chats').chat_list.add_widget(Command(text=message,size_hint_x=size,halign=halign))
Clock.schedule_once(response, 1)
screen_manager.get_screen('chats').text_input.text = ""
global counter
counter = 0
def clear_image(self):
global counter
if counter==0:
self.ids.img2.source ='LOGO.png'
self.ids.img2.reload()
counter += 1
elif counter==1:
self.ids.img2.source ='on.png'
self.ids.img2.reload()
counter += 1
elif counter==2:
self.ids.img2.source ='off.png'
self.ids.img2.reload()
counter += 1
elif counter==3:
self.ids.img2.source =''
self.ids.img2.reload()
counter =0
if __name__ == "__main__":
main().run()
My chats.kv file
<Command>
size_hint_y:None
pos_hint:{"right": .99}
height: self.texture_size[1]
padding: 12,10
theme_text_color: "Custom"
text_color:53/255,56/255,60/255,1
canvas.before:
Color:
rgb: (1, 1,1,1)
RoundedRectangle:
size:self.width,self.height
pos:self.pos
radius:[23,0,23, 23]
<Response>
size_hint_y:None
pos_hint:{"x": .01}
height: self.texture_size[1]
padding: 12,10
theme_text_color: "Custom"
text_color: 53/255,56/255,60/255,1
canvas.before:
Color:
rgb: ( 0,1,1, 1)
RoundedRectangle:
size:self.width,self.height
pos:self.pos
radius:[0,23,23,23]
MDScreen:
bot_name: bot_name
text_input: text_input
chat_list: chat_list
name: "chats"
MDFloatLayout:
canvas :
Color:
rgb:1,1,1, 1
Rectangle:
id: img2
source:'q3.png'
size:self.size
pos:self.pos
MDFloatLayout:
md_bg_color: 0,1,1,1
size_hint_y:.11
pos_hint: {"center_y":.96}
MDLabel:
id: bot_name
text:"OLIVIA"
right_action_items: [["dots-vertical", lambda x: app.callback(x)]]
font_size: "25sp"
pos_hint: {"center_y": .43}
halign: "center"
theme_text_color: "Custom"
text_color: 53/255,56/255,60/255,1
MDIconButton:
icon:"emma.png"
pos_hint:{"center_x":.2,"center_y":.43}
user_font_size:"15sp"
theme_text_color:"Custom"
text_color:53/255,56/255,60/255,1
md_bg_color: 127/255,1, 212/255, 1
MDIconButton:
icon:"video-outline"
pos_hint:{"center_x":.80,"center_y":.43}
user_font_size:"31sp"
theme_text_color: "Custom"
text_color:53/255,56/255,60/255,1
MDIconButton:
text:"M"
pos_hint:{"center_x":.90,"center_y":.43}
user_font_size:"31sp"
theme_text_color: "Custom"
text_color:53/255,56/255,60/255,1
on_release: app.clear_image()
ScrollView:
size_hint_y:.78
background_color:1,1,1,1
pos_hint:{"x":0,"y":.116}
do_scroll_x:False
do_scroll_y:True
BoxLayout:
id:chat_list
orientation:'vertical'
size:(root.width,root.height)
height:self.minimum_height
size_hint:None, None
pos_hint:{"top": 1}
cols:1
spacing:3
MDFloatLayout:
size_hint_y:.08
md_bg_color:0,1,1,1
MDFloatLayout:
size_hint:.8, .75
pos_hint:{"center_x":.43,"center_y":.5}
md_bg_color:0,1,1,1
canvas:
Color:
rgb:1,1,1, 1
RoundedRectangle:
size:self.size
pos:self.pos
radius:[23, 23, 23, 23]
TextInput:
id:text_input
hint_text:"Type your message"
size_hint:1, None
pos_hint:{"center_x":.5,"center_y":.5}
multiline:False
font_size:"18sp"
height:self.minimum_height
cursor_color:1, 170/255, 23/255, 1
cursor_width:"2sp"
foreground_color:53/255,56/255,60/255,1
background_color:0,0,0,0
padding:30
MDIconButton:
icon:"send-outline"
pos_hint:{"center_x":.91,"center_y":.5}
user_font_size:"23sp"
theme_text_color:"Custom"
text_color:1,1,1,1
md_bg_color: 0,1,1,1
on_press:app.send()
Any help would be great
You cannot assign an id to a canvas instruction, but you can assign one to the widget that contains the canvas instruction. And, if you want to change the canvas instruct using python, it will be easier if the canvas instructions are defined in python rather than in kv. In order to do that, you can define an extension of MDFloatLayout that does the canvas instructions:
class MyMDFloatLayout(MDFloatLayout):
def __init__(self, **kwargs):
super(MyMDFloatLayout, self).__init__(**kwargs)
with self.canvas:
Color(1, 1, 1, 1) # set the colour
# Setting the size, position, and source of canvas
self.rect = Rectangle(pos=self.pos,
size=self.size,
source='q3.png')
# Update the canvas when the position/size changes
self.bind(pos=self.update_rect,
size=self.update_rect)
# update function which makes the canvas adjustable.
def update_rect(self, *args):
self.rect.pos = self.pos
self.rect.size = self.size
Then you can use this widget in your kv file in place of the MDFloatLayout that contains the canvas that we want to adjust:
MyMDFloatLayout:
id: img2
# canvas :
# Color:
# rgb:1,1,1, 1
# Rectangle:
# id: img2
# source:'q3.png'
# size:self.size
# pos:self.pos
Note that these canvas instructions in the kv are no longer required
Then, in your python code:
def clear_image(self):
global counter
if counter == 0:
widget = self.root.get_screen('chats').ids.img2
widget.rect.source = 'LOGO.png'
# self.ids.img2.source = 'LOGO.png'
# self.ids.img2.reload()
counter += 1
and similar for the other counter values.

Change text of label does not update text of label KIVY

I am trying to update a text of a label but it does not seem to update the text at all. I have a python file myfirebase.py and a kivy file signinscreen.kv.
The label id is "login_message" that I am trying to update. It is supposed to be updated in the python file with the following command: App.get_running_app().root.ids['signin_screen'] .ids['login_message'].text = 'invalid username or password'
There is no error; but it simply does not update the text of the label.
myfirebase.py:
"""
import requests
import json
from kivy.app import App
class MyFirebase():
def sign_in(self, username, password):
result_users =
requests.get("https://uniquedatabase-c4647-
default-rtdb.firebaseio.com/" + "users" + ".json")
data_users =
json.loads(result_users.content.decode())
incorrect_info = True
for users in data_users.values():
if username == users['username']:
passcode = users['password']
if password == passcode:
incorrect_info = False
App.get_running_app().my_user_id =
users
App.get_running_app().change_screen
('home_screen')
break
if incorrect_info:
App.get_running_app().root.ids['signin_screen']
.ids['login_message'].text = 'invalid username or
password'
"""
"""
<SigninScreen>:
FloatLayout:
GridLayout:
rows: 1
pos_hint: {"top": 1, "right": 1}
size_hint: 1, .2
Image:
source: 'images/Uniquelogo.jpg'
size: self.texture_size
TextInput:
id:login_username
hint_text: "username"
size_hint: .8,.1
pos_hint: {"top": .7, "right": .9}
TextInput:
id:login_password
hint_text: "password"
size_hint: .8,.1
pos_hint: {"top": .5, "right": .9}
Label:
id: login_message
text: ''
size_hint: .8,.1
pos_hint: {"top": .3, "right": .9}
color: 1,0,0,1
Button:
pos_hint: {"top": .2, "right": 0.75}
size_hint: 0.5, 0.25
text: 'Sign In'
color: 0,0,0,1
background_normal: ''
background_color: 1,0.95,0,1
on_release:
app.my_firebase.sign_in(login_username.text,
login_password.text)
"""
Main.py
"""
import sys
sys.path.append("/".join(x for x in __file__.split("/")
[:-1]))
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.button import ButtonBehavior
from kivy.uix.image import Image
import requests
import json
from myfirebase import MyFirebase
from workoutbanner import WorkoutBanner
from kivy.properties import ListProperty, StringProperty,
ObjectProperty
from kivy.utils import platform
if platform == 'ios':
from pyobjus import autoclass
from kivy.clock import mainthread
class HomeScreen(Screen):
pass
class ImageButton(ButtonBehavior,Image):
pass
class SigninScreen(Screen):
pass
class MealofthedayScreen(Screen):
pass
class SettingsScreen(Screen):
pass
class SigninScreen(Screen):
pass
class ColorScreen(Screen):
pass
class MainApp(App):
native_image_picker = ObjectProperty(None)
image_path = StringProperty("")
my_user_id = "user1"
user_table = "users"
activity_table = "activities"
user_id = StringProperty('user1')
get_users = requests.get("https://uniquedatabase-c4647-default-
rtdb.firebaseio.com/" + user_table + ".json")
data_get_users = json.loads(get_users.content.decode())
image_source_profile =
StringProperty(str(data_get_users[my_user_id]['picture']))
color_writings = StringProperty(str(data_get_users[my_user_id]
['color']))
def build(self):
self.my_user_id = 'user1'
self.my_firebase = MyFirebase()
GUI = Builder.load_file("main.kv")
return GUI
def on_start(self):
#Query database data
if platform == 'ios':
self.native_image_picker =
autoclass("NativeImagePicker").alloc().init()
result_users = requests.get("https://uniquedatabase-c4647-
default-rtdb.firebaseio.com/" + self.user_table + ".json")
result_activities = requests.get("https://uniquedatabase-
c4647-default-rtdb.firebaseio.com/" + self.activity_table
+ ".json")
data_users = json.loads(result_users.content.decode())
data_activities =
json.loads(result_activities.content.decode())
streak_label =
self.root.ids['home_screen'].ids['streak_label']
streak_label.text = str(data_users[self.my_user_id]['streak'])
banner_grid = self.root.ids['home_screen'].ids['banner_grid']
for workouts in data_activities.values():
W =
WorkoutBanner(user=workouts['user'],
date=workouts['date'],
firstName=workouts['firstName']
,typeWorkout=workouts['typeOfWorkout'],
lenghtWorkout=workouts['lenghtOfWorkout']
,color_writings = self.color_writings)
banner_grid.add_widget(W)
def update(self):
print("Updating image...")
folder = "/".join(x for x in self.user_data_dir.split("/")
[:-1])
image_path = folder + "/" + "cached.png"
self.image_source_profile = image_path
my_profile_picture_data = '{"picture":"%s"}'%image_path
requests.patch("https://uniquedatabase-c4647-default-
rtdb.firebaseio.com/" + self.user_table + "/" +
self.my_user_id + ".json",
data=my_profile_picture_data)
def pick_image(self):
if platform == 'ios':
self.native_image_picker.displayImagePicker()
def changeColor(self,color):
if color == 'red':
color_code = 'ff0000'
my_color_data = '{"color":"%s"}'%color_code
requests.patch("https://uniquedatabase-c4647-default-
rtdb.firebaseio.com/" + self.user_table + "/" +
self.my_user_id + ".json",
data=my_color_data)
elif color == 'electric blue':
color_code = '0000ff'
my_color_data = '{"color":"%s"}'%color_code
requests.patch("https://uniquedatabase-c4647-default-rtdb.firebaseio.com/" + self.user_table + "/" + self.my_user_id + ".json",
data=my_color_data)
elif color == 'cyan':
color_code = '00eeee'
my_color_data = '{"color":"%s"}'%color_code
requests.patch("https://uniquedatabase-c4647-default-rtdb.firebaseio.com/" + self.user_table + "/" + self.my_user_id + ".json",
data=my_color_data)
elif color == 'green':
color_code = '008000'
my_color_data = '{"color":"%s"}'%color_code
requests.patch("https://uniquedatabase-c4647-default-rtdb.firebaseio.com/" + self.user_table + "/" + self.my_user_id + ".json",
data=my_color_data)
elif color == 'yellow':
color_code = 'ffff00'
my_color_data = '{"color":"%s"}'%color_code
requests.patch("https://uniquedatabase-c4647-default-rtdb.firebaseio.com/" + self.user_table + "/" + self.my_user_id + ".json",
data=my_color_data)
elif color == 'purple':
color_code = '9b30ff'
my_color_data = '{"color":"%s"}'%color_code
requests.patch("https://uniquedatabase-c4647-default-rtdb.firebaseio.com/" + self.user_table + "/" + self.my_user_id + ".json",
data=my_color_data)
#Fill HomeScreen feed
def change_screen(self,screen_name):
screen_manager = self.root.ids["screen_manager"]
screen_manager.current = screen_name
#mainthread
def on_correct_info(self, users):
self.my_user_id = users
self.change_screen('home_screen')
#mainthread
def on_incorrect_info(self):
self.root.ids['signin_screen'].ids['login_message'].text = 'invalid username or password'
MainApp().run()
I think there's an easier way to do this.
First of all, I noticed you're not using fstring, I highly recommend using it, in my code example, I've added it there for the requests.get function as an example.
As well, it seems you can have self.my_firebase = MyFirebase() under the Build function of the app and it should work with the code below
regarding the id "login_message" - You need to add the label also under SignInScreen, so all other widgets under SigninScreen can access it, finally, I passed login_message in the app.firebase_sigin function, and change its value from there.
<SigninScreen>
login_message: login_message
Please take a look, and let me know if you have any further questions:
myfirebase.py
from kivy.app import App
import requests
import json
class MyFirebase():
BASE_URL = 'https://uniquedatabase-c4647-default-rtdb.firebaseio.com'
def sign_in(self, username, password):
result_users = requests.get(f"{self.BASE_URL}/users.json")
data_users = json.loads(result_users.content.decode())
for users in data_users.values():
if username == users['username']:
passcode = users['password']
if password == passcode:
return True
else:
return False
kv
<SigninScreen>:
login_message: login_message
FloatLayout:
GridLayout:
rows: 1
pos_hint: {"top": 1, "right": 1}
size_hint: 1, .2
Label:
id: login_message
text: ''
size_hint: .8,.1
pos_hint: {"top": .3, "right": .9}
color: 1,0,0,1
TextInput:
id:login_username
hint_text: "username"
size_hint: .8,.1
pos_hint: {"top": .7, "right": .9}
TextInput:
id:login_password
hint_text: "password"
size_hint: .8,.1
pos_hint: {"top": .5, "right": .9}
Button:
pos_hint: {"top": .2, "right": 0.75}
size_hint: 0.5, 0.25
text: 'Sign In'
color: 0,0,0,1
on_release:
app.firebase_signin(login_username.text, login_password.text, login_message)
main.py
from kivy.app import App
from kivy.uix.screenmanager import Screen
from myfirebase import MyFirebase
from kivy.lang import Builder
...
class SigninScreen(Screen):
pass
....
class MainApp(App):
def firebase_signin(self, username, password, login_message):
succeeded = self.my_firebase.sign_in(username, password)
if succeeded:
# here you implement changing screens, etc..
do_something = "doing something.."
else:
login_message.text = "invalid username or password"
def build(self):
self.my_user_id = 'user1'
self.my_firebase = MyFirebase()
GUI = Builder.load_file("main.kv")
return GUI
MainApp().run()
Before pressing the signin button
After pressing the signin button

Can't update LABEL text on kivy file

I have a problem with updating a label text: id: time_ // the strange thing is , i can read(print) with self.ids.time_.text. Merci for help
class Scroll(Screen):
def __init__(self, **kwargs):
super(Scroll, self).__init__(**kwargs)
self.sec = 0
self.min = 0
def Label_updater(self,time):
print(self.ids.time_.text)
#self.ids.time_.text= str(time)
self.ids.time_.text='new_ text'
def start_timer(self, *args):
self.sec += 1
self.time = f'00:0{self.sec}'
self.Label_updater(self.time)
def on_start(self):
Clock.schedule_interval(self.start_timer, 1)
kivy file :
<Scroll>:
id: scroll_id
canvas:
Color:
rgba: 149 / 250.0, 77 / 250.0, 114 / 250.0, 0.9
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
spacing:7
padding:10
size_hint:(1,0.1)
pos_hint:{'top':1,'b':1}
Label:
id: score
text: 'Score: 00'
Label:
id: level
text: 'Level: 01'
Label:
id: time_
size_hint: (1.0, 0.83)
text: '00:00'
color: 'red'
BoxLayout:
size_hint:(1,0.9)
GamePage:
padding: 20,20,20,20
will try to explain the probleme with some pictures
in class GamePage i did create some Buttons with callback = pressed( )
in pressed from there u see the starter object activating start_timer() (( this will start the timer ))
enter image description here
enter image description here
when i push a Button ---> everything is working fine till i can print(self.ids.time_.text) and i see in logfile the timer working
but in the screen the Label text still 00:00
enter image description here
but if i press the button ( added from the kivy file ) everything is working fine
i want to start the timer when i push any button
enter image description here

Add function to button in kivy file

I am trying to bind my calculations function to the submit button. I am new to Kivy and trying to get in some practice. Any tips or tricks for learning are greatly appreciated. Here is my code:
Python File:
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
class MyGrid(Widget):
pass
class MyApp(App):
def build(self):
return MyGrid()
def calculations(self):
org_amount = float(self.ids.orgamount.text)
org_tip = int(self.ids.orgtip.text)
org_split = int(self.ids.split1.text)
tip1 = org_tip/100
tip = round(tip1 * org_amount, 2)
total = round(tip + org_amount, 2)
if org_split == 0:
split = org_split
else:
split = round(total/org_split,2)
if __name__ == "__main__":
MyApp().run()
KIVY FILE:
<MyGrid>:
title: 'tipBot v1.0'
auto_dismiss: False
GridLayout:
cols:2
size: root.width * 0.8, root.height * 0.8
row_default_height: 30
row_force_default: True
center: root.width/2, root.height/2
Label:
text: "Enter orginal bill amount: "
TextInput:
id: orgamount
hint_text: 'Enter number w/ 2 decimal places'
hint_text_color: 'blue'
multiline:False
Label:
text: "How much tip will you leave: "
TextInput:
id: orgtip
hint_text: 'Enter whole number'
hint_text_color: 'blue'
multiline:False
Label:
text: "How many patrons will split the bill: "
TextInput:
id: split1
multiline: False
Label:
text: "Orignal Bill Amount: "
TextInput:
id: amount
multiline: False
Label:
text: "Amount of tip: "
TextInput:
id: tip
multiline: False
Label:
text: "Total with tip: "
TextInput:
id: withtip
multiline: False
Label:
text:"Amount for each patron split: "
TextInput:
id:patronsplit
multiline: False
Button:
id: Clear
text: "Clear"
size_hint_x: 0
on_release:
orgamount.text = ''
orgtip.text = ''
split1.text = ''
amount.text = ''
tip.text = ''
withtip.text = ''
patronsplit.text =''
Button:
id: Submit
text: "Submit"
size_hint_x:0.5
on_press: root.calculations()
enter code here
The problem is that in your kv, the line:
on_press: root.calculations()
is trying to call the calculations() method of the root object of the kv rule, which is MyGrid. The fix is to just move the calculations() method into MyGrid:
class MyGrid(Widget):
def calculations(self):
org_amount = float(self.ids.orgamount.text)
org_tip = int(self.ids.orgtip.text)
org_split = int(self.ids.split1.text)
tip1 = org_tip / 100
tip = round(tip1 * org_amount, 2)
total = round(tip + org_amount, 2)
if org_split == 0:
split = org_split
else:
split = round(total / org_split, 2)
class MyApp(App):
def build(self):
return MyGrid()

Kivy TextInput how to change hint_text font size

Is there a way to change a TextInput hint_text font size in Kivy? I could not find any documentation on using something as hint_text_size.
TextInput:
id: text_input_unique
hint_text: 'example: Stand25'
hint_text_size: 16
multiline: False
size_hint_y: None
height: 50
font_size: 32
halign: 'center'
cursor_color: (0,0,0,1)
The TextInput uses the same font properties for hint_text as it does for the main text (except for color). Here is an extension of TextInput that honors a hint_font_size property:
class TextInputwHintSize(TextInput):
hint_font_size = NumericProperty(sp(15))
def __init__(self, **kwargs):
self.regular_font_size = sp(15)
self.ignore_font_size_change = False
super(TextInputwHintSize, self).__init__(**kwargs)
Clock.schedule_once(self.set_font_size)
def set_font_size(self, dt):
self.ignore_font_size_change = True
if self.text == '':
self.font_size = self.hint_font_size
def on_font_size(self, instance, size):
if self.ignore_font_size_change:
return
self.regular_font_size = size
def on_text(self, instance, text):
if text == '':
self.font_size = self.hint_font_size
else:
self.font_size = self.regular_font_size
for example, use this like:
TextInputwHintSize:
id: text_input_unique
hint_text: 'example: Stand25'
hint_font_size: 16
multiline: False
size_hint_y: None
height: 50
font_size: 32
halign: 'center'
cursor_color: (0,0,0,1)

Resources