Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 20.60 KB | None | 0 0
  1. from math import log, pow, sqrt, cos, sin, tan, exp
  2. from tkinter import *
  3.  
  4. equation: str = ''
  5. operation_set = False
  6. first_element_dot = False
  7. second_element_dot = False
  8.  
  9.  
  10. def calc(event):
  11.     global equation, operation_set
  12.     if len(equation) != 0:
  13.         txt = field.get()
  14.         operands = txt.split(' ')
  15.         if len(operands) == 3:
  16.             try:
  17.                 firstValue = float(operands[0])
  18.                 operation = operands[1]
  19.                 secondValue = float(operands[2])
  20.                 if operation_set:
  21.                     if operation == '+':
  22.                         equation = str(plus(firstValue, secondValue))
  23.                         set_text(equation)
  24.                         operation_set = False
  25.                     elif operation == '-':
  26.                         equation = str(minus(firstValue, secondValue))
  27.                         set_text(equation)
  28.                         operation_set = False
  29.                     elif operation == '×':
  30.                         equation = str(multiply(firstValue, secondValue))
  31.                         set_text(equation)
  32.                         operation_set = False
  33.                     elif operation == '÷':
  34.                         try:
  35.                             equation = str(divide(firstValue, secondValue))
  36.                             set_text(equation)
  37.                         except ZeroDivisionError:
  38.                             equation = 'Error'
  39.                             set_text(equation)
  40.                             equation = ''
  41.                         operation_set = False
  42.                     elif operation == '%':
  43.                         equation = str(mod(firstValue, secondValue))
  44.                         operation_set = False
  45.                     val = equation.split('.')
  46.                     global first_element_dot, second_element_dot
  47.                     second_element_dot = False
  48.                     if val[1] == '0':
  49.                         equation = val[0]
  50.                         first_element_dot = False
  51.                     else:
  52.                         first_element_dot = True
  53.                     set_text(equation)
  54.             except ValueError:
  55.                 return
  56.  
  57.  
  58. def pop(event):
  59.     global equation, operation_set, first_element_dot, second_element_dot
  60.     if len(equation) != 0:
  61.         if equation[len(equation) - 1] == ' ':
  62.             equation = equation[:-1]
  63.             equation = equation[:-1]
  64.             equation = equation[:-1]
  65.             operation_set = False
  66.         elif equation[len(equation) - 1] == '.' and not operation_set:
  67.             first_element_dot = False
  68.             equation = equation[:-1]
  69.         elif equation[len(equation) - 1] == '.' and operation_set:
  70.             second_element_dot = False
  71.             equation = equation[:-1]
  72.         else:
  73.             equation = equation[:-1]
  74.         set_text(equation)
  75.         return
  76.  
  77.  
  78. def set_text(text):
  79.     field.configure(state=NORMAL)
  80.     field.delete(0, END)
  81.     field.insert(0, text)
  82.     field.configure(state='readonly')
  83.     return
  84.  
  85.  
  86. def clearAll(event):
  87.     global equation
  88.     equation = ''
  89.     set_text(equation)
  90.     global operation_set, second_element_dot, first_element_dot
  91.     operation_set = False
  92.     second_element_dot = False
  93.     first_element_dot = False
  94.     return
  95.  
  96.  
  97. def pasteOne(event):
  98.     global equation
  99.     equation += str(1)
  100.     set_text(equation)
  101.     return
  102.  
  103.  
  104. def pastePlus(event):
  105.     global operation_set, equation
  106.     if not operation_set and len(equation) != 0:
  107.         operation_set = True
  108.         equation += ' + '
  109.         set_text(equation)
  110.         return
  111.  
  112.  
  113. def pasteMinus(event):
  114.     global operation_set, equation
  115.     if not operation_set and len(equation) != 0:
  116.         operation_set = True
  117.         equation += ' - '
  118.         set_text(equation)
  119.         return
  120.  
  121.  
  122. def pasteMultiplication(event):
  123.     global operation_set, equation
  124.     if not operation_set and len(equation) != 0:
  125.         operation_set = True
  126.         equation += ' × '
  127.         set_text(equation)
  128.         return
  129.  
  130.  
  131. def pasteDivide(event):
  132.     global operation_set, equation
  133.     if not operation_set and len(equation) != 0:
  134.         operation_set = True
  135.         equation += ' ÷ '
  136.         set_text(equation)
  137.         return
  138.  
  139.  
  140. def pasteMod(event):
  141.     global operation_set, equation
  142.     if not operation_set and len(equation) != 0:
  143.         operation_set = True
  144.         equation += ' % '
  145.         set_text(equation)
  146.         return
  147.  
  148.  
  149. def pasteDot(event):
  150.     global equation, operation_set, first_element_dot, second_element_dot
  151.     try:
  152.         if not operation_set and not first_element_dot and equation[len(equation) - 1]:
  153.             equation += '.'
  154.             set_text(equation)
  155.             first_element_dot = True
  156.         elif operation_set and not second_element_dot and equation[len(equation) - 1] != ' ':
  157.             equation += '.'
  158.             set_text(equation)
  159.             second_element_dot = True
  160.     except IndexError:
  161.         return
  162.  
  163.  
  164. def pasteTwo(event):
  165.     global equation
  166.     equation += str(2)
  167.     set_text(equation)
  168.     return
  169.  
  170.  
  171. def pasteA(event):
  172.     global equation
  173.     equation += 'A'
  174.     set_text(equation)
  175.     return
  176.  
  177.  
  178. def pasteB(event):
  179.     global equation
  180.     equation += 'B'
  181.     set_text(equation)
  182.     return
  183.  
  184.  
  185. def pasteC(event):
  186.     global equation
  187.     equation += 'C'
  188.     set_text(equation)
  189.     return
  190.  
  191.  
  192. def pasteD(event):
  193.     global equation
  194.     equation += 'D'
  195.     set_text(equation)
  196.     return
  197.  
  198.  
  199. def pasteE(event):
  200.     global equation
  201.     equation += 'E'
  202.     set_text(equation)
  203.     return
  204.  
  205.  
  206. def pasteF(event):
  207.     global equation
  208.     equation += 'F'
  209.     set_text(equation)
  210.     return
  211.  
  212.  
  213. def pasteThree(event):
  214.     global equation
  215.     equation += str(3)
  216.     set_text(equation)
  217.     return
  218.  
  219.  
  220. # sin, cos, sqrt, tg
  221.  
  222. def pasteFour(event):
  223.     global equation
  224.     equation += str(4)
  225.     set_text(equation)
  226.     return
  227.  
  228.  
  229. def pasteFive(event):
  230.     global equation
  231.     equation += str(5)
  232.     set_text(equation)
  233.     return
  234.  
  235.  
  236. def pasteSix(event):
  237.     global equation
  238.     equation += str(6)
  239.     set_text(equation)
  240.     return
  241.  
  242.  
  243. def pasteSeven(event):
  244.     global equation
  245.     equation += str(7)
  246.     set_text(equation)
  247.     return
  248.  
  249.  
  250. def pasteEight(event):
  251.     global equation
  252.     equation += str(8)
  253.     set_text(equation)
  254.     return
  255.  
  256.  
  257. def pasteNine(event):
  258.     global equation
  259.     equation += str(9)
  260.     set_text(equation)
  261.     return
  262.  
  263.  
  264. def pasteZero(event):
  265.     global equation
  266.     equation += str(0)
  267.     set_text(equation)
  268.     return
  269.  
  270.  
  271. def plus(a, b):
  272.     return a + b
  273.  
  274.  
  275. def minus(a, b):
  276.     return a - b
  277.  
  278.  
  279. def divide(a, b):
  280.     return a / b
  281.  
  282.  
  283. def mod(a, b):
  284.     return a % b
  285.  
  286.  
  287. def multiply(a, b):
  288.     return a * b
  289.  
  290.  
  291. def invertValue(event):
  292.     global operation_set, equation
  293.     if not operation_set:
  294.         equation = str(-1 * float(equation))
  295.         val = equation.split('.')
  296.         if val[1] == '0':
  297.             equation = val[0]
  298.         set_text(equation)
  299.  
  300.  
  301. def dec2bin(value):
  302.     if value >= 1:
  303.         g = int(log(value, 2))
  304.     else:
  305.         g = -1
  306.     h = g + 1
  307.     ig = pow(2, g)
  308.     st = ""
  309.     while value > 0 or ig >= 1:
  310.         if value < 1:
  311.             if len(st[h:]) >= 10:
  312.                 break
  313.         if value >= ig:
  314.             st += "1"
  315.             value -= ig
  316.         else:
  317.             st += "0"
  318.         ig /= 2
  319.     st = st[:h] + "." + st[h:]
  320.     return st
  321.  
  322.  
  323. # CONVERTING FUNCTIONS
  324.  
  325. # DEC
  326.  
  327. def bin(event):
  328.     global equation
  329.     if len(equation) == 0:
  330.         return
  331.     if not operation_set:
  332.         try:
  333.             if systemMode == 0:
  334.                 equation = dec2bin(float(equation))
  335.             elif systemMode == 1:
  336.                 equation = dec2bin(float(format(int(equation, 16))))
  337.             if equation[len(equation) - 1] == '.':
  338.                 equation = equation[:-1]
  339.             set_text(equation)
  340.             equation = ''
  341.         except ValueError:
  342.             return
  343.  
  344.  
  345. def hexConversion(event):
  346.     global systemMode, equation
  347.     if len(equation) == 0:
  348.         return
  349.     if not operation_set:
  350.         print(systemMode)
  351.         if systemMode == 0:
  352.             equation = format(int(equation), 'X')
  353.         elif systemMode == 2:
  354.             equation = format(int(int(equation, 2)), 'X')
  355.         set_text(equation)
  356.  
  357.  
  358. def toDec(event):
  359.     global systemMode, equation
  360.     equation = ''
  361.     set_text(equation)
  362.     decBtn.configure(state=DISABLED)
  363.     hexBtn.configure(state=NORMAL)
  364.     binBtn.configure(state=NORMAL)
  365.     modBtn.configure(state=NORMAL)
  366.     plusBtn.configure(state=NORMAL)
  367.     minusBtn.configure(state=NORMAL)
  368.     multiplyBtn.configure(state=NORMAL)
  369.     divideBtn.configure(state=NORMAL)
  370.     cosBtn.configure(state=NORMAL)
  371.     sinBtn.configure(state=NORMAL)
  372.     tgBtn.configure(state=NORMAL)
  373.     sqrtBtn.configure(state=NORMAL)
  374.     sqrtBtn.configure(state=NORMAL)
  375.     dotBtn.configure(state=NORMAL)
  376.     pow2.configure(state=NORMAL)
  377.     pow3.configure(state=NORMAL)
  378.     ex.configure(state=NORMAL)
  379.     invert.configure(state=NORMAL)
  380.     hexA.configure(state=DISABLED)
  381.     hexB.configure(state=DISABLED)
  382.     hexC.configure(state=DISABLED)
  383.     hexD.configure(state=DISABLED)
  384.     hexE.configure(state=DISABLED)
  385.     hexF.configure(state=DISABLED)
  386.     twoBtn.configure(state=NORMAL)
  387.     threeBtn.configure(state=NORMAL)
  388.     fourBtn.configure(state=NORMAL)
  389.     fiveBtn.configure(state=NORMAL)
  390.     sixBtn.configure(state=NORMAL)
  391.     sevenBtn.configure(state=NORMAL)
  392.     eightBtn.configure(state=NORMAL)
  393.     nineBtn.configure(state=NORMAL)
  394.     equalBtn.configure(state=NORMAL)
  395.     systemMode = 0
  396.  
  397.  
  398. def toHex(event):
  399.     global systemMode, equation
  400.     equation = ''
  401.     set_text(equation)
  402.     equalBtn.configure(state=NORMAL)
  403.     hexBtn.configure(state=DISABLED)
  404.     decBtn.configure(state=NORMAL)
  405.     binBtn.configure(state=NORMAL)
  406.     modBtn.configure(state=DISABLED)
  407.     plusBtn.configure(state=DISABLED)
  408.     minusBtn.configure(state=DISABLED)
  409.     pow2.configure(state=DISABLED)
  410.     pow3.configure(state=DISABLED)
  411.     ex.configure(state=DISABLED)
  412.     invert.configure(state=DISABLED)
  413.     multiplyBtn.configure(state=DISABLED)
  414.     divideBtn.configure(state=DISABLED)
  415.     cosBtn.configure(state=DISABLED)
  416.     sinBtn.configure(state=DISABLED)
  417.     tgBtn.configure(state=DISABLED)
  418.     sqrtBtn.configure(state=DISABLED)
  419.     sqrtBtn.configure(state=DISABLED)
  420.     dotBtn.configure(state=DISABLED)
  421.     hexA.configure(state=NORMAL)
  422.     hexB.configure(state=NORMAL)
  423.     hexC.configure(state=NORMAL)
  424.     hexD.configure(state=NORMAL)
  425.     hexE.configure(state=NORMAL)
  426.     hexF.configure(state=NORMAL)
  427.     twoBtn.configure(state=NORMAL)
  428.     threeBtn.configure(state=NORMAL)
  429.     fourBtn.configure(state=NORMAL)
  430.     fiveBtn.configure(state=NORMAL)
  431.     sixBtn.configure(state=NORMAL)
  432.     sevenBtn.configure(state=NORMAL)
  433.     eightBtn.configure(state=NORMAL)
  434.     nineBtn.configure(state=NORMAL)
  435.     equalBtn.configure(state=DISABLED)
  436.     systemMode = 1
  437.  
  438.  
  439. def toBin(event):
  440.     global systemMode, equation
  441.     equation = ''
  442.     set_text(equation)
  443.     equalBtn.configure(state=DISABLED)
  444.     hexBtn.configure(state=NORMAL)
  445.     decBtn.configure(state=NORMAL)
  446.     binBtn.configure(state=DISABLED)
  447.     modBtn.configure(state=DISABLED)
  448.     pow2.configure(state=DISABLED)
  449.     pow3.configure(state=DISABLED)
  450.     ex.configure(state=DISABLED)
  451.     invert.configure(state=DISABLED)
  452.     plusBtn.configure(state=DISABLED)
  453.     minusBtn.configure(state=DISABLED)
  454.     multiplyBtn.configure(state=DISABLED)
  455.     divideBtn.configure(state=DISABLED)
  456.     cosBtn.configure(state=DISABLED)
  457.     sinBtn.configure(state=DISABLED)
  458.     tgBtn.configure(state=DISABLED)
  459.     sqrtBtn.configure(state=DISABLED)
  460.     sqrtBtn.configure(state=DISABLED)
  461.     dotBtn.configure(state=DISABLED)
  462.     hexA.configure(state=DISABLED)
  463.     hexB.configure(state=DISABLED)
  464.     hexC.configure(state=DISABLED)
  465.     hexD.configure(state=DISABLED)
  466.     hexE.configure(state=DISABLED)
  467.     hexF.configure(state=DISABLED)
  468.     twoBtn.configure(state=DISABLED)
  469.     threeBtn.configure(state=DISABLED)
  470.     fourBtn.configure(state=DISABLED)
  471.     fiveBtn.configure(state=DISABLED)
  472.     sixBtn.configure(state=DISABLED)
  473.     sevenBtn.configure(state=DISABLED)
  474.     eightBtn.configure(state=DISABLED)
  475.     nineBtn.configure(state=DISABLED)
  476.     systemMode = 2
  477.  
  478.  
  479. # HEX
  480.  
  481. def hex2dec(event):
  482.     global equation
  483.     if len(equation) == 0:
  484.         return
  485.     print(int(equation, 16))
  486.  
  487.  
  488. # BIN
  489.  
  490. def getSqrt(event):
  491.     global equation
  492.     if len(equation) == 0:
  493.         return
  494.     if not operation_set:
  495.         equation = str(sqrt(float(equation)))
  496.         val = equation.split('.')
  497.         if val[1] == '0':
  498.             equation = val[0]
  499.         set_text(equation)
  500.  
  501.  
  502. def getCos(event):
  503.     global equation
  504.     if len(equation) == 0:
  505.         return
  506.     if not operation_set:
  507.         equation = str(cos(float(equation)))
  508.         val = equation.split('.')
  509.         if val[1] == '0':
  510.             equation = val[0]
  511.         set_text(equation)
  512.  
  513.  
  514. def decimalConservation(event):
  515.     global systemMode, equation
  516.     if len(equation) == 0:
  517.         return
  518.     if not operation_set:
  519.         print(systemMode)
  520.         if systemMode == 1:
  521.             equation = format(int(equation, 16))
  522.         elif systemMode == 2:
  523.             equation = str(int(equation, 2))
  524.         set_text(equation)
  525.  
  526.  
  527. def getSin(event):
  528.     global equation
  529.     if len(equation) == 0:
  530.         return
  531.     if not operation_set:
  532.         # print(format(int(equation), 'x'))
  533.         equation = str(sin(float(equation)))
  534.         val = equation.split('.')
  535.         if val[1] == '0':
  536.             equation = val[0]
  537.         set_text(equation)
  538.  
  539.  
  540. def getTan(event):
  541.     global equation
  542.     if len(equation) == 0:
  543.         return
  544.     if not operation_set:
  545.         equation = str(tan(float(equation)))
  546.         val = equation.split('.')
  547.         if val[1] == '0':
  548.             equation = val[0]
  549.         set_text(equation)
  550.  
  551.  
  552. def getExp(event):
  553.     global equation
  554.     if len(equation) == 0:
  555.         return
  556.     if not operation_set:
  557.         equation = str(exp(float(equation)))
  558.         val = equation.split('.')
  559.         if val[1] == '0':
  560.             equation = val[0]
  561.         set_text(equation)
  562.  
  563.  
  564. def getPow2(event):
  565.     global equation
  566.     if len(equation) == 0:
  567.         return
  568.     if not operation_set:
  569.         equation = str((float(equation) ** 2))
  570.         val = equation.split('.')
  571.         if val[1] == '0':
  572.             equation = val[0]
  573.         set_text(equation)
  574.  
  575.  
  576. def getPow3(event):
  577.     global equation
  578.     if len(equation) == 0:
  579.         return
  580.     if not operation_set:
  581.         equation = str((float(equation) ** 3))
  582.         val = equation.split('.')
  583.         if val[1] == '0':
  584.             equation = val[0]
  585.         set_text(equation)
  586.  
  587.  
  588. # def hex2dec(event):
  589.  
  590. # MAIN CONFIGURATIONS
  591.  
  592. root = Tk()
  593. root.title('Calculator')
  594. root.resizable(False, False)
  595.  
  596. top = Frame(root)
  597. top.pack(side=TOP)
  598. center = Frame(root)
  599. center.pack()
  600. bottom = Frame(root)
  601. bottom.pack(side=BOTTOM)
  602.  
  603. # FIRST ROW
  604. field = Entry(top, font=15, width=27)
  605. field.configure(state='disabled')
  606. backspace = Button(top, text='<', width=3, fg='magenta', highlightbackground='cyan', highlightthickness=5)
  607.  
  608. # SECOND ROW
  609. clearBtn = Button(center, text='AC', width=6, height=3, font=20)
  610. modBtn = Button(center, text='mod', width=6, height=3, font=20)
  611. hexBtn = Button(center, text='HEX', width=6, height=3, font=20)
  612. binBtn = Button(center, text='BIN', width=6, height=3, font=20)
  613. decBtn = Button(center, text='DEC', width=6, height=3, font=20, state=DISABLED)
  614.  
  615. # THIRD ROW
  616.  
  617. hexA = Button(center, text='A', width=6, height=3, font=20, state=DISABLED)
  618. hexB = Button(center, text='B', width=6, height=3, font=20, state=DISABLED)
  619. hexC = Button(center, text='C', width=6, height=3, font=20, state=DISABLED)
  620. pow2 = Button(center, text='x^2', width=6, height=3, font=20)
  621. pow3 = Button(center, text='x^3', width=6, height=3, font=20)
  622.  
  623. # FOURTH ROW
  624.  
  625. hexD = Button(center, text='D', width=6, height=3, font=20, state=DISABLED)
  626. hexE = Button(center, text='E', width=6, height=3, font=20, state=DISABLED)
  627. hexF = Button(center, text='F', width=6, height=3, font=20, state=DISABLED)
  628. ex = Button(center, text='e^x', width=6, height=3, font=20)
  629. invert = Button(center, text='+/-', width=6, height=3, font=20)
  630.  
  631. # THIRD ROW
  632. sevenBtn = Button(center, text='7', width=6, height=3, font=20)
  633. eightBtn = Button(center, text='8', width=6, height=3, font=20)
  634. nineBtn = Button(center, text='9', width=6, height=3, font=20)
  635. multiplyBtn = Button(center, text='×', width=6, height=3, font=20)
  636. cosBtn = Button(center, text='COS', width=6, height=3, font=20)
  637.  
  638. # FOURTH ROW
  639. fourBtn = Button(center, text='4', width=6, height=3, font=20)
  640. fiveBtn = Button(center, text='5', width=6, height=3, font=20)
  641. sixBtn = Button(center, text='6', width=6, height=3, font=20)
  642. divideBtn = Button(center, text='÷', width=6, height=3, font=20)
  643. sinBtn = Button(center, text='SIN', width=6, height=3, font=20)
  644.  
  645. # FIFTH ROW
  646. oneBtn = Button(center, text='1', width=6, height=3, font=20)
  647. twoBtn = Button(center, text='2', width=6, height=3, font=20)
  648. threeBtn = Button(center, text='3', width=6, height=3, font=20)
  649. plusBtn = Button(center, text='+', width=6, height=3, font=20)
  650. tgBtn = Button(center, text='TG', width=6, height=3, font=20)
  651. # SIXTH ROW
  652. zeroBtn = Button(center, text='0', width=6, height=3, font=20)
  653. dotBtn = Button(center, text='•', width=6, height=3, font=20)
  654. equalBtn = Button(center, text='=', width=6, height=3, font=20)
  655. minusBtn = Button(center, text='-', width=6, height=3, font=20)
  656. sqrtBtn = Button(center, text='√', width=6, height=3, font=20)
  657. # BOTTOM
  658.  
  659. systemMode = 0
  660. # Modes:
  661. # 0 - decimal
  662. # 1 - heximal
  663. # 2 - binary
  664. decimal = Radiobutton(bottom, text='DEC', variable=systemMode, value=0, state='normal')
  665. binary = Radiobutton(bottom, text='BIN', variable=systemMode, value=1)
  666. heximal = Radiobutton(bottom, text='HEX', variable=systemMode, value=2)
  667.  
  668. # APPENDING
  669. field.grid(row=0, column=0, columnspan=2)
  670. backspace.grid(row=0, column=3)
  671.  
  672. clearBtn.grid(row=1, column=0)
  673. modBtn.grid(row=1, column=1)
  674. hexBtn.grid(row=1, column=2)
  675. binBtn.grid(row=1, column=3)
  676. decBtn.grid(row=1, column=4)
  677. hexD.grid(row=2, column=0)
  678. hexE.grid(row=2, column=1)
  679. hexF.grid(row=2, column=2)
  680. pow2.grid(row=2, column=3)
  681. pow3.grid(row=2, column=4)
  682. hexA.grid(row=3, column=0)
  683. hexB.grid(row=3, column=1)
  684. hexC.grid(row=3, column=2)
  685. ex.grid(row=3, column=3)
  686. invert.grid(row=3, column=4)
  687. sevenBtn.grid(row=4, column=0)
  688. eightBtn.grid(row=4, column=1)
  689. nineBtn.grid(row=4, column=2)
  690. multiplyBtn.grid(row=4, column=3)
  691. cosBtn.grid(row=4, column=4)
  692. fourBtn.grid(row=5, column=0)
  693. fiveBtn.grid(row=5, column=1)
  694. sixBtn.grid(row=5, column=2)
  695. divideBtn.grid(row=5, column=3)
  696. sinBtn.grid(row=5, column=4)
  697. oneBtn.grid(row=6, column=0)
  698. twoBtn.grid(row=6, column=1)
  699. threeBtn.grid(row=6, column=2)
  700. plusBtn.grid(row=6, column=3)
  701. tgBtn.grid(row=6, column=4)
  702. zeroBtn.grid(row=7, column=0)
  703. dotBtn.grid(row=7, column=1)
  704. equalBtn.grid(row=7, column=2)
  705. minusBtn.grid(row=7, column=3)
  706. sqrtBtn.grid(row=7, column=4)
  707. decimal.grid(row=0, column=0)
  708. binary.grid(row=0, column=1)
  709. heximal.grid(row=0, column=2)
  710.  
  711. clearBtn.bind('<Button-1>', clearAll)
  712. oneBtn.bind('<Button-1>', pasteOne)
  713. twoBtn.bind('<Button-1>', pasteTwo)
  714. threeBtn.bind('<Button-1>', pasteThree)
  715. fourBtn.bind('<Button-1>', pasteFour)
  716. fiveBtn.bind('<Button-1>', pasteFive)
  717. sixBtn.bind('<Button-1>', pasteSix)
  718. sevenBtn.bind('<Button-1>', pasteSeven)
  719. eightBtn.bind('<Button-1>', pasteEight)
  720. nineBtn.bind('<Button-1>', pasteNine)
  721. zeroBtn.bind('<Button-1>', pasteZero)
  722. backspace.bind('<BackSpace>', pop)
  723. backspace.bind('<Button-1>', pop)
  724. plusBtn.bind('<Button-1>', pastePlus)
  725. minusBtn.bind('<Button-1>', pasteMinus)
  726. modBtn.bind('<Button-1>', pasteMod)
  727. divideBtn.bind('<Button-1>', pasteDivide)
  728. multiplyBtn.bind('<Button-1>', pasteMultiplication)
  729. dotBtn.bind('<Button-1>', pasteDot)
  730. equalBtn.bind('<Button-1>', calc)
  731. hexBtn.bind('<Button-1>', hexConversion)
  732. binBtn.bind('<Button-1>', bin)
  733. sqrtBtn.bind('<Button-1>', getSqrt)
  734. tgBtn.bind('<Button-1>', getTan)
  735. cosBtn.bind('<Button-1>', getCos)
  736. sinBtn.bind('<Button-1>', getSin)
  737. decimal.bind('<Button-1>', toDec)
  738. binary.bind('<Button-1>', toBin)
  739. heximal.bind('<Button-1>', toHex)
  740. pow2.bind('<Button-1>', getPow2)
  741. pow3.bind('<Button-1>', getPow3)
  742. ex.bind('<Button-1>', getExp)
  743. decBtn.bind('<Button-1>', decimalConservation)
  744. hexA.bind('<Button-1>', pasteA)
  745. hexB.bind('<Button-1>', pasteB)
  746. hexC.bind('<Button-1>', pasteC)
  747. hexD.bind('<Button-1>', pasteD)
  748. hexE.bind('<Button-1>', pasteE)
  749. hexF.bind('<Button-1>', pasteF)
  750. invert.bind('<Button-1>', invertValue)
  751. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement