我正在使用最新版本的 iframe-resizer/react 来自动调整 iframe 的高度和宽度。每当我对内容做出反应时,我都会收到运行时错误 -VM2860:1
我正在使用最新版本的 iframe-resizer/react 来自动调整 iframe 的高度和宽度。每当我对内容做出反应时,我都会收到运行时错误,指出 -VM2860:1 未捕获的语法错误:意外的令牌“s”,\'scroll-to-top\' 不是有效的 JSON
我不知道这是从哪里来的。我检查了 iframe 中发生的事件。那里也没有提到 scroll-to-top 这个东西。
下面是我编写的代码片段。请帮我解决这个问题。
import IFrameResizer from "@iframe-resizer/react";
<IFrameResizer
src={iframeSrc}
license="GPLv3"
className="iframe-dialog"
title="Iframe Dialog"
onLoad={onLoad}
scrolling={false}
forwardRef={iframeRef}
style={{
width: "100%",
border: "none",
opacity: "100",
height: "100vh",
}}
/>
我已尝试使用 iframe-resizer/react 中提供的 onResized、onMessage 处理程序来获取消息,但仍然没有任何反应。
每次我单击当前正在使用的应用程序中的按钮时,程序都会进入“无响应”状态,然后启动其自身的另一个实例,而旧实例仍处于活动状态。我不知道...
每次我单击当前正在使用的应用程序中的按钮时,程序都会进入“无响应”状态,然后启动其自身的另一个实例,而旧实例仍处于活动状态。我不知道如何或为什么,因为在 IDE 中运行时它可以工作。只要我用 auto-py-to-exe 打包它,它就会这样做。
按钮的代码:
info_but = customtkinter.CTkButton(menu,text="", font=custom_font,
image=info_def,bg_color="#FDF6E4",fg_color="#FDF6E4",hover_color="#3b444b",
width=70, command= info_menu,height=70)
info_but.place(x=20, y=220)
被调用的函数:
def info_menu():
global update_label, gpu_label
stop_thread()
# Beispielverwendung
os_ver = f"{uname().system} {uname().release}" # get_gpu_models()
threaded_check_for_new_version(repo_owner, repo_name, current_version)
proc_info = cpuinfo.get_cpu_info()
# RAM Informationen
ram = psutil.virtual_memory()
for child in frame.winfo_children():
child.destroy()
content_frame = customtkinter.CTkFrame(frame, width=880, height=600)
content_frame.place(x=0, y=0)
label = customtkinter.CTkLabel(content_frame, text=f"General Information:",anchor="w", justify="left", width=200, height=30, font=custom_font2)
label.grid(row=0, column=0, padx=(10,10),pady=(10,30))
label = customtkinter.CTkLabel(content_frame, text=f"App version:",anchor="w", width=130, justify="left", height=20,font=custom_font)
label.grid(row=2, column=0, padx=(150,10),pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"{current_version}",anchor="w", width=130, height=20,font=custom_font)
label.grid(row=2, column=1, padx=360,pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"Build date:",anchor="w", width=130, justify="left", height=20,font=custom_font)
label.grid(row=3, column=0, padx=(150,10),pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"05/2024",anchor="w", width=130, height=20,font=custom_font)
label.grid(row=3, column=1, padx=360,pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"Publisher:",anchor="w", width=130, justify="left", height=20,font=custom_font)
label.grid(row=4, column=0, padx=(150,10),pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"",anchor="w", width=130, height=20,font=custom_font)
label.grid(row=4, column=1, padx=360,pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"Update avaiable:",anchor="w", width=130, justify="left", height=20,font=custom_font)
label.grid(row=5, column=0, padx=(150,10),pady=10)
update_label = customtkinter.CTkLabel(content_frame, text=f"Working"
,anchor="w", width=130, height=20,font=custom_font)
update_label.grid(row=5, column=1, padx=360,pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"Authentic:",anchor="w", width=130, justify="left", height=20,font=custom_font)
label.grid(row=6, column=0, padx=(150,10),pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"Yes",anchor="w", width=130, height=30,font=custom_font)
label.grid(row=6, column=1, padx=360,pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"System Information:",anchor="w", justify="left", width=200, height=30, font=custom_font2)
label.grid(row=7, column=0, padx=(10,10),pady=(20,10))
label = customtkinter.CTkLabel(content_frame, text=f"CPU Model:",anchor="w", width=130, justify="left", height=20,font=custom_font)
label.grid(row=10, column=0, padx=(150,10),pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"{'{0}'.format(proc_info['brand_raw'])}",anchor="w", width=130, height=20,font=custom_font,wraplength=130)
label.grid(row=10, column=1, padx=360,pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"Architecture:",anchor="w", width=130, justify="left", height=20,font=custom_font)
label.grid(row=9, column=0, padx=(150,10),pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"{'{0}'.format(proc_info['arch'])}",anchor="w", width=130, height=20,font=custom_font)
label.grid(row=9, column=1, padx=360,pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"OS:",anchor="w", width=130, justify="left", height=20,font=custom_font)
label.grid(row=8, column=0, padx=(150,10),pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"{os_ver}",anchor="w", width=130, height=20,font=custom_font)
label.grid(row=8, column=1, padx=360,pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"GPU:",anchor="w", width=130, justify="left", height=20,font=custom_font)
label.grid(row=11, column=0, padx=(150,10),pady=10)
gpu_label = customtkinter.CTkLabel(content_frame, text=f"Working",anchor="w", width=130, height=20,font=custom_font)
gpu_label.grid(row=11, column=1, padx=360,pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"Avaiable RAM:",anchor="nw", width=130, justify="left", height=20,font=custom_font)
label.grid(row=12, column=0, padx=(150,10),pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"{str(ram.total / 1024**3)[:4]} GB",anchor="w", width=130, height=20,font=custom_font)
label.grid(row=12, column=1, padx=360,pady=(10,10))
label = customtkinter.CTkLabel(content_frame, text=f"",anchor="nw", width=130, justify="left", height=20,font=custom_font)
label.grid(row=13, column=0, padx=(150,10),pady=10)
label = customtkinter.CTkLabel(content_frame, text=f"",anchor="w", width=130, height=20,font=custom_font)
label.grid(row=13, column=1, padx=360,pady=(10,10))
threaded_get_gpu_models(gpu_label)
影响:
def fetch_latest_version(repo_owner, repo_name, current_version):
global cached_result
url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest"
response = requests.get(url)
if response.status_code == 200:
latest_version = response.json().get('tag_name')
comparison_result = semver.compare(current_version, latest_version)
if comparison_result < 0:
cached_result = [True, latest_version]
elif comparison_result == 0:
cached_result = [False, latest_version]
else:
cached_result = [False, current_version] # Deine Version ist neuer
else:
cached_result = [False, None]
update_label_text()
def update_label_text():
global cached_result, update_label
if cached_result[0]:
update_label.configure(text="Yes")
else:
if cached_result[1] is None:
update_label.configure(text="Error")
else:
update_label.configure(text="No")
root.update()
def check_for_new_version(repo_owner, repo_name, current_version):
global cached_result, cache_lock
root.update()
with cache_lock:
if cached_result[1] is None:
fetch_latest_version(repo_owner, repo_name, current_version)
else:
update_label_text()
def threaded_check_for_new_version(repo_owner, repo_name, current_version):
thread = threading.Thread(target=check_for_new_version, args=(repo_owner, repo_name, current_version))
thread.start()
def fetch_gpu_models(result):
try:
gpus = GPUtil.getGPUs()
gpu_models = set(gpu.name for gpu in gpus)
result.append(list(gpu_models) if gpu_models else ["Unknown"])
except Exception as e:
result.append(["Unknown"])
update_model_label(gpu_label,result[0])
def update_model_label(gpu_label,gpu_models):
gpu_label.configure(text=f"{gpu_models[0]}")
root.update()
def get_gpu_models(gpu_label):
result = []
fetch_gpu_models(result)
return result[0] if result else ["Unknown"]
def threaded_get_gpu_models(gpu_label):
thread = threading.Thread(target=get_gpu_models, args=(gpu_label,))
thread.start()
我修复了单击按钮时 IDE 抛出的所有错误,例如线程处理等,但仍然没有成功。我还更改了变量和函数的名称,因为我注意到我(愚蠢地)多次将这个名称用于不同的事物。
stop_thread 不是罪魁祸首,因为它是在错误发生之后添加的。