vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

I have played around with VPython, looks like I have to do some more. Here are some of my favorite programs ...

# experiments with visual Python (VPython)
# free download from http://vpython.org
# bounce a ball on the floor (no wind resistance)
# drag the right mouse button to change viewing angle

import visual as vs

vs.scene.width = 350
vs.scene.height = 500
vs.scene.center = (0,0.5,0)
vs.scene.title = "Bouncing Ball (drag right mouse button)"
# avoid autoscale (default)
vs.scene.autoscale = False

# a box object with attributes (x, y, z) or (length, height, width), color
floor = vs.box(pos=(0, -5.4, 0), size=(4, 0.2, 4), color=vs.color.green)

# a spherical object with attributes position (x, y, z), radius, color
ball = vs.sphere(pos=(0, 7.3, 0), radius=0.7, color=vs.color.red)

# ball moves in the y axis
ball.velocity = vs.vector(0, -1, 0)

# delta time
dt = 0.005
while 1:
    # set the rate of animation speed (update frequency)
    vs.rate(200)
    # change the position of ball based on the velocity on the y axis
    ball.pos = ball.pos + ball.velocity * dt
    # reverse ball direction within the y range
    if ball.y < -5:
        ball.velocity.y = -ball.velocity.y
    else:
        ball.velocity.y = ball.velocity.y - 9.8 * dt

and ...

# experiments with visual Python (VPython)
# free download from http://vpython.org
# create random spheres of random color, size and position
# animate into random directions displaying a trail
# drag the right mouse button to change the viewing angle

import visual as vs
import …
lllllIllIlllI commented: Great posts, amazing effort +1
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Ene, you are using global instances, so the frame.panel1 or frame.panel2 reference is actually not needed. You can just use panel1 and panel2. However, your approach keeps things together.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The module pygame makes it easy to load, display and move images around the screen ...

# experiments with module pygame
# free from: http://www.pygame.org/
# load, display and move an image

import pygame as pg

# initialize pygame
pg.init()

# pick an image you have (.bmp  .jpg  .png  .gif)
# if the image file is not in the working folder,
# use the full pathname like "C:/Images/gifs/Pooh.gif"
image_file = "Pooh.gif"

# RGB color tuple used by pygame
white = (255, 255, 255)

# create a 300x300 white screen
screen = pg.display.set_mode((300,300))
screen.fill(white)

# load the image from a file
# convert() unifies the pixel format for faster blit
image = pg.image.load(image_file).convert()

# draw image, position the image ulc at x=50, y=20
screen.blit(image, (50, 20))

# get the rectangle the image occupies
# rec(x, y, w, h)
start_rect = image.get_rect()

# set up the timed event loop
x = 0
y = 0
clock = pg.time.Clock()
keepGoing = True
while keepGoing:
    # set rate of move
    clock.tick(30)
    for event in pg.event.get():
        # quit when user clicks on window x
        if event.type == pg.QUIT:
            keepGoing = False
    # move the image ...
    x += 1
    y += 1
    # stop when x exceeds limit
    if x > 270:
        keepGoing = False
    image_rect = start_rect.move(x, y)
    # this erases the old sreen with white
    screen.fill(white)
    # put the image on the screen at new location
    screen.blit(image, image_rect)
    # update screen
    pg.display.flip()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

I am showing you the basic framework of a simple quiz program. You can improve this program and/or set up a different dictionary of question:answer pairs, like country:capital or roman numerals:value ...

# question and answer quiz using a dictionary
# here a US state capital quiz, but easy to modify
# has optional file save and load

import pickle
import random

def test(d):
    # key words would come up in the dictionary's hash order
    # so shuffle the word list obtained from d.keys()
    word_list = d.keys()
    # shuffle is an inplace operation
    random.shuffle(word_list)
    for word in word_list:
        count = 0
        while True:
            # change the prompt to whatever suites your quiz
            prompt = "What is the capital of " + word + ": "
            ans = raw_input(prompt)
            if ans.lower() == d[word].lower():
                print "Correct!"
                break
            else:
                print "That is incorrect. Try again."
                count += 1
                # ask 3 times then go on to the next word
                if count >= 3:
                    break

def save_d(filename, d):
    '''save the dictionary to a file'''
    fout = open(filename, "w")
    pickle.dump(d, fout)
    fout.close()

def load_d(filename):
    '''load the dictionary from a file'''
    fin = open(filename, "r")
    d = pickle.load(fin)
    fin.close()
    return d


