Reputation: 1
I'm having trouble with assigning a value to a variable while using TextInput from the Kivy library.
First of all, I'm trying to create a lease calculator on Kivy. I have already created the calculator but now I'm trying to convert it to the Kivy framework so I can use it on an android device.
I got stuck while trying to subtract the two values (lease and mileage). I tried:
milesleft = int(lease) - int(mileage)
but it told me "int() argument must be a string or a number, not 'TextInput'"
I'm very confused and have been searching for awhile for a solution. Please, any help or advice is appreciated!
leaseapp.py
import kivy
kivy.require('1.7.2')
from datetime import datetime, timedelta
import time
from kivy.core.window import Window
from kivy.uix.textinput import TextInput
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.scatter import Scatter
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.config import Config
from kivy.base import runTouchApp
if __name__ == '__main__':
root = BoxLayout(orientation='vertical', padding=20, spacing=10)
lease = TextInput(multiline=False, hint_text="Lease allowance per year", input_type='number')
lease.add_widget(TextInput(size_hint=(1, None)))
root.add_widget(lease)
mileage = TextInput(multiline=False, hint_text="Current mileage", input_type='number')
mileage.add_widget(TextInput(size_hint=(1, None)))
root.add_widget(mileage)
milesleft = int(lease) - int(mileage)
submitbutton = Button(text='Submit')
root.add_widget(submitbutton)
runTouchApp(root)
Upvotes: 0
Views: 1172