为什么将py文件转换为exe后我的日历什么也不显示

问题描述 投票:0回答:1

我想问一问,当我在Pycharm中运行文件时,它能够显示日历Show Calendar,但是当我从py文件转换为.exe格式时,它没有显示错误,但是我的日历却没有显示 As show in here。我有pip install tkcalendar,但我可能知道为什么转换为.exe格式后为什么我的日历没有出现。我使用python 3.8.2

Below are my code: 

def chooseStartDate():
    def print_sel():
        global startDate
        startDate = cal.selection_get()
        tk.Label(this, text=startDate).grid(row=4, column=2)
        top.destroy()
    top = tk.Toplevel(this)
    now = datetime.datetime.now()
    cal = Calendar(top, font="Arial 14", selectmode='day', year=now.year, month=now.month, day=now.day)
    cal.pack(fill="both", expand=True)
    tk.Button(top, text="ok", command=print_sel).pack()

this = tk.Tk()
tk.Label(this, text="Start Date: ").grid(row=4, column=0)
tk.Button(this, text="Choose Date", command=chooseStartDate).grid(row=4, column=1)
this.mainloop()

谢谢。

python python-3.x tkinter tk tkcalendar
1个回答
0
投票

生成exe文件时,请使用--hiddenimport=babel.numbers

这应该可以解决问题。

pyinstaller.exe --onefile -w --hiddenimport=babel.numbers your_script_name.py
© www.soinside.com 2019 - 2024. All rights reserved.