If you use the Windows OS, then IronPython allows you to create a GUI program taking advantage of the .NET framework. You also have the option to compile the program into a standalone .exe file (and the needed .dll file).
''' ip_ListBox_99BoB.py add '99 bottles of beer' lyrics to a .NET list box simplified code using some defaults IronPython gives access to the Windows .NET or Linux Mono libraries download the IronPython installer version 2.7.3 from http://ironpython.codeplex.com/releases/view/81726 run with the IronPython interpreter this way ... (might have to add full path) ipy.exe ip_ListBox_99BoB.py tested with IronPython 2.7.3 by vegaseat 28may2013 ''' import clr clr.AddReference('System.Windows.Forms') clr.AddReference("System.Drawing") import System from System.Windows.Forms import * from System.Drawing import * from System.Collections import ArrayList class BeerSong(Form): def __init__(self): # width, height of form self.ClientSize = System.Drawing.Size(220, 326) self.Text = '99 BoB lyrics' # create the listbox and fill the form (self) with it box = ListBox() # light yellow box.BackColor = System.Drawing.Color.FromArgb(255, 255, 224) box.Dock = DockStyle.Fill self.Controls.Add(box) # move the lyrics into ArrayList then transfer to the box array = ArrayList() bottle = "%s bottle" beer = "s of beer on the wall!" take = "Take one down, pass it around," for k in range(99, 0, -1): # an exercise in slicing s1 = bottle % k + beer[k==1:] s2 = (bottle % k + beer[k==1:])[:-13] + "!" s3 = bottle % (k-1 or "No") s4 = beer[k==2:-1] + "!" array.Add(s1) array.Add(s2) array.Add(take) array.Add(s3+s4) array.Add(" ") box.DataSource = array Application.Run(BeerSong())
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.