I want to use pywebview on tkinter. But it doesn't work

429 Views Asked by At

I try to implement url to appear in a specific area in tkinter using pywebview, but an error occurs.

Source Code.

import tkinter as tk
import webview
import threading

def show_website():
    # Tkinter 창 생성
    root = tk.Tk()

    # Create a frame for the website display area
    frame = tk.Frame(root)
    frame.pack(fill=tk.BOTH, expand=True)

    # Creating a Web View Window
    webview_frame = tk.Frame(frame)
    webview_frame.pack(fill=tk.BOTH, expand=True)

    window = webview.create_window("Web View Example", webview_frame, width=800, height=600)

    url = "https://www.example.com"
    window.load_url(url)

    root.mainloop()



if __name__ == '__main__':
    t = threading.Thread(target=show_website)
    t.start()
    t.join()

If you do this, a main window fail will occur.

0

There are 0 best solutions below