Escolar Documentos
Profissional Documentos
Cultura Documentos
"
$ % &'
( ) '*
& +)
!"#$
%
!
( )$ *
"
'&
( )$
$%&
'&
(
( * , ,+
(
(
%&
)
*
"
(
(
--- %& .*
'&
' $
+
!
"
$%&
*+
* 1
30 !
5
$&'"#$
*)
*"
1
$%&
!
30
&
'&
!
(
(
---
*+
&
7
!&"
4
0
7 ! 8
1 30
"
92
Josu Labaki
#
/
$%&
&
;< 2$
:
=& 2
labaki@feis.unesp.br
+ &,
!
.,
>
* "
@
!
$ ! &$ !
>B
E$
!
#;=
2/
>?
@F
>G
@>
!4 $ & &!&$
56
@E
! 7!
50
>
@G
@5 &
@H
E$ 8
*)
-' $
=>,
4!
$8
/9
?A
#;=
?G
?#
3
,
7
EH
>
E>
EA
A#
!
>>
>
>
!
, &, 1
E
!
30
AI
A?
: -;
-,
$
!>
!7 ! 8
9<
02
.,
$%&
"
&
"
'
=
/5
"
-
+
!
30
*
30
*"
$%&
)
"
&
"
$%&
'
* 37
)
"
1
30
2?
'4
! &$ $ $7$-!@'>
A,
$
<
30
"
* 0 !
#;=
!
)
!
1 !
'
#;=
"
+
)
K !
&
B"
'
L
M
+
!
1
=
!
&
* 0
$
"
* 0
L & NO
P)
M
!
& "
'
M
+
& NO
K
L
2
* 0
L
2
M
!
'
* 0
30
!
&
=
/5
K
>
+
&
-
+
!
"
5?
L
$
'
"
&
<
* 30
->
!
* &
4
-
#;= <
"
!
&
%!
#;= P )
0
,!
* 1
"
1
To bind: ligar. Tambm nos referiremos ao processo de binding por fazer binding, ligar, relacionar,
atribuir, etc.
&
:
&
% K
#;=
2
"
#;=
!
* 0 !
!
&
"
30
* 0 X
&
M
!
* 0 L
F & M
1
F
X!
* 0
1
&
"
* 7
)
" 0
8*
* &
K !
#;=
!
8
&
"!
8*
30
*
=
/5
"
"
,
=
/5
!
S
2?
#;=
$ ! &$!
, ! B',
!
!-.
0
#;=
1
)
=
/5
0
)
No necessrio implementar os exemplos deste Mdulo. Todos eles esto disponveis para download a
partir de http://labaki.tk.
&
*
+
!
'
& "
#;=
&
&
L M'
"& !
M
+
'
'
&
30
"
"1
* 7
&
& !*
30
P)
&
<
& "
"
*
*
2
30
!
"!
!
0
1
"
!
&
8
" 9<
#;=
* 30
5?
-$ C,
$D,
&1
1
-
* 0
<
"
1
'
' )
&
)+ 0
1 self.fr1
*
K 30
8
1
30
&
8
+ +,
.
37
* 0
'>!&$E
)
$%&
8 ! *
,
30 T
* ,
* 0
T
* ,
U
!
T
*U
37
30
37
"
* 0
self.botao['bg']='green'
;
"
<
)
1
&
&
30
&
0
!
&
&
;
&
K
! *
&
! 0
!
"
&
* 0
'
,+
0
)
V
30
* 0
30
<
37
K
!
* 0
&
F3
1 W
* 0
1
'
L
M
! L
&M
! L
* 0
M
! L"
M
!
+
W
'>!&$E
P)
* 7
'
*
)
*
+
!
* 0
* 0
&!
&
1
&
!P
& >@
<-6
& >C
&
"
* 0
>@
!
30
L M
10
"
&
37
* 7
"
6?
&
37 !
$,
-,
$ ! &$D,
&1
*
* 7
30
!
=
,
'
2 "*
+
! 6=
#B '
+
!
$'
! 5F
'
* 1+
!
1
, <0
-
!
-
"
0
0
&
M
"
* 7
*
*
0 V
0
,
*
L
$ $
1
* 0
!
L 9
M
11
* 0
* 1
L & 9
M
* 0
<
"
)
"
'
!
S
30
* 0
1
K !
!
* 7
37
#;=
from Tkinter import *
class Packing:
def __init__(self,instancia_Tk):
self.container1=Frame(instancia_Tk)
self.container2=Frame(instancia_Tk)
self.container3=Frame(instancia_Tk)
self.container1.pack()
self.container2.pack()
self.container3.pack()
Button(self.container1,text='B1').pack()
Button(self.container2,text='B2').pack(side=LEFT)
Button(self.container2,text='B3').pack(side=LEFT)
self.b4=Button(self.container3,text='B4')
self.b5=Button(self.container3,text='B5')
self.b6=Button(self.container3,text='B6')
self.b6.pack(side=RIGHT)
self.b4.pack(side=RIGHT)
self.b5.pack(side=RIGHT)
raiz=Tk()
Packing(raiz)
raiz.mainloop()
12
'>!&$E
!
!
0
$!
,'
R
&
$+
!
!
* 7
30
,'
* 0
30
X5 F + Y
* 0
L EM
* 7
'
*?! *A! *C+
,'
X6=
#B +
P)
'
*C! *?! *A+
9
"
* 7
#;=
W
23
<
* 0
$+
0
*
"
L @M
,'
37
4$
5
$
7
'
$ 67$
5
%
'8
13
, &, 1
O
"
&
37
"
&
37
4
*
1 ,
2?
&
6
$ &$4$'
< 6
$
* 0
"<Button-1>"!
< 6 "<Return>"
/
&
* 0
K
10
* 0
&
self.botaoverde.bind("<Button-1>", self.muda_cor)
Y
8
* 1
"
* 0
30
)
"
&
9
' 5 !,
!9
!
37
14
'>!&$E
15
* 0
&
* 0
K
,
*)
*)
37
37
*)
*)
&
muda_cor(self, event)
: $
0
: $
);
#;= 2
1;!
* 0
" !
* 0
*
*
&
2
self.botaoverde.bind(("<Button-1>","<Button-3>"), self.muda_cor)
* 0
* 0
30
-
K
*
F3
1
* 0 Z
"<ButtonRelease-X>"
'
Z
>!@
+
*
E!
* 0
"<Motion>"
!
"<Leave>"
16
5?
F$-$
$ &
->
!&$
"
/
'
J
!
!
&
"
/5
&
&
"
+2
<
M
!
" 1
!
2B=
F[
1*
-
,
;
)6 $ +
P)
,
/!
,1
"<Return>"
< 6
"<Delete>"
/5
"<BackSpace>"
"<Escape>"
2
2
"<Left>"
"<Right>"
"<Up>"
2
2
* 1
-
"<Down>"
&
"<FocusIn>"
"<FocusOut>"
17
;
5F !
P
"<KeyPress-ALFA>"
"
"<KeyRelease-ALFA>"
"<KeyPress-ALFA>"
"<Button-1>"
"ALFA"
"<1>"
B"
<$
37
0
"
"<Double-Button-1>"
* 0
"<Triple-KeyPress-P>"
$
&
* 0
"<Any-KeyPress>"
"<Any-Button>"!
P)
*
37
30
* 7 !
* 0
0 2;<\ <
* 0
#6
P !6=
/#
-
6=
2 /!
F5
O
"
"
0
3
1
! )
&
!
*
8
!
$
<0
K
1
30
* 7
18
19
'>!&$E
$ +
< 6
<0
0 > Y
&
!
1
< 6
>)!
0 >P
&
&
" &
* 0
0 >
*
]( $ " ^
]( $
$ ^
* 0
20
30
* 0+
#;=' 1
30
30
6?
* 0
* .
K
&
&
!0
"
: $
* 0
* 0
) 1
)
" &
&
* 0
,
);
=
0
!
&
* 0
"<ButtonRelease>"
!
'
+
!
K!
"
L
&
&
&"
!
M
* 0
"
!
30
30
30
1
"
self.nome_do_widget['command']=self.event_handler
;
8
K
*)
30
'
+ 0
&
1
30
&
21
22
'>!&$E
* 0
&
&
* 0
2
)
"
"
* 0
* 0
0
"
* 0
2?
!4 $ &
!&$
D,
&1
&
"
&
30
-N
* &
%
! 1
"
0
%!
)
"
* 0
& 8
37
30
)
"
* 7
'
&+
& !
30
K
, $
"
1
1
!show = '*'
1* "
"
&
&
&
30
30
,
30
"
&
<
3
23
'
"
* 0
24
height=3,text='AGUARDANDO...')
self.msg.pack()
def conferir(self):
NOME=self.nome.get()
SENHA=self.senha.get()
if NOME == SENHA:
self.msg['text']='ACESSO PERMITIDO'
self.msg['fg']='darkgreen'
else:
self.msg['text']='ACESSO NEGADO'
self.msg['fg']='red'
self.nome.focus_force()
instancia=Tk()
Passwords(instancia)
instancia.mainloop()
'>!&$E
? 4$
25
! 7!
K
-
"
37 !
& !
37 !
$
&
*)
&
& !
! 8
*)
!
.
30
* 7
$
-
30
1
0 A+ $
"
@$
K! K
5!
<
&!
*
8
37
1
&
20 GG
37
&
*
-
0
!
O
"
.
* "
from Tkinter import *
class Kanvas:
def __init__(self,raiz):
self.canvas1 = Canvas(raiz, width=100, height=200,
cursor='X_cursor', bd=5,
bg='dodgerblue')
self.canvas1.pack(side=LEFT)
self.canvas2 = Canvas(raiz, width=100, height=200,
cursor='dot', bd=5,
bg='purple')
self.canvas2.pack(side=LEFT)
26
instancia=Tk()
Kanvas(instancia)
instancia.mainloop()
'>!&$E
3
)
K
S
30
0
1
!
2?
"
$$ &
30
&
!&!
!
=
"
* &
0
&
27
*
1
&!
G:H
/ 8 VP )
* .
J
G:H(-I
!
0 '
>I!
HI+
"'
>I!
. HI+X '
>I!>I+
;
W
&
28
5?
, )!
&
&
'
1>!%>+
!
'
1@!%@+
!'
1E!%E+
'
1!%+
!
* &
)
" 0
)!
$>X '
1>!%>+ $@X '
1@!%@+
!*
8
"
<
;
"
,!
* 7
& 0
"
"
&
<
"
.
4
0 ,
30
&
&
&
&
30
$>_
I` $>_
>` $@_
I` $@_
>`
/
30
!&"
"
>I
&
$> $@/ 2
37
&
&
37
.
30 !
30
!
"
&
'
,
29
30
self.last=[x,y]
def right(self): # Desenha um segmento para a direita
x, y = self.last[0]+10, self.last[1]
self.canvas.create_line(self.last, x, y, fill='purple')
self.last=[x,y]
instancia=Tk()
Linhas(instancia)
instancia.mainloop()
'>!&$E #;=
0
=
&
'
,
0
"
6?
$>
;
1$ $ H
K 1'>
$
&
:$
&
&
37
0
&.
&
,
"
&
9
&
"
"
!
6 :
3
&
&
&
30
&
3
8
37
+
!,
31
self.nome_do_canvas.create_text(x, y)
1 !
1
30
5!
30
:
"
'
1!
%+ =
!
'
1!
%+
1
'
>II!>II+
'
>II!>II+
)
"
&
* 7
30 ,
&
&
'
K
<
" !
+ 6=
#B '
&
"
30
0 5F '
&
&
"1
2
30
*
30
< 6
&
& X2J
! *
30
* 1
*
30
"
"
&
0+
!
0
"
3
&
"
< 6
P)
)
)
32
"
'
>II!>I+
"
&
@II /
"
'
>II!@II.>I+X '
>II!>HI+
!
0
&
@II
*
'
>II! $
<
6
*
6
$
>I+
!
*8
1
3
33
C',
font=('Arial','26','bold'),
anchor=CENTER, fill='white')
instancia=Tk()
SPFC(instancia)
instancia.mainloop()
'>!&$E
O
"
"
0
&
"! &
0.
92
0
&
30 0
34
<
:
L
2$F M
< 6'0
" !)
"
0+
!
/?
30
>
,
! -$
&
:
)
* &
K!
" !
"
)
; .
:
&
"
&
&
:
30
37
35
30
1 1
.& " !
&
&
!
30
8
5
XCI
!
.& " !
1
!&"
6 ! B 6/
&
&
XHI
)
"
"
&
P)
&
30
$= 25=
'
0+
&
*
&
:
6 $
!
<0
&
1
*
37
&
"
0
"
8
&
<
'
ECIbV+
$
3
"
-
9
W
36
&
&
self.altura-25,
175, self.altura-175,
fill='deepskyblue', outline='darkblue')
fonte=('Comic Sans MS', '14', 'bold')
Label(self.frame, text='Fatia: ',
font=fonte, fg='blue').pack(side=LEFT)
self.porcentagem=Entry(self.frame, fg='red',
font=fonte, width=5)
self.porcentagem.focus_force()
self.porcentagem.pack(side=LEFT)
Label(self.frame, text='%',
font=fonte, fg='blue').pack(side=LEFT)
self.botao=Button(self.frame, text='Desenhar',
command=self.cortar, font=fonte,
fg='darkblue', bg='deepskyblue')
self.botao.pack(side=LEFT)
def cortar(self):
arco=self.canvas.create_arc
fatia=float(self.porcentagem.get())*359.9/100.
arco(25, self.altura-25,
175, self.altura-175,
37
fill='yellow', outline='red',
extent=fatia)
self.porcentagem.focus_force()
instancia=Tk()
Fatias(instancia)
instancia.mainloop()
'>!&$E
<
ACc
P)
4*
#;=
Y
K
!
&
&
*
ACc
"
&
38
9?
-,
!4
*)
*)
!
*)
&
*)
=
/
*)
!A
!
K
*)
:
$
&
30
2
*)
Z>!
!L
>M
!L
@M
!
*)
=
/ A)! A0!
=
/
<
=
/
M
+
!Z/
K
&
+ /
Z@!
=
/
*)
!
=
/
' L
* ,
30
8
&
".
L
*
>M
!*
=
/
39
0
*
&
=
/!
&!
&
30 V;
0
+
30
"
=
/'
) $
&
30
9
<
30 '
&
9
0
"
30
!
.
P)
30
Xd
d
40
155, self.altura-85,
182, self.altura-15, fill='dodgerblue')
ret(45, self.altura-35,
90, self.altura-60, fill='darkblue', outline='')
ret(110, self.altura-35,
155, self.altura-60, fill='darkblue', outline='')
self.texto(100, self.altura-50, text=':',
font=self.fonte, fill='yellow')
# Fim do desenho do relgio----------------------self.mostrar=Button(self.frame, text='Que horas so?',
command=self.mostra,
font=('Comic Sans MS', '11', 'bold'),
fg='darkblue', bg='deepskyblue')
self.mostrar.pack(side=LEFT)
def mostra(self):
self.canvas.delete('digitos_HORA')
self.canvas.delete('digitos_MIN')
HORA = str( localtime()[3] )
MINUTO = str( localtime()[4] )
self.texto(67.5, self.altura-50, text=HORA, fill='yellow',
font=self.fonte, tag='digitos_HORA')
self.texto(132.5, self.altura-50, text=MINUTO, fill='yellow',
font=self.fonte, tag='digitos_MIN')
instancia=Tk()
Horas(instancia)
instancia.mainloop()
41
'>!&$E
&
"
!
!
'
"
"
&
!"B 4$
$
6
6
6=
D3
'
&
4$
!"
3$
4$
*)
0
30
0
=
30
* 7
&
:
#;=
+
'
4$
6*
3
'
S &
*)
$ X>!
"
!
&
&
*
*)
<
.
!
-
!
"
_`
42
8
!
*)
=
/
VVV$
e/!
30 '
Z! e+
*)
30 '
Z[
Z! e[
=
/
e+
9
9
9<0
*3
* 1 9;
*)
*)
!*
1
$*)
"
30
L
1
M *)
*
=
//!
*
"
"
*)
*)
43
'>!&$E
30
&
<
!
0 '
&
#;=
"
3!
"
&
*8
L
*
&
&
30 9
*
*
*)
'
+
&
44
"
-' $
P)
2?
*8
,
7
M $&$ &!L
!
>
!
37
30 $
*
*
K
B"
5 %,
K
%,
&
&
N "1
)
G
Y
N "1
N 8
N 8
"
%
* 0
& &
"
$
&
0
,
'
-
G(
&+
!
*
"
"
)
8
G $!
)
*
&
*8
&
"
/!
1
)
G
"1
1
!
)
45
)
&
&
)
)
"1
0
<
'>!&$E
46
6
&
)
* 0
* 0
"1
9$
&
EII
8
$>
$ , &$!
&
,
*
"
&
5?
! EII
6
,!
"
! %
M
V+
&
-! * - !
,!
,%*
-&
-& ! *
'
!
+
!
+
+
!
'K
*
*
+
!
"
6#
&1
&
20
'K
'
*
'
,
37
0
B"
&!
)
"
M2
'
#38c602+
!
*
! *
"1
8
'
@AA! @AA! @AA+
!
'
I! I! I+
47
0
*
37
30
*"
#;= <
"
&
!
"
&
"
* 0
48
def misturar(self):
cor="#%02x%02x%02x" %(int(self.vermelho.get()),
int(self.verde.get()),
int(self.azul.get()))
self.canvas.delete('bola')
self.canvas.create_oval(15, 15, 185, 185,
fill=cor, tag='bola')
self.rgb['text'] = cor
self.vermelho.focus_force()
inst = Tk()
Palheta(inst)
inst.mainloop()
'>!&$E
'
* 0!
4$
5 > 0MM $
GI
J
4$
3
+
K0L
$ $3
6
49
6?
$4$& -$@ , ! $ ,
"#$&$4$'
)
30
5/
30
)
! ,
+
!
5/
30
L
*
'
)
30
/!
&
30
0
30
30
"
!
2 ) @)
30
"
30
&
2)
x_absoluto = C1.winfo_pointerx()
0 ! 5+
x_origem = C1.winfo_rootx()
N 5+
0
$
V2
*3
0!
30
*"
"
1
&
&
&
30
<
!
&
"
50
self.canvas.pack()
def desenhar(self,event):
x_origem = self.canvas.winfo_rootx()
y_origem = self.canvas.winfo_rooty()
x_abs = self.canvas.winfo_pointerx()
y_abs = self.canvas.winfo_pointery()
try:
P = (x_abs - x_origem, y_abs - y_origem)
self.canvas.create_line(self.ultimo_P, P)
self.ultimo_P = P
except:
self.ultimo_P=(x_abs - x_origem, y_abs - y_origem)
inst = Tk()
AutoCADE(inst)
inst.mainloop()
'>!&$E
51
!
1
*)
&
'
1!%+
1
K!
30
"
*
5!
"
8
>I!
I!
'
1!%+
&
&
*)
=
/
"
*"
2 &
>I
'
K
@I '
I!I!I+ /
&W
&1
"
)
"
52
cor="#%02x%02x%02x" %(self.tom[0],
self.tom[1],
self.tom[2])
self.canvas.delete('bola')
self.canvas.create_oval(45, 120, 155, 10, fill=cor,
outline='', tag='bola')
inst = Tk()
Palheta2(inst)
inst.mainloop()
'>!&$E
<
"
@C
P)
8
!
0!
@AA
"
*)
*
* 0
L
L
".
M
*)
M
&
0
"
30
! &
*)
)
Q
'
. .
53
/?
-,
!&$ & 1 $4
#;=
(
,
!
"
& K
&
, 0
"
&
30
,' &+
-
,06
"
- $
G)
&
$
1
'
+
!
30
-E
-@
&
- $
G)
,G)/
->
"
"
"
"
,)6
,G0/
"
& "
30
& @!
,16
G0
,G0/
-@ $
-
,)
*
- $
&
$
!
K
!
54
2
30
X@!
&
"
&
37
"
30
* 1
30
"
& K
!
"
30
0
-
3
S
30
55
/
+
"
/
<
#;=
"
*
!
*
30
/!
#;=
!
30
,<
&
0
"1
&
56
'>!&$E
8 O$
4$
C
8D '
57
: -;
-,
$
37
&
"
30
* ,f
.
"
&
37
(
( *, ,
F"
/ 8
1
*
"
"
#;=
"
,
P)
&
$ &
#"
"
*"
8
FK
#;=
!
!
*
! 1 *30
F3
*
&
1*
& "
37
8
F
0
"
&
8
"
!*
)
&
8
$
K &
30
#;=
9
"
*
8
30
58
&
"
* 0
&
&
)L
"
"
&
)
"
"
K
30
"
"
&
1*
"
30
30
30
&
*)
"
* 7
&
&
!
1
&
&
"
! 8
& !
*)
&
&
*
&
" <0
*)
#;=
&
K 30
!
"
"
4
)
&
!
<0
"
30
"
30
"
)
*
"
)
"
5
&
&
*
"
* .
)
1
59
3
37
* .
9<0
"
30
&
3
&
37
"
'
*
0
)
<0
)
" &"
=>,
4!
!>
!7 ! ?
?
?
P)
!
*
K9
!
"
"
&
'
&
* "
!
"
,5
L
& "
M
?& !"
+ 5"
"
<-
&
30
8
! *
! &"
*1
'
&
1
30
+
! &"
-
30
! &"
37
30
K
30
$
&
&.
&
DH "
S 0
)
"
37
"
$%& .
30
S
8
*
>>E "
!
)
60
30
&
"
*
1
9
;
! $
$&/ !
6 & J
,!
0
30
30
1
!
30
&
<
"
P$
S
30
2$
&
&
K
!
"
S
30
*)
* &
&
#
!
8
B ,!
)
!
,
*
"
!
&
J. Labaki
labaki@feis.unesp.br
http://labaki.tk
&$-'4
$ $&
&, ,
@';
&$ >
,
7 4
61