•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 397,975 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,958 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
A simple example of applying a font to a text displayed with wxPython's wx.StaticText widget.
# experiments with wx.StaticText(), set a font for the text # tested with Python25 and wxPython28 vegaseat 02oct2007 import wx class MyFrame(wx.Frame): def __init__(self, parent, id, title, data): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, size=(500, 380)) panel = wx.Panel(self, -1) # font type: wx.DEFAULT, wx.DECORATIVE, wx.ROMAN, wx.SCRIPT, wx.SWISS, wx.MODERN # slant: wx.NORMAL, wx.SLANT or wx.ITALIC # weight: wx.NORMAL, wx.LIGHT or wx.BOLD #font1 = wx.Font(10, wx.SWISS, wx.ITALIC, wx.NORMAL) # use additional fonts this way ... font1 = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Comic Sans MS') text1 = wx.StaticText(panel, -1, data, pos=(20,15)) text1.SetFont(font1) # center frame on screen self.Center() # show the frame self.Show(True) data = """\ Al Gore: The Wild Years America's Most Popular Lawyers Career Opportunities for History Majors Different Ways to Spell "Bob" Dr. Kevorkian's Collection of Motivational Speeches Ethiopian Tips on World Dominance Everything Men Know About Women Everything Women Know About Men One Hundred and One Spotted Owl Recipes by the EPA Staple Your Way to Success The Amish Phone Book The Engineer's Guide to Fashion Ralph Nader's list of pleasures""" application = wx.PySimpleApp() # create instance of class MyFrame window = MyFrame(None, -1, "The World's Shortest Books", data) # start the event loop application.MainLoop()
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)