当尝试使用cx_freeze构建文件时,会弹出错误消息
Thread Unit
我知道还有其他帖子对此进行了介绍,但是我已经尝试添加
type
myThread = class(TThread)
protected
procedure Execute; override;
private
procedure Sinchro;
public
constructor Create (some parameters); reintroduce; //reference to procedure need to be added here?
destructor Destroy; override;
end;
procedure myThread.Execute;
begin
try
//do some stuff...
except
on E: Exception do
begin
//handle exception
end;
end;
try
//do some stuff
finally
Synchronize(Sinchro);
end;
end;
constructor myThread.Create(some parameters);
begin
inherited Create(True);
//handle parameters
//handle reference to my procedure?
end;
procedure myThread.Sinchro;
begin
//call to my procedure
end;
这是其他帖子推荐的,但是我仍然遇到相同的错误
到目前为止,这是我的代码
raise KeyError(key) from None
KeyError: 'TCL_LIBRARY'
编辑:更改代码
更改代码后,它当前可以正常运行,但仅创建一个具有ul-launchable exe的文件夹
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll')
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll')
编辑2: 所以我做了更多修改,发现TCL错误来自包括ctypes(不确定原因)。所以我删除了它,并将我的python版本更改为3.6,它的构建非常完美。但是我更希望包含ctypes,因为我使用它来禁用应用程序缩放。
还有另一种方法来处理屏幕缩放或解决TCL错误吗?
答案 0 :(得分:0)
cx_freeze不适用于python 3.7,因此切换到3.6使其可以工作,然后添加
import os.path
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')
设置目录以使用ctypes