sneekula 969 Nearly a Posting Maven

Python25 has sqlite3 builtin, so you could use that.

sneekula 969 Nearly a Posting Maven

Mixing tabs and spaces will give you very troublesome indentations. I recommend to stick with spaces only, since not everyone's tab settings are the same.

Somewhere in your program you have to get a value for image_name before you call your function.

sneekula 969 Nearly a Posting Maven

To colorize words you are asking too much of good old Tkinter. You most likely need to got with the wx.StyledTextCtrl() widget.
This STC control wraps the Scintilla editor component so it will work with wxPython. Could be that something like this is available for Tlinter.

How about IDLE, that's written using the Tkinter GUI toolkit.

sneekula 969 Nearly a Posting Maven

Looking through IDLE's source code (should be right on your drive) might give you some insight into code highlighting.

sneekula 969 Nearly a Posting Maven

She is even prettier than Romney?

sneekula 969 Nearly a Posting Maven

Q: "What did the blond fellow say after reading the buxom waitress' name tag?"
A: " 'Debbie' ... that's cute. What did you name the other one?''

sittas87 commented: lol. Gotcha +3
sneekula 969 Nearly a Posting Maven

I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
~~~ Albert Einstein

sneekula 969 Nearly a Posting Maven

Will archaeologists date any old thing?

sneekula 969 Nearly a Posting Maven

Only if We Want Naomi Campbell to Win!

Now that is funny!

Was the failed balloon company a victim of inflation?

sneekula 969 Nearly a Posting Maven

Que?
LMAO

"Honey, I can't come to bed now, someone on the internet is wrong!"

sneekula 969 Nearly a Posting Maven

Looks like you might just have to laugh at some of the silly stuff the present Republican Administration is doing.

sneekula 969 Nearly a Posting Maven

Diet Coke.

Hello Duki, glad to see you are still around! Enjoy your Diet Coke!

I had an Einstein Wildberry Blender, yum!

sneekula 969 Nearly a Posting Maven

Have you ever said anything useful?

Oh sweet Jesus! There I said something useful! That alone beats all your posts combined.

sneekula 969 Nearly a Posting Maven

And everybody wants to be loved -- not everybody, but -- you run for office, I guess you do. You never heard anybody say, 'I want to be despised, I'm running for office.'
(W. in Tipp City, OH 04/19/2007)

sneekula 969 Nearly a Posting Maven

Solar power will not come overnight.
~~~ Gerald Ford (former US president)

sneekula 969 Nearly a Posting Maven

What was John McSame thinking when he was looking at McDame? Or was he thinking?

Hopefully Captain McCain treats his runningmate a little warmer than his wife. He treats his wife in public like she has an infectious disease.

sneekula 969 Nearly a Posting Maven

An ant with only half the brain cells couldn't function, that does not hold true for humans.

sneekula 969 Nearly a Posting Maven

There's a lot of people who want me to get out of acting and want me to run for governor. I think it's mostly the movie critics.
~~~ Arnold Schwarzenegger

sneekula 969 Nearly a Posting Maven

An amateur is someone who supports himself with outside jobs which enable him to paint. A professional is someone whose wife works to enable him to paint.

sneekula 969 Nearly a Posting Maven

Actually the module shelve works better with dictionaries:

# save and retrieve data via a shelve byte stream file
# creates a 'persistent to file' dictionary

import shelve

phonebook = {
'Andrew Parson': 8806336,
'Emily Everett': 6784346, 
'Peter Power': 7658344,
'Lewis Lame': 1122345
}

# dictionary data will be in a shelve byte stream file
shlv2 = shelve.open('phonebook.slv')

phonebook['Ginger Roger'] = 1234567

# this will save all current phonebook data 
# access key will "phone_dict"
shlv2["phone_dict"] = phonebook

phonebook['Larry Lark'] = 9234568

# you can update again before you close
shlv2["phone_dict"] = phonebook
shlv2.close()

print '-'*50

# testing ...
# this could be a second program ...
# retrieve the saved data from the file
shlv3 = shelve.open('phonebook.slv')
#print shlv3.keys()
# use the access key "phone_dict"
# notice that this loads right into a dictionary
phonebook2 = shlv3["phone_dict"]
print phonebook2

print '-'*50

print phonebook2['Lewis Lame']
print phonebook2['Larry Lark']
print phonebook2['Ginger Roger']

shlv3.close()
sneekula 969 Nearly a Posting Maven

Our Python friend leegeorg07 just pointed out a good tutorial site at:
http://www.sthurlow.com/python/

