1

my code is:

from tkinter import *
import tkinter as tk


def minimize_window():
    root2.iconify()

def exit_fullscreen():
    root2.destroy()    

def new_root():
    global root2, time_label
    root2 = Tk()
    root2.title("MONEY")
    root2.geometry('1500x700')
    
    # Open the window in fullscreen mode
    root2.attributes('-fullscreen', True)
    root2.resizable(False, False)
    
    # Create an exit button (X)
    exit_button = Button(root2, text="X", font="ar 15 bold", command=exit_fullscreen, bg='red', fg='white')
    exit_button.place(x=1450, y=10)  # Position in the top right corner
    
    # Create a minimize button (-)
    minimize_button = Button(root2, text="-", font="ar 15 bold", command=minimize_window, bg='gray', fg='white')
    minimize_button.place(x=1400, y=10)  # Position next to the exit button
    

root2.mainloop()

is there any thing wroge because when i run it i got what i want 1- the full screen mode 2- the 2 buttons but the buttons not lie what i want, i want it stay in the same place for it without change

6
  • Aside: why are you using globals? It seems to me that root2.inconify and root2.destroy don't need wrappers at all. Commented Aug 20, 2024 at 20:07
  • Anyways, what precisely about this code is insufficient? Is it that you want the buttons to be in the top right corner? Please edit your question to include these details. Commented Aug 20, 2024 at 20:13
  • 1
    Study how relx and anchor options of place() work. Commented Aug 20, 2024 at 23:14
  • @Anerdw about your first comment i need the global because this is a small part of my full project so there is allot of codes and second i guess maybe you understand what i i want (every program you open it have 3 buttons in the top right side wech is (-) minimize (x) close and between them the square that control the maximize ) but i want to make the program when i run it have only(-) and (x) and it open directly full screen mode and you didn't give me my answer (-_-) Commented Aug 22, 2024 at 13:33
  • 1
    Yes, if you understand how those options of place() work, then you can achieve what you want. Commented Aug 22, 2024 at 13:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.