# use a dictionary of state:capital pairs
# this keeps word and answer together and is easy to modify
d = {
'Alabama': 'Montgomery',
'Alaska': 'Juneau',
'Arizona': 'Phoenix',
'Arkansas': 'Little Rock',
'California': 'Sacremento',
'Colorado': 'Denver',
'Connecticut': 'Hartford',
'Delaware': 'Dover',
'Florida': 'Tallahassee',
'Georgia': 'Atlanta',
'Hawaii': 'Honolulu',
'Idaho': 'Boise',
'Illinois': 'Springfield',
'Indiana': 'Indianapolis',
'Iowa': 'Des Moines', …
Nick Evan commented: Rep for overall work in this thread +9
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

My way of joking is to tell the truth.

Shanti C commented: smart.... +2
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You really need to establish a list of row_lists ...

# forming a matrix/grid ...

class Grid(object):
    """Grid class with a width, height"""
    def __init__(self, width, height):
        #self.grid = []
        self.width = width
        self.height = height

    def new_grid(self):
        """Create an empty grid"""
        self.grid = []
        row_grid = []
        cell_value = 0
        for col in range(self.width):
            for row in range(self.height):
                row_grid.append(cell_value)
            self.grid.append(row_grid)
            row_grid = []  # reset row
        #print self.grid, col, row  # testing
        return self.grid

    def custom_grid(self, startx, endx, starty, endy, val=1):
        """put val into selected rows (y) and columns (x)"""
        self.grid = []
        row_grid = []
        cell_value = 0  # default val
        for col in range(self.width):
            for row in range(self.height):
                if (startx <= col <= endx) and (starty <= row <= endy):
                    row_grid.append(val)
                else:
                    row_grid.append(cell_value)
            self.grid.append(row_grid)
            row_grid = []  # reset row
        return self.grid

    def print_grid(self):
        for col in range(self.width):
            for row in range(self.height):
                print self.grid[col][row],
            print


my_grid = Grid(10, 10)
print "Empty grid ..."
my_grid.new_grid()
my_grid.print_grid()

print '-'*20

print "Custom grid ..."
# note that x forms the columns and y forms the rows
my_grid.custom_grid(startx=3, endx=6, starty=3, endy=6, val=1)
my_grid.print_grid()

"""
my output -->
Empty grid ...
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
--------------------
Custom grid ...
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
"""
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Reality says yes!

Alex Edwards commented: Nice sig =P +3
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

BC

Nice comic strip, I am still smiling!

Carlos got a letter from the IRS (US tax collectors). Apparently he owed them another $800. So he sent them this letter back, "If you'll remember, I fastened my return with a paper clip, which according to your very own latest government pentagon spending figures will more than make up for the difference."

Ezzaral commented: :D +11
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Write a Python program to find the five digit number, that when multiplied by 4 gives a number with the 5 digits in reverse order?

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Sorting lists in Python is simple, but when the list elements are numeric strings like they are in Tkinter or wxPython ListBoxes you need to sort them as floats not strings to make it work properly. Here is an example ...

def cmp_float(s1, s2):
    """
    s1 and s2 are numeric strings in a list
    compare to sort as floats low to high
    """
    if float(s1) > float(s2): return 1
    elif float(s2) > float(s1): return -1
    else: return 0


q = ['4.5', '11.3', '1.6', '9.4', '10.2', '-7.3']

print q
print sorted(q)
# you need to supply a custom compare function
print sorted(q, cmp=cmp_float)

"""
my output -->
['4.5', '11.3', '1.6', '9.4', '10.2', '-7.3'] <-- unsorted
['-7.3', '1.6', '10.2', '11.3', '4.5', '9.4'] <-- sorted as strings
['-7.3', '1.6', '4.5', '9.4', '10.2', '11.3'] <-- sorted as floats
"""
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Another way to put a lot of wxPython widgets on a limited display area is to use a scrolled panel like the wx.lib.scrolledpanel.ScrolledPanel() widget ...

# testing wxPython's
# wx.lib.scrolledpanel.ScrolledPanel(parent, id, pos, size, style)
# allows for more space than the parent frame has

import wx
import  wx.lib.scrolledpanel as sp

class MyScrolledPanel(wx.lib.scrolledpanel.ScrolledPanel):
    def __init__(self, parent):
        # make the scrolled panel larger than its parent
        wx.lib.scrolledpanel.ScrolledPanel.__init__(self, parent,
            wx.ID_ANY, size=(800, 600), style=wx.TAB_TRAVERSAL)
        # scroll bars won't appear until required
        # default is SetupScrolling(scroll_x=True, scroll_y=True)
        self.SetupScrolling()
        self.SetBackgroundColour("blue")

        # this will take up plenty of space for the test
        self.createMultiLabel()

    def createMultiLabel(self):
        # things to put on the labels
        label_string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ->UM'

        # wx.GridSizer(rows, cols, vgap, hgap)
        gsizer = wx.GridSizer(6, 5, 0, 0)

        # create a list of labels
        # acccess with self.labels[0], self.labels[1] etc.
        self.labels = []
        for c in label_string:
            self.labels.append(wx.StaticText(self, wx.ID_ANY,
                label=c, style=wx.ALIGN_CENTRE|wx.SUNKEN_BORDER))

        # iterate through the list of labels and set layout
        # also font and colour
        font = wx.Font(60, wx.MODERN, wx.NORMAL, wx.BOLD)
        for x in self.labels:
            x.SetFont(font)
            x.SetBackgroundColour("yellow")
            gsizer.Add(x, 0, flag=wx.ALL, border=20)  # |wx.EXPAND

        # set the sizer
        self.SetSizer(gsizer)


app = wx.App(0)
# create a frame, no parent, use default ID, set title, size
caption = "Multilabel display in a scrolled panel"
frame = wx.Frame(None, wx.ID_ANY, caption, size=(400, 300))
MyScrolledPanel(frame)
frame.Show(True)
app.MainLoop()
sneekula commented: interesting approach +4
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Very nice contribution of a spreadsheet like grid Snee!

If you ever have to present a lot of widgets on a limited space, the wx.NoteBook() widget is a great solution. In this case, I used it for a distance, area and volume conversion program. A start at least, generic enough so more conversions can easily be added. Just tab your way through the pages ...

# experiments with wxPython's wx.Notebook() widget
# converting distance, area and volume units
# tested with Python25 and wxPython28 by vegaseat 11aug2008

import wx

class MyNotebook(wx.Frame):
    def __init__(self, parent, title, distD, areaD, volD):
        wx.Frame.__init__(self, parent, wx.ID_ANY, title,
            size=(460, 360))

        # style=wx.NB_TOP is default
        # could use style=wx.NB_BOTTOM
        nb = wx.Notebook(self, wx.ID_ANY)
        # MyPage(parent, conversion dictionary, preselected choice)
        self.page1 = MyPage(nb, distD, 3)
        self.page2 = MyPage(nb, areaD, 2)
        self.page3 = MyPage(nb, volD, 0)
        nb.AddPage(self.page1, "Distance Conversion")
        nb.AddPage(self.page2, "Area Conversion")
        nb.AddPage(self.page3, "Volume Conversion")
        # start with page1 active
        self.page1.SetFocus()

class MyPage(wx.Panel):
    """
    each panel instance creates the notbook page content
    from the given conversion dictionary convD
    """
    def __init__(self, parent, convD, preselect):
        wx.Panel.__init__(self, parent, wx.ID_ANY)
        oatmeal3 = '#FCFFE1'
        self.SetBackgroundColour(oatmeal3)

        self.convD = convD

        # create list of possible units
        self.options = convD.keys()

        self.radiobox1 = wx.RadioBox(self, wx.ID_ANY,
            "Select a unit to convert from",
            choices=self.options, style=wx.VERTICAL)
        # set radio button 1 as selected (first button is 0)
        self.radiobox1.SetSelection(preselect)
        # bind mouse click to an action
        self.radiobox1.Bind(wx.EVT_RADIOBOX, self.onAction)

        self.radiobox2 = wx.RadioBox(self, wx.ID_ANY,
            "Select a unit to convert to  ",
            choices=self.options, style=wx.VERTICAL)
        # set radio button 1 as selected (first …
Aia commented: Thank you for the tutorials. +9
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Python is very much like Java, it compiles your source code into bytecode (Python Virtual Machine code) that the Python interpreter then converts to the actual CPU specific code.

Programs like Py2Exe are really packagers that take your bytecode, any needed modules, the Python interpreter (Pythonxx.dll) and package it all into a .exe file, that for all pratical matters behaves like an executable file.

Scuppery commented: couldn't say it any better +1
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Show one of those ever popular animated gif images Zoe style ...

# use wx.animate.GIFAnimationCtrl() to show an animated gif

import wx
import wx.animate     # ..\wx\animate.py

app = wx.App(0)
frame = wx.Frame(None, wx.ID_ANY, "Show an animated gif",
    size=(250, 150))
frame.SetBackgroundColour("white")

# pick an animated GIF file you have in the working directory
# (give it the full path if located in another directory)
ag_fname = 'AG_Dog.gif'
# create the instance with this file name
ag = wx.animate.GIFAnimationCtrl(frame, wx.ID_ANY, ag_fname)
# clear the background
ag.GetPlayer().UseBackgroundColour(True)
# continuously loop through the frames of the gif file (default)
ag.Play()

frame.Show()
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

In case you would ever need to fool with the wx.Frame itself. The wx.Frame default style is wx.DEFAULT_FRAME_STYLE and is normally defined as:
wx.MINIMIZE_BOX|wx.MAXIMIZE_BOX|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.CAPTION|
wx.CLOSE_BOX|wx.CLIP_CHILDREN
so remove wx.MAXIMIZE_BOX to disable it ...

# a wx.Frame with the max button/box disabled

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize,
            style=wx.MINIMIZE_BOX|wx.RESIZE_BORDER|wx.SYSTEM_MENU|
                  wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN)


