当前位置: 首页 > 工具软件 > Fonty Python > 使用案例 >

python fonttool_Python font.Font方法代码示例

夏知
2023-12-01

本文整理汇总了Python中tkinter.font.Font方法的典型用法代码示例。如果您正苦于以下问题:Python font.Font方法的具体用法?Python font.Font怎么用?Python font.Font使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块tkinter.font的用法示例。

在下文中一共展示了font.Font方法的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _init_fonts

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def _init_fonts(self, root):

# See:

self._sysfont = Font(font=Button()["font"])

root.option_add("*Font", self._sysfont)

# TWhat's our font size (default=same as sysfont)

self._size = IntVar(root)

self._size.set(self._sysfont.cget('size'))

self._boldfont = Font(family='helvetica', weight='bold',

size=self._size.get())

self._font = Font(family='helvetica',

size=self._size.get())

if self._size.get() < 0: big = self._size.get()-2

else: big = self._size.get()+2

self._bigfont = Font(family='helvetica', weight='bold',

size=big)

开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:19,

示例2: create_tags

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def create_tags(self):

super().create_tags() # for url tag

# Don't modify predefined fonts!

baseFont = tkfont.nametofont("TkDefaultFont")

size = baseFont.cget("size") # -ve is pixels +ve is points

bodyFont = tkfont.Font(family=baseFont.cget("family"), size=size)

titleFont = tkfont.Font(family=baseFont.cget("family"),

size=((size - 8) if size < 0 else (size + 3)),

weight=tkfont.BOLD)

self.text.config(font=bodyFont)

self.text.tag_config("title", font=titleFont,

foreground="navyblue", spacing1=3, spacing3=5)

self.text.tag_config("versions", foreground="darkgreen")

self.text.tag_config("above5", spacing1=5)

self.text.tag_config("above3", spacing1=3)

开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:18,

示例3: create_widgets

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def create_widgets(self, **kwargs):

"""

Widgets shown:

- The frame's title,

- The checkbutton to enable/disable displaying,

- The textbox.

"""

self.top_frame = tk.Frame(self)

tk.Label(self.top_frame,

text=kwargs.get('title', '')).grid(row=0, column=0)

tk.Checkbutton(self.top_frame,

variable=self.enabled_checkbox,

text="Display?").grid(row=0, column=1)

self.serial_monitor = tk.Text(self,

relief="sunken",

height=int(self.total_width / 10),

width=int(self.total_width),

font=tkFont.Font(size=kwargs.get("fontsize",

13)))

self.top_frame.grid(row=0)

self.serial_monitor.grid(row=1)

开发者ID:LaboratoireMecaniqueLille,项目名称:crappy,代码行数:27,

示例4: test_fontchooser_selection

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def test_fontchooser_selection(self):

chooser = FontChooser(self.window)

self.window.update()

chooser._font_family_list.listbox.selection_set(1)

chooser._font_family_list._on_click()

self.window.update()

results = chooser.font

self.assertIsInstance(results, tuple)

self.assertEqual(len(results), 2)

self.assertIsInstance(results[0], tuple)

self.assertEqual(len(results[0]), 2)

self.assertIsInstance(results[1], font.Font)

chooser._on_family('')

self.window.update()

results = chooser.font

self.assertIsNone(results[0])

开发者ID:TkinterEP,项目名称:ttkwidgets,代码行数:18,

示例5: test_fontselectframe_family

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def test_fontselectframe_family(self):

frame = FontSelectFrame(self.window)

frame.pack()

self.window.update()

frame._family_dropdown.set(font.families()[1])

self.window.update()

frame._on_family(frame._family_dropdown.get())

results = frame.font

self.assertIsInstance(results, tuple)

self.assertEqual(len(results), 2)

self.assertIsInstance(results[0], tuple)

self.assertEqual(len(results[0]), 2)

self.assertIsInstance(results[1], font.Font)

frame._on_size(20)

frame._on_family('Arial')

frame._on_properties((True, True, True, True))

self.window.update()

results = frame.font

