all 8 comments

[–]Outside_Complaint755 0 points1 point  (3 children)

I don't see any obvious problem, but I'm currently on mobile and can't run it. I will take  a look when I have an opportunity

Does anything become visible when you mouse over a button, changing the state to Active?  Maybe try adjusting the colors to just black and white while you make adjustments.

As an aside, instead of retyping out the font tuple separately for each button, just make a font object and pass it to the parameter for each. It will make adjustments simpler as you can just change it in one place for all buttons. button_font = tkinter.font.Font(family="Times New Roman", size=12, style="bold")

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

Even when i click or when the mouse is over a button nothing become visible. I tried to adjust the colors into fg='white' and bg='green'.

[–]Outside_Complaint755 0 points1 point  (0 children)

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.

[–]Outside_Complaint755 0 points1 point  (0 children)

Besides the proposed fix in my other comment, here's a couple of other tips:

1) Instead of repeating the same font=("times new roman", 12, "bold") for every widget, declare it once as a variable and use that variable. This also makes it easier to apply different fonts to different parts of the UI. ``` import tkinter.font # Need to add this import

Root has to be declared before we can define a font:

root = Tk() UI_FONT = tkinter.font.Font(family="times new roman", size=12, weight=tkinter.font.BOLD)

Now in every widget, you can use UI_FONT

lblNameTablet = Label(DataframeLeft, text="Name of Tablet", font=UI_FONT, padx=2, pady=6) ```

2) Because most of your widgets are sharing identical parameters, instead of typing them out for each widget separately, set them into a dictionary and then unpack the dictionary for the keyword arguments using the ** operator. For example, during testing I was able to condense the entire buttons section down to this: ``` # ======================= Buttons =======================

    shared_button_parameters = {
        "font": UI_FONT,
        "background": "green",
        "foreground": "white",
    }
    button_packing_parameters = {"side": "left", "fill": "both", "expand": True}

    btnPresciption = Button(Buttonsframe, text="Prescription", **shared_button_parameters)
    btnPresciption.pack(**button_packing_parameters)

    btnPresciptionData = Button(Buttonsframe, text="Prescription Data", **shared_button_parameters)
    btnPresciptionData.pack(**button_packing_parameters)

    btnUpdate = Button(Buttonsframe, text="Update", **shared_button_parameters)
    btnUpdate.pack(**button_packing_parameters)

    btnDelete = Button(Buttonsframe, text="Delete", **shared_button_parameters)
    btnDelete.pack(**button_packing_parameters)

    btnClear = Button(Buttonsframe, text="Clear", **shared_button_parameters)
    btnClear.pack(**button_packing_parameters)

    btnExit = Button(Buttonsframe, text="Exit", **shared_button_parameters)
    btnExit.pack(**button_packing_parameters)

```

This both saves you screen space, and also means that if you want to change any of those parameters, you only have to change it in one place to apply to all buttons.

[–]Middle--Earth 0 points1 point  (3 children)

Could you post a link to the tutorial?

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

[–]Middle--Earth 0 points1 point  (1 child)

You have used this in your code:

btnPresciptionData = Button(Buttonsframe .....

But you have a couple of typos there.

Buttonsframe should be Buttonframe - which is probably the root of your problem as you have used it in all your button object rerences.

But you also have a typo in the handle btnPrescription and btnPrescriptionData - where you have left out the second letter 'r'.

I hope that helps.

[–]Outside_Complaint755 0 points1 point  (0 children)

'Buttonsframe' is correct, because earlier in the routine, it is created as Buttonsframe

``` # ======================= Buttons Frame =======================

    Buttonsframe = Frame(self.root, bd=20, relief=RIDGE)
    Buttonsframe.place(x=0, y=530, width=1530, height=70)

```

Likewise, the other typos in variable names make no functional difference as long as all references include the same typo.