我正在尝试使用 pyinstaller 在 Windows 上安装 python 应用程序,其中我正在使用 tkcalendar。应用程序正在运行,但 tkcalendar.Calendar 没有。
当我在没有安装的情况下运行应用程序时,一切正常,但如果我这样做,日历小部件不会出现。我认为 pyinstaller 看到了这个模块,但他对 tkcalendar 正在使用的模块有问题。我尝试使用 --path=/.../python/Lib/site-packages 运行 pyinstaller 但这没有用。将模块文件复制到应用程序目录也无济于事。
我有一个 tkcalendar,它是日历、DateEntry 的预定义小部件,我正在尝试获取用户为 DateEntry 选择的日期。 虽然可以使用“selection_get()”提取日历小部件的选定日期,但我找不到 DateEntry 的任何内容。
我试过 get_date(),get(),_date(), cget(), ._selection() 等等,但它们似乎没有返回/打印用户选择的日期。请帮忙,如果需要任何补充信息,请告诉我
代码[选自一个简单的 tkcalendar 教程]:
import tkinter as tk
from tkinter import ttk
from tkcalendar import Calendar, DateEntry
def calendar_view():
def print_sel():
print(cal.selection_get())
top = tk.Toplevel(root)
cal = Calendar(top,
font="Arial 14", selectmode='day',
cursor="hand1", year=2018, month=2, day=5)
cal.pack(fill="both", expand=True)
ttk.Button(top, text="ok", command=print_sel).pack()
def dateentry_view():
top = tk.Toplevel(root)
ttk.Label(top, text='Choose date').pack(padx=10, pady=10)
cal = DateEntry(top, width=12, background='darkblue',
foreground='white', borderwidth=2)
cal.pack(padx=10, pady=10)
print(cal.cget(DateEntry))
root = tk.Tk()
s = ttk.Style(root) …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为日期条目创建下拉日历。下面是我的代码的一部分:
它的下拉部分不起作用,我似乎无法在DateEntry()
任何地方找到ttk 日历的语法来包含日历小部件选项!
#creating the frame
from tkinter import *
from tkcalendar import *
root = Tk()
f1=Frame(root,width=1500,height=100,relief=SUNKEN,bd=4,bg='light steel blue')
f1.pack(side=TOP)
f2=Frame(root,width=1500,height=550,relief=SUNKEN,bd=4,bg='white')
f2.pack()
f3=Frame(root,width=1600,height=100,relief=SUNKEN,bd=4,bg='white')
f3.pack(side=BOTTOM)
#Creating the date column
l4=Label(f2,text='DATE',font=('tahoma',20,'bold'),fg='black',anchor='w')
l4.grid(row=0,column=3)
cal=DateEntry(f2,dateformat=3,width=12, background='darkblue',
foreground='white', borderwidth=4,Calendar =2018)
cal.grid(row=1,column=3,sticky='nsew')
Run Code Online (Sandbox Code Playgroud)
我正在尝试使 tkcalendar 与我的窗口融为一体。
import tkinter
from tkcalendar import Calendar
window = tkinter.Tk()
window.configure(background = "black")
cal = Calendar(window, background = "black" , disabledbackground = "black" , borderbackground = "black" , headersbackground = "black" , normalbackground = "black" )
cal.config(background = "black")
cal.pack()
window.mainloop()
Run Code Online (Sandbox Code Playgroud)
我已阅读 tkcalendar 文档并尝试通过调用小部件类的配置方法来更改所有样式元素:
cal.configure(background = "black")
Run Code Online (Sandbox Code Playgroud)
; 但是,我的日历仍然保持灰色,而不是融入黑色窗口背景。是否可以更改日历的实际背景颜色?
使用tkcalendardateentry
python模块,每次我在小部件上选择日期时,它都会将其缩短为格式。如果可能的话,我希望它能扩大到,或者至少是今年。m/d/yy
mm/dd/yyyy
使用set_date方法时,它将显示输入的任何内容(字符串),但一旦单击另一个日期,就会恢复为缩短的格式。
有什么办法让它始终显示完整日期吗?我似乎找不到允许我使用的格式参数,%Y
所以这就是我问的原因。
我正在尝试使用 pyinstaller 从这个脚本中获取 .exe 文件
我在测试目录中时使用了这个命令pyinstaller -w -F test.py
文件 test.py 包含
from tkinter import *
from tkcalendar import DateEntry
root = Tk()
date = DateEntry(root, year=2001, month=11, day=11, width=17,)
date.pack()
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
我得到的 .exe 文件不起作用?
当我执行此pyinstaller -F test.py 时,我收到控制台上没有名为 babel.numbers 的模块的错误
我正在寻找一种在 tkinter 窗口内显示日历或其他日期选择器的方法。我知道 tkcalendar 并且它效果很好。但是,我正在寻找一种无需 tkcalendar 即可实现此目的的方法,因为 tkcalendar 是根据 GPLv3 获得许可的。我搜索了互联网,发现所有论坛都一致表示,包含“import tkcalendar”字样的代码,即使未编译,也被视为派生作品,因此也必须根据 GPLv3 获得许可。这些威胁都没有得到法律专家的答复,但我不想冒险进口任何根据 GLP 许可的东西。
有人可以建议 tkcalendar 的替代方案,或者建议如何在不从源代码复制的情况下重新创建它吗?
编辑:我被要求添加一个解释,说明我的 GPL 问题是什么。我的问题是,据我了解,导入 tkcalendar 的代码被视为 tkcalendar 的“派生作品”,因此也需要根据 GPL 获得许可。不过,我不想在 GPL 下许可我的程序,因此据我了解,我无法导入任何 GPL 许可的模块。