busimus / cutelog

GUI for logging
MIT License
479 stars 45 forks source link

Feature request: Embedded cutelog #16

Open cdgriffith opened 3 years ago

cdgriffith commented 3 years ago

It would be nice to have a separate entry that used an existing QT MainWindow that would make cutelog easily added to other QT based programs.

Possibly add a way to pass through a custom program name as well, so it could display in the title bar "ProgramName Logs (powered by cutelog)" or similar.

cdgriffith commented 3 years ago

So far I can launch it:

    def start_cutelog(self):
        from cutelog.main_window import MainWindow
        import sys
        if sys.platform == 'win32':
            import ctypes
            appid = 'busimus.cutelog'
            ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(appid)

        self.mw = MainWindow(logging.getLogger('my_log'), self)
        self.mw_close_event = self.mw.closeEvent
        self.mw.closeEvent = lambda x: print('nope')
        self.mw.hide()

    def show_logs(self):
        self.mw.show()

    def closeEvent(self, event):
        self.mw_close_event(event)
        super().closeEvent(event)

    def quit(self):
        pass # required as closeEvent() in cutelog calls parent_app.quit

Opens and closes fine.

But has an issue with resource paths (installed via pip) Once a log message is sent:

  File "...venv/lib/python3.8/site-packages/cutelog/logger_tab.py", line 512, in setupUi
    self.ui = loadUi(CONFIG.get_ui_qfile('logger.ui'), baseinstance=self)
  File "..../venv/lib/python3.8/site-packages/cutelog/config.py", line 160, in get_ui_qfile
    raise FileNotFoundError('ui file not found: ":/ui/{}"'.format(name))
FileNotFoundError: ui file not found: ":/ui/logger.ui"