Created
          April 13, 2021 05:53 
        
      - 
      
 - 
        
Save rodrigo-x/73fd991e81d58cb1de3bc8c7a9c7391f to your computer and use it in GitHub Desktop.  
    tkinter + canvas
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| import tkinter as tk | |
| root = tk.Tk() | |
| # A window será desenhada com o Canvas e serão setados a largura e altura | |
| canvas = tk.Canvas(width = 400, height = 400, bg = '#9ed2c5') | |
| canvas.pack(expand = tk.YES, fill = tk.BOTH) # Expandir o Canvas e tornar responsivo | |
| # Criando várias linhas no lado esquerdo dentro do range | |
| for line in range(1, 400, 2): | |
| canvas.create_line(0, line, 50, line) | |
| canvas.create_arc(380, 250, 60, 20, width = 4, fill = '#1561ad') | |
| canvas.create_line(0, 600, 200, 150, width = 20, fill = '#8e8e90') | |
| canvas.create_oval(10, 10, 200, 200, width = 4, fill = '#6ed3cf') | |
| canvas.create_oval(200, 200, 140, 140, width = 4, fill = '#6ed3cf') | |
| canvas.create_rectangle(200, 200, 300, 300, width = 5, fill = '#7A9D96') | |
| canvas.create_rectangle(250, 250, 350, 350, width = 5, fill = '#7A9D96') | |
| canvas.create_rectangle(300, 300, 400, 400, width = 5, fill = '#7A9D96') | |
| canvas.create_line(50, 330, 240, 330, width = 50, fill = '#cd5554') | |
| # Label com fundo | |
| label = tk.Label(canvas, text = 'Rodrigo Nery', fg = '#ffffff', bg = '#acb7ae') | |
| label.pack() | |
| canvas.create_window(340, 20, window = label) | |
| # Label normal | |
| canvas.create_text(220, 380, text = 'Rodrigo Nery', font = ("Segoi 14 bold")) | |
| root.title('Canvas - Formas geométricas') | |
| root.resizable(False, False) | |
| root.eval('tk::PlaceWindow . center') | |
| root.mainloop() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment