sneekula 969 Nearly a Posting Maven

The owner of a drug store walks in to find a guy leaning heavily against a wall. The owner asks the clerk, "What's with that guy over there by the wall?"

The clerk says, "Well, he came in here this morning to get something for his cough. I couldn't find the cough syrup, so I gave him an entire bottle of laxative."

The owner says, "You idiot! You can't treat a cough with laxatives!"

The clerk says, "Oh yeah? Look at him, he's afraid to cough!"

sneekula 969 Nearly a Posting Maven

Judging from the steep increase in the price of milk, US dairy cows have joined OPEC.

sneekula 969 Nearly a Posting Maven

Just on the news, a Florida couple has spotted the image of Jesus in the image of the Virgin Mary that had gradually appeared in their worn out bathmat.

sneekula 969 Nearly a Posting Maven

They say marriages are made in Heaven. But so is thunder and lightning.
~~ Clint Eastwood

Rashakil Fol commented: I believe you've already posted your favorite quote in this thread. -1
sneekula 969 Nearly a Posting Maven

Whether or not we can be ever fully safe is up -- you know, is up in the air.
--George W. Bush (10/27/2004 interview with Sean Hannity)

sneekula 969 Nearly a Posting Maven

Ronald Reagan for president!
He's a better president dead than either of the current candidates will ever be alive.

God bless you! Let's vote for the Gipper then!

sneekula 969 Nearly a Posting Maven

What came first, the fruit or the color orange?

And God said onto himself on day six, "I shall maketh this fruit and color it orange!"

sneekula 969 Nearly a Posting Maven

Are Space and Time related, since both have no end?

sneekula 969 Nearly a Posting Maven

If you would write range() in Python you would have to do something like this:

def range(start, stop=None, step=1):
    """if start is missing it defaults to zero, somewhat tricky"""
    if stop == None:
        stop = start
        start = 0
    # rest of the code here ...
sneekula 969 Nearly a Posting Maven

The US now spends more on its military then the rest of the world combined. I hope the new leadership comes to its senses. After all it was Ike (Eisenhower) that warned us about the military-industrial complex getting out of hand!

sneekula 969 Nearly a Posting Maven

When you make matriz global to the class it just keeps appending to it. Change your code this way:

# Square matrix

import random

class Matriz:
	"""Math operations with matrixes"""

	#matriz = []  # don't make this global!!!!
	grau_matriz = 0;

	def __init__ (self, grau_matriz, inicio):

		self.grau_matriz = grau_matriz

		#Decides if array will be populated with 0's or random numbers
		if inicio == 0:
			self.zero()
		elif inicio == 1:
			self.aleatoria()

	def zero(self):
		"""This method generates a N X N array with zeroes"""
		self.matriz = []
		for i in range(self.grau_matriz):
			linha = []
			for j in range(self.grau_matriz):
				linha.append(0)

			self.matriz.append(linha)

	def aleatoria(self):
		"""This method generates a N X N array with random values"""
		self.matriz = []
		for i in range(self.grau_matriz):
			linha = []
			for j in range(self.grau_matriz):
				linha.append(random.randrange( 1, 10 ))

			self.matriz.append(linha)

	def show(self):

		"""This method prints the array as an N x N format"""

		for i in range(self.grau_matriz):
			for j in range(self.grau_matriz):
				print "%2d " % self.matriz[i][j],
			print

		print


# test it ...
if __name__ == '__main__':
    matrix_a = Matriz(3,1)
    matrix_b = Matriz(3,0)
    matrix_c = Matriz(3,1)

    matrix_a.show()
    print
    matrix_b.show()
    print
    matrix_c.show()
sneekula 969 Nearly a Posting Maven

This code sample shows you how to add an about message box to your wxPython program:

# wxPython Frame with menu, statusbar, and about dialog

import wx

