Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix imports, errors, encoding #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions tkcalc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#-*-coding: utf-8-*-
from Tkinter import *
# from https://www.techinfected.net/2016/02/make-gui-calculator-in-python-windows-linux.html
# % provides a remainder, not a true % operation

from tkinter import *
import math

class calc:
Expand All @@ -16,7 +19,7 @@ def equals(self):
self.getandreplace()
try:
self.value= eval(self.newtext) #evaluate the expression using the eval function
except SyntaxError or NameErrror:
except SyntaxError or NameError:
self.e.delete(0,END)
self.e.insert(0,'Invalid Input!')
else:
Expand All @@ -29,7 +32,7 @@ def squareroot(self):
self.getandreplace()
try:
self.value= eval(self.newtext) #evaluate the expression using the eval function
except SyntaxError or NameErrror:
except SyntaxError or NameError:
self.e.delete(0,END)
self.e.insert(0,'Invalid Input!')
else:
Expand All @@ -43,7 +46,7 @@ def square(self):
self.getandreplace()
try:
self.value= eval(self.newtext) #evaluate the expression using the eval function
except SyntaxError or NameErrror:
except SyntaxError or NameError:
self.e.delete(0,END)
self.e.insert(0,'Invalid Input!')
else:
Expand Down Expand Up @@ -73,7 +76,7 @@ def __init__(self,master):
self.e.focus_set() #Sets focus on the input text area

self.div='÷'
self.newdiv=self.div.decode('utf-8')
self.newdiv=self.div

#Generating Buttons
Button(master,text="=",width=10,command=lambda:self.equals()).grid(row=4, column=4,columnspan=2)
Expand Down