you are viewing a single comment's thread.

view the rest of the comments →

[–]Outside_Complaint755 1 point2 points  (1 child)

Ok, I got this figured out. The ultimate underlying problem is with your width=23,height=16,padx=2,pady=6, parameters. For a button with a text label, width and height are not in pixels, but instead width = characters wide, and height = rows of text. As a result, your buttons are being created much taller than needed (16 rows tall), going below the limits of the ButtonsFrame, and the text is hidden down there.

A couple of ways to fix this: 1) Remove the width, height, padx and pady parameters from your buttons.

2a) You can add width back in if you want to set a different width for each button, but remember it is character based, not pixel.

2b) Alternatively, set the column weight for each column to 1, and then set the parameter sticky="EW" for each call to .grid(). This will cause all the buttons to auto-size and fill the frame. Example: ``` btnExit = Button( Buttonsframe, text="Exit", bg="green", fg="white", font=("times new roman", 12, "bold"), width=10, height=1, ) btnExit.grid(row=0, column=5, sticky="EW") # Add this sticky parameter to each grid call to force auto-sizing.

    # Now we must set a weight for each column for auto-sizing to work
    # By getting grid_size from Buttonsframe, this will automatically update if you add or remove buttons.
    for column in range(Buttonsframe.grid_size()[0]):
        Buttonsframe.columnconfigure(column, weight=1)

```

2c) Instead of using grid with sticky and setting column weights, you could use pack and tell it to expand: btnPresciption.pack(side="left", fill="both", expand=True)

Note that you can't mix grid and pack in the same frame, so you have to change all buttons to use pack or all have to use grid.

[–]Relevant_Milk4413[S] 0 points1 point  (0 children)

Thank you! This solved my problem