app = wx.App(0)
# create a MyFrame instance and show the frame
MyFrame(None, 'Max box disabled', (400, 300)).Show()
app.MainLoop()

Here is an example of a frame without a border or title bar. Note that you have to supply your own exit button ...

# wx.Frame with no title bar

import wx

def exit(event):
    frame.Close(True)

app = wx.App(0)
# create a window, no-parent, -1 is default ID, style with no titlebar
frame = wx.Frame(parent=None, id=-1, pos=(50,100), size=(300,200), 
    style=wx.MINIMIZE_BOX)
frame.SetBackgroundColour('green')

# provide exit for a frame without titlebar
quit = wx.Button(frame, id=-1, label='Exit', pos=(0,175))
quit.Bind(wx.EVT_BUTTON, exit)

# show the window
frame.Show(True)

# start the event loop
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Using the wxPython GUI toolkit example in post ...
http://www.daniweb.com/forums/post651930-38.html
... come up with a program to create a collage of images.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Just a modification of the above scheme. This time we don't use a blank image, but an image we have and, let's say, write some fancy text on the image and then save it ...

# create a canvas on top of an image
# then draw some text on the image
# and save the finishd drawing

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent=None, id=-1, title=None):
        wx.Frame.__init__(self, parent, id, title)
        self.statbmp = wx.StaticBitmap(self)
        self.draw_image()
        self.save_image()

    def draw_image(self):
        # make sure you have the image in the working
        # directory or give the full path, load the image
        image = wx.Bitmap("roses.jpg")
        canvas_dc = wx.MemoryDC(image)
        # the image is now the background for the canvas
        canvas_dc.DrawBitmap(image, 0, 0)

        face = u'Comic Sans MS'
        font = wx.Font(22, wx.SWISS, wx.NORMAL, wx.NORMAL, False, face)
        canvas_dc.SetFont(font)
        canvas_dc.SetTextForeground('red')
        canvas_dc.DrawText("Sweet Roses!", x=80, y=10)

        # display the image drawing
        self.statbmp.SetBitmap(image)

    def save_image(self):
        """save the drawing"""
        finished_image = self.statbmp.GetBitmap()
        #finished_image.SaveFile("myimage.png", wx.BITMAP_TYPE_PNG)
        finished_image.SaveFile("myimage.jpg", wx.BITMAP_TYPE_JPEG)


