Want to print Text on the Button, and automatically write(update) the value to a txt file

14 views
Skip to first unread message

Vita

unread,
May 23, 2020, 12:04:53 PM5/23/20
to Kivy users support

I am very beginner in making App and kivy
Thank you for your anticipated patience in this stupid question.

Untitled.png

This is what I tried to make. 
The user can select only one among the options, 
for examples, I select DOG and TEA and click the save button. 
Then, the result is automatically updated in previously saved file.
 How can I make this Print and save system on this code? Or any tips?

from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem
from kivy.lang import Builder




Builder.load_string("""
<Test>:
    do_default_tab: False
    TabbedPanelItem:
        text: 'page1'
        BoxLayout:
            BoxLayout:
                orientation:"
vertical"
                Button:
                    text: 'dog'
                Button:
                    text: 'cat'
            BoxLayout:
                orientation:"
vertical"
                Button:
                    text: 'tea'
                Button:
                    text: 'soda'
            Button:
                text: 'save'              


    TabbedPanelItem:
        text: 'page2'
        BoxLayout:                
            TextInput:
       
            Button:
                text: 'button'
"""
)




class MyApp(TabbedPanel):
   
def build(self):
       
return Test()


if __name__ == '__main__':
#    MyApp().run()

Elliot Garbus

unread,
May 23, 2020, 1:16:14 PM5/23/20
to kivy-...@googlegroups.com

Choosing between dog/Cat, Tea, and Soda

Use ToggleButtons, these will ‘hold’ the selection.  Use group to make them work like radio buttons, given the user can only choose one of each category.

 

The class MyApp must be derived from App.

 

class MyApp(App):
   
def build(self):
       
return Test()

 

Here is a little bit to help get you started:

 

 

from kivy.app import App
from kivy.lang import Builder

kv =
"""
TabbedPanel:

    do_default_tab: False
    TabbedPanelItem:
        text: 'page1'
        BoxLayout:
            BoxLayout:
                orientation:"vertical"
                ToggleButton:
                    text: 'dog'
                    group: 'animal'
                ToggleButton:
                    text: 'cat'
                    group: 'animal'
            BoxLayout:
                orientation:"vertical"
                ToggleButton:
                    text: 'tea'
                    group: 'drink'
                ToggleButton:
                    text: 'soda'
                    group: 'drink'

            Button:
                text: 'save'              


    TabbedPanelItem:
        text: 'page2'
        BoxLayout:               
            TextInput:

            Button:
                text: 'button'
"""


class MyApp(App):
   
def build(self):
       
return Builder.load_string(kv)


if __name__ == '__main__':
    MyApp().run()



 

 

 

From: Vita
Sent: Saturday, May 23, 2020 9:05 AM
To: Kivy users support
Subject: [kivy-users] Want to print Text on the Button, and automaticallywrite(update) the value to a txt file

 

 

I am very beginner in making App and kivy

Thank you for your anticipated patience in this stupid question.

 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/15410ef4-7b29-4053-a5c8-945a2dbb2d35%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages