无法导入tkFont

时间:2019-06-24 11:06:46

标签: python tkinter

我想导入tkfont,但是不起作用

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()

我遇到以下错误:

回溯(最近通话最近一次):

文件“ exercise.py”,第2行,位于

导入tkFont

ModuleNotFoundError:没有名为“ tkFont”的模块

1 个答案:

答案 0 :(得分:1)

您可能试图在Python 3下运行Python 2代码,从而对库进行了一些重组。

如果您用$ php artisan cache:clear && php artisan route:cache && php artisan config:cache && php artisan view:clear替换当前的导入内容,就足以使您前进。