app = wx.App(0)
MyFrame(title='draw on an image and save it').Show()
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

In a previous example we have learned how to create a wxPython canvas and draw shapes on it. If you want to save your artistic creation to one of the common image files, you have to create the canvas on top of a blank bitmap. Here is an example ...

# create a canvas on top of a blank bitmap
# this allows to save any canvas drawings
# created to a standard image file

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent=None, id=-1, title=None):
        wx.Frame.__init__(self, parent, id, title)
        self.statbmp = wx.StaticBitmap(self)
        self.draw_image()
        self.save_image()

    def draw_image(self):
        # select the width and height of the blank bitmap
        w, h = 340, 340
        # create the blank bitmap as a draw background
        draw_bmp = wx.EmptyBitmap(w, h)
        # create the canvas on top of the draw_bmp
        canvas_dc = wx.MemoryDC(draw_bmp)
        # fill the canvas white
        canvas_dc.SetBrush(wx.Brush('white'))
        canvas_dc.Clear()

        # draw a bunch of circles ...
        # pen colour
        canvas_dc.SetPen(wx.Pen('red', 1))
        # fill colour
        canvas_dc.SetBrush(wx.Brush('yellow'))
        for x in range(10, 180, 10):
            y = x
            r = x
            canvas_dc.DrawCircle(x, y, r)

        # now put the canvas drawing into a bitmap to display it
        # remember the canvas is on top of the draw_bmp
        self.statbmp.SetBitmap(draw_bmp)

    def save_image(self):
        """save the drawing"""
        finished_image = self.statbmp.GetBitmap()
        #finished_image.SaveFile("mydrawing.png", wx.BITMAP_TYPE_PNG)
        finished_image.SaveFile("mydrawing.jpg", wx.BITMAP_TYPE_JPEG)


app = wx.App(0)
MyFrame(title='draw and save').Show()
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Sizers look a little complex at first, but they can make your component layouts a lot simpler. The wx.GridSizer() is particularly well suited for a bunch of similar widgets generated with a for loop. In this case I used the gridsizer for the buttons of a simple calculator. The buttons simply keep wrapping from left to right, down a notch then left to right again ...

# create a calulator button layout with wx.GridSizer()
# then add a few things to form a tiny wxPython calculator

import wx

class MyFrame(wx.Frame):
    """make a frame, inherits wx.Frame"""
    def __init__(self):
        # create a frame/window, no parent
        wx.Frame.__init__(self, None, wx.ID_ANY, 'wx_Calc',
            pos=(300, 150), size=(185, 160))
        self.SetBackgroundColour('green')
        # main sizer
        vsizer = wx.BoxSizer(wx.VERTICAL)

        self.edit = wx.TextCtrl(self, -1, value="", size=(165, 20))

        # follows layout of calculator keys
        self.btn_list = [
        '7', '8', '9', '/', 'c',
        '4', '5', '6', '*', 'bs',
        '1', '2', '3', '-', '**',
        '0', '.', '=', '+', 'neg'
        ]

        # wx.GridSizer(rows, cols, vgap, hgap)
        gsizer = wx.GridSizer(4, 5, 2, 2)

        self.btn = range(len(self.btn_list))
        for ix, b_label in enumerate(self.btn_list):
            # set up a consecutive unique id for each button
            id = 1000 + ix
            self.btn[ix] = wx.Button(self, id, label=b_label, size=(20, 20))
            # the gridsizer fills left to right one row at a time
            gsizer.Add(self.btn[ix], 0, wx.ALL|wx.EXPAND, border=2)
            self.btn[ix].Bind(wx.EVT_BUTTON, self.btnClick)

        # now add the whole thing to the main sizer and set it
        vsizer.Add(self.edit, 0, wx.EXPAND)
        vsizer.Add(gsizer, 0, wx.EXPAND)
        self.SetSizer(vsizer)

    def btnClick(self, event):
        # get the label of the button clicked
        label = self.btn_list[event.GetId() - …
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The wx.SpinCtrl() is a graphical way to enter integers. You can click on the up or down arrows to change the value, or use the keyboard to type the value directly, once the spinbox has the focus. Just run the code to see what it does ...

# test the wx.SpinCtrl() widget
# wx.SpinCtrl(parent, id, value, pos, size, style, min, max, initial)
# used for integer number input
# style =
# wx.SP_ARROW_KEYS  can use arrow keys to change the value
# wx.SP_WRAP  value wraps at the minimum and maximum.

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
        self.SetBackgroundColour("yellow")

        # create a spinctrl widget for inteer input
        self.spin = wx.SpinCtrl( self, wx.ID_ANY, value="",
            pos=(10, 20), size=(80, 25), min=-100, max=1000,
            initial=98, style=wx.SP_ARROW_KEYS)
        # bind mouse click on arrows to an action
        self.spin.Bind(wx.EVT_SPINCTRL, self.onAction)
        # you can edit the value directly
        self.spin.Bind(wx.EVT_TEXT, self.onAction)

        # create an output widget
        s1 = "click on arrows to change the spinbox value \n"
        s2 = "or type the integer value directly"
        self.label = wx.StaticText(self, wx.ID_ANY, s1+s2, pos=(10, 60))

    def onAction(self, event):
        """ some action code"""
        val = self.spin.GetValue()
        f = str(round(val * 9.0/5 + 32, 2))
        c = str(round((val - 32)*5/9.0, 2))
        v = str(val)
        s1 = v + " degree Fahrenheit is " + c + " degree Celcius \n"
        s2 = v + " degree Celcius is " + f + " degree Fahrenheit"
        self.label.SetLabel(s1 + s2)


app = wx.App(0)
# create a MyFrame instance and show …
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The wx.RadioBox() widget is just a convenient way to group a bunch of radio buttons and give them a title. Radio buttons are used if you want only one of the group selected. Here is an example ...

# test the wx.RadioBox() widget
# wx.RadioBox(parent, id, label, pos, size, choices, style)
# combines a wx.StaticBox() with wx.RadioButton()
# only one radiobutton can be selected

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
        self.SetBackgroundColour("yellow")

        self.options = ['now', 'later', 'much later', 'never']
        # create an input widget
        self.radiobox = wx.RadioBox(self, wx.ID_ANY, "Select one option",
            pos=(10, 10), choices=self.options, style=wx.VERTICAL)
        # set radio button 1 as selected (first button is 0)
        self.radiobox.SetSelection(1)
        # bind mouse click to an action
        self.radiobox.Bind(wx.EVT_RADIOBOX, self.onAction)
        # create an output widget
        self.label = wx.StaticText(self, wx.ID_ANY, "" , pos=(10, 120))
        # show present selection
        self.onAction(None)

    def onAction(self, event):
        """ some action code"""
        #index = self.radiobox.GetSelection()
        #s = "You selected option " + self.options[index]
        # better ...
        s = "You selected option " + self.radiobox.GetStringSelection()
        self.label.SetLabel(s)


app = wx.App(0)
# create a MyFrame instance and show the frame
MyFrame(None, 'testing wx.RadioBox()', (300, 200)).Show()
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Ever wanted to know how many named colours wxPython has? Here is a short demo code to find out ...

# test the wx.Choice() widget and wx.lib.colourdb
# wx.Choice(parent, id, pos, size, choices, style)
# has no style options

import wx
import wx.lib.colourdb as colourdb

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
        # create a panel to show the selected colour
        self.panel = wx.Panel(self, wx.ID_ANY, pos=(0,40), size=(250, 130))

        # create a sorted colour list from the wx colour data base
        colourdb.updateColourDB()
        colour_list = sorted(colourdb.getColourList())
        # create a choice widget
        self.choice = wx.Choice(self, wx.ID_ANY, choices=colour_list)
        # select item 0 (first item) in sorted colour list
        self.choice.SetSelection(0)
        # set the current frame color to the choice
        self.SetBackgroundColour(self.choice.GetStringSelection())
        # bind the checkbox events to an action
        self.choice.Bind(wx.EVT_CHOICE, self.onChoice)

    def onChoice(self, event):
        bgcolour = self.choice.GetStringSelection()
        # change colour of the panel to the selected colour ...
        self.panel.SetBackgroundColour(bgcolour)
        self.panel.Refresh()
        # show the selected color in the frame title
        self.SetTitle(bgcolour.lower())


app = wx.App(0)
# create a MyFrame instance and show
MyFrame(None, 'Select a colour', (250, 170)).Show()
app.MainLoop()

Might as well get used to the British spelling of colour!
I left some US spellings in there for you to find.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You can use wxPython's ImageDialog to preview the image to be loaded. Also use a scrolled window to display oversized images ...

# test the wx.lib.imagebrowser.ImageDialog()
# and display the loaded image on a scrolled window

import wx
import os
import wx.lib.imagebrowser

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=(600,400),
            style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)

        # create a srolled window to put the image on
        self.scrollw = wx.ScrolledWindow(self, wx.ID_ANY)
        self.scrollw.SetBackgroundColour('green')
        # set EnableScrolling(bool x_scrolling, bool y_scrolling)
        self.scrollw.EnableScrolling(True, True)
        # create the scroll bars, set max width and height
        max_width = 1000
        max_height = 1000
        # SetScrollbars(pixelsPerUnitX, pixelsPerUnitY, noUnitsX, noUnitsY)
        self.scrollw.SetScrollbars(20, 20, max_width/20, max_height/20)

        # create a statusbar at the bottom of the frame
        self.CreateStatusBar()

        # create the menubar at the top of the frame
        menubar = wx.MenuBar()
        # setting up the menu
        filemenu = wx.Menu()
        # alt/o is hotkey, "Open file" shows up in statusbar
        filemenu.Append(wx.ID_OPEN, "&Open","Open image file")
        filemenu.AppendSeparator()
        # alt/x is hotkey
        filemenu.Append(wx.ID_EXIT,"E&xit","Exit program")
        # add the filemenu to the menubar
        menubar.Append(filemenu,"&File")
        # add the finished menubar to the frame/window
        self.SetMenuBar(menubar)

        # bind event to an action
        self.Bind(wx.EVT_MENU, self.onExit, id=wx.ID_EXIT)
        self.Bind(wx.EVT_MENU, self.onOpen, id=wx.ID_OPEN)

    def onExit(self,event):
        """close the frame"""
        self.Close(True)

    def onOpen(self,event):
        """open an image file via wx.lib.imagebrowser.ImageDialog()"""
        dirname = ''
        dialog = wx.lib.imagebrowser.ImageDialog(self, dirname)
        if dialog.ShowModal() == wx.ID_OK:
            filename = dialog.GetFile()
            image = wx.Bitmap(filename)
            self.SetStatusText(filename)
            # bitmap upper left corner is in position (x, y) = (5, 5)
            wx.StaticBitmap(self.scrollw, wx.ID_ANY, image, pos=(5, 5),
                size=(image.GetWidth(), image.GetHeight()))
        dialog.Destroy()


