S
skanemupp
1st question:
when i run this program 1 will be printed into the interpreter when i
run it BUT without me clicking the actual button.
when i then click the button "1", nothing happens.
obv i dont want any output when i dont push the button but i want it
when i do.
what am i doing wrong here?
2nd question:
i want all the buttons to have the same size. i thought i should use
row/columnspan but i dont get that to work.
how should i do?
when i run this program 1 will be printed into the interpreter when i
run it BUT without me clicking the actual button.
when i then click the button "1", nothing happens.
obv i dont want any output when i dont push the button but i want it
when i do.
what am i doing wrong here?
2nd question:
i want all the buttons to have the same size. i thought i should use
row/columnspan but i dont get that to work.
how should i do?
Code:
#! /usr/bin/env python
from Tkinter import *
import tkMessageBox
class GUIFramework(Frame):
"""This is the GUI"""
def __init__(self,master=None):
"""Initialize yourself"""
"""Initialise the base class"""
Frame.__init__(self,master)
"""Set the Window Title"""
self.master.title("Calculator")
"""Display the main window"
with a little bit of padding"""
self.grid(padx=10,pady=10)
self.CreateWidgets()
def CreateWidgets(self):
self.enText = Entry(self)
self.enText.grid(row=0, column=0, columnspan=8, padx=5,
pady=5)
self.enText = Entry(self)
self.enText.grid(row=1, column=0, columnspan=8, padx=5,
pady=5)
self.btnDisplay = Button(self, text="1",
command=self.Display(1))
self.btnDisplay.grid(row=3, column=0, padx=5, pady=5)
self.btnDisplay = Button(self, text="2", default=ACTIVE)
self.btnDisplay.grid(row=3, column=1, padx=5, pady=5)
self.btnDisplay = Button(self, text="3", default=ACTIVE)
self.btnDisplay.grid(row=3, column=2, padx=5, pady=5)
self.btnDisplay = Button(self, text="+", default=ACTIVE)
self.btnDisplay.grid(row=3, column=3, padx=5, pady=5)
self.btnDisplay = Button(self, text="4", default=ACTIVE)
self.btnDisplay.grid(row=4, column=0, padx=5, pady=5)
self.btnDisplay = Button(self, text="5", default=ACTIVE)
self.btnDisplay.grid(row=4, column=1, padx=5, pady=5)
self.btnDisplay = Button(self, text="6", default=ACTIVE)
self.btnDisplay.grid(row=4, column=2, padx=5, pady=5)
self.btnDisplay = Button(self, text="-", default=ACTIVE)
self.btnDisplay.grid(row=4, column=3, padx=5, pady=5)
self.btnDisplay = Button(self, text="7", default=ACTIVE)
self.btnDisplay.grid(row=5, column=0, padx=5, pady=5)
self.btnDisplay = Button(self, text="8", default=ACTIVE)
self.btnDisplay.grid(row=5, column=1, padx=5, pady=5)
self.btnDisplay = Button(self, text="9", default=ACTIVE)
self.btnDisplay.grid(row=5, column=2, padx=5, pady=5)
self.btnDisplay = Button(self, text="*", default=ACTIVE)
self.btnDisplay.grid(row=5, column=3, padx=5, pady=5)
self.btnDisplay = Button(self, text="0", default=ACTIVE)
self.btnDisplay.grid(row=6, column=0, padx=5, pady=5)
self.btnDisplay = Button(self, text="C", default=ACTIVE)
self.btnDisplay.grid(row=6, column=1, padx=5, pady=5)
self.btnDisplay = Button(self, text="r", default=ACTIVE)
self.btnDisplay.grid(row=6, column=2, padx=5, pady=5)
self.btnDisplay = Button(self, text="/", default=ACTIVE)
self.btnDisplay.grid(row=6, column=3, padx=5, pady=5)
def Display(self, xbtn):
if xbtn==1:
print 1
if __name__ == "__main__":
guiFrame = GUIFramework()
guiFrame.mainloop()