How to add print command on_press

36 views
Skip to first unread message

Sheena Wadhwa

unread,
Jun 22, 2016, 2:44:18 AM6/22/16
to Kivy users support

I have a sample code. That having menu on click options. I want to open csv file when i press a particular button and print its data. I am aware how to print csv file data with simple button but in menu am confused where to insert the data. i want to add read csv option and print its data under button. Click on "Teacher Information" > "Click here for teacher information" > This will ask for choose csv file from the folder > Then prints the data in python shell or on its own console window..

Any help will be appriciated

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen

Builder.load_string("""
<MenuScreen>:
    BoxLayout:
        Button:
            text: 'Teacher Information'
            on_press: root.manager.current = 'teacher'

        Button:
            text: 'Student Information'
            on_press: root.manager.current = 'student'

        Button:
            text: 'Attendence'
            on_press: root.manager.current = 'attendence'

        Button:
            text: 'Quit'

<TeacherScreen>:
    BoxLayout:
        Button:
            text: 'Click here to see Teacher Information'
            on_press: root.manager.current = 'teacher'

        Button:
            text: 'Back to menu'
            on_press: root.manager.current = 'menu'

<StudentScreen>:
    BoxLayout:
        Button:
            text: 'Click here to see Student Information'
        Button:
            text: 'Back to menu'
             on_press: root.manager.current = 'menu'

<AttendenceScreen>:
    BoxLayout:
        Button:
            text: 'Click here to see Teacher Attendence'

        Button:
            text: 'Click here to see Student Attendence'

        Button:
            text: 'Back to menu'
            on_press: root.manager.current = 'menu'

""")

class MenuScreen(Screen):
    pass

class TeacherScreen(Screen):
    pass

 class StudentScreen(Screen):
     pass

 class AttendenceScreen(Screen):
    pass


sm = ScreenManager()
sm.add_widget(MenuScreen(name='menu'))
sm.add_widget(TeacherScreen(name='teacher'))
sm.add_widget(StudentScreen(name='student'))
sm.add_widget(AttendenceScreen(name='attendence'))


class TestApp(App):

    def build(self):
        return sm

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

ZenCODE

unread,
Jun 22, 2016, 8:30:04 AM6/22/16
to Kivy users support
You could the the 'on_enter' on 'on_pore_enter' events on the screen classes? Something like:

class TeacherScreen(Screen):
    def on_enter(self, *args):


Sheena Wadhwa

unread,
Jun 22, 2016, 8:48:40 AM6/22/16
to kivy-...@googlegroups.com
i am aware of these but thats the issue that am not able to place at correct place

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/2iHN4sXA53s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ZenCODE

unread,
Jun 22, 2016, 4:19:41 PM6/22/16
to Kivy users support
Perhaps below? If this does not help, where is the 'correct place'? The below shows how to use the buttons presses. Where else would you want to do it?

<TeacherScreen>:
    BoxLayout:
        Button:
            text: 'Click here to see Teacher Information'
            on_press: root.show_teacher_info()


class TeacherScreen(Screen): def show_teacher_info(self):
# Do what you need here

Sheena Wadhwa

unread,
Jun 23, 2016, 6:18:32 AM6/23/16
to Kivy users support
This gives the following error:


 Invalid property name

Sheena Wadhwa

unread,
Jun 23, 2016, 6:51:52 AM6/23/16
to kivy-...@googlegroups.com
It gives an error when i try to insert this code


Sheena Wadhwa

unread,
Jun 23, 2016, 8:29:56 AM6/23/16
to kivy-...@googlegroups.com
error resolved thanks
Reply all
Reply to author
Forward
0 new messages