2
I would like to know how to create the maximize, minimize, and close buttons in Python (Tkinter). After the title bar is removed, new buttons must be created to customize the window and leave it different from the default. Below is the incomplete code I’m creating in windows 7: (everything inside the def function has to have identation) Obs: the program starts in from Tkinter import * and ends in the window.mainloop().
from tkinter import *
janela = Tk()
janela.title(" >>> Como criar os botão Maximizar? <<< ")
janela['bg'] = 'gray'
janela.wm_attributes('-fullscreen','true')
janela.geometry('340x400+500+200')
m = 0
def minimizar():
janela.overrideredirect(False)
janela.iconify()
janela.wm_attributes('-fullscreen', 'True')
def fechar():
janela.destroy()
def maximizar1():
global m
m = 0
janela.overrideredirect(True)
janela.geometry('1360x800+0+0')
def maximizar():
global m
m = 1
janela.wm_attributes('-fullscreen', 'False')
janela.overrideredirect(True)
janela.geometry('340x300+500+200')
def maxi():
print('1m=> ', m)
if m == 0:
maximizar()
elif m == 1:
maximizar1()
def move():
pass
bt1 = Button(janela, text='Minimizar', font=("Helvetica", 14), bg='grey', command=minimizar)
bt1.grid(row=0, column=1)
bt2 = Button(janela, text='Maximizar', font=("Helvetica", 14), bg='grey', command=maxi)
bt2.grid(row=0, column=2)
bt3 = Button(janela, text='Sair', font=("Helvetica", 14), bg='grey', command=fechar)
bt3.grid(row=0, column=3)
janela.mainloop()
To learn how to format your questions read Help with Markdown editing.
– Augusto Vasques