Revisão | 8d0fe5eb9633d2d00a073d3756354e52863221b8 (tree) |
---|---|
Hora | 2013-03-28 17:53:34 |
Autor | pylaf |
Commiter | pylaf |
follow Logic in main module
@@ -840,7 +840,7 @@ | ||
840 | 840 | def gethollow(self,substance): |
841 | 841 | return self.substances[substance] |
842 | 842 | |
843 | -def extract_components(module): | |
843 | +def extract_modules(module): | |
844 | 844 | result = {} |
845 | 845 | ignore = [laf.Logic,tkext.tkWidget,vtkext.vtkLogic,vtkext.implicit.ImplicitFunction] |
846 | 846 | for k,mdl in inspect.getmembers(module,lambda x:inspect.ismodule(x)): |
@@ -853,15 +853,36 @@ | ||
853 | 853 | result[cls] = None |
854 | 854 | return result |
855 | 855 | |
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 | + | |
856 | 868 | class ClassChooser(ttk.Treeview,object): |
857 | 869 | chosenclass = Port() |
858 | 870 | def __init__(self,master=None,**kw): |
859 | 871 | ttk.Treeview.__init__(self,master,selectmode='browse',**kw) |
872 | + self.tracking_class = {} | |
873 | + # | |
874 | + # モジュールに含まれるロジッククラスを追跡する | |
860 | 875 | 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(): | |
863 | 877 | if k not in self.tracking_class: |
864 | 878 | 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 | + # | |
865 | 886 | self.bind('<<TreeviewSelect>>', self.selected) |
866 | 887 | self.loop() |
867 | 888 | def selected(self,e): |