我试图让所有选项可见,但是即使增加尺寸,屏幕也不会放大,也不能解决问题
class App(tk.Tk):
def __init__(self, gerenciador):
super().__init__()
self.gerenciador = gerenciador
self.title("Gerenciador de Apostas")
self.geometry("1000x700") # Ajustei o tamanho da janela para ter mais espaço
# Canvas e Scrollbar
self.canvas = tk.Canvas(self)
self.canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
self.scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.canvas.yview)
self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
self.canvas.configure(yscrollcommand=self.scrollbar.set)
self.canvas.bind('<Configure>', self.on_canvas_configure)
self.frame_principal = ttk.Frame(self.canvas)
self.canvas.create_window((0, 0), window=self.frame_principal, anchor=tk.NW)
一开始,页面无法向下滚动,所以我添加了滚动,但是当“日期”过滤器出现时,日期供您选择而不是书写,以便用户更容易能够插入日期,但由于屏幕有限,日历仍然隐藏,有人可以帮我解决这个问题吗?
我尝试通过增加
self.geometry("1000x700")
来进行更改,但没有成功。
我还尝试了以下配置:
# Configuração do layout responsivo
self.frame_principal.grid_rowconfigure(0, weight=1)
self.frame_principal.grid_rowconfigure(1, weight=3) self.frame_principal.grid_rowconfigure(2, weight=2) self.frame_principal.grid_columnconfigure(0, weight=1)
您可以基于
DateEntry
创建自定义小部件并覆盖函数drop_down()
以在输入框上方显示日历:
from tkcalendar import DateEntry
...
class MyDateEntry(DateEntry):
def drop_down(self):
super().drop_down() # call the original drop_down()
# calculate the new position of the calendar window
# note that self._top_cal is the window containing the calendar
x = self.winfo_rootx()
y = self.winfo_rooty() - self._top_cal.winfo_height()
# move the calendar window
self._top_cal.geometry(f"+{x}+{y}")
然后在代码中使用
MyDateEntry
而不是 DateEntry
。
我的测试代码的结果: