Run python kivy file

Asked

Viewed 809 times

0

I’m doing a crud maintenance using python/kivy. It’s four main files, one for table P, one for A, and one for C. The fourth main file is the main screen that will have three buttons for you to choose which table to edit and, when clicked on this button, runs the main of the selected table. However, I don’t remember how to execute a file when the button is clicked. Follow the main python code:

import kivy
from main_Aluno.py import Manutencao_A
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button 

class TelaPrincipal(App):
    pass

class Button(BoxLayout):
    def clickA(self)
        return main_Aluno.py
    def clickP(self):
        return main_Professor.py
    def clickC(self): 
        return main_Curso.py

botao = TelaPrincipal()
botao.run() 

Note: Maintenance is the class that contains the main A

I don’t know if it’s relevant but follow the kivy code too:

<Button@BoxLayout>:
    orientation: vertical

    Label:
        text: "Escolha a tela a ser editada"
    Button: 
        text: "Alunos"
        on_press: root.clickA()
    Button:
        text: "Professores" 
        on_press: root.clickP()
    Button:
        text: "Cursos"
        on_press: root.clickC()  

1 answer

1


You must be wanting to run the files through functions regardless of the classes it is not?

import kivy
import main_Aluno, main_Professor, main_Curso
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button 

class TelaPrincipal(App):
    pass

class MainButtons(Button):
    def clickA(self):
        main_Aluno.funcaoA()
    def clickP(self):
        main_Professor.funcaoP()
    def clickC(self): 
        main_Curso.funcaoC()

botao = TelaPrincipal()
botao.run() 

Kv file

BoxLayout:
    orientation: vertical

    Label:
        text: "Escolha a tela a ser editada"
    MainButtons: 
        text: "Alunos"
        on_press: self.clickA()
    MainButtons:
        text: "Professores" 
        on_press: self.clickP()
    MainButtons:
        text: "Cursos"
        on_press: self.clickC()  

Browser other questions tagged

You are not signed in. Login or sign up in order to post.