当我尝试customtkinter在 Python 3.12 中导入时,出现以下错误:
File "c:\Users\judel\OneDrive\Documents\Python\main.py", line 1, in <module>
import customtkinter as ttk
File "C:\Users\judel\AppData\Local\Programs\Python\Python312\Lib\site-packages\customtkinter\__init__.py", line 10, in <module>
from .windows.widgets.appearance_mode import AppearanceModeTracker
File "C:\Users\judel\AppData\Local\Programs\Python\Python312\Lib\site-packages\customtkinter\windows\__init__.py", line 1, in <module>
from .ctk_tk import CTk
File "C:\Users\judel\AppData\Local\Programs\Python\Python312\Lib\site-packages\customtkinter\windows\ctk_tk.py", line 2, in <module>
from distutils.version import StrictVersion as Version
ModuleNotFoundError: No module named 'distutils'
Run Code Online (Sandbox Code Playgroud)
为什么会发生这种情况?为什么找不到标准库中的模块?
def video_downloader(video_url_list: List[str], download_folder: str) -> None:
"""
Download videos from a list of YouTube video URLs.
Args:
video_urls (List[str]): The list of YouTube video URLs to download.
download_folder (str): The folder to save the downloaded videos.
"""
successful_downloads = 0
valid_urls: List[str] = []
for url in video_url_list:
if not url:
continue
try:
with tempfile.TemporaryDirectory() as temp_dir:
cleaned_url = clean_youtube_url(url=url)
if _get_streams(url=cleaned_url, temp_dir=temp_dir):
create_folder(download_folder)
_merge_streams(
temp_dir=temp_dir, url=url, download_folder=download_folder
)
logger.info(f"The video from {url} was downloaded successfully")
successful_downloads += 1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 tkinter 和自定义 tkinter 制作一个用于数据输入的小型应用程序。代码在 python 中运行良好,我使用 pyinstaller --onefile --noconsole try45.py 制作了它的 exe 文件
但在运行 exe 文件时,它会给出标记为“脚本中未处理的异常”的错误。其详细信息附如下,
I have also attached the image of the error. The first two lines of it say "Failed to execute script 'try45' due to unhandled exception: [Errno 2] No such file or directory: 'C:\Users\Farzan Bashir\AppData\Local\Temp\_MEI127522\customtkinter\assets\themes\blue.json"
and the details in next lines are,
Traceback (most recent call last): File "try45.py", line 2, in File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked …
我最近决定开始学习 Python,在做几个小项目作为实践方法时,我发现了这个customtkinter库 ( https://github.com/TomSchimansky/CustomTkinter ),可以使用 Python 进行更现代的 GUI 开发。
我想做的事情要么需要文件的拖放组件,要么需要文件选择器对话框,这似乎在带有模块的原始库中有所存在,但似乎在文档中没有直接提及库包装器。tkintertkinterdnd2customtkinter
有谁知道如何专门使用拖放文件customtkinter?
如果没有 的直接包装器customtkinter,有没有办法将 的样式应用customtkinter到tkinderdnd2模块?当像这样使用它时,显然它只是使用默认tkinter样式:
from tkinter import TOP, Entry, Label, StringVar
from tkinterdnd2 import *
def get_path(event):
pathLabel.configure(text = event.data)
root = TkinterDnD.Tk()
root.geometry("350x100")
root.title("Get file path")
nameVar = StringVar()
entryWidget = Entry(root)
entryWidget.pack(side=TOP, padx=5, pady=5)
pathLabel = Label(root, text="Drag and drop file in the entry box")
pathLabel.pack(side=TOP)
entryWidget.drop_target_register(DND_ALL)
entryWidget.dnd_bind("<<Drop>>", get_path)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)