107k views
1 vote
Run the demo program fontdemo.py to explore the font families available on your system. Then write a code segment that centers the labels COURIER, HELVETICA, and TIMES horizontally in a GUI window. The text of each label should be the name of a font family. Substitute a different font family if necessary.

User Mclayton
by
4.8k points

2 Answers

3 votes

Answer:

from tkinter import * from tkinter import font window = Tk() window.title("Font-Family") window.geometry("450x450") # Prints all the font families available with the system print(font.families()) # Label 1 for Courier font family font_label1 = Label(window, text="COURIER", fg="black", font="Courier") font_label1.config(anchor=CENTER) font_label1.pack() # Label 2 for Helvetica font family font_label2 = Label(window, text="HELVETICA", fg="black", font="Helvetica") font_label2.config(anchor=CENTER) font_label2.pack() # Label 3 for Times font family font_label3 = Label(window, text="TIMES", fg="black", font="Times") font_label3.config(anchor=CENTER) font_label3.pack() window.mainloop()

Step-by-step explanation:

User Joachim Seminck
by
5.6k points
4 votes

Answer:

See explaination for program code

Step-by-step explanation:

from tkinter import * from tkinter import font window = Tk() window.title("Font-Family") window.geometry("450x450") # Prints all the font families available with the system print(font.families()) # Label 1 for Courier font family font_label1 = Label(window, text="COURIER", fg="black", font="Courier") font_label1.config(anchor=CENTER) font_label1.pack() # Label 2 for Helvetica font family font_label2 = Label(window, text="HELVETICA", fg="black", font="Helvetica") font_label2.config(anchor=CENTER) font_label2.pack() # Label 3 for Times font family font_label3 = Label(window, text="TIMES", fg="black", font="Times") font_label3.config(anchor=CENTER) font_label3.pack() window.mainloop()

See attachment for sample output and screenshot

Run the demo program fontdemo.py to explore the font families available on your system-example-1
Run the demo program fontdemo.py to explore the font families available on your system-example-2
User JBLaf
by
5.8k points