sneekula 969 Nearly a Posting Maven

Just remember that py2exe brings in some Dynamic Link Libraries (DLL) that are unique to the Windows OS.

You might be better off putting PortablePython onto a cheap USB flash drive.

sneekula 969 Nearly a Posting Maven

nothing against zetlins first reply but he did just copy that from the tutorial from here

He should have given some credit to the original source.

Reminds me of a quote from Albert Einstein:

Plagiarism is stealing from one source.
Research is stealing from many sources
.

sneekula 969 Nearly a Posting Maven

Sorry Mister Moderator, I found this program on my hardrive (under yet unfinished projects). Now I know where it came from. I was thinking about refining it into a random story teller. Now that would be a worthwhile project.

sneekula 969 Nearly a Posting Maven

If you would have a drink everytime McCain says "Friends", you would drown!

sneekula 969 Nearly a Posting Maven

Just saw this in the news:
Denmark's parliament on Monday approved the construction of a 400 megawatt (MW) offshore wind turbine park. The park will generate enough electricty to power 400 000 Danish homes. Denmark is home to Vestas, the world's biggest supplier of wind turbines.

Probably more effective than drilling a bunch of holes offshore. I always thought Siemens of Germany was the largest producer of wind turbines. Too bad that one of our troubled car makers doesn't get into that business.

I just visited T. Boone Pickens' Energy Plan site and found it very interesting.
http://www.pickensplan.com/?c=Google&a=Pickens-Keywords&k=pickens

Even an oil multibillionaire like him has seen the light, and wants to do something for his country. Very noble and smart.

sneekula 969 Nearly a Posting Maven

I was trying to create an alternative calculator using some of wxPython's input widgets like wx.Choice and wx.TextCtrl. This turned out to be a good example for the wx.GridBagSizer too. The basic workings are there, but as always there is room for improvement:

# do some simple math operations with
# wx.Choice(parent,id,pos,size,choices,style)

import wx
from math import *

class MyFrame(wx.Frame):
    def __init__(self, parent, title, operation_list):
        wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(350, 270))
        self.SetBackgroundColour('green')

        # create choice widget for the math operations
        self.choice = wx.Choice(self, wx.ID_ANY, choices=operation_list)
        # select item 0 (first item) in choices list to show
        self.choice.SetSelection(0)
        self.choice.SetToolTip(wx.ToolTip('select one math operation'))
        # bind the checkbox events to action
        self.choice.Bind(wx.EVT_CHOICE, self.onAction)
        
        edit_label1 = wx.StaticText(self, wx.ID_ANY, 'enter x')
        self.edit1 = wx.TextCtrl(self, wx.ID_ANY, value="1",
            size=(200, 20))
        
        edit_label2 = wx.StaticText(self, wx.ID_ANY, 'enter y')
        self.edit2 = wx.TextCtrl(self, wx.ID_ANY, value="1",
            size=(200, 20))
            
        edit_label3 = wx.StaticText(self, wx.ID_ANY, 'result')
        self.edit3 = wx.TextCtrl(self, wx.ID_ANY, value="",
            size=(200, 20))
        self.edit3.SetToolTip(wx.ToolTip('double click to move data to x'))
        self.edit3.Bind(wx.EVT_LEFT_DCLICK, self.onDoubleClick)
        
        self.button = wx.Button(self, wx.ID_ANY, label='Calculate')
        # bind mouse event to action
        self.button.Bind(wx.EVT_BUTTON, self.onAction)
        
        # hgap is between columns, vgap between rows
        sizer = wx.GridBagSizer(vgap=0, hgap=0)
        # pos=(row, column)
        sizer.Add(edit_label1, pos=(0,0), flag=wx.ALL|wx.EXPAND, border=10)
        sizer.Add(self.edit1, pos=(0,1), flag=wx.ALL|wx.EXPAND, border=10)
        sizer.Add(edit_label2, pos=(1,0), flag=wx.ALL|wx.EXPAND, border=10)
        sizer.Add(self.edit2, pos=(1,1), flag=wx.ALL|wx.EXPAND, border=10)
        # span=(rowspan, columnspan)
        sizer.Add(self.choice, pos=(2,0), span=(1, 2),
            flag=wx.ALL|wx.EXPAND, border=10)
        sizer.Add(self.button, pos=(3,0), span=(1, 2),
            flag=wx.ALL|wx.EXPAND, border=10)
        sizer.Add(edit_label3, pos=(4,0), flag=wx.ALL|wx.EXPAND, border=10)
        sizer.Add(self.edit3, pos=(4,1), flag=wx.ALL|wx.EXPAND, border=10)
        self.SetSizerAndFit(sizer)

    def onAction(self, event):
        op = self.choice.GetStringSelection()
        x = float(self.edit1.GetValue())
        y = float(self.edit2.GetValue())
        if y == 0.0 and op == 'x / y' :
            result …
