我有这个脚本
from tkinter import *
from tkinter import ttk
from tkinter.scrolledtext import ScrolledText
import tkinter as tk
from formularios import tabmain0
import webbrowser
import tkinterweb
def home():
container = ttk.Frame(tabmain0)
canvas = tk.Canvas(container)
scrollbar_x = ttk.Scrollbar(container, orient="horizontal", command=canvas.xview)
scrollbar_y = ttk.Scrollbar(container, orient="vertical", command=canvas.yview)
scrollable_frame = ttk.Frame(tabmain0)
scrollable_frame.bind("<Configure>", lambda e: canvas.configure(scrollregion=canvas.bbox("all")))
canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
canvas.configure(xscrollcommand=scrollbar_x.set)
canvas.configure(yscrollcommand=scrollbar_y.set)
stathomelib = LabelFrame(scrollable_frame, text="Library", padx=5, pady=5, highlightbackground="black",
highlightthickness=2)
stathomelib.grid(row=3, column=0, columnspan=2, sticky=NW, pady=2)
stathomedoc = LabelFrame(scrollable_frame, text="Documentation", padx=5, pady=5, highlightbackground="black",
highlightthickness=2)
stathomedoc.grid(row=3, column=2, columnspan=2, sticky=NW, pady=2)
home_browser = LabelFrame(scrollable_frame, text="", padx=5, pady=5, highlightbackground="black",
highlightthickness=2)
home_browser.grid(row=0, column=99, rowspan=99, sticky='ne', pady=2)
valido_browser = tk.IntVar()
valido_browser.set(False)
checkbrowser = tk.Checkbutton(home_browser, fg="blue", selectcolor="red", text="Open in Browser",
variable=valido_browser)
checkbrowser.grid(row=0, column=99, columnspan=3, sticky="wn")
frm_browser_home = ScrolledText(home_browser, width=15, height=13)
frm_browser_home.grid(column=99, row=1, padx=10, columnspan=99, rowspan=99, pady=10, ipady=310, sticky='ne')
def choose_browser(urlbook):
if valido_browser.get() == 1:
webbrowser.open(urlbook)
else:
frm_browser_home.insert(tk.INSERT, urlbook)
frame = tkinterweb.HtmlFrame(home_browser)
frame.load_website(urlbook)
frame.grid(row=0, column=99)
global varLnkOrder
varLnkOrder = ""
varLbook = open("Confs/bookmarks.txt", "r").readlines()
for line in varLbook:
undef = ""
if ":stathomelib" in line:
varLnkOrder = stathomelib
taman = 43
c = 0
i = 0
elif ":stathomedoc" in line:
varLnkOrder = stathomedoc
taman = 43
c = 0
i = 0
if len(line) > 1:
titul, urlbook = line.split('<=>')
if len(titul) > 1:
link1 = Label(varLnkOrder, width=taman, text=titul + str(undef), justify="left", anchor="center",
fg="blue", cursor="draft_large")
link1.grid(row=i, column=c, sticky="n", pady=2)
link1.bind("<Button-1>", lambda e, urlbook=urlbook: choose_browser(urlbook.rstrip()))
i += 1
line == ""
container.pack(expand=1, fill="both")
scrollbar_x.pack(side="bottom", fill="x")
scrollbar_y.pack(side="right", fill="y")
canvas.pack(side="bottom", fill="both", expand=True)
它适用于 tkinterweb,但我需要访问的网站在这里无法正常工作,有人可以帮忙吗?
也许使用cefpython3?Iv 尝试使用 cefpython3 但没有成功。
我需要知道是否有办法改进 tkinterweb 以正确显示网站,或者是否有人可以帮助我设置 cefpython3。