Python3 KivyMD - MDDialog get ItemConfirm text value - kivy

I want to pass to my project_selected function the selected item in my MDDialog after pressing the OK button. But I can't figure out how can I get the value and do this.
I could print the value inside my set_icon funtion in ItemConfirm class, but I don't know whats the better way to pass that value to HomeWindow(Screen) class or if it is possible to call it directly from inside of it once that the ItemConfirm is already called from inside a function that is part of HomeWindow class.
main.py
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen, ScreenManager
from kivymd.app import MDApp
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
from kivymd.uix.list import OneLineAvatarIconListItem
class ItemConfirm(OneLineAvatarIconListItem):
divider = None
def set_icon(self, instance_check):
print(self.text)
instance_check.active = True
check_list = instance_check.get_widgets(instance_check.group)
for check in check_list:
if check != instance_check:
check.active = False
class HomeWindow(Screen):
dialog = None
def show_confirmation_dialog(self):
projects = [{id: 0, name: "example1"},{id: 1, name: "example2"}]
if not self.dialog:
self.dialog = MDDialog(
title="Projects",
type="confirmation",
auto_dismiss=False,
items=[ItemConfirm(text=f"{project['name']}") for project in projects],
buttons=[
MDFlatButton(text="CANCEL", theme_text_color="Custom"),
MDFlatButton(
text="OK",
theme_text_color="Custom",
on_release=self.project_selected,
),
],
)
self.dialog.open()
def project_selected(self, *args, **kwargs):
self.ids.project_selection.text = self.dialog.text
class WindowManager(ScreenManager):
pass
class RlogTimer(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "BlueGray"
self.root = Builder.load_file("templates/main.kv")
return self.root
if __name__ == "__main__":
RlogTimer().run()
templates/main.kv
#: import NoTransition kivy.uix.screenmanager.NoTransition
WindowManager:
HomeWindow:
<ScreenManager>:
transition: NoTransition()
<ItemConfirm>:
on_release: root.set_icon(check)
CheckboxLeftWidget:
id: check
group: "check"
<HomeWindow>:
name: "home"
MDBoxLayout:
orientation: "vertical"
MDToolbar:
id: title
title: "Redmine logTimer"
right_action_items: [["clock", lambda x: app.callback_2()]]
MDFlatButton:
id: project_selection
text: "Select Project"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: root.show_confirmation_dialog()

You can achieve that as follows,
First create a prop. say, selected_project in HomeWindow as,
class HomeWindow(Screen):
dialog = None
selected_project = StringProperty()
Now set its value in method set_icon as,
def set_icon(self, instance_check):
...
app = MDApp.get_running_app() # Access the running app instance.
home_screen = app.root.get_screen("home") # Access required screen.
home_screen.selected_project = self.text # Now set value.
...
Now it's time to set this value in method project_selected,
def project_selected(self, *args, **kwargs):
self.ids.project_selection.text = self.selected_project

Related

.kv is loaded multiples times, you might have unwanted behaviors

I can run my code but I'm having such unwanted behavior enter image description here, I combined my source code with the https://dev.to/ngonidzashe/how-to-create-a-simple-to-do-list-application-with-kivymd-d89 , and I guess I didn't combine it right here are my code:
import mysql.connector
from kivy.lang import Builder
from kivymd.uix.dialog import MDDialog
from kivymd.uix.button import MDFlatButton
from kivy.uix.screenmanager import ScreenManager
from kivymd.app import MDApp
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.picker import MDDatePicker
from datetime import datetime
from kivymd.uix.list import TwoLineAvatarIconListItem, ILeftBodyTouch
from kivymd.uix.selectioncontrol import MDCheckbox
from database import Database
from kivy.core.window import Window
Window.size = (350, 600)
db = Database()
class MainApp(MDApp):
def build(self):
global screen_manager
screen_manager = ScreenManager()
screen_manager.add_widget(Builder.load_file("login.kv"))
screen_manager.add_widget(Builder.load_file("register.kv"))
screen_manager.add_widget(Builder.load_file("main.kv"))
return screen_manager
database = mysql.connector.connect(host='localhost',
database='loginform',
user='root',
password='****')
cursor = database.cursor()
def send_data(self, user, password):
self.cursor.execute(f"insert into example2 values('{user.text}','{password.text}')")
self.database.commit()
def receive_data(self, user, password):
self.cursor.execute("select * from example2")
user_list = []
for i in self.cursor.fetchall():
user_list.append(i[0])
if user.text in user_list and user.text != "":
self.cursor.execute(f"select password from example2 where user='{user.text}'")
for j in self.cursor:
if password.text == j[0]:
open_button = MDFlatButton(text='Open the App', on_release=self.open_app)
close_button = MDFlatButton(text='Close', on_release=self.close_dialg)
self.dialog = MDDialog(text='Welcome to the *****',
buttons=[close_button, open_button])
self.dialog.open()
else:
try_button = MDFlatButton(text='Try Again', on_release=self.close_dialg)
self.dialog = MDDialog(title='Incorrect Password',
text='You entered wrong password please try again',
buttons=[try_button])
self.dialog.open()
else:
open_regist = MDFlatButton(text="Register", on_release=self.open_regist)
close_button = MDFlatButton(text='Close', on_release=self.close_dialg)
self.dialog = MDDialog(title='Incorrect User',
text='There are no such user',
buttons=[close_button, open_regist])
self.dialog.open()
def open_regist(self, *args):
screen_manager.current = "register"
self.dialog.dismiss()
def close_dialg(self, *args):
self.dialog.dismiss()
def open_app(self, *args):
screen_manager.current = "tasks"
self.dialog.dismiss()
task_list_dialog = None # Here
# Add the below functions
def show_task_dialog(self):
if not self.task_list_dialog:
self.task_list_dialog = MDDialog(
title="Create Task",
type="custom",
content_cls=DialogContent(),
)
self.task_list_dialog.open()
def on_start(self):
"""Load the saved tasks and add them to the MDList widget when the application starts"""
try:
completed_tasks, uncomplete_tasks = db.get_tasks()
if uncomplete_tasks != []:
for task in uncomplete_tasks:
add_task = ListItemWithCheckbox(pk=task[0], text=task[1], secondary_text=task[2])
self.root.ids.container.add_widget(add_task)
if completed_tasks != []:
for task in completed_tasks:
add_task = ListItemWithCheckbox(pk=task[0], text='[s]' + task[1] + '[/s]',
secondary_text=task[2])
add_task.ids.check.active = True
self.root.ids.container.add_widget(add_task)
except Exception as e:
print(e)
pass
def close_dialog(self, *args):
self.task_list_dialog.dismiss()
def add_task(self, task, task_date):
"""Add task to the list of tasks"""
# Add task to the db
created_task = db.create_task(task.text, task_date) # Here
# return the created task details and create a list item
self.root.ids['container'].add_widget(
ListItemWithCheckbox(pk=created_task[0], text='[b]' + created_task[1] + '[/b]',
secondary_text=created_task[2])) # Here
task.text = ''
class DialogContent(MDBoxLayout):
"""OPENS A DIALOG BOX THAT GETS THE TASK FROM THE USER"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
# set the date_text label to today's date when user first opens dialog box
self.ids.date_text.text = str(datetime.now().strftime('%A %d %B %Y'))
def show_date_picker(self):
"""Opens the date picker"""
date_dialog = MDDatePicker()
date_dialog.bind(on_save=self.on_save)
date_dialog.open()
def on_save(self, instance, value, date_range):
"""This functions gets the date from the date picker and converts its it a
more friendly form then changes the date label on the dialog to that"""
date = value.strftime('%A %d %B %Y')
self.ids.date_text.text = str(date)
# create the following two classes
class ListItemWithCheckbox(TwoLineAvatarIconListItem):
"""Custom list item"""
def __init__(self, pk=None, **kwargs):
super().__init__(**kwargs)
# state a pk which we shall use link the list items with the database primary keys
self.pk = pk
def mark(self, check, the_list_item):
"""mark the task as complete or incomplete"""
if check.active == True:
# add strikethrough to the text if the checkbox is active
the_list_item.text = '[s]' + the_list_item.text + '[/s]'
db.mark_task_as_complete(the_list_item.pk) # here
else:
the_list_item.text = str(db.mark_task_as_incomplete(the_list_item.pk)) # Here
def delete_item(self, the_list_item):
"""Delete the task"""
self.parent.remove_widget(the_list_item)
db.delete_task(the_list_item.pk) # Here
class LeftCheckbox(ILeftBodyTouch, MDCheckbox):
"""Custom left container"""
if __name__ == '__main__':
app = MainApp()
app.run()
and here is my kv file with this:
MDScreen:
name: "tasks"
MDFloatLayout:
MDLabel:
id: task_label
halign: 'center'
markup: True
text: "[u][size=48][b]TASKS[/b][/size][/u]"
pos_hint: {'y': .45}
ScrollView:
pos_hint: {'center_y': .5, 'center_x': .5}
size_hint: .9, .8
MDList:
id: container
MDFloatingActionButton:
icon: 'plus-thick'
on_release: app.show_task_dialog() #functionality to be added later
elevation_normal: 12
pos_hint: {'x': .8, 'y':.05}
<DialogContent>:
orientation: "vertical"
spacing: "10dp"
size_hint: 1, None
height: "130dp"
GridLayout:
rows: 1
MDTextField:
id: task_text
hint_text: "Add Task..."
pos_hint: {"center_y": .4}
max_text_length: 50
on_text_validate: (app.add_task(task_text, date_text.text), app.close_dialog())
MDIconButton:
icon: 'calendar'
on_release: root.show_date_picker()
padding: '10dp'
MDLabel:
spacing: '10dp'
id: date_text
BoxLayout:
orientation: 'horizontal'
MDRaisedButton:
text: "SAVE"
on_release: (app.add_task(task_text, date_text.text), app.close_dialog())
MDFlatButton:
text: 'CANCEL'
on_release: app.close_dialog()
<ListItemWithCheckbox>:
id: the_list_item
markup: True
LeftCheckbox:
id: check
on_release:
root.mark(check, the_list_item)
IconRightWidget:
icon: 'trash-can-outline'
theme_text_color: "Custom"
text_color: 1, 0, 0, 1
on_release:
root.delete_item(the_list_item)
I would be very thankful if someone can help or give some tips, how to improve. I'm open to have private conversation.
A kv file with the name main.kv will be loaded automatically by Kivy for your application (See documentation). So your code:
screen_manager.add_widget(Builder.load_file("main.kv"))
is loading main.kv a second time. The easiest fix is to just rename the main.kv file.

Kivymd Custom Input Dialog. problem with getting text

I am creating an Input Dialog using kivymd. Whenever I try to fetch the text from the text field, it doesn't output the text, rather it seems like the text is not there. (the dialog just pops up ok and the buttons are working fine).
part of the kivy code
<Content>
MDTextField:
id: pin
pos_hint: {"center_x": 0.5, "center_y": 0.5}
color_mode: 'custom'
line_color_focus: [0,0,1,1]
part of the python code
class Content(FloatLayout):
pass
class MenuScreen(Screen):
def __init__(self, **kwargs):
super(MenuScreen, self).__init__(**kwargs)
def show_confirmation_dialog(self):
# if not self.dialog:
self.dialog = MDDialog(
title="Enter Pin",
type="custom",
content_cls=Content(),
buttons=[
MDFlatButton(
text="cancel",on_release=self.callback
),
MDRaisedButton(
text="[b]ok[/b]",
on_release=self.ok,
markup=True,
),
],
size_hint_x=0.7,
auto_dismiss=False,
)
self.dialog.open()
def callback(self, *args):
self.dialog.dismiss()
def ok(self, *args):
pin = Content().ids.pin.text
if pin == "":
toast("enter pin")
else:
toast(f"pin is {pin}")
You can call the Content class to a variable and use it in the MDDialog.content_cls.
def show_custom_dialog(self):
content_cls = Content() # call the class to a variable
self.cdialog = MDDialog(content_cls=content_cls,
type='custom', title='Enter Pin'
)
self.cdialog.buttons = [
MDFlatButton(text='cancel',on_release=self.close_dialog),
MDRaisedButton(text='Ok',
on_release=lambda x:self.get_data(x,content_cls))
]
self.cdialog.open()
Then create a function that will get the event_button and the content class as arguments by use of lambda expression in the button as shown above.
def get_data(self,instance_btn, content_cls):
textfield = content_cls.ids.pin
# get input
value = textfield._get_text()
# do stufs here
toast(value)
At this point you can extract any id in the Content class.I hope this helps.
Refer below for full code
from kivmd.app import MDApp
from kivymd.uix.floatlayout import MDFloatLayout
from kivymd.uix.dialog import MDDialog
from kivymd.uix.button import MDFlatButton, MDRaisedButtom
from kivy.lang.builder impor Builder
from kivy.toast import toast
kv = '''
MDBoxLayout:
orientation : 'vertical'
MDFlatbutton:
text : 'Dialog'
pos_hint : {'center_x':.5'}
on_release : app.show_custom_dialog()
<Content>:
MDTextField:
id : pin
pos_hint : {'center_x':.5,'center_y':.5}
'''
class Content(MDFloatLayout):
pass
class InputDialogApp(MDApp):
cdialog = None
def build(self):
return Builder.load_string(kv)
def show_custom_dialog(self):
content_cls = Content()
self.cdialog = MDDialog(title='Enter Pin',
content_cls=content_cls,
type='custom')
self.cdialog.buttons = [
MDFlatButton(text="Cancel",on_release=self.close_dialog),
MDRaisedButton(text="Ok",on_release=lambda x:self.get_data(x,content_cls))
]
self.cdialog.open()
def close_dialog(self, instance):
if self.cdialog:
self.cdialog.dismiss()
def get_data(self, instance_btn, content_cls):
textfield = content_cls.ids.pin
value = textfield._get_text()
# do stuffs here
toast(value)
self.close_dialog(instance_btn)
if __name__ == '__main__':
InputDialogApp().run()
I was also having this problem, and the comment by edwin helped a lot. However, one suggestion. instead of formatting it with buttons = [...] inside of MDDialog as opposed to after, like so self.cdialog = MDDialog(..., buttons = [...]) since otherwise the buttons dont show up but other than that it should work!

Recycleview AttributeError: 'super' object has no attribute '__getattr__'

please check why the below program is giving an
AttributeError: 'super' object has no attribute '__getattr__'
.py:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ListProperty, NumericProperty, ObjectProperty
from kivy.uix.recycleview.views import RecycleDataViewBehavior
from kivy.uix.textinput import TextInput
# from kivy.effects.scroll.ScrollEffect import ScrollEffect
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.gridlayout import GridLayout
from kivy.uix.recycleboxlayout import RecycleBoxLayout
Builder.load_file('so_extractTIC.kv')
class RecycleItem(ScreenManager,RecycleDataViewBehavior, TextInput):
index = NumericProperty(0)
def refresh_view_attrs(self, rv, index, data):
self.index = index
return super(RecycleItem, self).refresh_view_attrs(rv, index, data)
class DataView(Screen):
DataList = ListProperty()
TextInputNum = NumericProperty(10)
def __init__(self,*args,**kwargs):
super(DataView, self).__init__(*args,**kwargs)
# for key, val in self.ids.items():
# print("key={0}, val={1}".format(key, val))
data12= []
for x in range(self.TextInputNum):
data12.append({'text': '', 'height': 50})
self.ids.rv.data = data12
def extract_data(self,rv):
print(self.parent.parent.parent)
self.DataList.clear()
for x in range(self.TextInputNum):
self.DataList.append(self.ids.rv.data[x]['text'])
print(self.DataList)
class RootWidget(ScreenManager):
pass
class MainApp(App):
def build(self):
# self.root = Builder.load_string(APP_KV)
return RootWidget()
if __name__ == '__main__':
MainApp().run()
.kv:
<DataView>:
BoxLayout:
orientation: 'vertical'
RecycleView:
size_hint_y: 0.9
viewclass: 'RecycleItem'
id: rv
key_size: 'size'
# effect_cls: ScrollEffect
cols: 1
RecycleBoxLayout:
id: rvbox
cols: rv.cols
orientation: 'vertical'
size_hint_y: None
height: self.minimum_height
default_size_hint: 1, None
Button:
text: 'Submit'
size_hint_y: 0.1
on_release: root.extract_data()
<RecycleItem>:
on_text: self.parent.parent.data[self.index]['text'] = self.text
<RootWidget>:
DataView:
name:"DataView_screen"
I have been searching for extract data from recycleview using textInput boxes. Please find the link for the query:
Retrieve Data from Kivy Recycleview
I am trying to inherit from ScreenManager, but it is giving the 'super' attribute error. Tried passing id as argument in the .kv and tried to find real parent but nothing works.
Also, please suggest how to use the above code for recycle GridLaout, with 2d rows and columns, i tried using for loops, but getting key related errors.
like:
for z in range(12):
for y in range(8):
self.table_data12.append(self.ids.idname.data[y][z]['text'])
thanks!
In your DataView class, the __init__() method references self.ids, but the ids are not yet available at that point. You can delay that referencing by using Clock.schedule_once() like this:
def __init__(self, *args, **kwargs):
super(DataView, self).__init__(*args, **kwargs)
# for key, val in self.ids.items():
# print("key={0}, val={1}".format(key, val))
Clock.schedule_once(self.setup_data)
def setup_data(self, dt):
data12 = []
for x in range(self.TextInputNum):
data12.append({'text': '', 'height': 50})
self.ids.rv.data = data12
I see no reason for making the RecycleItem a subclass of ScreenManager.
In your 'kv, the on_textline forRecycleItem` can be:
<RecycleItem>:
on_text: app.root.get_screen('DataView_screen').ids.rv.data[self.index]['text'] = self.text
And the submit Button can be:
Button:
text: 'Submit'
size_hint_y: 0.1
on_release: root.extract_data(rv)

How do i create a countdown timer in ModalView after pressing a button?

I am trying to create a modalview with a timer in it. Upon pressing the "begin" button, a modal view should appear and the countdown should start. However, I am getting an valueerror message. ValueError: TimerView.timer has an invalid format (got main.TimerView object at 0x0000017AD40D6180>>>).May I know which part of the code is wrong? Thanks in advance.
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition, WipeTransition, NoTransition, SlideTransition
from kivymd.theming import ThemeManager
from kivy.properties import StringProperty, NumericProperty
from kivy.uix.modalview import ModalView
from kivymd.uix.label import MDLabel
from kivy.clock import Clock
class TimerView(ModalView):
number = NumericProperty(15)
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.background = "transparent_image.png"
self.background_color = [1/3,1/3,1/3,0.8]
self.auto_dismiss = False
self.size_hint = (None,None)
self.size = (150,50)
timer_countdown = MDLabel(font_style = 'H1', theme_text_color = 'Primary',
text = str(self.number), halign = 'center',
text_color = (1,1,1,1), size_hint_y = None)
self.add_widget(timer_countdown)
def decrement_time(self, dt):
self.number -= 1
def start(self,*args):
self.timer = Clock.schedule_interval(self.decrement_time, 1)
def stop(self):
Clock.unschedule(self.timer)
class MainScreen(Screen):
pass
class BeginScreen(Screen):
pass
class MyScreenManager(ScreenManager):
def __init__(self,**kwargs):
super().__init__(**kwargs)
self.view = TimerView()
def open_view(self):
self.view.bind(on_open=self.view.start)
self.view.open()
main_widget_kv = ('''
#: import ScrollEffect kivy.effects.scroll.ScrollEffect
MyScreenManager:
BeginScreen:
<BeginScreen>:
begin_button:begin_button
name: "begin"
canvas.before:
Color:
rgb: .1, .1, .1
FloatLayout:
id: begin_layout
Button:
id: begin_button
text: 'Begin'
font_size: 24
on_press: app.root.open_view()
size_hint: (.4,.25)
pos_hint: {"center_x":.5, "center_y":.2}
color: [0,0,0,1]
''')
class TestApp(MDApp):
def __init__(self,**kwargs):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Red"
super().__init__(**kwargs)
def build(self):
main_widget = Builder.load_string(main_widget_kv)
return main_widget
if __name__ == '__main__':
TestApp().run()
When you set the text of a Label in python code, it uses the value at that time, and will not change automatically. If you do the same thing in kv, it will update automatically (provided that the text references a Property). So just changing self.number has no effect on your timer_countdown Label.
So, you need to update that text explicitly. Here is a modified version of your code that does that:
class TimerView(ModalView):
number = NumericProperty(15)
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.background = "transparent_image.png"
self.background_color = [1/3,1/3,1/3,0.8]
self.auto_dismiss = False
self.size_hint = (None,None)
self.size = (150,50)
self.timer_countdown = MDLabel(font_style = 'H1', theme_text_color = 'Primary',
text = str(self.number), halign = 'center',
text_color = (1,1,1,1), size_hint_y = None)
self.add_widget(self.timer_countdown)
def decrement_time(self, dt):
self.number -= 1
# self.timer_countdown.text = str(self.number)
def on_number(self, instance, value):
self.timer_countdown.text = str(value)
def start(self,*args):
self.t = Clock.schedule_interval(self.decrement_time, 1)
def stop(self):
Clock.unschedule(self.t)
A reference to the MDLabel is kept in self.timer_countdown and the on_number() method gets executed whenever number changes, and just updates the MDLabel. Note that you can also do the update by just uncommenting the line:
# self.timer_countdown.text = str(self.number)
In that case, number does not need to be a Property, and the on_number() method is not needed.

Kivy Text Input. Setting text with Clock.schedule_once()

I though that it will be fairly simple to show set some text to TextInput and show it on the screen but it seems I was wrong. In the below code I need to set text Lorem ipsum... to the text input and switch the tabs. I can see the text only when I uncomment Clock.schedule_interval(self.set_text, 1). I would use Clock.schedule_once or any other way than just constantly calling set_text() method.
'''
Test of the widget TabbedPanel.
'''
from kivy.app import App
from kivy.clock import Clock
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelHeader
from kivy.factory import Factory
theRoot = """
#:import Factory kivy.factory.Factory
<EditButton>
orientation: 'vertical'
Button:
text: 'Switch to Edit Screen'
on_press: root.change_tab()
<EditInput>
orientation: 'vertical'
TextInput:
id: text_input
<UnCloseableHeader>
color: 0,0,0,1
disabled_color: self.color
# variable tab_width
text: 'tabx'
size_hint_x: None
width: self.texture_size[0] + 40
BoxLayout:
pos: root.pos
size_hint: None, None
size_y: 20
padding: 3
Label:
id: lbl
text: root.text
<MainTabbedPanel>:
size_hint: (1, 1)
do_default_tab: False
#default_tab: edit_button_tab
tab_width: 130
FloatLayout:
EditButton:
id: edit_button
EditInput:
id: edit_input
UnCloseableHeader:
id: edit_button_tab
text: 'Edit'
content: edit_button.__self__
UnCloseableHeader:
id: edit_input_tab
text: 'Edit Tab'
content: edit_input.__self__
MainTabbedPanel:
"""
class EditInput(BoxLayout):
notes = ''
def __init__(self, **kwargs):
super(EditInput, self).__init__(**kwargs)
print('NOTES', self.notes)
#Clock.schedule_interval(self.set_text, 1)
Clock.schedule_once(self.set_text, -1)
def set_text(self, dt):
print('SET TEXT', self.notes)
self.ids.text_input.text = self.notes
class EditButton(BoxLayout):
def __init__(self, **kwargs):
super(EditButton, self).__init__(**kwargs)
def change_tab(self):
EditInput.notes = 'Lorem ipsum...'
EditInput()
mtp = App.get_running_app().root
mtp.switch_to(mtp.ids.edit_input_tab)
class MainTabbedPanel(TabbedPanel):
tab = ''
def __init__(self, **kwargs):
super(MainTabbedPanel, self).__init__(**kwargs)
self.tabs_showing = True
class UnCloseableHeader(TabbedPanelHeader):
pass
Factory.register('UnCloseableHeader', cls=UnCloseableHeader)
sm = Builder.load_string(theRoot)
class TabbedPanelApp(App):
def build(self):
return sm
if __name__ == '__main__':
TabbedPanelApp().run()
EDIT
I've tried with:
SNIPPET
def change_tab(self):
EditInput.notes = 'Lorem ipsum...'
EditInput()
and:
Clock.schedule_once(self.set_text, 1)
It works in about 50% of cases witch is pretty hard to understand
You can take advantage of Property binding that kv sets up for you. Change your EditInput class to simply:
class EditInput(BoxLayout):
notes = StringProperty('')
no need for any of the methods. Then, in your kv, change the EditInput rule to:
<EditInput>
orientation: 'vertical'
TextInput:
id: text_input
text: root.notes
and change the change_tab method of EditButton to:
def change_tab(self):
mtp = App.get_running_app().root
mtp.ids.edit_input.notes = 'Lorem ipsum...'
mtp.switch_to(mtp.ids.edit_input_tab)
Note that changing the notes property of the EditInput instance will automatically change the TextInput (due to the property binding set up by kv).
Also, the line in change_tab():
EditInput()
is creating a new instance of the EditInput class that is unused and will be garbage collected.

Resources