使用生成jupyter notebook --generate-config
配置jupyterlab的配置文件,修改配置文件code /Users/xx/.jupyter/jupyter_lab_config.py
如下三项去掉jupyterlab的token认证和自动打开浏览器。
1 2 3 4 5 6 7 8 # c.ExtensionApp.open_browser = False c.ExtensionApp.open_browser = False # c.ServerApp.password_required = False c.ServerApp.password_required = False # c.ServerApp.token = '<generated>' c.ServerApp.token = ''
配置QWebEngineView的无边框浏览器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 import sysfrom PyQt5.QtCore import QUrlfrom PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineProfilefrom PyQt5.QtWidgets import QApplication, QMainWindowclass Window (QMainWindow ): def __init__ (self ): super (Window, self).__init__() self.browser = QWebEngineView() self.setCentralWidget(self.browser) self.setWindowTitle('Data Viewer' ) self.browser.page().profile().setPersistentCookiesPolicy( QWebEngineProfile.PersistentCookiesPolicy.NoPersistentCookies) self.browser.load(QUrl("http://localhost:8888/lab" )) self.show() def run_browser (): app = QApplication(sys.argv) win = Window() win.resize(1400 , 900 ) win.setFixedSize(1400 , 900 ) app.exit(app.exec_()) return 1 if __name__ == "__main__" : run_browser()
完整的启动器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import sysfrom os import sep, getcwd, chdirfrom subprocess import Popenfrom simple_browser import run_browserif __name__ == "__main__" : task_list = [] path = getcwd() + sep + r"notebook" chdir(path) task = Popen(r"jupyter lab" , shell=True ) task_list.append(task) browser = run_browser() if browser: task.terminate() task.kill() sys.exit()
最终效果,没有多个title标题栏清爽多了