def setup(self): self.loop = asyncio.get_event_loop() self.thread = threading.Thread(target=self.start_loop, args=(self.loop,)) self.thread.start() # 当程序退出时关闭线程 Bloc_App().app_closed.connect(self.close)
def closeEvent(self, a0: QtGui.QCloseEvent) -> None: Bloc_App().app_closed.emit()
class BaseView(QWidget): ''' 静态资源管理器 ''' resource: ResourceLoader = ResourceLoader() ''' 路由管理器 ''' router: RouteManager = RouteManager() ''' 全局数据块 ''' global_bloc: Bloc_App = Bloc_App() ''' 配置对象 ''' config = Config() ''' 主题对象 ''' theme = Theme() ''' 图标字体 ''' fontawesome = FontAwesome() def set_style(self): ''' 设置样式 https://stackoverflow.com/questions/31178695/qt-stylesheet-not-working ''' self.setAttribute(QtCore.Qt.WA_StyledBackground) if hasattr(self, 'style_name'): with open(Config().qss_path + '/' + self.style_name + '.qss', 'r', encoding='utf-8') as f: self.setStyleSheet(f.read()) def procedure(self): ''' 初始化流程,set_ui > place > configure > set_signal ''' self.set_style() if hasattr(self, 'set_ui'): self.set_ui() if hasattr(self, 'place'): self.place() if hasattr(self, 'configure'): self.configure() if hasattr(self, 'set_bloc'): self.set_bloc() if hasattr(self, 'set_signal'): self.set_signal() def show_vloading(self): if not hasattr(self, 'inner_loader'): self.inner_loader = Loading(self, modal=False) self.inner_loader.show() def hide_vloading(self): if hasattr(self, 'inner_loader'): self.inner_loader.on_outer_close.emit()