def __init__(self, master = None): # call the frame constructor Frame.__init__(self, master) # give the calculator a 10 pixel border all around self.grid(padx=10, pady=10) # try Bitsteam Vera font first cause its a cool (and open-source) if "Bitstream Vera Sans Mono" in tkFont.families(): self.font = tkFont.Font(family="Bitstream Vera Sans Mono", size="14") else: self.font = tkFont.Font(family="Courier", size="14") # populate the widgets self.__populate() # Call Calculator class constructor Calculator.__init__(self, display = self.display) # the functions of the calculator self.functions = { "add":[CFunctions.add, "+", 2, self.TYPE_OPERATOR], "subtract":[CFunctions.subtract, "-", 2, self.TYPE_OPERATOR], "multiply":[CFunctions.multiply, "*", 2, self.TYPE_OPERATOR], "divide":[CFunctions.divide, u"\u00F7", 2, self.TYPE_OPERATOR], "tan":[math.tan, "Tan", 1, self.TYPE_FUNCTION], "sin":[math.sin, "Sin", 1, self.TYPE_FUNCTION], "cos":[math.cos, "Cos", 1, self.TYPE_FUNCTION], "atan":[math.tan, "aTan", 1, self.TYPE_FUNCTION], "asin":[math.sin, "aSin", 1, self.TYPE_FUNCTION], "acos":[math.cos, "aCos", 1, self.TYPE_FUNCTION], "todegree":[math.degrees, ">Deg", 1, self.TYPE_FUNCTION], "toradian":[math.radians, ">Rad", 1, self.TYPE_FUNCTION], "pow":[CFunctions.pow, "^", 2, self.TYPE_OPERATOR], "mod":[CFunctions.fmod, "%", 2, self.TYPE_OPERATOR], "factorial":[CFunctions.factorial, "Factorial", 1, self.TYPE_FUNCTION], "log":[CFunctions.log, "log", 2, self.TYPE_FUNCTION], "ln":[math.log, "ln", 1, self.TYPE_FUNCTION], "sqrt":[decimal.Decimal.sqrt, u"\u221A", 1, self.TYPE_FUNCTION], "exp":[math.exp, "e^", 1, self.TYPE_FUNCTION], } # set the binds (virtual and keys) self.__setBinds()
def __init__(self, a, b): Calculator.__init__(self, a, b) print("child class constructor") name = input("Give me your name: ") print("Your name is " + name)