Subscribe to Blog.Parse(typeof(PsychoCoder), Richard McCutchen);        RSS Feed
-----

52 Week Challenge - Week 4 - The Conclusion

Icon 4 Comments
Here's mine in IronPython. It creates a Windows form loaded with all available fonts installed, then allows what that text looks like in various sizes.

This is really my first try wit IronPython so be nice loil

import System.Drawing
import System.Drawing.Text
import System.Windows.Forms
from System.Drawing import *
from System.Drawing.Text import *
from System.Windows.Forms import *

installedFonts = InstalledFontCollection()
fontNames = [font for font in installedFonts.Families]

form = Form()
form.Text = 'PsychoCoder''s IronPython Font Previewer'
form.Width = 1024
form.Height = 768

fontsListBox = ListBox()
fontsListBox.Width = 230

for font in fontNames:
	fontsListBox.Items.Add(font.Name)
fontsListBox.SelectedIndex = 0	

cboFontSizes = ComboBox()
cboFontSizes.Width = 45
for i in range(9, 21):
	cboFontSizes.Items.Add(str(i))
cboFontSizes.Text = '30'

txtFontPreview = TextBox()
txtFontPreview.Font = Font(fontNames[0], 30, FontStyle.Regular)
txtFontPreview.Multiline = True
txtFontPreview.Text = u"This is what the font looks like!"

sbPreviewer = StatusBar()
sbPreviewer.Text = 'A total of %d fonts were discovered' % len(fontNames)

#now add the controls and set the layout
fontsListBox.Dock = DockStyle.Left
txtFontPreview.Dock = DockStyle.Fill

#cboFontSizes.Dock = DockStyle.Top
cboFontSizes.Location = System.Drawing.Point(400,100)
sbPreviewer.Dock = DockStyle.Bottom
form.Controls.Add(txtFontPreview)
form.Controls.Add(cboFontSizes)
form.Controls.Add(fontsListBox)
form.Controls.Add(sbPreviewer)
form.ActiveControl = fontsListBox

#event to change the font of the preview TextBox
def LoadFontPreview():
	try:
		txtFontPreview.Font = Font(fontNames[fontsListBox.SelectedIndex], int(cboFontSizes.Text), FontStyle.Regular)
		sbPreviewer.Text =  "%s was selected" % (fontNames[fontsListBox.SelectedIndex])
		#sbPreviewer.Text = ''
	except Exception,e:
		sbPreviewer.Text = unicode(e)
		
fontsListBox.SelectedIndexChanged += lambda sender, args: LoadFontPreview()
cboFontSizes.TextChanged += lambda sender, args: LoadFontPreview()

form.ShowDialog()




There, now you can actually see that I can code in something other than C# and VB.NET (and PHP of course). Now to wove on to Weeks f Challenge: Ruby. I've never done anything with Ruby so this should fun :)

4 Comments On This Entry

Page 1 of 1

BenignDesign 

01 February 2010 - 10:07 AM
Conclision? Is that when you collide with your conclusion?? :)
0

PsychoCoder 

01 February 2010 - 11:53 AM
LOL nope, that's when I try to type something after I've taken my sleeping pills LOL!
0

JonnoFury 

02 February 2010 - 10:33 AM
Where do I go to get in on this weeks project?
0

PsychoCoder 

02 February 2010 - 02:30 PM
@JonnoFury:

Check out this weeks challenge here. Happy Coding my friend!
0
Page 1 of 1

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

May 2020

S M T W T F S
     12
3456789
10111213141516
17181920212223
24 25 2627282930
31      

Recent Entries

Search My Blog

1 user(s) viewing

1 Guests
0 member(s)
0 anonymous member(s)