if __name__ == '__main__': import sys from PyQt5.QtWidgets import QApplication app = QApplication(sys.argv) ##################################################### print('main') import sys sys.path.append("../") module_name = "view" #模块名 class_name = "HomeView" #类名 method = "show" #方法名 module = __import__(module_name) # import module print ("#module:",module ) print('dir', dir(module)) cl = getattr(module,class_name) print("#class:",cl ) obj = cl() # new class print("#obj:",obj ) mtd = getattr(obj,method) print("#method:",mtd ) mtd() # call def ##################################################### sys.exit(app.exec_())
需要在__init__.py文件中引出才行....囧
今天未来得及看的:
https://github.com/processone/grapherl
http://toutiao.com/i6215417552374333953/?tt_from=mobile_qq&utm_campaign=client_share&app=news_article&utm_source=mobile_qq&iid=3160476964&utm_medium=toutiao_ios