Answers for "how to change font of label in tkinter"

7

tkinter change font family and size of label

from tkinter import *
import tkinter.font as font

gui = Tk(className='Python Examples - Button')
gui.geometry("500x200")

# define font
myFont = font.Font(family='Helvetica', size=20, weight='bold')

# create button
button = Button(gui, text='My Button', bg='#0052cc', fg='#ffffff')
# apply font to the button label
button['font'] = myFont
# add button to gui window
button.pack()

gui.mainloop()
Posted by: Guest on April-14-2020
3

how to change the font of a label in tkinter

#How to change the font of a label in Tkinter

#Import 
from tkinter import *

#Screen
window = Tk()
window.title("New Window")
window.geometry("300x250")

Label(window, text = "This is my new project in python!", font = ("Bahnschrift", 14)).pack()
#-------------------------------------------------------------------------------------------
#'font' tells python that we are going to do something with the font
#-------------------------------------------------------------------------------------------
#'()' are needed becuase that is just how python works
#-------------------------------------------------------------------------------------------
#'"___"' put your font name in the quotes
#-------------------------------------------------------------------------------------------
#10 put vyour fontsize after adding a comma after the font name
#-------------------------------------------------------------------------------------------
Posted by: Guest on November-12-2020
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
1

font in tkinter

import tkinter.font as TkFont

font = tkFont.Font ( option, ... )
# Exaple
helv36 = tkFont.Font(family="Helvetica",size=36,weight="bold")
Posted by: Guest on November-02-2020

Code answers related to "how to change font of label in tkinter"

Python Answers by Framework

Browse Popular Code Answers by Language