Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I hope I got to understand your question. You are asking for methods to do this. The plain answer is that you have the whole Python to do all the operations you want. Kivy is a library that provides a lot of components to design GUI. It also provides you with a language that is parsed by the <code>Builder.load_string()</code>. Here is an example that might be more or less what you are looking for. It is sort of a calculator on the first screen. The second screen is empty and you can move between them with the bottom buttons.</p> <p>The calculator on the first screen has two <code>InputTexts</code> and two buttons (<code>Sum</code> and <code>Product</code>). The Sum Button has the implementation of a sum directly on the kivy language. The Product Button calls a method in the root (an instance of Calc). The method doesn't exist by itself. I created in the python code below the kivy section. There is some comments on the code for what I am saying.</p> <pre><code>from kivy.app import App from kivy.lang import Builder from kivy.uix.floatlayout import FloatLayout Builder.load_string(""" &lt;Calc&gt;: # This are attributes of the class Calc now a: _a b: _b result: _result AnchorLayout: anchor_x: 'center' anchor_y: 'top' ScreenManager: size_hint: 1, .9 id: _screen_manager Screen: name: 'screen1' GridLayout: cols:1 TextInput: id: _a text: '3' TextInput: id: _b text: '5' Label: id: _result Button: text: 'sum' # You can do the opertion directly on_press: _result.text = str(int(_a.text) + int(_b.text)) Button: text: 'product' # Or you can call a method from the root class (instance of calc) on_press: root.product(*args) Screen: name: 'screen2' Label: text: 'The second screen' AnchorLayout: anchor_x: 'center' anchor_y: 'bottom' BoxLayout: orientation: 'horizontal' size_hint: 1, .1 Button: text: 'Go to Screen 1' on_press: _screen_manager.current = 'screen1' Button: text: 'Go to Screen 2' on_press: _screen_manager.current = 'screen2'""") class Calc(FloatLayout): # define the multiplication of a function def product(self, instance): # self.result, self.a and self.b where defined explicitely in the kv self.result.text = str(int(self.a.text) * int(self.b.text)) class TestApp(App): def build(self): return Calc() if __name__ == '__main__': TestApp().run() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload