from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.config import Config
#Config.set('graphics','resizable',0)
#Config.set('graphics','width',400)
#Config.set('graphics','height',500)
class mainApp(App):
def plm(self,instance):
self.formula=str(int(self.formula) - int(self.formula)*2)
self.lbl.text=self.formula
def kv(self,instance):
self.formula=str(int(self.formula) * int(self.formula))
self.lbl.text=self.formula
def kub(self,instance):
self.formula=str(int(self.formula) * int(self.formula)* int(self.formula))
self.lbl.text=self.formula
def clean(self,instance):
self.lbl.text = "0"
self.formula = "0"
def result(self,instance):
exit=eval(self.lbl.text)
if exit%1==0:
exit=int(exit)
self.lbl.text = str(exit)
self.formula = str(exit)
def update_label(self):
self.lbl.text = self.formula
def add_operation(self,instance):
if ( str(instance.text).lower()=='x'):
self.formula+=("*")
else:
if ( str(instance.text).lower()==':'):
self.formula+=("/")
else:
self.formula+=str(instance.text)
self.update_label()
def add_num(self,instance):
if (self.formula == "0"):
self.formula=""
self.formula+=str(instance.text)
print(self.formula)
self.update_label()
def build(self):
self.formula=""
bls = BoxLayout (orientation = 'vertical')
gls = GridLayout(cols = 4,size_hint = (1,.6))
class btn(Button):
font_size=30
self.lbl=Label(text="0",font_size=35,halign="right",valign="center",size_hint=(1,.450),text_size=(400-50,500*.4-50))
bls.add_widget(self.lbl)
gls.add_widget(btn(text="7",on_press=self.add_num))
gls.add_widget(btn(text="8",on_press=self.add_num))
gls.add_widget(btn(text="9",on_press=self.add_num))
gls.add_widget(btn(text="x",on_press=self.add_operation))
gls.add_widget(btn(text="4",on_press=self.add_num))
gls.add_widget(btn(text="5",on_press=self.add_num))
gls.add_widget(btn(text="6",on_press=self.add_num))
gls.add_widget(btn(text="-",on_press=self.add_operation))
gls.add_widget(btn(text="1",on_press=self.add_num))
gls.add_widget(btn(text="2",on_press=self.add_num))
gls.add_widget(btn(text="3",on_press=self.add_num))
gls.add_widget(btn(text="+",on_press=self.add_operation))
gls.add_widget(btn(text=":",on_press=self.add_operation))
gls.add_widget(btn(text="0",on_press=self.add_num))
gls.add_widget(btn(text=".",on_press=self.add_num))
gls.add_widget(btn(text="=",on_press=self.result))
gls.add_widget(btn(text="AC",on_press=self.clean))
gls.add_widget(btn(text="x²",on_press=self.kv))
gls.add_widget(btn(text="x³",on_press=self.kub))
gls.add_widget(btn(text="±",on_press=self.plm))
bls.add_widget(gls)
return(bls)
mainApp().run()
a=input()