本文整理汇总了Python中tkinter.font.Font.config方法的典型用法代码示例。如果您正苦于以下问题:Python Font.config方法的具体用法?Python Font.config怎么用?Python Font.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.font.Font
的用法示例。
在下文中一共展示了Font.config方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize
# 需要导入模块: from tkinter.font import Font [as 别名]
# 或者: from tkinter.font.Font import config [as 别名]
def initialize(self):
#Create the menubar
self.menubar=Menu(self)
menu=Menu(self.menubar,tearoff=0)
self.menubar.add_cascade(label="File",menu=menu)
menu.add_command(label="Open",command=self.openfile)
#menu.add_command(label="Exit")
menu=Menu(self.menubar,tearoff=0)
self.menubar.add_cascade(label="Tools",menu=menu)
menu.add_command(label="Class",command=self.classwindow)
menu.add_command(label="Hilbert",command=self.hilbertwindow)
menu.add_command(label="Entropy",command=self.entropywindow)
menu.add_command(label="Gradient",command=self.gradientwindow)
self.master.config(menu=self.menubar)
#Configure grid layout
self.columnconfigure(0,pad=5)
self.columnconfigure(1,pad=5)
self.columnconfigure(2,pad=5)
self.rowconfigure(0,pad=5)
self.rowconfigure(0,pad=5)
#Add canvas to plot points from converted hex values
self.plotcanvas=Canvas(self,width=256,height=256)
self.plotcanvas.configure(background='black')
self.plotcanvas.grid(row=0,column=0)
#Add listbox to hold the current group of hexvalues
listframe=Frame(self)
hexscroll=Scrollbar(listframe,orient=VERTICAL)
hexbox_font = Font(size=8)
hexbox_font.config(family={"posix": "Monospace","nt": "Courier New"})
self.hexbox=Listbox(listframe,width=75,height=20,font=hexbox_font,yscrollcommand=hexscroll.set,selectmode=EXTENDED)
hexscroll.config(command=self.hexbox.yview)
hexscroll.pack(side=RIGHT,fill=Y)
self.hexbox.pack(side=LEFT)
listframe.grid(row=0,column=1)
#Add slider for location in hex lines and size of window of hex values
commandframe=Frame(self)
playframe=Frame(commandframe)
windowframe=Frame(commandframe)
self.playslider=Scale(playframe,command=self.playslider_moved)
self.playslider.configure(from_=0,to=100)
self.playslider.configure(orient=HORIZONTAL)
self.playslider.pack(side=BOTTOM)
hexaddress=gethexaddress(int(self.playslider.get()))
self.currhexaddress=Label(playframe,width=20,text=hexaddress)
self.currhexaddress.pack(side=TOP)
self.curroffset=Label(windowframe,text=self.hexaddressoffset)
self.curroffset.pack(side=TOP)
self.windowslider=Scale(windowframe,command=self.windowslider_moved)
self.windowslider.configure(from_=100,to=600,orient=HORIZONTAL)
self.windowslider.pack(side=TOP)
self.windowslider.set(self.hexaddressoffset)
playframe.pack(side=LEFT)
windowframe.pack(side=RIGHT)
commandframe.grid(row=1,columnspan=2)
self.pack()
示例2: SyntexHighlight
# 需要导入模块: from tkinter.font import Font [as 别名]
# 或者: from tkinter.font.Font import config [as 别名]
def SyntexHighlight(self, event=None):
from tkinter.font import Font
for tag in self.tag_names():
self.tag_delete(tag)
self.mark_set("range_start", "1.0")
data = self._get_value()
self.tag_configure("Token.Comment", foreground="#F00")
bolder = Font(family=self.app.cnf['font'][0])
bolder.config(size=self.app.cnf['font'][1]-2)
bolder.config(weight="bold")
for token, content in lex(data, PythonLexer()):
self.mark_set("range_end", "range_start + %dc" % len(content))
self.tag_add(str(token), "range_start", "range_end")
self.mark_set("range_start", "range_end")
self.tag_config("Token.Comment.Single", foreground="#F00")
self.tag_config("Token.Literal.String.Doc", foreground="#F00")
for tag in self.tag_names():
if 'Token.Keyword' == tag:
self.tag_config(tag, foreground="#008", font=bolder)
elif 'Token.Keyword.Namespace' == tag:
self.tag_config(tag, foreground="#00F", font=bolder)
elif 'Token.Name.Class' in tag:
self.tag_config(tag, foreground="#F30", background='#AFA')
elif 'Token.Name.Function' in tag:
self.tag_config(tag, foreground="#A3A", background='#FFA')
elif 'Token.Literal' in tag:
self.tag_config(tag, foreground="#6A0")
elif 'Token.Operator' in tag:
self.tag_config(tag, foreground="#A3A")
print(self.tag_names())
示例3: __init__
# 需要导入模块: from tkinter.font import Font [as 别名]
# 或者: from tkinter.font.Font import config [as 别名]
def __init__(self, master=None, **cnf):
ScrolledText.__init__(self, master, **cnf)
bold = Font(font=self['font']).copy()
bold.config(weight='bold')
italic = Font(font=self['font']).copy()
italic.config(slant='italic')
# Define tags for formatting styles
self.tag_config('X', underline=1)
self.tag_config('!', font=bold)
self.tag_config('_', font=italic)
# Set state to idle
self.fp = None
self.lineno = 0