Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Gerando exceções de import
- try:
- import tkinter as tk
- except ImportError as error:
- print(error)
- root = tk.Tk()
- '''
- Conceito de componetização de botões
- Botão de Quit
- '''
- button = tk.Button(root, text = 'Quit', command = root.destroy)
- '''
- O place serve pra colocar o botão onde eu quiser, assim como o grid
- e o pack
- '''
- button.place(x = '30', y = '30')
- '''
- O configure eu coloco estilos no botão
- '''
- button.configure(justify = 'center', relief = 'ridge', bd = '0',
- background = 'white')
- '''
- Função de imprimir no terminal com botões widgets
- Padrão snake_case PEP8: https://www.python.org/dev/peps/pep-0008/
- '''
- def imprimir_no_terminal():
- print('Olá mundo!')
- button_impress = tk.Button(root, text = 'Clique Aqui!',
- command = lambda: imprimir_no_terminal())
- button_impress.place(x = '100', y = '30')
- root.title('Tkinter - Button')
- root.geometry('300x300')
- root.resizable(False, False)
- root.eval('tk::PlaceWindow . center')
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement