Como criar uma aplicação Desktop usando Python

 O Python possui diversas bibliotecas para construção de GUI, sendo o Tkinter o mais conhecido (inclusive o adotado pelo próprio Python).

A lib já vem com o Python, não é preciso baixar nada além do próprio Python.


Para importar a biblioteca: import tkinter as tk

 
Exemplo:
import tkinter as tk

class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.create_widgets()

    def create_widgets(self):
        self.hi_there = tk.Button(self)
        self.hi_there["text"] = "Hello World\n(click me)"
        self.hi_there["command"] = self.say_hi
        self.hi_there.pack(side="top")

        self.quit = tk.Button(self, text="QUIT", fg="red",
                              command=self.master.destroy)
        self.quit.pack(side="bottom")

    def say_hi(self):
        print("hi there, everyone!")

root = tk.Tk()
app = Application(master=root)
app.mainloop()


Referências:

Comentários

Postagens mais visitadas deste blog

Como criar um jogo usando Python

Biblioteca Python: Random