hey all. i need some help with my calculator and i was wondering if anyone knew how to make it so if you click on a button it would pop up the value of that button in the entry screen.

## -*- coding: utf-8 -*-
## SDD, Major Project, Extreme Calculator, Screen Shot
## Programmer: Steven Browne
## Date Started: Thursday, 25th Febuary 2010
## Filename: tkinterScreenDesign20100225.pyw

from Tkinter import *

class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.grid()
        self.createEdit()
        self.createView()
        self.createHelp()
        self.createQuit()
        self.createOnOff()
        self.createDelete()
        self.createClear()
        self.createSeven()
        self.createEight()
        self.createNine()
        self.createDivide()
        self.createFour()
        self.createFive()
        self.createSix()
        self.createTimes()
        self.createOne()
        self.createTwo()
        self.createThree()
        self.createMinus()
        self.createZero()
        self.createNegative()
        self.createDecimal()
        self.createPlus()
        self.createEquals()





## Buttons at top of window, adjust to suit proper format
## Use page 43 in the Tkinter book for pop down button




    def createEdit(self):
        self.mb = Menubutton(self, text="Edit", relief=FLAT, font=("Arial", 8))
        self.mb.grid(row=0, column=0)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.copyVar = IntVar()
        self.pasteVar = IntVar()
        self.mb.menu.add_checkbutton(label="Copy Ctrl+C", variable=self.copyVar)
        self.mb.menu.add_checkbutton(label="Paste Ctrl+V", variable=self.pasteVar)

    def createView(self):
        self.mb = Menubutton(self, text="View", relief=FLAT, font=("Arial", 8))
        self.mb.grid(row=0, column=1)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.digitGroupingVar = IntVar()
        self.mb.menu.add_checkbutton(label="Digit Grouping", variable=self.digitGroupingVar)

    def createHelp(self):
        self.mb = Menubutton(self, text="Help", relief=FLAT, font=("Arial", 8))
        self.mb.grid(row=0, column=2)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.helpTopicsVar = IntVar()
        self.aboutExtremeCalculatorVar = IntVar()
        self.mb.menu.add_checkbutton(label="Help Topics", variable=self.helpTopicsVar)
        self.mb.menu.add_checkbutton(label="About Extreme Calculator", variable=self.aboutExtremeCalculatorVar)

    def createQuit(self):
        self.mb = Menubutton(self, text="Quit", relief=FLAT, font=("Arial", 8))
        self.mb.grid(row=0, column=3)
        self.mb.menu = Menu(self.mb, tearoff=0)
        self.mb["menu"] = self.mb.menu
        self.exitVar = IntVar()
        self.mb.menu.add_command(label="Exit", command=self.quit)




## Screen




    entry = tk.Entry(width=33, bg="yellow")
    entry.grid(row=0, column=0, columnspan=5)





## First Row of buttons





    def createOnOff(self):
        top=self.winfo_toplevel()
        top.rowconfigure(1, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)
        self.columnconfigure(0, weight=1)
        self.Button = Button ( self, text="On/Off", font=("Arial", 12), bg="white", fg="magenta", cursor="crosshair")
        self.Button.grid(row=1, column=0, sticky=N+E+S+W)

    def createDelete(self):
        top=self.winfo_toplevel()
        top.rowconfigure(1, weight=1)
        top.columnconfigure(1, weight=1)
        self.rowconfigure(1, weight=1)
        self.columnconfigure(1, weight=1)
        self.Button = Button ( self, text="Delete", font=("Arial", 12), bg="white", fg="magenta", cursor="crosshair")
        self.Button.grid(row=1, column=1, sticky=N+E+S+W)

    def createClear(self):
        top=self.winfo_toplevel()
        top.rowconfigure(1, weight=1)
        top.columnconfigure(2, weight=1)
        self.rowconfigure(1, weight=1)
        self.columnconfigure(2, weight=1)
        self.Button = Button ( self, text="Clear", font=("Arial", 12), bg="white", fg="magenta", cursor="crosshair")
        self.Button.grid(row=1, column=2, sticky=N+E+S+W)

    def createDivide(self):
        top=self.winfo_toplevel()
        top.rowconfigure(1, weight=1)
        top.columnconfigure(3, weight=1)
        self.rowconfigure(1, weight=1)
        self.columnconfigure(3, weight=1)
        self.Button = Button ( self, text="    รท    ", font=("Arial", 12), bg="white", fg="red", cursor="crosshair")
        self.Button.grid(row=1, column=3, sticky=N+E+S+W)