class MyFrame(wx.Frame):
    """
    create a frame, with menu, statusbar and about dialog
    inherits wx.Frame
    """
    def __init__(self):
        # create a frame/window, no parent, default to wxID_ANY
        wx.Frame.__init__(self, None, wx.ID_ANY, 'About (click File)',
            pos=(300, 150), size=(300, 350))

        # create a status bar at the bottom
        self.CreateStatusBar()
        self.SetStatusText("This is the statusbar")

        menu = wx.Menu()
        # the optional & allows you to use alt/a
        # the last string argument shows in the status bar on mouse_over
        menu_about = menu.Append(wx.ID_ANY, "&About", "About message")
        menu.AppendSeparator()
        # the optional & allows you to use alt/x
        menu_exit = menu.Append(wx.ID_ANY, "E&xit", "Quit the program")

        # create a menu bar at the top
        menuBar = wx.MenuBar()
        # the & allows you to use alt/f
        menuBar.Append(menu, "&File")
        self.SetMenuBar(menuBar)

        # bind the menu events to an action/function/method
        self.Bind(wx.EVT_MENU, self.onMenuAbout, menu_about)
        self.Bind(wx.EVT_MENU, self.onMenuExit, menu_exit)

    def onMenuAbout(self, event):
        dlg = wx.MessageDialog(self,
            "a simple application using wxFrame, wxMenu\n"
            "a statusbar, and this about message.  snee",
            "About", wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()

    def onMenuExit(self, event):
        # via wx.EVT_CLOSE event
        self.Close(True)

app = wx.App(0)
# create class instance
window = MyFrame()
window.Show(True)
# start the event loop
app.MainLoop()
sneekula 969 Nearly a Posting Maven

The wxPython GUI toolkit has some interesting widgets, one of them is a complete analog clock widget. Here is an example:

# looking at the wxPython analog clock widget

import wx
from wx.lib import analogclock as ac

class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title)

        clock = ac.AnalogClockWindow(self)
        clock.SetBackgroundColour('gray')
        clock.SetHandColours('black')
        clock.SetTickColours('WHITE')
        # set hour and minute ticks
        clock.SetTickSizes(h=15, m=5)
        # set hour style
        clock.SetTickStyles(ac.TICKS_ROMAN)
        self.SetSize((400,350))


app = wx.App()
frame = MyFrame(None, wx.ID_ANY, "analogclock")
frame.Show()
app.MainLoop()
sneekula 969 Nearly a Posting Maven

On your class and Tkinter GUI code, I would recommend that you first get your feet wet on some smaller sample code. As it is now, it makes not much sense.

sneekula 969 Nearly a Posting Maven

In this case you are better off to use just Python. Actually, regular expressions aren't necessarily faster. I added plenty of comments to help you:

ts = 'xyz abc mno def'
# separate at space to create a list
space = ' '
qs = ts.split(space)

# search for these items
search_list = ['abc', 'def', 'ghi']

# append this string to search item
s = 'zzz'

# now create a new list with processed search items
new_list = []
for q in qs:
    if q in search_list:
        # concatinate strings
        q += s
    new_list.append(q)

# join the list to form the modified string
new_ts = space.join(new_list)

print new_ts  # xyz abczzz mno defzzz
sneekula 969 Nearly a Posting Maven

I streamlined your code a little:

import random

print "Enter 3 integer numbers and i'll choose 1 at random"

while True:
    a = input("first number? ")
    b = input("second number? ")
    c = input("third number? ")
    # put your numbers in a list
    nmlist = [a, b, c]

    if type(a+b+c) == int:
        print 'I picked', random.choice(nmlist)
    else:
        print "Please enter integers only!"
    choice = raw_input("Press Enter to keep going, or enter q to quit: ")
    if choice == 'q':
        break

I assumed you want to enter integers only.

sneekula 969 Nearly a Posting Maven

True friends are the once you can call up at three in the morning.

sneekula 969 Nearly a Posting Maven

Acoording to the Detroit News once mighty General Motors Market Value (outstanding stocks * stock price) now is less then Toyota's profits of last year.

sneekula 969 Nearly a Posting Maven

In a recent survey of American office workers, the most joyful part of their day is the radio morning show on their drive into work.

sneekula 969 Nearly a Posting Maven

There are other terms, but for simplicity (much like lumping me in with neocons or such) popular generalizations are sometimes used. And, opinions vary.

Why do you always link to some outlandish blogger? Don't you have a mind of your own?

Dave Sinkula commented: Yes, of course. I just point where I care to rather than rehash better-worded material. Why do you post tripe with no substance? -3
sneekula 969 Nearly a Posting Maven

Talking to my physics professors and fellow students, lithium ion battery electric cars or compressed air powered cars are much more feasible than hydrogen cars. They use electricity more directly.

Hydrogen fuel is a convenient buzzword for politicos. An easy thing to sell to an uneducated public. Oh, we have plenty of hydrogen! Many of them confuse it with water.

