Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I cannot agree more with @inclement. You should use the <a href="http://kivy.org/docs/guide/lang.html" rel="nofollow noreferrer">Kivy Language</a>. I suggest you to use the <a href="http://kivy.org/docs/api-kivy.uix.screenmanager.html" rel="nofollow noreferrer">ScreenManager</a>. Below I am posting a simplified example of a <a href="https://stackoverflow.com/questions/17428320/kivy-input-values-for-simple-calculations/17438904#17438904">previous answer</a> I gave. notice that you can have as many screens as you want and swap between using the property <code>current</code>:</p> <pre><code>on_press: root.current = 'screen2' </code></pre> <p>The <a href="http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties" rel="nofollow noreferrer">properties</a> (or <a href="http://kivy.org/docs/guide/events.html#introduction-to-properties" rel="nofollow noreferrer">here</a>) of Kivy are more than simple attributes. They trigger events that are use to keep the interface up to date. You can also use the Kivy Language to bind your events as @inclement pointed out. You just need to do something like this to call a method that is defined in the <code>Calc</code> class:</p> <pre><code>on_press: root.product(*args) </code></pre> <p>Or even executed in the Kivy Language if it is not to complicated.</p> <pre><code>on_press: _result.text = str(int(_a.text) + int(_b.text)) </code></pre> <p>Here is the code of something similar you are trying to achieve:</p> <pre class="lang-py prettyprint-override"><code>from kivy.app import App from kivy.lang import Builder from kivy.uix.screenmanager import ScreenManager Builder.load_string(""" &lt;Calc@ScreenManager&gt;: a: _a b: _b result: _result Screen: name: 'screen1' Button: size_hint: .3,.1 center: self.parent.center text: 'Go to Screen 2' on_press: root.current = 'screen2' Screen: name: 'screen2' GridLayout: cols: 2 Label: text: 'Value 1' TextInput: id: _a text: '3' Label: text: 'Value 2' TextInput: id: _b text: '5' Label: text: 'Result' 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) Button: text: 'Go to Screen 1' on_press: root.current = 'screen1' """) class Calc(ScreenManager): # 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.
    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.
    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