Hi,
I'm newbie on Jython and on this forum as well.
I need to create a GUI with Swing.
My original code is based on Tkinter (see below, code adapted from Tony Veijalainen's Tkinter Info Grid by loops and tuples).
The main point is the use of mainloop() allowing the program to enter an event loop.
Within this loop, the user can enter new values via the Entry widget.
Is there anything equivalent or similar on Jython ?
What I basically need is to create a layout that is editable and that can collect variables to list.
Thanks for help
Best regards
from Tkinter import *
data = [
('a', 0, 'liters soda'),
('b', 0, 'liters beer')
]
## Create grid, extracting infos from the data array
## Collect the text variables to list for use
def createWidgets(root, clist=[]):
L=0
while L < len(data):
cg_w=DoubleVar()
clist.append(cg_w)
l_w=Label(root, text=data[L][2])
l_w.grid(row=L)
c_w=Entry(root, textvariable=cg_w, width=3)
c_w.grid(row=L,column=1)
L+=1
root=Tk()
root.title('Bar')
##
cl=[]
createWidgets(root,cl)
## Example of simple function using values from an edited list (cl)
def Calc():
L=0
v=0
lit=0
for L,v in enumerate(cl):
lit+=v.get()
TotLiters.configure(text='%g' % lit)
compute = Button(root, text=' Total liters = ', command=Calc)
compute.grid(row=0,column=3)
TotLiters=Label(root, width=10)
TotLiters.grid(row=0,column=4)
root.mainloop()