Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.app import App
- from kivy.uix.boxlayout import BoxLayout
- from kivy.lang import Builder
- from kivy.uix.label import Label
- from kivy.uix.button import Button
- from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
- from kivy.properties import StringProperty, ObjectProperty, NumericProperty
- from time import time
- class MenuScreen(Screen):
- pass
- class LenghtScreen(Screen):
- def config(self):
- if self.ids.select1.text == "Select unit":
- self.ids.select1.text = self.ids.pending.text
- self.ids.select1.color = .3, 1, .4, 1
- self.ids.select2.text = "Select unit"
- self.ids.select2.color = 1, 0, 0, 1
- elif self.ids.select1.text != "Select unit" and self.ids.select2.text == "Select unit":
- self.ids.select2.text = self.ids.pending.text
- self.ids.select2.color = .3, 1, .4, 1
- elif self.ids.select1.text != "Select unit" and self.ids.select2.text != "Select unit":
- self.ids.select1.text = 'Select unit'
- self.ids.select1.color = 1, 0, 0, 1
- self.ids.select2.text = ""
- def undo(self):
- if self.ids.select1.text != "Select unit" and self.ids.select2.text == "Select unit":
- self.ids.select1.text = "Select unit"
- self.ids.select1.color = 1, 0, 0, 1
- self.ids.select2.text = ""
- def undo2(self):
- if self.ids.select1.text != "Select unit" and self.ids.select2.text != "Select unit":
- self.ids.select2.text = "Select unit"
- self.ids.select2.color = 1, 0, 0, 1
- # def entry1(self):
- # s
- def entryx(self):
- if self.ids.select1.text == "Select unit":
- self.ids.entry2.text = "No unit selected"
- if self.ids.select1.text != "Select unit" and self.ids.select2.text == "Select unit":
- self.ids.entry2.text = "Unit selection incomplete"
- if self.ids.select1.text != "Select unit" and self.ids.select2.text != "Select unit":
- self.ids.entry2.text += self.ids.select1.text + " is equal to"
- def convert(self):########################################
- if self.ids.entry.text == "":
- self.ids.output.text = "Please enter value"
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Centimeter":
- entry = self.ids.entry.text
- convert1 = float(self.ids.entry.text) * 1
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' cm'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Decimeter":
- convert1 = float(self.ids.entry.text) / 10
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' dm'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Feet":
- convert1 = float(self.ids.entry.text) / 30.48
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' ft'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Inches":
- convert1 = float(self.ids.entry.text) / 0.39370
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' in'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Kilometer":
- convert1 = float(self.ids.entry.text) * (1.0 ** 2)
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' km'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Light Year":
- convert1 = float(self.ids.entry.text) / (9.140675309081 ** 17)
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' ly'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Meter":
- convert1 = float(self.ids.entry.text) / 100
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' m'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Micrometer":
- convert1 = float(self.ids.entry.text) * 10000
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + " µM"
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Mile":
- convert1 = float(self.ids.entry.text) / 160934.4
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' mi'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Millimeter":
- convert1 = float(self.ids.entry.text) * 10
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' mm'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Nanometer":
- convert1 = float(self.ids.entry.text) * 10000000
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' nm'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Nautical Mile":
- convert1 = float(self.ids.entry.text) * (5.3995680 * (10 ** -6))
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' nmi'
- elif self.ids.select1.text == "Centimeter" and self.ids.select2.text == "Yard":
- convert1 = float(self.ids.entry.text) * 0.010936133
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' yd'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Centimetet":
- convert1 = float(self.ids.entry.text) * 10
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' cm'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Decimeter":
- convert1 = float(self.ids.entry.text) * 1
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' dm'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Feet":
- convert1 = float(self.ids.entry.text) * 0.328084
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' ft'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Inches":
- convert1 = float(self.ids.entry.text) * 3.93701
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' in'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Kilometer":
- convert1 = float(self.ids.entry.text) * 0.00001
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' km'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Light Year":
- convert1 = float(self.ids.entry.text) * 1.057E-7
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' ly'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Meter":
- convert1 = float(self.ids.entry.text) * 0.1
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' m'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Micrometer":
- convert1 = float(self.ids.entry.text) * 100000
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + " µM"
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Mile":
- convert1 = float(self.ids.entry.text) * 6.21371E-5
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' mi'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Millimeter":
- convert1 = float(self.ids.entry.text) * 100
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' mm'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Nanometer":
- convert1 = float(self.ids.entry.text) * 1E+18
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' nm'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Nautical Mile":
- convert1 = float(self.ids.entry.text) * 5.39957E-5
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' nmi'
- elif self.ids.select1.text == "Decimeter" and self.ids.select2.text == "Yard":
- convert1 = float(self.ids.entry.text) * 0.109361
- convert2 = '%2f' %(convert1)
- self.ids.output.text = str(convert2) + ' y'
- class MassScreen(Screen):
- pass
- class takeApp(App):
- def build(self):
- sm = ScreenManager()
- sm.add_widget(MenuScreen(name = 'nm'))
- sm.add_widget(LenghtScreen(name = 'lns'))
- return sm
- if __name__=="__main__":
- takeApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement