我需要做的是输出到提交按钮下面的标签,现在它打印到控制台,有人能告诉我做这件事的代码吗???
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
class MyGrid(GridLayout):
def __init__(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)
self.cols = 1
self.inside = GridLayout()
self.inside.cols = 1
self.inside.add_widget(Label(text="Sale Price: ", font_size=100))
self.name = TextInput(input_filter="int", multiline=False, font_size=150)
self.inside.add_widget(self.name)
self.add_widget(self.inside)
self.submit = Button(text="Run the Numbers", font_size=100)
self.submit.bind(on_press=self.pressed)
self.add_widget(self.submit)
def pressed(self, instance):
name = int(self.name.text)
calc = name * .0975
tax = name + calc
#######first franklin#########
#######6 months#######
a = tax * .06
b = tax + a
c = b / 6
######12 months#####
d = tax * .08
e = tax + d
f = e / 12
######24 months####
g = tax * .15
h = tax + g
i = h / 24
########Synchrony########
#####24 months 0#####
j = tax * .14
k = tax + j
l = k / 24
#####36 months 0#####
m = tax * .18
n = tax + m
o = n / 36
#####24 months 0#####
p = tax * .14
q = tax + p
r = q / 48
#####6 months deffered#####
p = tax * .14
q = tax + p
r = q / 48
print("First Franklin Loans")
print(c, "for 6 months total cost:", b)
print(f, "for 12 months total cost:", e)
print(i, "for 24 months total cost:", h)
print(" ")
print("Synchrony Loans")
print("Deferred Interest Loans")
print("deferred for 6 months total cost")
print("deferred for 12 months total cost")
print("deferred for 18 months total cost")
print("No Interest loans")
print(l, "for 24 months total cost:", k)
print(o, "for 36 months total cost:", n)
print(r, "for 48 months total cost:", q)
self.name.text = ""
class MyApp(App):
def build(self):
return MyGrid()
if __name__ == "__main__":
MyApp().run()
只需打印到下面的标签,或者弹出一个包含新数据的窗口。除非我添加了更多内容,否则不会让我发布。我想不出其他问题,所以请忽略帖子的这一部分,只有这样我才能发布