GUI Problem....

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

GUI Problem....

jimmy joe jack
Hey, I was wondering about something. I'm a little tired and a bit hazy about what to do with this myself, so hopefully this is clear.

Basically, for giggles, I'm building like a budget calculator. I want it to have tabs for four pages at the top, so I switch to one screen I can total up my bills, another one my food...etc.

Not being an experienced programmer (at all), my method of creating "new screens" was to do a gui.destroy within a function and build a whole new page within a function, when a certain button is pressed. But after I put gui.destroy(), it seems like it won't let me put any new GUI stuff after. Like my "FOOD" label. Here's the code (so far). Hope this makes sense.


function page2()
gui.destroy()
screen.clear()
screen.moveto(0,40)
gui.label("FOOD")


screen.clear()
gui.title("Budget Calculator")
gui.menu({"exit"})
screen.moveto(220,0)
p1=gui.pbutton("1",1)
p2=gui.pbutton("2",1)
p3=gui.pbutton("3",1)
p4=gui.pbutton("4",1)

screen.moveto(0, 40)
gui.label("BILLS:")
screen.moveto(0,80)
gui.label("Car Insurance")
screen.moveto(150,80)
gui.label("$")
field1=gui.field(1,6,6,e)

gui.inserttext(field1,"hello")

screen.moveto(0,100)
gui.label("House Payment")
screen.moveto(150,100)
gui.label("$")
field2=gui.field(1,6,6,e)

screen.moveto(0,120)
gui.label("Gas")
screen.moveto(150,120)
gui.label("$")
field3=gui.field(1,6,6,e)

screen.moveto(0,140)
gui.label("Electric")
screen.moveto(150,140)
gui.label("$")
field4=gui.field(1,6,6,e)

screen.moveto(0,160)
gui.label("Water")
screen.moveto(150,160)
gui.label("$")
field5=gui.field(1,6,6,e)

screen.moveto(0,180)
gui.label("Garbage")
screen.moveto(150,180)
gui.label("$")
field6=gui.field(1,6,6,e)

screen.moveto(0,200)
gui.label("Association Fee")
screen.moveto(150,200)
gui.label("$")
field7=gui.field(1,6,6,e)

screen.moveto(0,220)
gui.label("Internet")
screen.moveto(150,220)
gui.label("$")
field8=gui.field(1,6,6,e)

screen.moveto(0,240)
gui.label("Car Gas")
screen.moveto(150,240)
gui.label("$")
field9=gui.field(1,6,6,e)


while true do
ev,id=gui.event()
if ev==appStop then break end
if ev==menuSelect and id==1 then os.exit() end
if ev==ctlSelect and id==p2 then  page2() end
end

gui.main()