下面是我试图运行的代码。我想打开一个浏览器并且仍然可以使用输入框。我正在使用线程并且浏览器打开或正确加载。但是,输入框变为非活动状态。浏览器打开时如何使用输入框。非常感谢任何帮助。
'''
import tkinter as tk
from tkinter import messagebox
from cefpython3 import cefpython as cef
import threading
import sys
def test_thread(frame,link):
sys.excepthook = cef.ExceptHook
window_info = cef.WindowInfo(frame.winfo_id())
window_info.SetAsChild(frame.winfo_id(), rect)
cef.Initialize()
browser = cef.CreateBrowserSync(window_info, url=link)
root.after(1,activate_after_thread)
cef.MessageLoop()
def on_closing():
print('closing')
help(cef)
root.destroy()
def activate_after_thread():
entry.config(bg="blue")
pass
root = tk.Tk()
root.geometry('800x600')
root.protocol('WM_DELETE_WINDOW', on_closing)
frame = tk.Frame(root, bg='blue', height=200)
frame2 = tk.Frame(root, bg='white', height=200)
frame.pack(side='top', fill='x')
frame2.pack(side='top', fill='x')
tk.Button(frame2, text='Exit', command=on_closing).pack(side='left')
tk.Button(frame2, text='Show something',
command=lambda: messagebox.showinfo('TITLE', 'Shown something')).pack(side='right')
#
var = tk.StringVar()
entry = tk.Entry(frame2, width=70, textvariable=var)
entry.pack()
rect = [0, 0, 800, 200]
print('browser: ', rect[2], 'x', rect[3])
link = "https://www.google.com/"
thread = threading.Thread(target=test_thread, args=(frame,link,))
thread.start()
root.mainloop()
'''