vegaseat commented: nice code snee +9
sneekula 969 Nearly a Posting Maven

I noticed that the car in front of me at the light had a bumper sticker that read "Honk if you love Jesus".

So I thought about it a bit, and since I love Jesus, I honked my horn.

I was very suprised when the driver of the car got out and yelled, "The light is still red you fugging ahsshole!!!!"

sneekula 969 Nearly a Posting Maven

The young are always ready to give to those who are older than themselves the full benefits of their inexperience.
~~~ Oscar Wilde

sneekula 969 Nearly a Posting Maven

God bless you!
You made the 1000 post milestone despite all the bad marks that jwenting gave you early on!

sneekula 969 Nearly a Posting Maven

I tried gpy2exe and it simply does not work with programs that use Tkinter or PIL.

sneekula 969 Nearly a Posting Maven

Don't forget Danieb's very own "Starting Python" at:
http://www.daniweb.com/forums/thread20774.html

You can find some helpful talk, code samples and hints.

sneekula 969 Nearly a Posting Maven

See if you can refine this random sentence generator a little:

# goofy sentence generator
# add more parts to it as you please

import random

def make_sentence(part1, part2, part3, n=1):
    """return n random sentences"""
    # convert to lists
    p1 = part1.split('\n')
    p2 = part2.split('\n')
    p3 = part3.split('\n')
    # shuffle the lists
    random.shuffle(p1)
    random.shuffle(p2)
    random.shuffle(p3)
    # concatinate the sentences
    sentence = []
    for k in range(n):
        try:
            s = p1[k] + ' ' + p2[k] + ' ' + p3[k]
            s = s[0].upper() + s[1:] + '.'
            sentence.append(s)
        except IndexError:
            break
    return sentence

# break a typical sentence into 3 parts
# first part of a sentence (subject)
part1 = """\
a drunken sailor
a giggling goose
the yearning youth
the obese ostrich
the bare barrister
this mean mouse
the skinny sister
the aspiring FBI agent
my bald uncle
old aunt Jessy
the green giant
a timid trucker
the lawless lawyer"""

# middle part of a sentence (action)
part2 = """\
jumps over
flies over
crawls under
runs across
hops across
rapidly removes
openly ogles
carefully tastes
tightly hugs
flirts with
cries over
thinks a lot about
passionately kisses
looks for
ardently admires
takes a whiff of"""

