Commit MetaInfo

Revisão8d0fe5eb9633d2d00a073d3756354e52863221b8 (tree)
Hora2013-03-28 17:53:34
Autorpylaf
Commiterpylaf

Mensagem de Log

follow Logic in main module

Mudança Sumário

Diff

diff -r 4dca62c9714a -r 8d0fe5eb9633 src/pylafiii/chef.py
--- a/src/pylafiii/chef.py Wed Mar 20 17:34:33 2013 +0900
+++ b/src/pylafiii/chef.py Thu Mar 28 17:53:34 2013 +0900
@@ -840,7 +840,7 @@
840840 def gethollow(self,substance):
841841 return self.substances[substance]
842842
843-def extract_components(module):
843+def extract_modules(module):
844844 result = {}
845845 ignore = [laf.Logic,tkext.tkWidget,vtkext.vtkLogic,vtkext.implicit.ImplicitFunction]
846846 for k,mdl in inspect.getmembers(module,lambda x:inspect.ismodule(x)):
@@ -853,15 +853,36 @@
853853 result[cls] = None
854854 return result
855855
856+def extract_components(module):
857+ result = {}
858+ ignore = [laf.Logic,tkext.tkWidget,vtkext.vtkLogic,vtkext.implicit.ImplicitFunction]
859+ klass = inspect.getmembers(module,lambda x:inspect.isclass(x))
860+ for k,cls in klass:
861+ for c in inspect.getmro(cls):
862+ if c is laf.Logic or c is tkext.tkWidget:
863+ # if cls is not laf.Logic and cls is not tkext.tkWidget and cls is not vtkext.vtkLogic:
864+ if cls not in ignore:
865+ result[cls] = None
866+ return result
867+
856868 class ClassChooser(ttk.Treeview,object):
857869 chosenclass = Port()
858870 def __init__(self,master=None,**kw):
859871 ttk.Treeview.__init__(self,master,selectmode='browse',**kw)
872+ self.tracking_class = {}
873+ #
874+ # モジュールに含まれるロジッククラスを追跡する
860875 self.pylaf = imp.load_module('pylafiii',*imp.find_module('pylafiii'))
861- self.tracking_class = {}
862- for k,v in extract_components(self.pylaf).iteritems():
876+ for k,v in extract_modules(self.pylaf).iteritems():
863877 if k not in self.tracking_class:
864878 self.tracking_class[k] = v
879+ #
880+ # メインモジュールに含まれるロジッククラスを追跡する
881+ main = sys.modules['__main__']
882+ for k,v in extract_components(main).iteritems():
883+ if k not in self.tracking_class:
884+ self.tracking_class[k] = v
885+ #
865886 self.bind('<<TreeviewSelect>>', self.selected)
866887 self.loop()
867888 def selected(self,e):
Show on old repository browser