Created
April 8, 2021 17:30
-
-
Save rodrigo-x/67b25ad7c0d32617b5f63b14c47fc318 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() | |
# Esse é o widget Canvas :) | |
canvas = tk.Canvas(root) | |
# E esse já é o primeiro método que trabalha com textos no Canvas | |
canvas.create_text(136, 50, text='Hello World!', anchor='nw', | |
font='TkMenuFont 15', fill='blue') | |
# Asssim como os outros widgets, é possível utilizar pack, place ou grid | |
canvas.pack() | |
# Nossa factory pattern de sempre | |
root.title('Canvas - Hello World!') | |
root.config(background = '#C5CBE3') | |
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