Hydrogen fuel cells have been around for a long time, not much innovation there! The innovation will have to be in the storage of hydrogen gas and there are all sorts of physical limitations. Actually, the nickel hydride rechargables used by the present hybrid cars are a modification of the hydrogen fuel cell, but nickel is just too heavy to be practicable for hydrogen storage. Also, any of this technology has a limited lifetime since the nickel gets inactive with use. When you drive a hybrid car get used to shelling out 3-5k for a replacement battery every 3 years.

One way around the hydrogen gas storage would be to generate hydrogen in the vehicle by reacting calcium hydride pellets with water in a controlled manner. However, making calcium hydride needs some pretty fancy equipment.

sneekula 969 Nearly a Posting Maven

Vista is a bitch isn't it? If I get a chance, I will try it on my friends Vista box.

sneekula 969 Nearly a Posting Maven

The frog known as the Poison-Arrow has enough poison on his body to kill up to 2000 people.

sneekula 969 Nearly a Posting Maven

Do Roman paramedics refer to IV's as "4's"?

sneekula 969 Nearly a Posting Maven

Use wx.DisplaySize(), it gives width, height tuple of the display screen

sneekula 969 Nearly a Posting Maven

Fighting for peace is like screwing for virginity.

sneekula 969 Nearly a Posting Maven

A question that defeats the purpose:
"Where's the self-help section?"

sneekula 969 Nearly a Posting Maven

The common snail crawls about 2.5 meters an hour.

sneekula 969 Nearly a Posting Maven

The latest news release mentions Mexico and South and Central Florida as the source of the Salmonella Saintpaul tainted tomatoes. These areas are also the main producers of tomatoes this time of the season. The bacteria could come from insect or bird feces.

The problem with tomatoes is that Salmonella actually penetrates the skin and can't be washed off. So if you eat a raw tomato, you can get the intestinal revenge!

I doubt that the Iranians did it.

sneekula 969 Nearly a Posting Maven

To be a leader you should be well educated.

sneekula 969 Nearly a Posting Maven

I find that PyScripter is more ornary with errors on Widows Vista than it is on Windows XP. Might be the OS that causes the problem.

Look at the popup window title when it it is forced to shut down under Vista! It is an OS window not a PyScripter window.

sneekula 969 Nearly a Posting Maven

The war between England and Zanzibar in 1896 was the shortest war ever.

sneekula 969 Nearly a Posting Maven

If John McCain starts smiling a lot at times when he really isn't supposed to, a Ron Paul (M.D.) and Bob Barr ticket might be the alternative for the GOP.

sneekula 969 Nearly a Posting Maven

err why dont you use just use a bit of simple logic and search it on google??if you dont believe me theres nothing i can do...its just your stupidity

Google is just a search engine, it does not verify its collection of data. So there is a huge amount of hogwash you can find there.

Salem commented: "It didn't work, I can't believe it didn't work! I found it on the Internet!" - Adam Savage, Mythbuster +17
sneekula 969 Nearly a Posting Maven

US tap water east of the Mississippi is unsuitable for home brewing beer because of its low alkaline content.

sneekula 969 Nearly a Posting Maven

There is a little IDE called PyPE that allows you to run selected code in the shell. It has its own more advanced shell window.

sneekula 969 Nearly a Posting Maven

Sure thing! Glad you liked it.

I'll clean it up tomorrow (or soonish) as there are a few errors and typos, as well as elaborate on some points (such as using multiple horizontal box sizers for more complex widget positioning). I'm also teaching myself about some other widgets, so I'll add them if I feel they could do with explaining.

The best way to learn is to teach a subject. I have enjoyed your presentation of wxPython too.

Compared to Tkinter, wxPython's power is in its clever widgets, a more pythonic approach.

sneekula 969 Nearly a Posting Maven

The Python function eval() will take a string and try to evaluate/interpret it.

BTW, the PyScripter IDE allows you to interpret your source code without having to create an official file. I hate the Python shell, it's okay for one liners only!

If I were stranded on an island and were only allowed one Python GU toolkit, I would take wxPython. Actually, Fuse left a real nice introduction to wxPython programming here:
http://www.daniweb.com/forums/post621707-8.html

sneekula 969 Nearly a Posting Maven

First, welcome to the forum!

What 'slate' is really telling you is that input() is for numbers and raw_input() is for strings. Using input() has certain risks since you can also enter a command and it will excute it.