self.assertEqual(results[0], ('Arial', 20, 'bold', 'italic',

'underline', 'overstrike'))

开发者ID:TkinterEP,项目名称:ttkwidgets,代码行数:23,

示例6: font

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def font(self):

"""

Selected font.

:return: font tuple (family_name, size, \*options), :class:`~font.Font` object

"""

if self._family is None:

return None, None

else:

font_tuple = self.__generate_font_tuple()

font_obj = tkfont.Font(family=self._family, size=self._size,

weight=tkfont.BOLD if self._bold else tkfont.NORMAL,

slant=tkfont.ITALIC if self._italic else tkfont.ROMAN,

underline=1 if self._underline else 0,

overstrike=1 if self._overstrike else 0)

return font_tuple, font_obj

开发者ID:TkinterEP,项目名称:ttkwidgets,代码行数:18,

示例7: launch

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def launch(self):

self.root = tk.Tk()

self.root.wait_visibility(self.root)

self.title_font = Font(size=16, weight='bold')

self.bold_font = Font(weight='bold')

self.root.geometry("900x600")

style = ttk.Style(self.root)

style.configure("TLable", bg="black")

self.add_toolbar(self.root)

self.add_send_command_box(self.root)

self.add_list_commands(self.root)

self.root.protocol("WM_DELETE_WINDOW", lambda root=self.root: self.on_closing(root))

self.root.createcommand('exit', lambda root=self.root: self.on_closing(root))

self.root.mainloop()

开发者ID:IBM,项目名称:clai,代码行数:21,

示例8: drawGrid

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def drawGrid(self, clearGrid = False):

font = tkFont.Font(family=zynthian_gui_config.font_topbar[0], size=self.fontsize)

if clearGrid:

self.gridCanvas.delete(tkinter.ALL)

self.columnWidth = self.gridWidth / self.horizontalZoom

self.trackTitleCanvas.delete("trackname")

self.playCanvas.delete("timetext")

# Draw cells of grid

self.gridCanvas.itemconfig("gridcell", fill=CELL_BACKGROUND)

for row in range(self.verticalZoom):

if row >= len(self.tracks):

break

if clearGrid:

self.trackTitleCanvas.create_text((0, self.rowHeight * (row + 0.5)), text="Track %d" % (self.tracks[row]), font=font, fill=CELL_FOREGROUND, tags=("rowtitle%d" % (row),"trackname"), anchor="w")

self.gridCanvas.create_text(self.gridWidth - self.selectThickness, self.rowHeight * (self.rowHeight * int(row + 0.5)), state="hidden", tags=("lastpatterntext%d" % (row), "lastpatterntext"), font=font, anchor="e")

self.drawRow(row)

self.playCanvas.create_text(0 * self.columnWidth, PLAYHEAD_HEIGHT / 2, text="%d"%(self.colOffset), tags=("timetext"), anchor="w", fill=CELL_FOREGROUND)

if clearGrid:

for clock in range(self.horizontalZoom):

self.gridCanvas.tag_lower("clock%d"%clock)

# Function to update selectedCell

#clock: Clock (column) of selected cell (Optional - default to reselect current column)

#track: Track number of selected cell (Optional - default to reselect current =row)

开发者ID:zynthian,项目名称:zynthian-ui,代码行数:27,

示例9: __init__

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def __init__(self, master=None, **kw):

now = datetime.datetime.now()

fwday = kw.pop('firstweekday', calendar.MONDAY)

year = kw.pop('year', now.year)

month = kw.pop('month', now.month)

sel_bg = kw.pop('selectbackground', '#ecffc4')

sel_fg = kw.pop('selectforeground', '#05640e')

super().__init__(master, **kw)

self.selected = None

self.date = datetime.date(year, month, 1)

self.cal = calendar.TextCalendar(fwday)

self.font = tkfont.Font(self)

self.header = self.create_header()

self.table = self.create_table()

self.canvas = self.create_canvas(sel_bg, sel_fg)

self.build_calendar()

开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Cookbook,代码行数:20,

示例10: __init__

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def __init__(self, canvas, drs, **attribs):

self._drs = drs

self._canvas = canvas

canvas.font = Font(font=canvas.itemcget(canvas.create_text(0, 0, text=''), 'font'))

canvas._BUFFER = 3

self.bbox = (0, 0, 0, 0)

开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:8,

示例11: __init__

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def __init__(self, drs, size_canvas=True, canvas=None):

"""

:param drs: ``DrtExpression``, The DRS to be drawn

:param size_canvas: bool, True if the canvas size should be the exact size of the DRS

:param canvas: ``Canvas`` The canvas on which to draw the DRS. If none is given, create a new canvas.

"""

master = None

if not canvas:

master = Tk()

master.title("DRT")

font = Font(family='helvetica', size=12)

if size_canvas:

canvas = Canvas(master, width=0, height=0)

canvas.font = font

self.canvas = canvas

(right, bottom) = self._visit(drs, self.OUTERSPACE, self.TOPSPACE)

width = max(right+self.OUTERSPACE, 100)

height = bottom+self.OUTERSPACE

canvas = Canvas(master, width=width, height=height)#, bg='white')

else:

canvas = Canvas(master, width=300, height=300)

canvas.pack()

canvas.font = font

self.canvas = canvas

self.drs = drs

self.master = master

开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:33,

示例12: get_avg_charwidth

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def get_avg_charwidth(widget=None, text=None):

if text is None:

text = string.printable

if widget is None:

font = tkfont.Font(font='TkTextFont')

else:

font = tkfont.Font(font=widget['font'])

return sum([font.measure(c) for c in text]) / len(text)

开发者ID:Dogeek,项目名称:rpg-text,代码行数:10,

示例13: __init__

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def __init__(self, root, text, suffix):

super().__init__(root)

self._text = tk.Text(self, width=90, yscrollcommand=self._text_scroll)

self._scroll = ttk.Scrollbar(self)

self._scroll.pack(side="left", fill="y")

self._scroll.config(command=self._scrollbar_scroll)

self._line_no = tk.Text(self, width=4, yscrollcommand=self._text_scroll)

self._line_no.pack(side="left", fill="y")

self._text.pack(side="right", fill="y")

self._text.insert(1.0, text)

for k, v in TEXT_COLORS.items():

self._text.tag_config(k, **v)

if suffix == ".sol":

pattern = r"((?:\s*\/\/[^\n]*)|(?:\/\*[\s\S]*?\*\/))"

else:

pattern = r"((#[^\n]*\n)|(\"\"\"[\s\S]*?\"\"\")|('''[\s\S]*?'''))"

for match in re.finditer(pattern, text):

self.tag_add("comment", match.start(), match.end())

self._line_no.insert(1.0, "\n".join(str(i) for i in range(1, text.count("\n") + 2)))

self._line_no.tag_configure("justify", justify="right")

self._line_no.tag_add("justify", 1.0, "end")

for text in (self._line_no, self._text):

text.config(**TEXT_STYLE)

text.config(tabs=tkFont.Font(font=text["font"]).measure(" "), wrap="none")

self._line_no.config(background="#272727")

self._text.bind("", root._search)

开发者ID:eth-brownie,项目名称:brownie,代码行数:33,

示例14: __init__

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def __init__(self, text, regexp=False, nocase=False):

self.text = text

self.pattern = tkinter.StringVar()

self.regexp = tkinter.IntVar(int(regexp))

self.nocase = tkinter.IntVar(int(nocase))

self.prev_pattern = ""

self.prev_regexp = regexp

self.prev_nocase = nocase

self.findings = []

self.current = -1

self.text.tag_config("search", background='yellow', foreground="black")

bold_font = Font(self.text)

bold_font.configure(weight="bold")

self.text.tag_config("search_current", font=bold_font)

开发者ID:YoannDupont,项目名称:SEM,代码行数:16,

示例15: addEntrySetting

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def addEntrySetting(self, var, labelText, descriptorText):

centerFrame = tk.Frame(self)

centerFrame.grid(row=self.counter, column="1", columnspan="2", sticky="w")

label = tk.Label(centerFrame, text=labelText)

label.grid(row=self.counter, column="1", sticky="w")

entry = tk.Entry(centerFrame, textvariable=var, width=25)

entry.grid(row=self.counter, column="2", sticky="w")

descriptor = tk.Label(self, text=descriptorText)

font = tkFont.Font(font=descriptor['font'])

font.config(slant='italic')

descriptor['font'] = font

descriptor.grid(row=self.counter+1, column="1", columnspan="2", sticky="w")

tk.Frame(self, height="10", width="10").grid(row=self.counter+2, column="1", columnspan="5")

self.counter += 3

开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:16,

示例16: __init__

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def __init__(self, parent, pilot, **kwargs):

tk.Frame.__init__(self, parent, **kwargs)

self.columnconfigure(1, weight=1)

#self.decimalPlaces = settings["decimalPlaces"]

#self.inThousands = settings["inThousands"]

self.weaponLabels = []

self.topFrame = tk.Frame(self, background="black")

self.topFrame.grid(row="0", column="0", columnspan="3", sticky="ew")

self.topFrame.columnconfigure(1, weight=1)

self.pilotLabel = tk.Label(self.topFrame, text=pilot['pilotName'], fg="white", background="black")

font = tkFont.Font(font=self.pilotLabel['font'])

font.config(weight='bold')

self.pilotLabel['font'] = font

self.pilotLabel.grid(row="0", column="0", sticky="w")

tk.Frame(self.topFrame, background="black").grid(row="0", column="1", sticky="news")

shipTypeString = "(" + pilot['shipType'] + ")"

self.shipLabel = tk.Label(self.topFrame, text=shipTypeString, fg="white", background="black")

font = tkFont.Font(font=self.shipLabel['font'])

font.config(slant='italic')

self.shipLabel['font'] = font

self.shipLabel.grid(row="0", column="2", sticky="e")

tk.Frame(self, highlightthickness="1", highlightbackground="dim gray", background="black").grid(row="1000", column="0", columnspan="3", sticky="we")

开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:29,

示例17: addLineCustomizationSection

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def addLineCustomizationSection(self, frame, text, checkboxValue, lineCheckbox, peakCheckbox, totalCheckbox, settingsList, m3Checkbox):

if checkboxValue.get():

frame.grid()

innerLabel = tk.Label(frame, text="Color and threshold (when to change colors) for this line:")

innerLabel.grid(row="0", column="0")

font = tkFont.Font(font=innerLabel['font'])

font.config(slant='italic')

innerLabel['font'] = font

if len(settingsList) == 0:

settingsList.append({"transitionValue": 0, "color": "#FFFFFF"})

for setting in settingsList:

valueHolder = setting["transitionValue"]

setting["transitionValue"] = tk.StringVar()

setting["transitionValue"].set(valueHolder)

innerFrame = tk.Frame(frame)

innerFrame.grid(row="1", column="0", columnspan="5")

self.expandCustomizationSettings(innerFrame, settingsList)

lineCheckbox.configure(state="normal")

settingsList[0].update({ "labelOnly": lineCheckbox.var })

peakCheckbox.configure(state="normal")

settingsList[0].update({ "showPeak": peakCheckbox.var })

totalCheckbox.configure(state="normal")

settingsList[0].update({ "showTotal": totalCheckbox.var })

if m3Checkbox:

m3Checkbox.configure(state="normal")

settingsList[0].update({ "showM3": m3Checkbox.var })

else:

for child in frame.winfo_children():

child.destroy()

frame.grid_remove()

settingsList.clear()

lineCheckbox.var.set(0)

lineCheckbox.configure(state="disabled")

peakCheckbox.var.set(0)

peakCheckbox.configure(state="disabled")

totalCheckbox.var.set(0)

totalCheckbox.configure(state="disabled")

if m3Checkbox:

m3Checkbox.var.set(0)

m3Checkbox.configure(state="disabled")

开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:42,

示例18: expandCustomizationSettings

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def expandCustomizationSettings(self, frame, settingsList):

index = 0

for setting in settingsList:

removeButton = tk.Button(frame, text="X", command=lambda i=index:self.removeLine(i, settingsList, frame))

font = tkFont.Font(font=removeButton['font'])

font.config(weight='bold')

removeButton['font'] = font

removeButton.grid(row=index, column="0")

initialLabel = tk.Label(frame, text="Threshold when the line changes color:")

initialLabel.grid(row=index, column="1")

initialThreshold = tk.Entry(frame, textvariable=settingsList[index]["transitionValue"], width=10)

if (index == 0):

initialThreshold.configure(state="disabled")

removeButton.configure(state="disabled", borderwidth="0", text=" X ")

initialThreshold.grid(row=index, column="2")

initialLabel = tk.Label(frame, text="Color:")

initialLabel.grid(row=index, column="3")

colorButton = tk.Button(frame, text=" ",

command=lambda i=index:self.colorWindow(settingsList[i], colorButton),

bg=settingsList[index]["color"])

colorButton.grid(row=index, column="4")

index += 1

addLineButton = tk.Button(frame, text="Add Another Threshold",

command=lambda:self.addLine(settingsList, frame))

addLineButton.grid(row="100", column="1")

开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:28,

示例19: addOption

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def addOption(self, title, function):

button = tk.Radiobutton(self, text=title, command=lambda:function(title),

indicatoron=0, value=self.counter,

selectcolor="#00FFFF", bg="#FFFFFF",

compound="top")

font = tkFont.Font(font=button['font'])

font.config(weight='bold')

button['font'] = font

button.grid(row=self.counter, column="0", sticky="ew")

if self.counter == 0:

button.select()

try:

chosenImage = self.images[title]

except KeyError:

chosenImage = "gear.png"

try:

image = tk.PhotoImage(file=sys._MEIPASS + '\\images\\' + chosenImage)

button.configure(image=image)

button.image = image

except Exception:

try:

path = os.path.join('PyEveLiveDPS', 'images', chosenImage)

image = tk.PhotoImage(file=path)

button.configure(image=image)

button.image = image

except Exception as e:

pass

self.counter += 1

开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:33,

示例20: makeCheckbox

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def makeCheckbox(self, initValue, boxText, description=None):

checkboxValue = tk.BooleanVar()

checkboxValue.set(initValue)

checkbox = tk.Checkbutton(self, text=boxText, variable=checkboxValue)

checkbox.var = checkboxValue

checkbox.grid(row=self.row, column="1", columnspan="2")

self.row += 1

if description:

descriptor = tk.Label(self, text=description)

font = tkFont.Font(font=descriptor['font'])

font.config(slant='italic')

descriptor['font'] = font

descriptor.grid(row=self.row, column="1", columnspan="2")

self.row += 1

return checkbox

开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:17,

示例21: makeListBox

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def makeListBox(self):

tk.Label(self, text="Order priority for pilots and weapons in the breakdown").grid(row="3", column="1")

descriptor = tk.Label(self, text="drag and drop entries to order them")

font = tkFont.Font(font=descriptor['font'])

font.config(slant='italic')

descriptor['font'] = font

descriptor.grid(row="4", column="1")

self.displayOrder = DDList(self)

for orderItem in settings.detailsOrder:

self.displayOrder.insert(tk.END, self.text[orderItem])

self.displayOrder.grid(row="5", column="1")

开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:13,

示例22: __init__

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def __init__(self, parent, mainWindow, **kwargs):

tk.Frame.__init__(self, parent, **kwargs)

self.mainWindow = mainWindow

self.columnconfigure(0, weight=1)

self.columnconfigure(4, weight=1)

self.configure(pady=10)

tk.Frame(self, height="0", width="1").grid(row="0", column="0")

tk.Frame(self, height="0", width="1").grid(row="0", column="4")

self.counter = 0

checkboxValue = tk.BooleanVar()

checkboxValue.set(settings.getGraphDisabled())

self.graphDisabled = tk.Checkbutton(self, text="Disable graph entirely", variable=checkboxValue)

self.graphDisabled.var = checkboxValue

self.graphDisabled.grid(row=self.counter, column="1", columnspan="2")

descriptor = tk.Label(self, text="Labels will still be shown")

font = tkFont.Font(font=descriptor['font'])

font.config(slant='italic')

descriptor['font'] = font

descriptor.grid(row=self.counter+1, column="1", columnspan="2")

tk.Frame(self, height="20", width="10").grid(row=self.counter+2, column="1", columnspan="5")

self.counter += 3

self.secondsVar = tk.StringVar()

self.secondsVar.set(settings.getSeconds())

self.addSetting(self.secondsVar, "Number of seconds to average values:",

"Recommended to set this value higher than your weapon cycle time")

self.intervalVar = tk.StringVar()

self.intervalVar.set(settings.getInterval())

self.addSetting(self.intervalVar, "How often to update graph/labels in milliseconds:",

"The lower you set this value, the higher your CPU usage will be")

self.transparencyVar = tk.StringVar()

self.transparencyVar.set(settings.getCompactTransparency())

self.addSetting(self.transparencyVar, "Window transparency percentage in compact mode:",

"100 is fully visible, 0 is invisible")

开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:40,

示例23: create_font

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def create_font(self):

weight = tkfont.BOLD if int(self.bold.get()) else tkfont.NORMAL

slant = tkfont.ITALIC if int(self.italic.get()) else tkfont.ROMAN

return tkfont.Font(family=self.fontFamily.get(),

size=self.fontPointSize.get(), weight=weight, slant=slant)

开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:7,

示例24: autowidth

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def autowidth(self, maxwidth):

f = font.Font(font=self.cget("font"))

pixels = 0

for item in self.get(0, "end"):

pixels = max(pixels, f.measure(item))

# bump listbox size until all entries fit

pixels = pixels + 10

width = int(self.cget("width"))

for w in range(0, maxwidth + 1, 5):

if self.winfo_reqwidth() >= pixels:

break

self.config(width=width + w)

开发者ID:AtsushiSakai,项目名称:PyJSONViewer,代码行数:14,

示例25: __init__

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import Font [as 别名]

def __init__(self, *args, **kw):

global ttyFont, fontHeight, fontWidth

ttyFont = tkFont.Font(family = 'Courier', size = 10)

fontWidth = max(map(ttyFont.measure, string.ascii_letters+string.digits))

fontHeight = int(ttyFont.metrics()['linespace'])

self.width = kw.get('width', 80)

self.height = kw.get('height', 25)

self.callback = kw['callback']

del kw['callback']

kw['width'] = w = fontWidth * self.width

kw['height'] = h = fontHeight * self.height

Tkinter.Frame.__init__(self, *args, **kw)

self.canvas = Tkinter.Canvas(bg='#000000', width=w, height=h)

self.canvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)

self.canvas.bind('', self.keyPressed)

self.canvas.bind('<1>', lambda x: 'break')

self.canvas.bind('', self.upPressed)

self.canvas.bind('', self.downPressed)

self.canvas.bind('', self.leftPressed)

self.canvas.bind('', self.rightPressed)

self.canvas.focus()

self.ansiParser = ansi.AnsiParser(ansi.ColorText.WHITE, ansi.ColorText.BLACK)

self.ansiParser.writeString = self.writeString

self.ansiParser.parseCursor = self.parseCursor

self.ansiParser.parseErase = self.parseErase

#for (a, b) in colorMap.items():

# self.canvas.tag_config(a, foreground=b)

# self.canvas.tag_config('b'+a, background=b)

#self.canvas.tag_config('underline', underline=1)

self.x = 0

self.y = 0

self.cursor = self.canvas.create_rectangle(0,0,fontWidth-1,fontHeight-1,fill='green',outline='green')

开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:36,

注:本文中的tkinter.font.Font方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

 类似资料: