Você está na página 1de 17

Python e Tkinter

Aplicaes Grficas fcil e rpido.

Bruno Gomes
brunopereiragomes@gmail.com

Mais sobre min

Associao Python
Brasil

Serra do estrondo - Axix - TO ( 1 de maio de 2015)

Agenda
IFMA
1. Call Jobs - 05 de Maio
2. GDG Meetup - 09 de Maio
3. Google IO - 28 de Maio
APYBR
1. Python Brasil - 13 a 17 de Outubro
AIPI
1. Quarto Passeio de Patins Inline - 24 de Maio

PYTHON
1.
2.
3.
4.
5.
6.

Interpretador interativo
Indentao obrigatria
Compilador de bytecode
Polimorfismo
multi paradigma
Biblioteca padro

Tkinter
Baseada em Tcl/Tk, a Tkinter acompanha a distribuio oficial do
interpretador Python. ( O TK GUI toolkit no faz parte do Python).
Licena:
Python (permite escrever livremente softwares comerciais, GPL ou sob
qualquer outra licena).
TK GUI toolkit ( BSD-style - impe poucas restries quando comparada
aquelas impostas por outras licenas )
Plataformas:
Unix, Linux, Windows, MacOS/X

Tkinter
VANTAGENS

Portabilidade
Aprendizado
Documentao

DESVANTAGEM

Pobre
Aparncia
Performance

Tkinter - Exemplo de cdigo


from Tkinter import *
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.button = Button(frame, text="QUIT",
fg="red",
command=frame.quit)
self.button.pack(side=LEFT)
self.hi_there = Button(frame, text="
Hello",
command=self.say_hi)
self.hi_there.pack(side=LEFT)
def say_hi(self):
print "hi there, everyone!"
root = Tk()
app = App(root)

Tkinter - Vocabulrio

Widget
Evento
Event handlers
binding

Tkinter - continers e pack

Tkinter - Posicionando

Tkinter - Binding
Sintaxe:
widget.bind( evento, event handler)
Alguns eventos:
"<Button-1>", "<Return>", "<ButtonRelease-X>", "<Motion>", "<Leave>",
"<Escape>",

Tkinter - Command binding


Sintaxe:
1. Widget(master, ...., command = self.event_handler)
2. self.nome_do_widget['command']=self.event_handler
Obs.: No precisa de informar o evento.

Tkinter - Widgets
Windows

Linux

Osx

Perguntas e algo mais

Obrigado

Você também pode gostar