terminal.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:porcupine 作者: Akuli 项目源码 文件源码
def start_xterm():
    tab = tabs.Tab(get_tab_manager())
    tab.title = "Terminal"
    content = tkinter.Frame(tab, container=True)
    content.pack(fill='both', expand=True)

    try:
        process = subprocess.Popen(['xterm', '-into', str(content.winfo_id())])
    except FileNotFoundError:
        messagebox.showerror("xterm not found", (
            "Seems like xterm is not installed. " +
            "Please install it and try again."))
        return

    def close_if_not_closed(junk):
        if tab in get_tab_manager().tabs:
            get_tab_manager().close_tab(tab)

    # the content is destroyed when the terminal wants to exit
    content.bind('<Destroy>', close_if_not_closed, add=True)

    # the tab is destroyed when the user wants to close it
    tab.bind('<Destroy>', lambda event: process.terminate(), add=True)

    get_tab_manager().add_tab(tab)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号