├── button.py ├── hello-there.py ├── hello.py ├── primitive-drawing.py └── textBox.py /button.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | root = None 4 | 5 | def buttonPressed(): 6 | global root 7 | root.destroy() 8 | 9 | def main(): 10 | global root 11 | root = Tk() 12 | w = Label(root, text="Hello!") 13 | w.pack() 14 | 15 | btn = Button(root, text="Exit", command=buttonPressed) 16 | btn.pack() 17 | root.mainloop() 18 | 19 | main() 20 | -------------------------------------------------------------------------------- /hello-there.py: -------------------------------------------------------------------------------- 1 | import pygame, sys 2 | from pygame.locals import* 3 | 4 | pygame.init() 5 | 6 | displaySurf = pygame.display.set_mode((400,300)) 7 | pygame.display.set_caption('Hello There!') 8 | 9 | while True: 10 | for event in pygame.event.get(): 11 | if event.type == QUIT: 12 | pygame.quit() 13 | sys.exit() 14 | 15 | pygame.display.update() 16 | -------------------------------------------------------------------------------- /hello.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | root = Tk() 4 | 5 | w = Label(root, text="hello!") 6 | w.pack() 7 | root.mainloop() 8 | 9 | -------------------------------------------------------------------------------- /primitive-drawing.py: -------------------------------------------------------------------------------- 1 | import pygame, sys 2 | from pygame.locals import* 3 | 4 | pygame.init() 5 | 6 | displaySurf = pygame.display.set_mode((500,400),0,32) 7 | pygame.display.set_caption('Drawing') 8 | 9 | black = (0,0,0) 10 | white = (255,255,255) 11 | red = (255,0,0) 12 | green = (0,255,0) 13 | blue = (0,0,255) 14 | 15 | displaySurf.fill(white) 16 | 17 | pygame.draw.polygon(displaySurf, green,((146,0),(291,106),(237,277),(56,277),(0,106))) 18 | pygame.draw.line(displaySurf, blue, (60,60),(120,60),4) 19 | pygame.draw.line(displaySurf, blue,(120,60),(60,120)) 20 | pygame.draw.line(displaySurf, blue, (60,120),(120,120),4) 21 | pygame.draw.circle(displaySurf, blue,(300,50),20,0) 22 | pygame.draw.ellipse(displaySurf, red, (300,250,40,80),1) 23 | pygame.draw.rect(displaySurf,red,(200,150,100,50)) 24 | 25 | pixObj = pygame.PixelArray(displaySurf) 26 | pixObj[480][380] = black 27 | pixObj[482][382] = black 28 | pixObj[484][384] = black 29 | pixObj[486][386] = black 30 | pixObj[488][388] = black 31 | 32 | while True: 33 | for event in pygame.event.get(): 34 | if event.type == QUIT: 35 | pygame.quit() 36 | sys.exit() 37 | pygame.display.update() 38 | -------------------------------------------------------------------------------- /textBox.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | root = None 4 | textBox = None 5 | 6 | def buttonPress(): 7 | global entryBox 8 | txt = textBox.get() 9 | print ("O conteúdo do form é:", txt) 10 | 11 | def createTextBox(parent): 12 | global textBox 13 | textBox = Entry(parent) 14 | textBox.pack() 15 | 16 | def main(): 17 | global root 18 | root = Tk() 19 | 20 | btn = Button(root, text="Show!", command=buttonPress) 21 | btn.pack() 22 | createTextBox(root) 23 | root.mainloop() 24 | 25 | main() 26 | --------------------------------------------------------------------------------