1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
import pygame
from const import *
import table
import group
import button, basic
def action_open(value):
print 'gui.action_open',"Scheduled to be deprecated."
value.setdefault('x',None)
value.setdefault('y',None)
value['container'].open(value['window'],value['x'],value['y'])
def action_setvalue(value):
print 'gui.action_setvalue',"Scheduled to be deprecated."
a,b = value
b.value = a.value
def action_quit(value):
print 'gui.action_quit',"Scheduled to be deprecated."
value.quit()
def action_exec(value):
print 'gui.action_exec',"Scheduled to be deprecated."
exec(value['script'],globals(),value['dict'])
class Toolbox(table.Table):
def __setattr__(self,k,v):
_v = self.__dict__.get(k,NOATTR)
self.__dict__[k]=v
if k == 'value' and _v != NOATTR and _v != v:
self.group.value = v
for w in self.group.widgets:
if w.value != v: w.pcls = ""
else: w.pcls = "down"
self.repaint()
def _change(self,value):
self.value = self.group.value
self.send(CHANGE)
def __init__(self,data,cols=0,rows=0,tool_cls='tool',value=None,**params):
print 'gui.Toolbox','Scheduled to be deprecated.'
params.setdefault('cls','toolbox')
table.Table.__init__(self,**params)
if cols == 0 and rows == 0: cols = len(data)
if cols != 0 and rows != 0: rows = 0
self.tools = {}
_value = value
g = group.Group()
self.group = g
g.connect(CHANGE,self._change,None)
self.group.value = _value
x,y,p,s = 0,0,None,1
for ico,value in data:
#from __init__ import theme
import app
img = app.App.app.theme.get(tool_cls+"."+ico,"","image")
if img:
i = basic.Image(img)
else: i = basic.Label(ico,cls=tool_cls+".label")
p = button.Tool(g,i,value,cls=tool_cls)
self.tools[ico] = p
#p.style.hexpand = 1
#p.style.vexpand = 1
self.add(p,x,y)
s = 0
if cols != 0: x += 1
if cols != 0 and x == cols: x,y = 0,y+1
if rows != 0: y += 1
if rows != 0 and y == rows: x,y = x+1,0
|