# ending part of a sentence (object)
part3 = """\
a rusty fence
the laughing cow
the weedcovered backyard
my moldy malt
the rancid old cheese
the jolly green jelly
a tiny stick
a bottle of beer
a singing blue nun
a big lardy lump
the smelly salesman
a big mug of …
sneekula 969 Nearly a Posting Maven

Imagination is the one weapon in the war against reality.

sneekula 969 Nearly a Posting Maven

Do you have blacks, too?
(A question to Brazilian President Fernando Cardoso by George W. Bush Washington, DC 11/08/2001)

sneekula 969 Nearly a Posting Maven

Computers make very fast, very accurate mistakes.

sneekula 969 Nearly a Posting Maven

I find it strange that McCain doesn't even know how many houses he owns.

There are plenty of rich old folks that don't know!

sneekula 969 Nearly a Posting Maven

Looks like a game of "he said she said"

sneekula 969 Nearly a Posting Maven

Cute English:

Sign in a Bucharest hotel lobby ...

The lift is being fixed for the next day.
During that time we regret that you will be unbearable.

sneekula 969 Nearly a Posting Maven

Using the wx.ToggleButton to play with wxPython's colours:

# testing the wxPython widgets ...
# wx.ToggleButton(parent, id, label, pos, size, style)
# wx.Dialog(parent, id, title, pos, size, style)
# note: id wx.ID_ANY is the same as -1
# also: if a button stays toggled the colours will mix

import wx

class MyDialog(wx.Dialog):
    def __init__(self, parent, mytitle):
        # use a simple dialog box rather than a frame
        wx.Dialog.__init__(self, parent, wx.ID_ANY, mytitle, 
            size=(300, 200))

        # wx.Colour(red, green, blue, alpha=wx.ALPHA_OPAQUE)
        # r, g, or b colour intensity can be 0 to 255
        self.colour = wx.Colour(0, 0, 0)  # black
        #print str(self.colour)  # (0, 0, 0, 255)

        tb1 = wx.ToggleButton(self, wx.ID_ANY, 'red', pos=(20, 20))
        tb2 = wx.ToggleButton(self, wx.ID_ANY, 'green', pos=(20, 60))
        tb3 = wx.ToggleButton(self, wx.ID_ANY, 'blue', pos=(20, 100))

        self.panel  = wx.Panel(self, wx.ID_ANY, pos=(150, 20), 
            size=(110, 110), style=wx.SUNKEN_BORDER)
        self.panel.SetBackgroundColour('black')

        self.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleRed, tb1)
        self.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleGreen, tb2)
        self.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleBlue, tb3)
        
        # create a label to show result
        self.label = wx.StaticText(self, wx.ID_ANY, "click a button",
            pos=(20, 140))

        self.Centre()
        self.ShowModal()
        self.Destroy()

    def ToggleRed(self, event):
        green = self.colour.Green()
        blue = self.colour.Blue()
        if  self.colour.Red():
            self.colour.Set(0, green, blue)
        else:
            self.colour.Set(255, green, blue)
        self.panel.SetBackgroundColour(self.colour)
        # clear old colour, set to new colour
        self.panel.ClearBackground()
        s = self.colour.GetAsString()
        self.label.SetLabel(s)

    def ToggleGreen(self, event):
        red = self.colour.Red()
        blue = self.colour.Blue()
        if  self.colour.Green():
            self.colour.Set(red, 0, blue)
        else:
            self.colour.Set(red, 255, blue)
        self.panel.SetBackgroundColour(self.colour)
        self.panel.ClearBackground()
        s = self.colour.GetAsString()
        self.label.SetLabel(s)

    def ToggleBlue(self, event):
        red = self.colour.Red()
        green = self.colour.Green()
        if  self.colour.Blue():
            self.colour.Set(red, green, 0)
        else:
            self.colour.Set(red, green, 255)
        self.panel.SetBackgroundColour(self.colour)
        self.panel.ClearBackground()
        s = self.colour.GetAsString()
        self.label.SetLabel(s)


app = wx.App(0)
MyDialog(None, 'wx.ToggleButton()')
app.MainLoop()

Also …

sneekula 969 Nearly a Posting Maven

It's a recession when your neighbour loses his job; it's a depression when you lose yours.
~~~ Harry S. Truman

sneekula 969 Nearly a Posting Maven

Did you hear about the welfare doll?

You wind it up and it doesn't work.

R0bb0b commented: LOL :) +2
sneekula 969 Nearly a Posting Maven

The word GOLF entered into the English language from the sport's rules originally used in Scotland:
"Gentlemen Only Ladies Forbidden"

sneekula 969 Nearly a Posting Maven

Oh the pain of "gorilla arm", looks like the medical profession will rake in the money more than ever.

Microsoft has to copy someone elses idea, this time it's the iPhone?

sneekula 969 Nearly a Posting Maven

Rosemary Potato Bread with Swiss Cheese and a mug of extra dark hot chocolate.

sneekula 969 Nearly a Posting Maven

Can barely wait till the VPs are announced!

Obama says he picked his running mate, but won't make it public until Saturday.

sneekula 969 Nearly a Posting Maven

Trilithium resin is a by-product of exposing dilithium to a matter/antimatter reaction in a warp core. -- Scottie

Mr. Scott tells everyone, “I did some research while I was waiting onboard the Enterprise. The main city on this planet is Bloop. They’re going to start powering it by using trilithium crystals. Not suitable for use on starships, the way dilithium is. Much too hazardous. Very powerful though. One crystal can power the entire city. That must be why the Klingons want it.”

sneekula 969 Nearly a Posting Maven

A Boeing 747s wingspan is longer than the Wright brother's first flight. Just in case you are dying to know that, the 747 jet uses 4,000 gallons of fuel to take off.

sneekula 969 Nearly a Posting Maven

Do you know the problem with lawyer jokes?

Lawyers don't think they're funny, and the rest of us don't think they're jokes!

sneekula 969 Nearly a Posting Maven

" Your morning thoughts may determine your conduct for the day. Optimistic thoughts will make your day bright and productive, while pessimistic thinking will make it dull and wasteful. Face each day cheerfully, smilingly and courageously, and it will naturally follow that your work will be a real pleasure and progress will be a delightful accomplishment."

Oh sweet Jesus, if the world would only be that simple!