app = wx.App(0)
# create MyFrame instance and show the frame
MyFrame(None, …
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

An Amish boy and his father were visiting a nearby mall. They were amazed by almost everything they saw, but especially by two shiny silver walls that moved apart and back together again by themselves.
The lad asked, "What is this, father?"

The father, having never seen an elevator, responded, "I have no idea what it is."

While the boy and his father were watching wide-eyed as an old lady in a wheelchair rolled up to the moving walls and pressed the button. The walls opened and the lady rolled between them into a small room. The walls closed.

A short time later the walls opened up again and a beautiful much younger woman stepped out.

The father looked at his son and said, "Quick go and get your mother."

William Hemsworth commented: haha, nice one +2
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Applying different fonts to a text display ...

# test wx.Font() and wx.FontDialog on a given text
# wx.Font(pointSize, family, style, weight, underline=false, faceName="",
#     encoding=wx.FONTENCODING_DEFAULT)

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, title, data):
        wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(600, 400))
        panel = wx.Panel(self, wx.ID_ANY)
        button = wx.Button(panel, wx.ID_ANY, label='Change Font',
            pos=(3, 3))
        button.Bind(wx.EVT_BUTTON, self.changeFont)

        # family: wx.DEFAULT, wx.DECORATIVE, wx.ROMAN, wx.SCRIPT, 
        # wx.SWISS, wx.MODERN
        # style: wx.NORMAL, wx.SLANT or wx.ITALIC
        # weight: wx.NORMAL, wx.LIGHT or wx.BOLD
        font = wx.Font(16, wx.SCRIPT, wx.NORMAL, wx.LIGHT)
        # use additional fonts this way ...
        #face = u'Comic Sans MS'
        #font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, face)

        self.text = wx.StaticText(panel, wx.ID_ANY, data, pos=(10,35))
        self.text.SetFont(font)

    def changeFont(self, event):
        dialog = wx.FontDialog(None, wx.FontData())
        if dialog.ShowModal() == wx.ID_OK:
            data = dialog.GetFontData()
            font = data.GetChosenFont()
            self.text.SetForegroundColour(data.GetColour())
            self.text.SetFont(font)
        dialog.Destroy()


data = """\
Al Gore:  The Wild Years
America's Most Popular Lawyers
Career Opportunities for History Majors
Different Ways to Spell "Bob"
Ethiopian Tips on World Dominance
Everything Men Know About Women
Everything Women Know About Men
Staple Your Way to Success
The Amish Phone Book
The Engineer's Guide to Fashion
Ralph Nader's list of pleasures"""

app = wx.App(0)
# create instance of MyFrame and show
MyFrame(None, "Text and Font", data).Show()
# start the event loop
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Dealing with mouse events ...

# get the position of the mouse when clicked or moved

import wx

class MyFrame(wx.Frame):
    """create a color frame, inherits from wx.Frame"""
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, wx.ID_ANY, "Move or click mouse")
        self.SetBackgroundColour('Goldenrod')
        # give it a fancier cursor
        self.SetCursor(wx.StockCursor(wx.CURSOR_PENCIL))

        # bind some mouse events
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
        self.Bind(wx.EVT_MOTION, self.OnMotion)

    def OnLeftDown(self, event):
        """left mouse button is pressed"""
        pt = event.GetPosition()  # position tuple
        self.SetTitle('LeftMouse click at = ' + str(pt))

    def OnRightDown(self, event):
        """right mouse button is pressed"""
        pt = event.GetPosition()
        self.SetTitle('RightMouse click at = ' + str(pt))

    def OnMotion(self, event):
        """mouse in motion"""
        pt = event.GetPosition()
        self.SetTitle('Mouse in motion at = ' + str(pt))


app = wx.App(0)
MyFrame(None).Show()
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

This shows you how to use wxPython's wx.lib.fancytext to show super and subscripted text in a specified font, colour and size. The text coding is XML ...

# wxPython's wx.lib.fancytext can show super and subscripted text
# using XML code

import  wx
import  wx.lib.fancytext as fancytext

class FancyText(wx.Panel):
    """display fancytext on a panel"""
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, wx.ID_ANY)
        self.Bind(wx.EVT_PAINT, self.OnPaint)

    def OnPaint(self, evt):
        """generate the fancytext on a paint dc canvas"""
        dc = wx.PaintDC(self)
        fancytext.RenderToDC(xml_str, dc, 0, 20)

# the XML code string
xml_str = """\
<font family="swiss" color="blue" size="20">
  H<sub>2</sub>O
  x<sup>3</sup> + y<sup>2</sup> - 15 = 0
</font>
"""

app = wx.App(0)
frame = wx.Frame(None, wx.ID_ANY, title='wxPython fancy text',
    pos=(100, 50), size=(500, 250))
FancyText(frame)
frame.Show(True)
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The largest loss of energy is in the voltage drop across the electrodes of an electrolytic cell. A matter of physics, nothing you can do about it. It simply means that over 60% of the electrical energy will be wasted as heat.

On top of that hydrogen is one of the worst things to store. It takes up a huge volume and will not stay liquid under pressure alone. Being the smallest molecule, it has a tendency to leak where normal gases would not. It takes only 2% hydrogen in the air to form a very explosive mixture.

I have worked with hydrogen gas for 40 years of my professional life, and believe me it does not leave any room for junk science or other mistakes.

itdupuis commented: very informative, thanks for your expertise! +1
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The idea of this thread is to help the beginning wxPython GUI programmer with hints and helpful code. Please feel free to contribute! If you have any questions start your own thread!

For info on wxPython modules see:
http://www.wxpython.org/docs/api/wx-module.html

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Easy ways to break out of nested loops came up in the forum, so I played with it a little. Using break will only get you out its associated loop like this example shows ...

