def main(): pyqtRemoveInputHook() QDir(QDir.homePath()).mkdir(".ricodebug") app = QApplication(sys.argv) app.setApplicationName("ricodebug") Icons() # We use all kinds of loggers here: # * a CriticalLogHandler that will abort the program whenever a critical error is received # * a FileHandler writing to a log in the home directory (all messages, for debugging) # * a LogViewHandler to have the log available in the GUI # * a ErrorLabelHandler that visually notifies the user of an error or a warning logger = logging.getLogger() formatter = logging.Formatter('[%(levelname)-8s] : %(filename)15s:%(lineno)4d/%(funcName)-20s : %(message)s') filehandler = logging.FileHandler(filename='%s/.ricodebug/ricodebug.log' % str(QDir.homePath())) filehandler.setFormatter(formatter) logger.addHandler(filehandler) logger.setLevel(logging.DEBUG) logger.addHandler(criticalloghandler.CriticalLogHandler()) window = MainWindow() logger.addHandler(window.logviewhandler) logger.addHandler(window.notificationFrameHandler) if (len(sys.argv) > 1): window.debugController.openExecutable(sys.argv[1]) window.show() logging.shutdown() sys.exit(app.exec_())
def main(): pyqtRemoveInputHook() QDir(QDir.homePath()).mkdir(".ricodebug") app = QApplication(sys.argv) app.setApplicationName("ricodebug") window = MainWindow() logging.basicConfig(filename='%s/.ricodebug/ricodebug.log' % str(QDir.homePath()), level=logging.DEBUG) logviewhandler = logview.LogViewHandler(window.ui.logView, window.ui.filterSlider) window.ui.filterSlider.setValue(3) errormsghandler = logview.ErrorLabelHandler(window) logger = logging.getLogger() logger.addHandler(logviewhandler) logger.addHandler(errormsghandler) if (len(sys.argv) > 1): window.debugController.openExecutable(sys.argv[1]) window.show() sys.exit(app.exec_())
class MainController(object): def __init__(self): self.app = QApplication(sys.argv) self.mw = MainWindow() self.project = ProjectModel() def link_mainwindow_anction(self): self.mw.action_new.triggered.connect(self.control_new) self.mw.action_open.triggered.connect(self.control_open) self.mw.action_about.triggered.connect(self.control_about) self.mw.action_paralist_dock_isclosed.triggered.connect( self.control_paralist_dock_isclosed) self.mw.action_exit.triggered.connect(self.control_exit) self.mw.action_import_normal_datafile.triggered.connect( self.control_import_normal_datafile) def control_start(self): self.mw.setup() self.link_mainwindow_anction() self.mw.show() return self.app.exec_() def control_new(self): self.project = ProjectModel() # 从主窗口中获得路径和名称 pro_dir, pro_name = self.mw.view_new() # 给项目对象赋值 self.project.new_project(pro_dir, pro_name) # 将窗口标题改成项目路径 self.mw.view_set_window_title(self.project.get_total_pro_dir()) def control_open(self): # 显示项目文件夹选择对话框 sel_pro = self.mw.view_open() # 对原来的项目对象进行重新赋值 open_status = self.project.open_project(sel_pro) # 显示项目打开状态 self.mw.view_open_status(open_status, self.project.get_total_pro_dir()) # 将窗口标题改成项目路径 self.mw.view_set_window_title(self.project.get_total_pro_dir()) def control_import_normal_datafile(self): file_name, ok = QFileDialog.getOpenFileNames(self.mw, 'Load', 'D:/') #multi files input self.project.import_datafile(file_name) self.mw.mw_paralist_dock.display(self.project.get_datafile_group()) def control_export_data(self): pass def control_exit(self): QApplication.closeAllWindows() def control_simple_math(self): pass def control_testpoint_manage(self): pass def control_synchronization(self): pass def control_tuning(self): pass def control_para_manage(self): pass def control_temp_manage(self): pass def control_options(self): pass def control_about(self): self.mw.view_about() def control_quick_plot(self): pass def control_custom_defined_plot(self): pass def control_multi_source_plot(self): pass def control_paralist_dock_isclosed(self): self.mw.control_paralist_dock_isclosed()
from PyQt5 import QtWidgets from views.mainwindow import MainWindow if __name__ == '__main__': import sys app = QtWidgets.QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_())