Skip to content

Instantly share code, notes, and snippets.

@rodrigo-x
Created March 15, 2021 20:37
Show Gist options
  • Save rodrigo-x/5a22d9ae527110c733015a87fb72336e to your computer and use it in GitHub Desktop.
Save rodrigo-x/5a22d9ae527110c733015a87fb72336e to your computer and use it in GitHub Desktop.
tkinter + html
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import tkinter as tk
from tk_html_widgets import HTMLLabel
root = tk.Tk()
# A Label HTML View
minha_label = HTMLLabel(root, html="""
<!-- Estilizei a Div inteira -->
<div style="background-color:#C5CBE3;">
<a href="https://www.facebook.com/rodrigon3ry"
style="text-decoration:none;color:#000000;">
<h1>Hello World</h1>
</a>
""")
# Continue usando o place.. Não tem problema :)
minha_label.place(x=115, y=125)
minha_label.fit_height()
# Sempre coloque o back no frame da Label que não faz parte do HTML
minha_label.config(background="#C5CBE3")
# Aquela Factory de sempre..
root.title("Exercício - Utilização da HTML + CSS Label")
root.geometry("400x350")
root.config(background="#C5CBE3")
root.resizable(False, False)
root.iconbitmap(r'home\rodrigo\html.ico')
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