-
Notifications
You must be signed in to change notification settings - Fork 0
/
03.Colorised_labels.py
31 lines (22 loc) · 977 Bytes
/
03.Colorised_labels.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import tkinter as tk
from tkinter import font
root = tk.Tk()
logo = tk.PhotoImage(file='python.gif')
# Colorized Labels in various fonts
# Some Tk widgets, like the label, text, and canvas widget, allow you to specify the fonts used to display text.
# This can be achieved by setting the attribute "font". typically via a "font" configuration option.
# You have to consider that fonts are one of several areas that are not platform-independent.
# The attribute fg can be used to have the text in another colour and the attribute bg can be used to change the background colour of the label.
w1 = tk.Label(root, text="I'll be in red", fg="red", font="Times").pack()
tk.Label(root,
text="Green Text in Helvetica Font",
fg = "light green",
bg = "dark green",
font = "Helvetica 16 bold italic").pack()
# root.mainloop()
tk.Label(root,
text="Blue Text in Verdana bold",
fg = "blue",
bg = "yellow",
font = "Verdana 10 bold").pack()
root.mainloop()