Python - Module: Tkinter - window manipulation

0

Like every good new programmer, a lot of ideas come up in the beginning, and one of them was this: how do I manipulate the windows? How so?

  • Remove rounded corners when running under Windows 7.
  • change the background where the name, icon, and minimize, maximize, and close buttons are
asked by anonymous 19.03.2017 / 01:59

2 answers

1

To remove the borders / decoration of a window in TkInter use the method:

.overrideredirect(True)

Example usage:

from tkinter import Tk, Label, Button

class Exemplo:
    def __init__(self, aplicacao):

        # Remove as bordas/decoração
        aplicacao.overrideredirect(True)

        #Cor de fundo como no exemplo da outra resposta
        root["bg"] = "gray"

        self.label = Label(aplicacao, text="Primeira janela")
        self.label.pack()

        self.greet_button = Button(aplicacao, text="Chamar função", command=self.minhafuncao)
        self.greet_button.pack()

        self.close_button = Button(aplicacao, text="Fechar", command=aplicacao.quit)
        self.close_button.pack()

    def minhafuncao(self):
        print("Testando!")

root = Tk()
minhajanela = Exemplo(root)
root.mainloop()
  

Note: .overrideredirect(True) can also be applied to a specific window / widget.

Then after applying overrideredirect you can create your own maximize, minimize or "decoration" (borders) of your own.

    
01.12.2017 / 22:39
0

Change the title of the window:

janela.title("Janela Principal")

Change the background inside the window:

janela["bg"] = "green"

Now make the color change changes in the Application Titles Bar and rounding the corners I do not know to inform you.

    
19.11.2017 / 18:57