Reputation: 139
I want to import tkFont
but it's not working
from tkinter import *
import tkFont
class BuckysButtons:
def __init__(self,master):
frame = Frame(master)
frame.pack()
helv36 = tkFont.Font(family="Helvetica",size=36,weight="bold")
self.printButton = Button(frame,font=helv36, text ="Print
Message",command = self.printMessage,compound ='top')
self.printButton.pack(side =LEFT)
self.quitButton = Button(frame, text ="quit", command = frame.quit)
self.quitButton.pack(side=LEFT)
def printMessage(self):
print("It worked!")
root = Tk()
b = BuckysButtons(root)
root.mainloop()
i'm getting following error:
Traceback (most recent call last):
File "exercise.py", line 2, in <module>
import tkFont
ModuleNotFoundError: No module named 'tkFont'
Upvotes: 10
Views: 23998
Reputation: 37003
It's possible you are trying to run Python 2 code under Python 3, which did some library reorganisation.
If you replace your current import with import tkinter.font as TkFont
that should suffice to move you forward.
Upvotes: 27