我想更改字体系列,但是它不起作用。
from tkinter import *
import tkinter.font as font
class Window:
def __init__(self):
root = Tk()
def_font=font.Font(family='Times')
root.title("Serial Conection Program")
self.mainFrame= Frame(root)
self.portLabel=Label(self.mainFrame, text="Port: ",font= def_font)
....
....
我正在尝试类似常规
font= 'Times'
的操作,但这也无法正常工作...也许解释器有问题(我使用python 3.6.1-anaconda3)?
There is an image( I tried to change font in label "connection" to family "Times"
最佳答案
它到底有什么用?您可以在屏幕截图中看到以下内容(使用Python 3.6.2)对我的作用:
from tkinter import *
import tkinter.font as font
class Window:
def __init__(self):
root = Tk()
#print(font.families()) # print list of what's available
root.title("Serial Connection Program")
self.mainFrame = Frame(root)
self.mainFrame.pack()
def_font=font.Font(family='Times')
self.portLabel = Label(self.mainFrame, text="Port1: ", font=def_font)
self.portLabel.pack()
my_font=font.Font(family='Arial')
self.portLabel = Label(self.mainFrame, text="Port2: ", font=my_font)
self.portLabel.pack()
root.mainloop()
win = Window()