Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d25c93e

Browse files
committed
adicionando novos exemplos
1 parent 16acbe8 commit d25c93e

File tree

9 files changed

+144
-0
lines changed
  • part3-guiProgramming/07-graphicalUserInterfaces

9 files changed

+144
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sys
2+
from tkinter import *
3+
4+
5+
class HelloClass:
6+
def __init__(self):
7+
widget = Button(None, text='hello event world\nola mundo event', command=self.quit)
8+
widget.pack()
9+
10+
def quit(self):
11+
print('hello class method world ')
12+
sys.exit()
13+
14+
HelloClass()
15+
mainloop()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sys
2+
from tkinter import *
3+
4+
class HelloCallable:
5+
def __init__(self):
6+
self.msg = '=-hello __call __ world-='
7+
8+
def __call__(self): # __call__ run depois quando chamado, funcionando logo depois
9+
print(self.msg)
10+
sys.exit()
11+
12+
13+
widget = Button(None, text='hello event world', command=HelloCallable())
14+
widget.pack()
15+
widget.mainloop()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
from tkinter import *
3+
4+
5+
def hello(event): # sempre tem que ter event na funcao para o bind funcionar
6+
print('press twice to exit/ aperte duas vezes para sair')
7+
8+
def quit(event): # sempre tem de ter event/variavel na funcao para o bind funcionar
9+
print('hello, I must be going/ola, eu devo ir embora ')
10+
sys.exit()
11+
12+
widget = Button(None, text='hello event world')
13+
widget.pack()
14+
15+
# bind left mouse click
16+
widget.bind('<Button-1>', hello) # bind('codigo da tecla/bind', 'funcao')
17+
widget.bind('<Double-1>', quit)
18+
19+
widget.mainloop()
20+
21+
22+
23+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from tkinter import *
2+
3+
4+
def greeting():
5+
print('hello stdout world/ola mundo stdout')
6+
7+
win = Frame()
8+
win.pack()
9+
10+
Label(win, text='hello container world/ola mundo container').pack(side=TOP)
11+
Button(win, text='hello/ola', command=greeting).pack(side=LEFT)
12+
Button(win, text='quit/sair', command=win.quit).pack(side=RIGHT)
13+
14+
win.mainloop()
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from tkinter import *
2+
3+
4+
def greeting():
5+
print('hello stdout world/ola mundo stdout')
6+
7+
win = Frame()
8+
win.pack()
9+
10+
Button(win, text='hello/ola', command=greeting).pack(side=LEFT)
11+
Button(win, text='quit/sair', command=win.quit).pack(side=RIGHT)
12+
Label(win, text='hello container world/ola mundo container').pack(side=TOP)
13+
14+
win.mainloop()
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from tkinter import *
2+
3+
4+
def greeting():
5+
print('hello stdout world/ola mundo stdout')
6+
7+
win = Frame()
8+
win.pack()
9+
10+
Button(win, text='hello/ola', command=greeting).pack(side=LEFT)
11+
Label(win, text='hello container world/ola mundo container').pack(side=TOP)
12+
Button(win, text='quit/sair', command=win.quit).pack(side=RIGHT)
13+
14+
win.mainloop()
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from tkinter import *
2+
3+
4+
def greeting():
5+
print('hello stdout world/ola mundo stdout')
6+
7+
win = Frame()
8+
win.pack()
9+
10+
Button(win, text='hello/ola', command=greeting).pack(side=LEFT, fill=Y)
11+
Label(win, text='hello container world/ola mundo container').pack(side=TOP)
12+
Button(win, text='quit/sair', command=win.quit).pack(side=RIGHT, expand=YES, fill=Y)
13+
14+
win.mainloop()
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from tkinter import *
2+
3+
4+
def greeting():
5+
print('hello stdout world/ola mundo stdout')
6+
7+
win = Frame()
8+
win.pack(side=TOP, expand=YES, fill=BOTH)
9+
10+
Button(win, text='hello/ola', command=greeting).pack(side=LEFT, fill=Y)
11+
Label(win, text='hello container world/ola mundo container').pack(side=TOP)
12+
Button(win, text='quit/sair', command=win.quit).pack(side=RIGHT, expand=YES, fill=Y)
13+
14+
win.mainloop()
15+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from tkinter import *
2+
3+
4+
def greeting():
5+
print('hello stdout world/ola mundo stdout')
6+
7+
win = Frame()
8+
win.pack(side=TOP, expand=YES, fill=BOTH)
9+
10+
11+
Button(win, text='hello/ola', command=greeting).pack(side=LEFT, anchor=N)
12+
Label(win, text='hello container world/ola mundo container').pack(side=TOP)
13+
Button(win, text='quit/sair', command=win.quit).pack(side=RIGHT)
14+
15+
win.mainloop()
16+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /