0

I need help on the use of Classes. I am trying to use the Font class in Python
to create my own instance. Erro is no Font! I though Font was a standard class in Python.

Any help for a newbie will be appreciated.
-----------------------------------------------------

from Tkinter import * 

class myStuff(Font):
    def __init__(self):
        item = myStuff.families()
        for each x in item
            print x
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by vegaseat
0

Font is not part of the bread and butter console version of Python. Any of the GUI toolkits and PyGame make fonts available.

Here is an example using the Tkinter GUI toolkit that normally comes with Python ...

import Tkinter as tk

# create mainwindow
root = tk.Tk()

mytext = " Hello, world! "
myfont = ('times', 48, 'bold')
# create a label showing mytext using myfont
# red characters on yellow background
label = tk.Label(root, text=mytext, font=myfont, fg='red', bg='yellow')
# position the label
label.pack()

# start the event loop
root.mainloop()

There is a class Font in tkFont.py look at ...

import tkFont
help(tkFont)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.