Python - Module: Tkinter - window manipulation

Asked

Viewed 3,130 times

0

as every good new programmer, at the beginning comes up many ideas and, one of them was the following: how do I manipulate windows? how so?

  • remove the rounded corners when running on Windows 7.
  • change the color (background) where the name, icon and minimize, max and close buttons are.
  • Please, if that’s not possible, let me know.

2 answers

1

To remove edges/decoration from a window in the TkInter use the method:

.overrideredirect(True)

Example of use:

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: The .overrideredirect(True) can also be applied in a window/widget specifies.

Then after applying the overrideredirect you can create your own maximize, minimize or "decorate" (edges) own.

0

Change the title of the window:

janela.title("Janela Principal")

Change the background inside the window:

janela["bg"] = "green"

Now make the color changes in the Application Title Bar and corner rounding I can’t tell you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.