## Second Row of buttons





    def createSeven(self):
        top=self.winfo_toplevel()
        top.rowconfigure(2, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(2, weight=1)
        self.columnconfigure(0, weight=1)
        self.Button = Button ( self, text="    7    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=2, column=0, sticky=N+E+S+W)

    def createEight(self):
        top=self.winfo_toplevel()
        top.rowconfigure(2, weight=1)
        top.columnconfigure(1, weight=1)
        self.rowconfigure(2, weight=1)
        self.columnconfigure(1, weight=1)
        self.Button = Button ( self, text="    8    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=2, column=1, sticky=N+E+S+W)

    def createNine(self):
        top=self.winfo_toplevel()
        top.rowconfigure(2, weight=1)
        top.columnconfigure(2, weight=1)
        self.rowconfigure(2, weight=1)
        self.columnconfigure(2, weight=1)
        self.Button = Button ( self, text="    9    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=2, column=2, sticky=N+E+S+W)

    def createTimes(self):
        top=self.winfo_toplevel()
        top.rowconfigure(2, weight=1)
        top.columnconfigure(3, weight=1)
        self.rowconfigure(2, weight=1)
        self.columnconfigure(3, weight=1)
        self.Button = Button ( self, text="    *    ", font=("Arial", 12), bg="white", fg="red", cursor="crosshair")
        self.Button.grid(row=2, column=3, sticky=N+E+S+W)





## Third Row of buttons





    def createFour(self):
        top=self.winfo_toplevel()
        top.rowconfigure(3, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(3, weight=1)
        self.columnconfigure(0, weight=1)
        self.Button = Button ( self, text="    4    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=3, column=0, sticky=N+E+S+W)

    def createFive(self):
        top=self.winfo_toplevel()
        top.rowconfigure(3, weight=1)
        top.columnconfigure(1, weight=1)
        self.rowconfigure(3, weight=1)
        self.columnconfigure(1, weight=1)
        self.Button = Button ( self, text="    5    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=3, column=1, sticky=N+E+S+W)

    def createSix(self):
        top=self.winfo_toplevel()
        top.rowconfigure(3, weight=1)
        top.columnconfigure(2, weight=1)
        self.rowconfigure(3, weight=1)
        self.columnconfigure(2, weight=1)
        self.Button = Button ( self, text="    6    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=3, column=2, sticky=N+E+S+W)

    def createMinus(self):
        top=self.winfo_toplevel()
        top.rowconfigure(3, weight=1)
        top.columnconfigure(3, weight=1)
        self.rowconfigure(3, weight=1)
        self.columnconfigure(3, weight=1)
        self.Button = Button ( self, text="    -    ", font=("Arial", 12), bg="white", fg="red", cursor="crosshair")
        self.Button.grid(row=3, column=3, sticky=N+E+S+W)





## Forth Row of buttons





    def createOne(self):
        top=self.winfo_toplevel()
        top.rowconfigure(4, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(4, weight=1)
        self.columnconfigure(0, weight=1)
        self.Button = Button ( self, text="    1    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=4, column=0, sticky=N+E+S+W)

    def createTwo(self):
        top=self.winfo_toplevel()
        top.rowconfigure(4, weight=1)
        top.columnconfigure(1, weight=1)
        self.rowconfigure(4, weight=1)
        self.columnconfigure(1, weight=1)
        self.Button = Button ( self, text="    2    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=4, column=1, sticky=N+E+S+W)

    def createThree(self):
        top=self.winfo_toplevel()
        top.rowconfigure(4, weight=1)
        top.columnconfigure(2, weight=1)
        self.rowconfigure(4, weight=1)
        self.columnconfigure(2, weight=1)
        self.Button = Button ( self, text="    3    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=4, column=2, sticky=N+E+S+W)

    def createPlus(self):
        top=self.winfo_toplevel()
        top.rowconfigure(4, weight=1)
        top.columnconfigure(3, weight=1)
        self.rowconfigure(4, weight=1)
        self.columnconfigure(3, weight=1)
        self.Button = Button ( self, text="    +    ", font=("Arial", 12), bg="white", fg="red", cursor="crosshair")
        self.Button.grid(row=4, column=3, sticky=N+E+S+W)





## Fifth Row of buttons





    def createZero(self):
        top=self.winfo_toplevel()
        top.rowconfigure(5, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(5, weight=1)
        self.columnconfigure(0, weight=1)
        self.Button = Button ( self, text="    0    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=5, column=0, sticky=N+E+S+W)

    def createNegative(self):
        top=self.winfo_toplevel()
        top.rowconfigure(5, weight=1)
        top.columnconfigure(1, weight=1)
        self.rowconfigure(5, weight=1)
        self.columnconfigure(1, weight=1)
        self.Button = Button ( self, text="   +/-   ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=5, column=1, sticky=N+E+S+W)

    def createDecimal(self):
        top=self.winfo_toplevel()
        top.rowconfigure(5, weight=1)
        top.columnconfigure(2, weight=1)
        self.rowconfigure(5, weight=1)
        self.columnconfigure(2, weight=1)
        self.Button = Button ( self, text="    .    ", font=("Arial", 12), bg="white", fg="blue", cursor="crosshair")
        self.Button.grid(row=5, column=2, sticky=N+E+S+W)

    def createEquals(self):
        top=self.winfo_toplevel()
        top.rowconfigure(5, weight=1)
        top.columnconfigure(3, weight=1)
        self.rowconfigure(5, weight=1)
        self.columnconfigure(3, weight=1)
        self.Button = Button ( self, text="    =    ", font=("Arial", 12), bg="white", fg="black", cursor="crosshair")
        self.Button.grid(row=5, column=3, sticky=N+E+S+W)




## Last part




        
app = Application()
app.master.title("Extreme Calculator") # This will be the name of the window
app.mainloop()

i just need to know how to make a number pop up in the entry screen

thank you

Study this little code example, it should give you a hint ...

# create a calculator key pad with Tkinter

import Tkinter as tk
# needs Python25 or higher
from functools import partial  

def click(btn):
    # test the button command click
    entry.insert('end', btn)


root = tk.Tk()

# typical calculator button layout
btn_list = [
'7',  '8',  '9',  '*',  'C',
'4',  '5',  '6',  '/',  'M->',
'1',  '2',  '3',  '-',  '->M',
'0',  '.',  '=',  '+',  'neg' ]

# create all buttons with a loop
# r, c are used to calculate the row/column position
r = 1
c = 0
n = 0
btn = range(len(btn_list))
for label in btn_list:
    # partial takes care of function and argument
    cmd = partial(click, label)
    # create the button
    btn[n] = tk.Button(root, text=label, width=5, command=cmd)
    # position the button
    btn[n].grid(row=r, column=c)
    # increment button index
    n += 1
    # update row/column position
    c += 1
    if c > 4:
        c = 0
        r += 1

entry = tk.Entry(root, width=33)
entry.grid(row=0, column=0, columnspan=5)

root.mainloop()

holy crap i just realized we had the same entry point

:)

please stop giving me examples just tell me how to do it with my code!!

:(

commented: Great attitude pal... -2

If they give it to you, then you wont learn.

If you haven't got it working by friday I'll work with you in SDD.
Its a good example, I believe I showed it to you earlier.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.