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