Answers for "tkinter font get custom"

4

python tkinter font

import tkinter
from tkinter.font import Font

root = tkinter.Tk()

font_1 = Font(family='Arial', 
              size=24, 
              weight='normal', 
              slant='italic', 
              underline=1, 
              overstrike=1)

font_2 = Font(family='Helvetica',
              size=12,
              weight='bold',
              slant='italic',
              underline=0,
              overstrike=0)

font_3 = Font(family='Courier', size=14, weight='normal', slant='roman', underline=0, overstrike=0)
font_4 = Font(family='Times', size=22, weight='bold', slant='roman', underline=0, overstrike=0)

my_label = tkinter.Label(master=root, text='Text', font=font_1)
my_label.pack()

tkinter.mainloop()
Posted by: Guest on February-09-2021
1

add font to the label in window tkinter

import tkinter

window = tkinter.Tk()       # creating the window object
window.title('my first GUI program')
window.minsize(width=600, height=500)

# label 
# adding text to the middle of the window
my_label = tkinter.Label(text='I am a Label', font=('Cursive', 24, 'bold'))
my_label.pack()

window.mainloop()           # keeping the window until we close it
Posted by: Guest on February-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language