help with python gui

Soldato
Joined
30 Nov 2005
Posts
13,916
hi have knocked up a GUI that I want but its just a rough design I know its the wrong way to do it but I don't know any better.

anyway i need to be able to add items to the left column and amounts in floats in right columns and when i press calc button the results will be displayed in bottom listbox showing list of items and the amounts broken back to 100

Code:
from Tkinter import *

root = Tk()

root.title('my gui')



def Calc():
    pass

def Clear():
    pass

def Quit():
    pass



label = Label(root, text = "item                 amount")

textframe =Frame(root)
textframe2 =Frame(root)
textframe3 =Frame(root)
textframe4 =Frame(root)
textframe5 =Frame(root)
textframe6 =Frame(root)
textframe7 =Frame(root)
textframe8 =Frame(root)
textframe9 =Frame(root)
textframe10 =Frame(root)


listframe =Frame(root)








calc_button = Button(textframe10, text="Calc", command = Calc)
clear_button = Button(textframe10, text="Clear", command = Clear)
quit_button = Button(textframe10, text="Quit", command = Quit)

text =Entry(textframe)
text2 =Entry(textframe)
text3 =Entry(textframe2)
text4 =Entry(textframe2)
text5 =Entry(textframe3)
text6 =Entry(textframe3)
text7 =Entry(textframe4)
text8 =Entry(textframe4)
text9 =Entry(textframe5)
text10 =Entry(textframe5)
text11 =Entry(textframe6)
text12 =Entry(textframe6)
text13 =Entry(textframe7)
text14 =Entry(textframe7)
text15 =Entry(textframe8)
text16 =Entry(textframe8)
text17 =Entry(textframe9)
text18 =Entry(textframe9)

scrollbar = Scrollbar(listframe, orient=VERTICAL)
listbox = Listbox(listframe, yscrollcommand=scrollbar.set, selectmode=EXTENDED)
scrollbar.configure(command=listbox.yview)



label.pack()

text.pack(side=LEFT, fill=X, expand=1)
text2.pack(side=LEFT, fill=X, expand=1)
text3.pack(side=LEFT, fill=X, expand=1)
text4.pack(side=LEFT, fill=X, expand=1)
text5.pack(side=LEFT, fill=X, expand=1)
text6.pack(side=LEFT, fill=X, expand=1)
text7.pack(side=LEFT, fill=X, expand=1)
text8.pack(side=LEFT, fill=X, expand=1)
text9.pack(side=LEFT, fill=X, expand=1)
text10.pack(side=LEFT, fill=X, expand=1)
text11.pack(side=LEFT, fill=X, expand=1)
text12.pack(side=LEFT, fill=X, expand=1)
text13.pack(side=LEFT, fill=X, expand=1)
text14.pack(side=LEFT, fill=X, expand=1)
text15.pack(side=LEFT, fill=X, expand=1)
text16.pack(side=LEFT, fill=X, expand=1)
text17.pack(side=LEFT, fill=X, expand=1)
text18.pack(side=LEFT, fill=X, expand=1)


    

textframe.pack(fill=X)
textframe2.pack(fill=X)
textframe3.pack(fill=X)
textframe4.pack(fill=X)
textframe5.pack(fill=X)
textframe6.pack(fill=X)
textframe7.pack(fill=X)
textframe8.pack(fill=X)
textframe9.pack(fill=X)
textframe10.pack(fill=X)

calc_button.pack(side=LEFT)
clear_button.pack(side=LEFT)
quit_button.pack(side=LEFT)
listbox.pack(side=LEFT,fill=BOTH, expand=1)
scrollbar.pack(side=LEFT, fill=Y)

listframe.pack(fill=BOTH, expand=1)

Frame(root, width=300, height=320).pack()
root.mainloop()
 
As you are using Tkinter I would suggest googling something like 'Tkinter tutorials' as there are several other GUI libraries for Python such as pygtk.

It sounds like you need to make use of an array/list/collection of some sort to store the GUI elements in, this would allow you to iterate over the elements and perform an operation on each one.
 
Back
Top Bottom