w = h = d = 10  # for testing
for x in range(0, w):
    for y in range(0, h):
        for z in range(0, d):
            print x, y, z
            stop = raw_input("Stop? y/n")
            # alas this will only break out of the z loop
            if stop == "y":
                break

One solution would be to put the nested loops into a function and use return to break out ...

def nested_loop():
    """use of return to exit a nested loop"""
    w = h = d = 10  # for testing
    for x in range(0, w):
        for y in range(0, h):
            for z in range(0, d):
                print x, y, z
                stop = raw_input("Stop? y/n")
                if stop == "y":
                    return

nested_loop()

You can also raise an exception to get out ...

# use of try/except to exit a nested loop
w = h = d = 10  # for testing
try:
    for x in range(0, w):
        for y in range(0, h):
            for z in range(0, d):
                print x, y, z
                if raw_input("Stop? y/n") == "y":
                    raise StopIteration()
except StopIteration:
    pass
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The module pygame is an SDL based GUI toolkit written for game development. It handles sound, images, animation and drawing objects like lines, circles, polygons. Here is a playful example to give you a taste of pygame code ...

# draw random circles with module pygame
# pygame free from: http://www.pygame.org/ 

import pygame as pg
import random as rn

# color rgb tuples
black = 0, 0, 0
blue = 0, 0, 255
green = 0, 255, 0
olive = 128, 128, 0
orange = 255, 165, 0
magenta = 255, 0, 255 
red = 255, 0, 0
yellow = 255, 255, 0
white = 255, 255, 255
color_list = [red, blue, green, yellow, olive, orange, magenta]

# window/screen width and height
w = 500
h = 500 
screen = pg.display.set_mode((w, h))
pg.display.set_caption('Draw a number of random circles')
screen.fill(black)

