WutLolz / -WIP-Calculator-App

0 stars 0 forks source link

the "main" menu's text: "Menu" is taking up close to the whole page after opening history menu #2

Open WutLolz opened 1 month ago

WutLolz commented 1 month ago

the term "main menu" will be used to refer to the menu used to access the history and customize buttons. so after i use the history menu and go back to the main menu. the main menu's label "Menu" is taking up almost the whole page and the buttons is centred and at the bottom of the app

Viddesh1 commented 1 month ago

Hello @WutLolz ,

The "Menu" label text is taking whole page because, Menu label is not removed by using grid_remove() function that you usually do.

I have changed the code in the funcion naming menu() where label variable are used in other functions too. I think it is important for the variables to be distinct. I have changed the variable from label to menu_label and also made it accessible in the global scope. If the global keyword is not used in functions then by default python consider member variables and member function that are present in the function as local variables.

def menu():
    hide_btn()

    # Made the global variable menu_label.
    global menu_label
    menu_label = Label(root, text="Menu", font=("Arial", 14))
    menu_label.grid(row=0, column=0, pady=10)

    global hist_btn
    hist_btn = tk.Button(root, text="History", command=lambda: set_up_history(), width=10, font=("Arial", 11))
    hist_btn.grid(row=1, column=0, padx=10)
    global bg_btn
    bg_btn = tk.Button(root, text="Customize", command=lambda: custom_bg(), width=10, font=("Arial", 11))
    bg_btn.grid(row=2, column=0)

Also, Removed the menu_label grid

#History
def hide_btn():
    .
    .
    .

    try:
        hist_btn.grid_remove()
        bg_btn.grid_remove()
        menu_label.grid_remove() # Removed the menu_label
    except:
        pass

I hope this resolves your issue of menu label taking up almost whole page.

Also, I am not sure why the some space is occupied at the top of the text_result widget. Please find the image below. Arrow represing the space occupied.

space_occupied_at_top

May be I think so that it is because somewhere some widget grid is not removed either in menu or history. The UI components are breaking too after i come back after clicking to history calculation. I am not sure why that is also occuring either. I think may be efficient grid structure or element placing needs to be used for this task.

Regards! Viddesh

Viddesh1 commented 3 weeks ago

Hello,

Closing this issue as completed. The menu label is not taking whole page any more. Related to to extra space allocation at the top of the text_result widget mentioned in the screen capture by arrow. I think a seperate issue needs to be created referencing this issue.

Edit:- I can not close this issue as i did not created it.

Thanks! Viddesh