"""and example of how to implement tabs"""
import pygame
from pgu import gui
from pygame.locals import *
# the following line is not needed if pgu is installed
import sys; sys.path.insert(0, "..")
from pgu import gui
from pgu import html
app = gui.Desktop()
def quit(e):
global _quit
_quit=1
#####################################
c = gui.Container(width=1024,height=768)
def i_disable(value):
item.disabled = True
item.blur()
item.chsize()
item = gui.Button(gui.Label('Quit this shit'))
item.connect(gui.CLICK,quit,None)
def c_add(value):
w = value
c.add(item,120,45)
w.value = gui.Label('Remove')
w.connect(gui.CLICK,c_remove,w)
def c_remove(value):
w = value
c.remove(item)
w.value = gui.Label('Add')
w.connect(gui.CLICK,c_add,w)
w = gui.Button("Add")
w.connect(gui.CLICK,c_add,w)
c.add(w,10,45)
#################################
t = gui.Table(width=1024,height=768)
tn = 0
tw = []
def t_add(value):
global tn
if (tn%6)==0: t.tr()
w = gui.Label(str(tn))
tw.append(w)
t.td(w)
tn+=1
def t_remove(value):
if len(tw):
w = tw.pop()
t.remove(w)
t.tr()
w = gui.Button('Add')
w.connect(gui.CLICK,t_add,None)
t.td(w,colspan=3)
w = gui.Button('Remove')
w.connect(gui.CLICK,t_remove,None)
t.td(w,colspan=3)
#####################################
d = gui.Document(width=1024,height=768)
dn = 0
dw = []
def d_add(value):
global dn
w = gui.Label("%d "%dn)
dw.append(w)
d.add(w)
dn+=1
def d_remove(value):
if len(dw):
w = dw.pop()
d.remove(w)
w = gui.Button('Add')
w.connect(gui.CLICK,d_add,None)
d.add(w)
d.space((8,8))
w = gui.Button('Remove')
w.connect(gui.CLICK,d_remove,None)
d.add(w)
d.space((8,8))
#######################################
def tab():
box.widget = g.value
g = gui.Group()
g.connect(gui.CHANGE,tab)
tt = gui.Table()
tt.tr()
b = gui.Tool(g,gui.Label("hauptseite"),c)
tt.td(b)
b = gui.Tool(g,gui.Label("kurse"),t)
tt.td(b)
b = gui.Tool(g,gui.Label("veranstaltungen"),d)
tt.td(b)
d1 = gui.Container()
b = gui.Tool(g,gui.Label("mitglieder"),d1)
tt.td(b)
d2 = gui.Container()
b = gui.Tool(g,gui.Label("andere vereine"),d2)
tt.td(b)
d3 = gui.Container()
b = gui.Tool(g,gui.Label("info"),d3)
tt.td(b)
d4 = gui.Container()
b = gui.Tool(g,gui.Label("kontakt"),d4)
tt.td(b)
d5 = gui.Container()
b = gui.Tool(g,gui.Label("veranstaltungen"),d5)
tt.td(b)
tt.tr()
spacer = gui.Spacer(1,100)
box = gui.ScrollArea(spacer,1024,768)
tt.td(box,style={'border':1,'backgorund':'red'},colspan=8)
app.connect(gui.QUIT,app.quit,None)
screen = pygame.display.set_mode((1024,768))
app.init(tt)
app.connect(gui.QUIT, app.quit, None)
#app.run(b)
pygame.display.toggle_fullscreen()
_quit=0
while not _quit:
for e in pygame.event.get():
if e.type is KEYDOWN and e.key == K_ESCAPE: _quit = 1
if e.type is QUIT: _quit = 1
app.event(e)
app.update(screen)
pygame.display.flip()
t = pygame.time.wait(10)