# draw n circles
n = 20 
for k in range(n):
    x = rn.randint(10, w)
    y = rn.randint(10, h)
    radius = rn.randint(2, h//3)
    color = rn.choice(color_list) 
    position = x, y
    # circle border width = 2  
    pg.draw.circle(screen, color, position, radius, 2)

# update display 
pg.display.flip()

# event loop ...
running = True 
while running:
    for event in pg.event.get():
        # quit when window corner x is clicked
        if event.type == pg.QUIT:
            running = False
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Here is an example showing you how to read off a number, in this case a phone number, digit by digit on your computer's sound system. You need to extract the attached Numbers.zip file into your working directory. It contains sound files 0.wav to 9.wav spoken by a pleasant female voice ...

# read each digit of a phone number using module pyglet
# download module pyglet from: http://www.pyglet.org/download.html
# soundfiles 0.wav ... 9.wav are in subdirectory num
# extract the Numbers.zip file into your working directory

import pyglet
import time

#window = pyglet.window.Window(640, 480)

# read all the sound sources into a list
sound = []
for n in range(0, 10):
    # soundfiles 0.wav ... 9.wav are in subdirectory num
    sound_file = "num/%s.wav" % n
    #print sound_file 
    sound.append(pyglet.media.load(sound_file, streaming=False))

# create an instance of the media player class
# for better control
s = pyglet.media.Player()
# optional volume setting 0.0 to 1.0
s.volume = 0.8

# read out a phone number string
phone_number_str = '734-344-9941'
for n in phone_number_str:
    if n.isdigit(): 
        s.queue(sound[int(n)])
        s.play()
        # give each digit play() time to finish properly
        # you might have to experiment with sleep seconds
        time.sleep(0.8)
        s.next()
    time.sleep(0.4)
        
pyglet.app.run()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Winpdb is a Platform Independent Python Debugger free from:
http://www.winpdb.org/
Once you get used to the strange way to load source files via File/Launch the GUI based debugger is very powerful. It highlights the active line in the source code, and follows data in a Locals/Globals/Exceptions window and also keeps track of Threads and the Stack.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Of all the large US cities (million+) Las Vegas Nevada has the lowest average IQ.

I doubt that this is true, because of the huge number of scam artists in town. To be a good scam artist you have to have some amount of IQ. Now, if you count the IQ of all the fools that come here and think they can win, you will have a point!

Now for the elephant:
Our eyes are the same size from the day we are born, our ears and nose however keep growing.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

More redheads are born each year in Scotland than in any other place in the world.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

A simple way to make a scrolling text ticker or marquee ...

# using Tkinter to create a marquee/ticker
# uses a display width of 20 characters
# not superly smooth but good enough to read

import Tkinter as tk
import time

root = tk.Tk()

# width=width chars, height=lines text
text = tk.Text(root, width=20, height=1, bg='yellow')
text.pack()

# use a proportional font to handle spaces correctly
text.config(font=('courier', 24, 'bold'))

s1 = "I was wondering how someone would go about making a scrolling ticker"

# pad front and end with 20 spaces
s2 = ' ' * 20
s = s2 + s1 + s2

for k in range(len(s)):
    # use string slicing to do the trick
    ticker_text = s[k:k+20]
    text.insert("1.1", ticker_text)
    root.update()
    # delay by 0.15 seconds
    time.sleep(0.15)

root.mainloop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

sneekula:
I know Snee is a science grad student. He likes the Cs, that is the C language, Computers, Church, Chemistry, Cooking and Cars. He seems to be light hearted, easy going, and on occasion will leave the Geek's Lounge to make a contribution to the Python forum.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

In honor of the Easter holidays and the upcoming start of April:
Both the male and female Easter bunny can lay eggs, but he female's eggs have more brilliant colors.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Tomorrow is Easter Sunday, and it's quite early this year. Use the following Python function to calculate the earliest Easter Sunday for the next 100 years (2008 to 2108) and for the next 1000 years ...

def calc_easter(year):
    """returns the date of Easter Sunday of the given yyyy year"""
    y = year
    # golden year - 1
    g = y % 19
    # offset
    e = 0
    # century
    c = y/100
    # h is (23 - Epact) mod 30
    h = (c-c/4-(8*c+13)/25+19*g+15)%30
    # number of days from March 21 to Paschal Full Moon
    i = h-(h/28)*(1-(h/28)*(29/(h+1))*((21-g)/11))
    # weekday for Paschal Full Moon (0=Sunday)
    j = (y+y/4+i+2-c+c/4)%7
    # number of days from March 21 to Sunday on or before Paschal Full Moon
    # p can be from -6 to 28
    p = i-j+e
    d = 1+(p+27+(p+6)/40)%31
    m = 3+(p+26)/30
    # returns (month, day, year) tuple of Easter Sunday
    return (m, d, y)
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Here is an example how to use Python25's new partial function in a Tkinter callback situation ...

# a tiny Tkinter calculator showing the
# use of the new Python25 partial function

import Tkinter as tk
from functools import partial  # needs Python25 or higher

def click(key):
    global memory
    if key == '=':
        # avoid division by integer
        if '/' in entry.get() and '.' not in entry.get():
            entry.insert(tk.END, ".0")
        # guard against the bad guys abusing eval()
        str1 = "-+0123456789."
        if entry.get()[0] not in str1:
            entry.insert(tk.END, "first char not in " + str1)
        # here comes the calculation part
        try:
            result = eval(entry.get())
            entry.insert(tk.END, " = " + str(result))
        except:
            entry.insert(tk.END, "--> Error!")
    elif key == 'C':
        entry.delete(0, tk.END)  # clear entry
    elif key == '->M':
        memory = entry.get()
        # extract the result
        if '=' in memory:
            ix = memory.find('=')
            memory = memory[ix+2:]
        root.title('M=' + memory)
    elif key == 'M->':
        entry.insert(tk.END, memory)
    elif key == 'neg':
        if '=' in entry.get():
            entry.delete(0, tk.END)
        try:
            if entry.get()[0] == '-':
                entry.delete(0)
            else:
                entry.insert(0, '-')
        except IndexError:
            pass
    else:
        # previous calculation has been done, clear entry
        if '=' in entry.get():
            entry.delete(0, tk.END)
        entry.insert(tk.END, key)

root = tk.Tk()
root.title("My Calculator PF")

# this also shows the calculator's button layout
btn_list = [
'7',  '8',  '9',  '*',  'C',
'4',  '5',  '6',  '/',  'M->',
'1',  '2',  '3',  '-',  '->M',
'0',  '.',  '=',  '+',  'neg' ]

# create all buttons with a loop
r = 1
c = 0
for b in btn_list:
    rel = 'ridge' …
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Q: "How many personal injury lawyers does it take to change a light bulb?"

A: "Two - one to turn the bulb, and one to shake him/her off the ladder and then sue the ladder company."

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

If you had a way to mark water molucules, and then added 1 drop of
that marked water into the earth's oceans and mixed it well. How many
of the marked molcules of water would you find in each drop of ocean water?

Some helpful information:
Avogadro's number N = 6.023 x 10^23 (6.023e23) molecules/mole
1 mole of water has a volume of 18 ml
Assume that 1 ml water contains 30 drops
Volume of all the earth's oceans is 1.35 billion cubic kilometers

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

How would you write a number (integer) using English words? Here is one way, and to keep it simple let's just use numbers from 1 to 999.

# write a number from 1 to 999 in English words

ones = ["", "one ","two ","three ","four ", "five ",
    "six ","seven ","eight ","nine "]

tens = ["ten ","eleven ","twelve ","thirteen ", "fourteen ",
    "fifteen ","sixteen ","seventeen ","eighteen ","nineteen "]

twenties = ["","","twenty ","thirty ","forty ",
    "fifty ","sixty ","seventy ","eighty ","ninety "]

# your test number between 1 and 999
n = 123

# separate into ones, tens/twenties, hundreds
b1 = n % 10
b2 = (n % 100)//10
b3 = (n % 1000)//100

print b1, b2, b3  # test, for n = 123 should show 3 2 1

# start with an empty string to build up
nw = ""
# no tens/twenties
if b2 == 0:
    nw = ones[b1] + nw
# we have tens
elif b2 == 1:
    nw = tens[b1] + nw
# we have twenties etc.
elif b2 > 1:
    nw = twenties[b2] + ones[b1] + nw
# we have hundreds
if b3 > 0:
    nw = ones[b3] + "hundred " + nw

print nw  # test 123 --> one hundred twenty three
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

A man is innocent until proven broke.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

What's the difference between a good lawyer and a great lawyer?

A good lawyer knows the law. A great lawyer knows the judge.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The housefly regurgitates its food and eats it again.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

I am keeping these to 100 pixel height thumbs so the JPEGs range between 5 and 15k (trying to safe Dani some disk space). You give me an educated guess what plane it is. I will (or you should) acknowledge the first correct guess.

hammerhead commented: Very good thread. Nice idea. +2
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The average American looks at eight houses before buying one.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

I think you are close, I remember reading that Japan uses 200 pairs of disposable chopsticks per person each year.

Here is another elephant:
The average western woman consumes 6 lbs of lipstick in her lifetime.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Lord Byron's fame rests not only on his writings and peotry, but also on his extravagant living and numerous love affairs. His daughter Ada Lovelace, notable in her own right, collaborated with Charles Babbage on the analytical engine, a predecessor to modern computers. The Ada computer language is named after her.