pythontkintertk-toolkittkcalendar

Why can't I make my app's screen responsive even by increasing ´self.geometry("1000x700")´?


Here's an image of the app: App image

I'm trying to make all the options visible, however even increasing the dimensions the screen doesn't enlarge and doesn't solve the problem

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)

At first, it wasn't possible to scroll down the page, so I added the scroll, but when the 'date' filter appears, the dates for you to select instead of writing, to make it easier for the user to be able to insert the date, but the calendar remains hidden because the screen is limited, could anyone help me solve this problem?

Hidden Calendar Error: Hidden Calendar Error

I tried to make changes by increasing self.geometry("1000x700"), but it didn't work.

I also tried the following configuration:

# 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)

Solution

  • You can create a custom widget based on DateEntry and override the function drop_down() to show the calendar above the entry box:

    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}")
    

    Then use MyDateEntry instead of DateEntry in your code.

    Result of my testing code:

    enter image description here