Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

python - Whats the best way to create a lot of kivy buttons depending on changing amount of functions in class?

I have a class like below that holds a bunch of functions for different equations to be solved. Each equation has a function to solve the equation and a function that returns the name of the function and the units associated with each variable.:

class EqList1():

    def xy_equation(unknown,varvalsdict):
        eq = 'x+y=-z*t'
        x,y,z,t = sym.symbols('x y z t')
        general.solver(unknown, varvalsdict, eq)
        print(ans)

    def xy_labels(self):
        equationname = 'xy'
        labelsdict = {'x':{'name':'x', 'unit':'meters'},'y':{'name':'y', 'unit':'meters'}
                      'z':{'name':'z', 'unit':'meters'},'t':{'name':'t', 'unit':'meters'}}
        return labelsdict, equationname

Now I am creating an app in kivy that has a main page where you select a button (EqList1) that takes you to a new page that will have a scrollbar with the names of all the equations in that class. What is the best way for me to create all of these buttons without having to have a button for every single equation in the kv file.

question from:https://stackoverflow.com/questions/65864090/whats-the-best-way-to-create-a-lot-of-kivy-buttons-depending-on-changing-amount

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...