Skip to content

Instantly share code, notes, and snippets.

@maluta
Created October 31, 2014 02:32
Show Gist options
  • Save maluta/f448c5a1431dc24e01bb to your computer and use it in GitHub Desktop.
Save maluta/f448c5a1431dc24e01bb to your computer and use it in GitHub Desktop.
Janela simples com dois botões.
from tkinter import *
def principal():
# definição da janela
janela = Tk()
# definindo o título da janela
janela.title("Exemplo #1")
# componentes
botão1 = Button(janela, text = "Botão #1")
botão2 = Button(janela, text = "Botão #2" )
# organização na tela
botão1.pack()
botão2.pack()
# definindo "ações" para os botões
botão1.configure(command=click_botão1)
botão2.configure(command=click_botão2)
# ações
def click_botão1():
print("evento: click no botão 1")
def click_botão2():
print("evento: click no botão 2")
# rodando nosso programa
if __name__ == '__main__':
principal()
mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment