Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # some button definitions
- <IconButton@MDIconButton>:
- theme_icon_color: "Custom"
- icon_color: app.colors[4]
- icon_size: "35sp"
- size_hint: 0.25,None
- <TButton@MDFlatButton>:
- font_size: "35sp"
- size_hint: 0.15,0.15
- font_name: "DejaVu"
- theme_text_color: "Custom"
- text_color: app.colors[3]
- <FButton@TButton>:
- theme_text_color: "Custom"
- text_color: app.colors[4]
- font_size: "25sp"
- <OpButton@TButton>:
- theme_text_color: "Custom"
- text_color: app.theme_cls.primary_color
- <T2Button@MDTextButton>:
- markup: True
- font_size: "45dp"
- font_style: "Caption"
- # main screen
- MDScreen:
- md_bg_color: app.colors[2]
- # This down here holds the top pannel
- MDBoxLayout:
- id: my_toolbar
- orientation: "horizontal"
- pos_hint: {"top":1}
- size_hint: 1,0.05
- # filler
- IconButton:
- opacity: 0
- disabled:True
- # calculator button
- IconButton:
- id: main_btn
- icon: "calculator-variant-outline"
- icon_color: app.theme_cls.primary_color
- on_release: app.change_screen("main_scr")
- # converter button
- IconButton:
- id: conv_btn
- icon: "arrow-decision"
- on_release: app.change_screen("converter_scr")
- # currency button
- IconButton:
- id: curr_btn
- icon: "bank"
- on_release: app.change_screen("currency_scr")
- # settings button
- IconButton:
- id: menu_caller
- icon: "dots-vertical"
- on_release: app.exit_menu.open()
- opacity: 1 if root.ids.manager.current in ["main_scr","about_scr"] else 0
- disabled: False if root.ids.manager.current in ["main_scr","about_scr"] else True
- icon_width: self.icon_width if root.ids.manager.current=="main_scr" else "0sp"
- # calculator screen
- MDScreenManager:
- id: manager
- MDScreen:
- name: "main_scr"
- # using a label instead of a real TextField
- # this is because of the use of `eval()`
- MDLabel:
- id: the_input
- text: "0"
- halign: "right"
- font_name: "DejaVu"
- font_size: "50sp"
- size_hint: 1,None
- pos_hint: {"center_x":.44,"center_y":0.61}
- # the line below the input
- MDSeparator:
- pos_hint: {"center_x":.5,"center_y":.58}
- color: app.colors[5]
- size_hint: .85,None
- height: "1dp"
- RelativeLayout:
- id: main_calc_btns
- size_hint: .95,.55
- pos_hint: {"center_y":0.3}
- OpButton:
- text: "C"
- pos_hint:{"center_x":.15,"center_y":.9}
- on_release: app.clear_input()
- MDIconButton:
- icon: "backspace-outline"
- theme_icon_color: "Custom"
- icon_color: app.theme_cls.primary_color
- icon_size: "35sp"
- pos_hint:{"center_x":.4,"center_y":.9}
- on_release: app.backspace()
- OpButton:
- text: "%"
- pos_hint:{"center_x":.65,"center_y":.9}
- on_release: app.insert_value("%")
- OpButton:
- text: "÷"
- pos_hint:{"center_x":.9,"center_y":.9}
- on_release: app.insert_value("/")
- TButton:
- text: "7"
- pos_hint:{"center_x":.15,"center_y":.7}
- on_release: app.insert_value("7")
- TButton:
- text: "8"
- pos_hint:{"center_x":.4,"center_y":.7}
- on_release: app.insert_value("8")
- TButton:
- text: "9"
- pos_hint:{"center_x":.65,"center_y":.7}
- on_release: app.insert_value("9")
- OpButton:
- text: "×"
- pos_hint:{"center_x":.9,"center_y":.7}
- on_release: app.insert_value("*")
- TButton:
- text: "4"
- pos_hint:{"center_x":.15,"center_y":.5}
- on_release: app.insert_value("4")
- TButton:
- text: "5"
- pos_hint:{"center_x":.4,"center_y":.5}
- on_release: app.insert_value("5")
- TButton:
- text: "6"
- pos_hint:{"center_x":.65,"center_y":.5}
- on_release: app.insert_value("6")
- OpButton:
- text: "-"
- pos_hint:{"center_x":.9,"center_y":.5}
- on_release: app.insert_value("-")
- TButton:
- text: "1"
- pos_hint:{"center_x":.15,"center_y":.3}
- on_release: app.insert_value("1")
- TButton:
- text: "2"
- pos_hint:{"center_x":.4,"center_y":.3}
- on_release: app.insert_value("2")
- TButton:
- text: "3"
- pos_hint:{"center_x":.65,"center_y":.3}
- on_release: app.insert_value("3")
- OpButton:
- text: "+"
- pos_hint:{"center_x":.9,"center_y":.3}
- on_release: app.insert_value("+")
- # this boy will be used to change the layout of calculator
- MDIconButton:
- icon: "phone-rotate-landscape"
- icon_size: "35sp"
- theme_icon_color: "Custom"
- icon_color: app.theme_cls.primary_color
- pos_hint:{"center_x":.15,"center_y":.1}
- #on_release: app.switch_lays()
- TButton:
- text: "0"
- pos_hint:{"center_x":.4,"center_y":.1}
- on_release: app.insert_value("0")
- TButton:
- text: "."
- pos_hint:{"center_x":.65,"center_y":.1}
- on_release: app.insert_value(".")
- MDFillRoundFlatButton:
- text: "="
- pos_hint: {"center_x":.9,"center_y":.1}
- font_size: "35sp"
- on_release: app.evaluate()
- # avanced buttons layout
- RelativeLayout:
- id: second_calc_btns
- size_hint: .95,.55
- disabled: True
- opacity: 0
- pos_hint: {"center_y":0.3}
- FButton:
- text: "2nd"
- pos_hint:{"center_x":.1,"center_y":.9}
- #on_release: app.insert_value("7",1)
- FButton:
- text: "deg"
- pos_hint:{"center_x":.3,"center_y":.9}
- #on_release: app.insert_value("7",1)
- FButton:
- text: "sin"
- pos_hint:{"center_x":.5,"center_y":.9}
- on_release: app.insert_value("sin(")
- FButton:
- text: "cos"
- pos_hint:{"center_x":.7,"center_y":.9}
- on_release: app.insert_value("cos(")
- FButton:
- text: "tan"
- pos_hint:{"center_x":.9,"center_y":.9}
- on_release: app.insert_value("tan(")
- FButton:
- text: "xⁿ"
- pos_hint:{"center_x":.1,"center_y":.76}
- on_release: app.insert_value("^")
- FButton:
- text: "lg"
- pos_hint:{"center_x":.3,"center_y":.76}
- on_release: app.insert_value("lg(")
- FButton:
- text: "ln"
- pos_hint:{"center_x":.5,"center_y":.76}
- on_release: app.insert_value("ln(")
- FButton:
- text: "("
- pos_hint:{"center_x":.7,"center_y":.76}
- on_release: app.insert_value("(")
- FButton:
- text: ")"
- pos_hint:{"center_x":.9,"center_y":.76}
- on_release: app.insert_value(")")
- FButton:
- text: "√"
- pos_hint:{"center_x":.1,"center_y":.62}
- on_release: app.insert_value("sqrt(")
- OpButton:
- text: "C"
- pos_hint:{"center_x":.3,"center_y":.62}
- on_release: app.clear_input()
- MDIconButton:
- icon: "backspace-outline"
- theme_icon_color: "Custom"
- icon_color: app.theme_cls.primary_color
- icon_size: "35sp"
- pos_hint:{"center_x":.5,"center_y":.62}
- on_release: app.backspace()
- OpButton:
- text: "%"
- pos_hint:{"center_x":.7,"center_y":.62}
- on_release: app.insert_value("%")
- OpButton:
- text: "÷"
- pos_hint:{"center_x":.9,"center_y":.62}
- on_release: app.insert_value("/")
- FButton:
- text: "x!"
- pos_hint:{"center_x":.1,"center_y":.48}
- on_release: app.insert_value("fact(")
- TButton:
- text: "7"
- pos_hint:{"center_x":.3,"center_y":.48}
- on_release: app.insert_value("7")
- TButton:
- text: "8"
- pos_hint:{"center_x":.5,"center_y":.48}
- on_release: app.insert_value("8")
- TButton:
- text: "9"
- pos_hint:{"center_x":.7,"center_y":.48}
- on_release: app.insert_value("9")
- OpButton:
- text: "×"
- pos_hint:{"center_x":.9,"center_y":.48}
- on_release: app.insert_value("*")
- FButton:
- text: "in"
- pos_hint:{"center_x":.1,"center_y":.34}
- on_release: app.insert_value("^(-1)")
- TButton:
- text: "4"
- pos_hint:{"center_x":.3,"center_y":.34}
- on_release: app.insert_value("4")
- TButton:
- text: "5"
- pos_hint:{"center_x":.5,"center_y":.34}
- on_release: app.insert_value("5")
- TButton:
- text: "6"
- pos_hint:{"center_x":.7,"center_y":.34}
- on_release: app.insert_value("6")
- OpButton:
- text: "-"
- pos_hint:{"center_x":.9,"center_y":.34}
- on_release: app.insert_value("-")
- FButton:
- text: "π"
- pos_hint:{"center_x":.1,"center_y":.2}
- on_release: app.insert_value("pi")
- TButton:
- text: "1"
- pos_hint:{"center_x":.3,"center_y":.2}
- on_release: app.insert_value("1")
- TButton:
- text: "2"
- pos_hint:{"center_x":.5,"center_y":.2}
- on_release: app.insert_value("2")
- TButton:
- text: "3"
- pos_hint:{"center_x":.7,"center_y":.2}
- on_release: app.insert_value("3")
- OpButton:
- text: "+"
- pos_hint:{"center_x":.9,"center_y":.2}
- on_release: app.insert_value("+")
- MDIconButton:
- icon: "phone-rotate-landscape"
- icon_size: "35sp"
- theme_icon_color: "Custom"
- icon_color: app.theme_cls.primary_color
- pos_hint:{"center_x":.1,"center_y":.06}
- #on_release: app.switch_lays()
- TButton:
- text: "e"
- pos_hint:{"center_x":.3,"center_y":.06}
- on_release: app.insert_value("e")
- TButton:
- text: "0"
- pos_hint:{"center_x":.5,"center_y":.06}
- on_release: app.insert_value("0")
- TButton:
- text: "."
- pos_hint:{"center_x":.7,"center_y":.06}
- on_release: app.insert_value(".")
- MDFillRoundFlatButton:
- text: "="
- pos_hint: {"center_x":.9,"center_y":.06}
- font_size: "35sp"
- on_release: app.evaluate()
- # converter screen
- MDScreen:
- name: "converter_scr"
- # i thinked of using pos_hint for these custom buttons
- FloatLayout:
- IconButton:
- pos_hint: {"center_x":.18,"center_y":.88}
- markup:True
- icon_size: "40sp"
- icon: "cake-variant-outline"
- T2Button:
- pos_hint: {"center_x":.18,"center_y":.83}
- text: "[color=bcbcbc][b]Mosha"
- IconButton:
- pos_hint: {"center_x":.5,"center_y":.88}
- markup:True
- icon_size: "40sp"
- icon: "diameter-outline"
- on_release: app.change_screen1("surface")
- T2Button:
- pos_hint: {"center_x":.5,"center_y":.83}
- text: "[color=bcbcbc][b]Sipërfaqja"
- IconButton:
- pos_hint: {"center_x":.82,"center_y":.88}
- markup:True
- icon_size: "40sp"
- icon: "scale-bathroom"
- T2Button:
- pos_hint: {"center_x":.82,"center_y":.83}
- text: "[color=bcbcbc][b]BMI"
- IconButton:
- pos_hint: {"center_x":.18,"center_y":.71}
- markup:True
- icon_size: "40sp"
- icon: "orbit-variant"
- on_release: app.change_screen1("data_binary")
- T2Button:
- pos_hint: {"center_x":.18,"center_y":.66}
- text: "[color=bcbcbc][b]Të dhëna"
- IconButton:
- pos_hint: {"center_x":.5,"center_y":.71}
- markup:True
- icon_size: "40sp"
- icon: "calendar-multiselect"
- T2Button:
- pos_hint: {"center_x":.5,"center_y":.66}
- text: "[color=bcbcbc][b]Data"
- IconButton:
- pos_hint: {"center_x":.82,"center_y":.71}
- markup:True
- icon_size: "40sp"
- icon: "tag-outline"
- T2Button:
- pos_hint: {"center_x":.82,"center_y":.66}
- text: "[color=bcbcbc][b]Zbritje"
- IconButton:
- pos_hint: {"center_x":.18,"center_y":.54}
- markup:True
- icon_size: "40sp"
- icon: "ruler"
- on_release: app.change_screen1("length")
- T2Button:
- pos_hint: {"center_x":.18,"center_y":.49}
- text: "[color=bcbcbc][b]Gjatësia"
- IconButton:
- pos_hint: {"center_x":.5,"center_y":.54}
- markup:True
- icon_size: "40sp"
- icon: "weight"
- on_release: app.change_screen1("weight")
- T2Button:
- pos_hint: {"center_x":.5,"center_y":.49}
- text: "[color=bcbcbc][b]Masa"
- IconButton:
- pos_hint: {"center_x":.82,"center_y":.54}
- markup:True
- icon_size: "40sp"
- icon: "hexadecimal"
- on_release: app.change_screen1("bases")
- T2Button:
- pos_hint: {"center_x":.82,"center_y":.49}
- text: "[color=bcbcbc][b]Sistemi\nNumerik"
- IconButton:
- pos_hint: {"center_x":.18,"center_y":.37}
- markup:True
- icon_size: "40sp"
- icon: "speedometer"
- on_release: app.change_screen1("speed")
- T2Button:
- pos_hint: {"center_x":.18,"center_y":.32}
- text: "[color=bcbcbc][b]Shpejtësia"
- IconButton:
- pos_hint: {"center_x":.5,"center_y":.37}
- markup:True
- icon_size: "40sp"
- icon: "thermometer"
- T2Button:
- pos_hint: {"center_x":.5,"center_y":.32}
- text: "[color=bcbcbc][b]Temperatura"
- IconButton:
- pos_hint: {"center_x":.82,"center_y":.37}
- markup:True
- icon_size: "40sp"
- icon: "clock-outline"
- on_release: app.change_screen1("time")
- T2Button:
- pos_hint: {"center_x":.82,"center_y":.32}
- text: "[color=bcbcbc][b]Koha"
- IconButton:
- pos_hint: {"center_x":.18,"center_y":.20}
- markup:True
- icon_size: "40sp"
- icon: "cube-outline"
- on_release: app.change_screen1("volume")
- T2Button:
- pos_hint: {"center_x":.18,"center_y":.15}
- text: "[color=bcbcbc][b]Volumi"
- # currency screen
- MDScreen:
- name: "currency_scr"
- FloatLayout:
- IconButton:
- pos_hint: {"center_x":.18,"center_y":.88}
- markup:True
- icon_size: "40sp"
- icon: "cash"
- T2Button:
- pos_hint: {"center_x":.18,"center_y":.83}
- text: "[color=bcbcbc][b]Monedha"
- IconButton:
- pos_hint: {"center_x":.5,"center_y":.88}
- markup:True
- icon_size: "40sp"
- icon: "elevation-rise"
- T2Button:
- pos_hint: {"center_x":.5,"center_y":.83}
- text: "[color=bcbcbc][b]Investimi"
- IconButton:
- pos_hint: {"center_x":.82,"center_y":.88}
- markup:True
- icon_size: "40sp"
- icon: "credit-card"
- T2Button:
- pos_hint: {"center_x":.82,"center_y":.83}
- text: "[color=bcbcbc][b]Kredi"
- # settings screen
- MDScreen:
- name: "settings_scr"
- # why not making it standart ?
- MDTopAppBar:
- title: "Cilësimet"
- pos_hint: {"top":1}
- md_bg_color: app.theme_cls.bg_darkest
- left_action_items:[["arrow-left",lambda x: app.change_screen("main_scr")]]
- # about screen
- MDScreen:
- name: "about_scr"
- MDIconButton:
- icon: "arrow-left"
- icon_size: "35sp"
- pos_hint: {"center_x":.05,"top":1}
- on_release:
- app.root.ids.my_toolbar.opacity = 0
- app.root.ids.my_toolbar.disabled = True
- app.change_screen("main_scr")
- MDLabel:
- text: "Rreth"
- halign: "center"
- # converter screen (pure conversions)
- MDScreen:
- name: "convy"
- MDBoxLayout:
- pos_hint: {"center_x":.5,"center_y":.95}
- size_hint: .9,.4
- orientation: "vertical"
- spacing: "50sp"
- MDBoxLayout:
- orientation: "horizontal"
- size_hint: .95,None
- TButton:
- id: first
- text: ""
- font_size: "25sp"
- on_release: app.first_menu.open()
- MDLabel:
- id: input_label
- text: "0"
- halign: "right"
- font_size: "25sp"
- MDBoxLayout:
- orientation: "horizontal"
- size_hint: .95,None
- TButton:
- id: second
- text: ""
- font_size: "25sp"
- on_release: app.second_menu.open()
- MDLabel:
- id: output_label
- text: "0"
- halign: "right"
- font_size: "25sp"
- MDSeparator:
- pos_hint: {"center_x":.5,"center_y":.6}
- color: app.colors[5]
- size_hint: .85,None
- height: "1dp"
- RelativeLayout:
- size_hint: .85,.55
- pos_hint: {"center_y":.31}
- TButton:
- text: "7"
- pos_hint: {"center_x":.2,"center_y":.85}
- on_release: app.insert_value("7")
- TButton:
- text: "8"
- pos_hint: {"center_x":.45,"center_y":.85}
- on_release: app.insert_value("8")
- TButton:
- text: "9"
- pos_hint: {"center_x":.7,"center_y":.85}
- on_release: app.insert_value("9")
- TButton:
- text: "4"
- pos_hint: {"center_x":.2,"center_y":.6}
- on_release: app.insert_value("4")
- TButton:
- text: "5"
- pos_hint: {"center_x":.45,"center_y":.6}
- on_release: app.insert_value("5")
- TButton:
- text: "6"
- pos_hint: {"center_x":.7,"center_y":.6}
- on_release: app.insert_value("6")
- TButton:
- text: "1"
- pos_hint: {"center_x":.2,"center_y":.35}
- on_release: app.insert_value("1")
- TButton:
- text: "2"
- pos_hint: {"center_x":.45,"center_y":.35}
- on_release: app.insert_value("2")
- TButton:
- text: "3"
- pos_hint: {"center_x":.7,"center_y":.35}
- on_release: app.insert_value("3")
- TButton:
- text: "0"
- pos_hint: {"center_x":.45,"center_y":.1}
- on_release: app.insert_value("0")
- TButton:
- text: "."
- pos_hint: {"center_x":.7,"center_y":.1}
- on_release: app.insert_value(".")
- TButton:
- text: "AC"
- theme_text_color: "Custom"
- text_color: app.theme_cls.primary_color
- pos_hint: {"center_x":.95,"center_y":.73}
- on_release: app.clear_input()
- MDIconButton:
- icon: "backspace-outline"
- icon_size: "40sp"
- ripple_scale: 0
- theme_icon_color: "Custom"
- icon_color: app.theme_cls.primary_color
- pos_hint: {"center_x":.95,"center_y":.48}
- on_release: app.backspace()
- MDIconButton:
- icon: "arrow-left-bottom"
- icon_size: "40sp"
- ripple_scale: 0
- theme_icon_color: "Custom"
- icon_color: app.theme_cls.primary_color
- pos_hint: {"center_x":.95,"center_y":.23}
- on_release: app.convert()
- # base converter
- MDScreen:
- name: "bases-convy"
- MDBoxLayout:
- pos_hint: {"center_x":.5,"center_y":.95}
- size_hint: .9,.4
- orientation: "vertical"
- spacing: "50sp"
- MDBoxLayout:
- orientation: "horizontal"
- size_hint: .95,None
- TButton:
- id: bases_first
- text: ""
- font_size: "25sp"
- on_release: app.bases_first_menu.open()
- MDLabel:
- id: bases_input_label
- text: "0"
- halign: "right"
- font_size: "25sp"
- MDBoxLayout:
- orientation: "horizontal"
- size_hint: .95,None
- TButton:
- id: bases_second
- text: ""
- font_size: "25sp"
- on_release: app.bases_second_menu.open()
- MDLabel:
- id: bases_output_label
- text: "0"
- halign: "right"
- font_size: "25sp"
- MDSeparator:
- pos_hint: {"center_x":.5,"center_y":.6}
- color: app.colors[5]
- size_hint: .85,None
- height: "1dp"
- RelativeLayout:
- size_hint: .95,.55
- pos_hint: {"center_y":.3}
- TButton:
- text: "7"
- pos_hint: {"center_x":.15,"center_y":.7}
- on_release: app.insert_value("7")
- TButton:
- text: "8"
- pos_hint: {"center_x":.4,"center_y":.7}
- on_release: app.insert_value("8")
- TButton:
- text: "9"
- pos_hint: {"center_x":.65,"center_y":.7}
- on_release: app.insert_value("9")
- TButton:
- text: "4"
- pos_hint: {"center_x":.15,"center_y":.5}
- on_release: app.insert_value("4")
- TButton:
- text: "5"
- pos_hint: {"center_x":.4,"center_y":.5}
- on_release: app.insert_value("5")
- TButton:
- text: "6"
- pos_hint: {"center_x":.65,"center_y":.5}
- on_release: app.insert_value("6")
- TButton:
- text: "1"
- pos_hint: {"center_x":.15,"center_y":.3}
- on_release: app.insert_value("1")
- TButton:
- text: "2"
- pos_hint: {"center_x":.4,"center_y":.3}
- on_release: app.insert_value("2")
- TButton:
- text: "3"
- pos_hint: {"center_x":.65,"center_y":.3}
- on_release: app.insert_value("3")
- TButton:
- text: "0"
- pos_hint: {"center_x":.4,"center_y":.1}
- on_release: app.insert_value("0")
- TButton:
- text: "AC"
- theme_text_color: "Custom"
- text_color: app.theme_cls.primary_color
- pos_hint: {"center_x":.15,"center_y":.9}
- on_release: app.clear_input()
- MDIconButton:
- icon: "backspace-outline"
- icon_size: "40sp"
- ripple_scale: 0
- theme_icon_color: "Custom"
- icon_color: app.theme_cls.primary_color
- pos_hint: {"center_x":.4,"center_y":.9}
- on_release: app.backspace()
- MDIconButton:
- icon: "arrow-left-bottom"
- icon_size: "40sp"
- ripple_scale: 0
- theme_icon_color: "Custom"
- icon_color: app.theme_cls.primary_color
- pos_hint: {"center_x":.65,"center_y":.9}
- on_release: app.conv_bases()
- TButton:
- text: "A"
- pos_hint: {"center_x":.65,"center_y":.1}
- on_release: app.insert_value("A")
- TButton:
- text: "B"
- pos_hint: {"center_x":.9,"center_y":.1}
- on_release: app.insert_value("B")
- TButton:
- text: "C"
- pos_hint: {"center_x":.9,"center_y":.3}
- on_release: app.insert_value("C")
- TButton:
- text: "D"
- pos_hint: {"center_x":.9,"center_y":.5}
- on_release: app.insert_value("D")
- TButton:
- text: "E"
- pos_hint: {"center_x":.9,"center_y":.7}
- on_release: app.insert_value("E")
- TButton:
- text: "F"
- pos_hint: {"center_x":.9,"center_y":.9}
- on_release: app.insert_value("F")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement