Answers for "tkinter change font"

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
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
2

how to change font in tkinter

import tkinter.font as font

#create Font object
myFont = font.Font(family='Helvetica')

button = Button(parent, font=myFont)
#or
button = Button(parent)
button['font'] = myFont
Posted by: Guest on August-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language