Commit MetaInfo

Revisión3cdb128e423719c742b1a1a9a61cad6bb3cd5427 (tree)
Tiempo2013-03-04 21:13:57
Autorbijoux
Commiterbijoux

Log Message

restore AutoTrig
restore SelectionPanel

Cambiar Resumen

Diferencia incremental

diff -r a0254635c1ac -r 3cdb128e4237 src/pylafiii/chef.py
--- a/src/pylafiii/chef.py Mon Mar 04 03:19:33 2013 +0900
+++ b/src/pylafiii/chef.py Mon Mar 04 21:13:57 2013 +0900
@@ -24,7 +24,7 @@
2424 コントロールパネルで自動生成可能なポートを返す
2525 '''
2626 MYTYPES = (types.IntType,types.FloatType,types.StringType,
27- numpy.float64,numpy.int64,data.SpecificTuple)
27+ numpy.float64,numpy.int64,data.SpecificTuple,data.Selection)
2828 members = {}
2929 for k,v in laf.getports(logic).iteritems():
3030 value = v.container.value
@@ -482,6 +482,11 @@
482482 b = data.TupleBridge(w)
483483 v.link(laf.port(b,'value'))
484484 ControlPanel(w,logic=b).pack()
485+ elif isproxyaccess and isinstance(v.container.value,data.Selection):
486+ # セレクションパネルの作成
487+ w = Tkinter.LabelFrame(self,text=k); w.grid(column=0,row=i,columnspan=2)
488+ w = data.SelectionPanel(w); w.pack()
489+ v.link(laf.port(w,'value'))
485490 else:
486491 # 通常は Entry リストを作成する
487492 if isproxyaccess:
@@ -790,12 +795,14 @@
790795
791796 def extract_components(module):
792797 result = {}
798+ ignore = [laf.Logic,tkext.tkWidget,vtkext.vtkLogic,vtkext.implicit.ImplicitFunction]
793799 for k,mdl in inspect.getmembers(module,lambda x:inspect.ismodule(x)):
794800 klass = inspect.getmembers(mdl,lambda x:inspect.isclass(x))
795801 for k,cls in klass:
796802 for c in inspect.getmro(cls):
797803 if c is laf.Logic or c is tkext.tkWidget:
798- if cls is not laf.Logic and cls is not tkext.tkWidget and cls is not vtkext.vtkLogic:
804+ # if cls is not laf.Logic and cls is not tkext.tkWidget and cls is not vtkext.vtkLogic:
805+ if cls not in ignore:
799806 result[cls] = None
800807 return result
801808
diff -r a0254635c1ac -r 3cdb128e4237 src/pylafiii/data.py
--- a/src/pylafiii/data.py Mon Mar 04 03:19:33 2013 +0900
+++ b/src/pylafiii/data.py Mon Mar 04 21:13:57 2013 +0900
@@ -1,8 +1,10 @@
11 # coding: utf-8
22
3+import Tkinter
34 from ingredient import Logic,ActualEvent,event
5+from tkext import tkWidget
46
5-class SpecificTuple(tuple,object):
7+class SpecificTuple(tuple):
68 keys = None
79
810 class Point(SpecificTuple):
@@ -40,3 +42,48 @@
4042 self.value = None
4143 # keys をクリアする
4244 self.keys = None
45+
46+class Selection(int):
47+ option = None
48+
49+class SelectionPanel(Tkinter.Frame,tkWidget):
50+ def __init__(self,*args,**kw):
51+ Tkinter.Frame.__init__(self,*args,**kw)
52+ self._value = Tkinter.IntVar(self.value)
53+ self._buffer = None
54+ self._updated = False
55+ self._event_loop()
56+ def _event_loop(self):
57+ self.populate_option()
58+ if self._updated:
59+ self._value.set(self._buffer)
60+ self._updated = False
61+ self.after(50,self._event_loop)
62+ @event
63+ def value(self):
64+ self._buffer = self.value
65+ self._updated = True
66+ def populate_option(self):
67+ # ひとつでも居住していなければラジオボタンを再生成する
68+ if self.value == None:
69+ return
70+ option = self.value.option
71+ option = [v.replace(' ','') for v in option]
72+ resident = [''.join(v.config()['text'][4]) for v in self.children.itervalues()]
73+ for o in option:
74+ if o not in resident:
75+ self.removeall()
76+ self.generate()
77+ break
78+ def removeall(self):
79+ scrap = [o for o in self.children.itervalues()]
80+ for o in scrap:
81+ o.destroy()
82+ def generate(self):
83+ option = self.value.option
84+ for i,o in enumerate(option):
85+ Tkinter.Radiobutton(self,text=o,variable=self._value,value=i,command=self.update).pack(anchor=Tkinter.W)
86+ def update(self):
87+ klass = self.value.__class__
88+ self.value = klass(self._value.get())
89+
\ No newline at end of file
diff -r a0254635c1ac -r 3cdb128e4237 src/pylafiii/tkext.py
--- a/src/pylafiii/tkext.py Mon Mar 04 03:19:33 2013 +0900
+++ b/src/pylafiii/tkext.py Mon Mar 04 21:13:57 2013 +0900
@@ -2,7 +2,7 @@
22
33 import Tkinter
44 import ingredient as laf
5-from ingredient import event
5+from ingredient import event,Port
66
77 class tkWidget(object): pass
88
@@ -34,3 +34,15 @@
3434 self._buffer = container.value
3535 self._updated = True
3636
37+class AutoTrig(Tkinter.Checkbutton,tkWidget):
38+ trig = Port()
39+ def __init__(self,master=None,cnf={},**kw):
40+ Tkinter.Checkbutton.__init__(self,master,cnf,**kw)
41+ self._status = Tkinter.IntVar()
42+ self.config(text='AutoTrig',variable=self._status)
43+ self._event_loop()
44+ def _event_loop(self):
45+ if self._status.get():
46+ self.trig
47+ self.after(50,self._event_loop)
48+
\ No newline at end of file
diff -r a0254635c1ac -r 3cdb128e4237 src/pylafiii/vtkext/__init__.py
--- a/src/pylafiii/vtkext/__init__.py Mon Mar 04 03:19:33 2013 +0900
+++ b/src/pylafiii/vtkext/__init__.py Mon Mar 04 21:13:57 2013 +0900
@@ -4,3 +4,4 @@
44 from actor import *
55 from mapper import *
66 from source import *
7+from implicit import *
diff -r a0254635c1ac -r 3cdb128e4237 src/pylafiii/vtkext/implicit.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pylafiii/vtkext/implicit.py Mon Mar 04 21:13:57 2013 +0900
@@ -0,0 +1,22 @@
1+# coding: utf-8
2+
3+import vtk
4+from pylafiii.ingredient import event
5+from pylafiii.data import Selection
6+from base import vtkLogic
7+
8+class ImplicitFunction(vtkLogic): pass
9+
10+class ImplicitBoolean(ImplicitFunction):
11+ vtkClass = vtk.vtkImplicitBoolean
12+ class OperationType(Selection):
13+ option = ('Union','Intersection','Difference','Union of Magnitudes')
14+ def initialize(self):
15+ self.optype = self.OperationType(self.vtkobj.GetOperationType())
16+ @event
17+ def optype(self):
18+ dct = {0:self.vtkobj.SetOperationTypeToUnion,
19+ 1:self.vtkobj.SetOperationTypeToIntersection,
20+ 2:self.vtkobj.SetOperationTypeToDifference,
21+ 3:self.vtkobj.SetOperationTypeToUnionOfMagnitudes}
22+ dct[self.optype].__call__()
Show on old repository browser