Anyway, if you want to use
op = input(">")
then op will not be a string
and you have to use this if statement
if op == 1:

In the matter of fact, input() allows you to create this very simple calculator, since it evaluates mathematical expressions directly:

print "At the >> prompt enter x op y"
print "where x and y are numbers and op is"
print "-  +  /  *  **  //  for instance 12 * 9"
result = input(">> ")
print "result =", result
sneekula 969 Nearly a Posting Maven

I made a patty using steamed lentils, fried it to make a delicious veggie burger. Washed it all down with a tall glass of TJ Bavarian Hefeweizen beer.

sneekula 969 Nearly a Posting Maven

Women were banned by royal decree from using hotel swimming pools in Jidda, Saudi Arabia, in 1979.
...

There is a good reason these folks hide their women under lots of robes.

sneekula 969 Nearly a Posting Maven

Top 10 reasons conservatives dislike McCain

WASHINGTON — While Republican John McCain is urging his conservative critics to rally around his presidential campaign, there is a lot of water under that bridge.

Here are the top 10 reasons some conservatives dislike the Arizona senator:

1. Campaign finance reform. McCain tried to limit the role of money in politics with measures that, critics say, stomp on the constitutional right to free speech.

2. Immigration. McCain has been a vocal supporter of a path to citizenship for illegal immigrants, although he now says he understands the border between the U.S. and Mexico must be sealed first.

3. Tax cuts. McCain twice voted against President Bush's tax cuts, saying in 2001 they helped the wealthy at the expense of the middle class and in 2003 that there should be no tax relief until the cost of the Iraq war was known. But he now wants to extend the tax cuts.

4. Gay marriage. McCain refuses to support a constitutional amendment to ban gay marriage.

5. Stem cell research. McCain would relax restrictions on federal dollars for embryonic stem cell research, which critics consider tantamount to abortion.

6. Global warming. Among the loudest voices in Congress for aggressive action against global warming and a frequent critic of the Bush administration on the issue.

7. "Gang of 14" member. One of seven Republicans and seven Democrats who averted a Senate showdown over whether filibusters could be used against Bush judicial nominees.

8. Kerry veep. McCain …

sneekula 969 Nearly a Posting Maven

Of course that is true -- In the USA they are called senators, congressmen, and lobbyists.

Nope, they are called moneybag bankers.

techbound commented: BTW I like "No one died when Clinton lied" :) +1
sneekula 969 Nearly a Posting Maven

My father bought an exercise machine to help him lose weight. He set it up in the basement, but didn’t use it much, so he moved it to the bedroom. It gathered dust there, too, so he put it in the living room.

Weeks later I asked how it was going.

He said. “I do get more exercise now. Every time I close the drapes, I have to walk around the darn machine.”

sneekula 969 Nearly a Posting Maven

Higher food prices will cure obesity.

Higher petrol prices will cure obesity.

Nick Evan commented: Haha +6
sneekula 969 Nearly a Posting Maven

Higher food prices will cure obesity.

sneekula 969 Nearly a Posting Maven

Fuse, very nice code ad explanation!
Python has a few string functions that make your code even easier. Simply use line.rstrip(). The default removes any trailing whitespace characters like '\n':

line = '0.00\t2.869e-12\t7.715e-08\t0.000e+00\t0.000e+00\n'
# remove any trailing whitspace characters (default)
line = line.rstrip()
line_list = line.split('\t')
print line_list  # ['0.00', '2.869e-12', '7.715e-08', '0.000e+00', '0.000e+00']
Fuse commented: thanks, didn't know that! +1
sneekula 969 Nearly a Posting Maven

On Windows you are looking for is a DLL called pyuno.dll. On my installation it is in:
C:\Program Files\OpenOffice.org 2.4\program\

You may have to copy that DLL into a folder mentioned in PYTHONPATH, so Python can find it, or you can start your program with:

import sys
# appends to PYTHONPATH  the location of pyuno.dll
sys.path.append(r"C:\Program Files\OpenOffice.org 2.4\program")
sneekula 969 Nearly a Posting Maven

Here is a wxPython tutorial that I have used:
http://wiki.wxpython.org/index.cgi/AnotherTutorial

sneekula 969 Nearly a Posting Maven

A freshly baked bread and Limburger cheese along with a Fat Tire Lager. Good for the soul!