To avoid the flicker, use .bmp file for your button image to reduce the palette problem (.jpg files bring in too many colors).
To avoid the flicker, use .bmp file for your button image to reduce the palette problem (.jpg files bring in too many colors).
Knowledge is power, if you know it about the right person.
- Ethel Mumford
Paint.NET (good features and you pick the price)
Open Office (beats MS Office new and old, donate if you like it)
wrar (beats winzip, pay if you like it)
alot of this stuff is becoming bull
Your opinion, not mine! My advice, don't read it, it's that simple!
The Olympic was the sister ship of the Titanic.
Python also has HTMLParser module that can help you muchly:
# extract a specified text from web page HTML source code
import urllib2
import HTMLParser
import cStringIO # acts like file in memory
class HTML2Text(HTMLParser.HTMLParser):
"""
extract text from HTML code basically using inherited
class HTMLParser and some additional custom methods
"""
def __init__(self):
HTMLParser.HTMLParser.__init__(self)
self.output = cStringIO.StringIO()
def get_text(self):
"""get the text output"""
return self.output.getvalue()
def handle_starttag(self, tag, attrs):
"""handle <br> tags"""
if tag == 'br':
# need to put one new line in
self.output.write('\n')
def handle_data(self, data):
"""normal text"""
self.output.write(data)
def handle_endtag(self, tag):
if tag == 'p':
# end of paragraph add newline
self.output.write('\n')
def extract(html, sub1, sub2):
"""
extract string from text between first
occurances of substrings sub1 and sub2
"""
return html.split(sub1, 1)[-1].split(sub2, 1)[0]
# you may need to update this web page for your needs
url = 'http://www.bom.gov.au/products/IDN10060.shtml#HUN'
# get the raw HTML code
try:
file_handle = urllib2.urlopen(url)
html1 = file_handle.read()
file_handle.close()
print '-'*70
print 'Data from URL =', url
except IOError:
print 'Cannot open URL %s for reading' % url
html1 = 'error!'
#print '-'*70; print html1 # testing
# extract code between sub1 and sub2
# you may need to update sub1 and sub2 for your needs
sub1 = 'www.bom.gov.au/weather/nsw</a></P><P>'
sub2 = 'The next routine forecast'
html2 = extract(html1, sub1, sub2)
#print '-'*70; print html2 # testing
# remove HTML tags to give clean text
p = HTML2Text()
p.feed(html2)
text = p.get_text()
print '-'*70
print text
print '-'*70
You can …
There are many icon libraries on the internet, for instance:
http://www.aha-soft.com/iconlibs.htm
They have a fair number of free ones to download.
HI
I was having a look into classes and i noticed i saw a lot of things likeclass fruitcake(object): pass
my question is what is the point of the "object" being in the class arguments as it is a Built In Function and i couldn't work out what putting it there did
Class object is the base class that is at the top of any inheritance tree. It designates the new style Python class (Python24 and higher) having some additional feautures like __slots__ which prevents new variable creation outside the class. __slots__ also replaces the usual __dict__ in the class to give speed improvement.
To show it's methods use:
print dir(object)
Also, do not use 'object' for variable name.
http://atheism.about.com/od/isatheismdangerous/a/AtheismKilled.htm
Errors on the page! Divine intervention?
Maybe this earth is another planet's hell.
In the USA people love their guns, so they will probably vote for the candidate that is willing to use a gun.
There was this blonde driving down the road. She glanced to her right and noticed another blonde sitting in the nearby field, rowing her boat with no water in sight.
The blonde angrily pulled her car over and yelled at the rowing blonde, "What do you think you're doing? It's things like this that give us blondes very bad name. If I could swim, I'd come out there and kick your behind!"
Anyone know good drug that fights senility? One of the presidential candidates is interested in cutting back his senior moments.
Although the brain accounts for less than 2% of one person's weight, it consumes 20% of the body's energy.
Moral: "Don't waste this energy!
Some editors like DrPython, UliPad, PyScripter, IDLE have internal output window that will stay open without the use of console wait line like raw_input("Press <Enter> to exit.")
Actually Snee made mistake in his code. Do not write your additional code in the __init__ctrls() method, boa tells you not to edit this part. If you do, the Frame Designer frowns on it, if you want to use it later to add additional widgets. So in the frame designer Evts tab pick FrameEvent and then wx.EVT_ACTIVATE to create the OnFrame1Activate() method. This is where your additional code goes. Here is the modified code:
#Boa:Frame:Frame1
import wx
import wx.grid
def create(parent):
return Frame1(parent)
[wxID_FRAME1, wxID_FRAME1GRID1,
] = [wx.NewId() for _init_ctrls in range(2)]
class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(366, 256), size=wx.Size(400, 250),
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
self.SetClientSize(wx.Size(384, 214))
self.Bind(wx.EVT_ACTIVATE, self.OnFrame1Activate)
self.grid1 = wx.grid.Grid(id=wxID_FRAME1GRID1, name='grid1',
parent=self, pos=wx.Point(0, 0), size=wx.Size(384, 214), style=0)
self.grid1.Center(wx.VERTICAL)
def __init__(self, parent):
self._init_ctrls(parent)
def OnFrame1Activate(self, event):
# under events pick FrameEvent and then wx.EVT_ACTIVATE
# now you can add your own code here and still have the use
# of BOA's Frame Designer
#
# give grid 8 rows and 5 columns
self.grid1.CreateGrid(8, 5)
# you can als add some simple cell formatting
self.grid1.SetColSize(3, 200)
self.grid1.SetRowSize(0, 25)
self.grid1.SetCellValue(0, 0, "First cell")
self.grid1.SetCellValue(1, 1, "Another cell")
self.grid1.SetCellValue(2, 2, "Yet another cell")
self.grid1.SetCellValue(3, 3, "This cell is read-only")
self.grid1.SetCellFont(0, 0, wx.Font(12, wx.ROMAN, wx.ITALIC, wx.NORMAL))
self.grid1.SetCellTextColour(1, 1, wx.RED)
self.grid1.SetCellBackgroundColour(2, 2, wx.CYAN)
self.grid1.SetReadOnly(3, 3, True)
if __name__ == '__main__':
# use 'Add module runner' in the Edit menu
# this gives you single source file code
app = wx.PySimpleApp()
frame = create(None)
frame.Show()
app.MainLoop()
I don't know about the rest of you, but I found the comments to this blog post quite entertaining.
One of the comments was peculiar strange:
4) Stop the EPA from allowing fuel efficient autos into the US.
That was from a Mad TV ad for 7-up, the front of the t-shirt said 'Make 7' and the back read 'up yours' - the dude could not figure out why everyone was throwing stuff at him.
An I was responding to someone's .sig that ended with 'up yours' - look back a post or 2
Very funny!
Writing your print statement to file:
# open/create text file for writing in main()
fout = open( "test1.txt", "w" ) # may need "a" for append
# in your program under this line
# print '\tn: %d, sort time: %f' % (n, dt)
# add this line
print >>fout, '\tn: %d, sort time: %f' % (n, dt)
# you may have to make 'fout' global or better pass
# it to your function as argument
You can also use Python's module profile:
import profile
def get_primes3(n):
if n < 2: return []
if n == 2: return [2]
nums = range(3, n, 2)
idx = 0
while idx <= (n - 1)**0.5 - 2:
for j in xrange( idx + nums[idx], n//2 - 1, nums[idx] ):
# replace nonprime with zero (False)
nums[j] = 0
idx += 1
while idx < n - 2:
if nums[idx] != 0:
break
idx += 1
# remove all zero items
return [2] + [x for x in nums if x != 0]
profile.run('get_primes3(15000)')
"""
result of profile.run
5 function calls in 0.004 CPU seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 :0(range)
1 0.000 0.000 0.000 0.000 :0(setprofile)
1 0.003 0.003 0.004 0.004 <module3>:3(get_primes3)
1 0.000 0.000 0.004 0.004 <string>:1(?)
1 0.000 0.000 0.004 0.004 profile:0(get_primes3(15000))
0 0.000 0.000 profile:0(profiler)
"""
The state has no business in the bedrooms of the nation.
(Pierre Elliott Trudeau, Canada)
Due to slight mistranslation, Revelation 13:18 is usually written as "the number of the beast ... is 666", instead of the correct "... is 6 by 6 by 6." Hence, the number of the beast is actually 216, not 666.
my post count is only 10 a day but its lately like 50+
So I noticed!
Sharing money is what gives it its value.
-- Elvis Presley
I do not agree with a word that you say, but I will defend to the death your right to say it.
(Voltaire aka François-Marie Arouet)
Why dont MS release a workstation version of server 2008? its basically what vista should have been in the first place
It's all in marketing! It's what you get when you have one of those marketing guys in charge. Sort of what happened to the US auto industry (more chrome, more chrome) before the Japanese came in.
I agree, whoever gets to 20,000 posts first should get the immensely coveted "Fickle Finger of Fate" award.
Yeah everyone always takes the mickey out of him lol.
and yeah, we need homes. House prices in the UK are sky high and people cant afford to buy them. However, theres simply not that much room (loads have been built in areas which flood)
Is he talking about houses people can buy? Or are they just some cheap cement caves that people can move into with minimum rent. The later does not make for very nice community to live in. I think that's what they tried in the US, and not even the police was brave enough to come and stop the rampant crime.
ignore post
I ignored it, so what now?
The EU is pretty much like the UN, one good idea at first, but then the beggar countries are taking over.
One positive note on the EU, it has so far prevented another war in Europe.
Dear Dad,
$chool i$ really great. I am making lot$ of friend$ and $tudying very hard. With all my $tuff, I $imply can`t think of anything I need. $o if you would like, you can ju$t $end me a card, a$ I would love to hear from you.
Love,
Your $on
The Reply:
Dear Son,
I kNOw that astroNOmy, ecoNOmics, and oceaNOgraphy are eNOugh to keep even an hoNOr student busy. Do NOt forget that the pursuit of kNOwledge is a NOble task, and you can never study eNOugh.
Love,
Dad
Ubuntu seems to be one ugly beast, I have heard other poeple complain about it, particularly Python programmers.
When I grow up I would love to look like Rodney Dangerfield. He made tons of money with his astonishingly good looks.
Rodney is one wonderful man, but when I grow up I rather want to look like actor Jean-Claude Van Damme. He has muscles like Arnold Schwarze... , but he is also very smart.
No great genius has ever existed without some touch of madness.
More haplographic errors occur with the letters "rr" than with the letters "aa", "ee", "ii", "oo", and "uu" combined.
historically it was the other way around as loads of wemen died in childbirth
On the other hand, lots of young men died as they were sent off to war.
lol techbound at least you tried ! Its a Fuchikoma from Ghost In The Shell, its pretty cool eh ?
The best avatar I have seen so far!
Of course. There are paybacks.
Good lord: Hillary requests $2.3 billion in earmarks
Is an earmark something like an earring?
I heard the iPhone has a replacement for that.
Wiping yourself with the iPhone? Isn't that rather unsanitary?
War is simply too dirty for gay people.
I just came back from donating to my city's composting effort. I feel good about that!
If people from Poland are called Poles, why aren't people from Holland called Holes?
One way to do this is to have your running application update shared datafile that can than be read from your Python program.
It would be very nice if you would use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help.
[code=python]
your Python code here
[/code]
Sky diving, ski jumping, car racing, target shooting, sailing, romance.
Boys usually grow at least as tall as their mothers.
Variable myFile is just file handle, what do you expect join() would do to it?
My God, that Python version must be at least 10 years old. I don't think pyTTS was out then.
jwenting - you spew the most amazing, er 'stuff'. George W. Bush was a draft dodger who got into the Guard thru political influence. While in the guard, he essentially went AWOL and was not seen by his commander for over a year.
To be honest, I don't 'hate' much and don't like personal attacks but I enjoy a good discussion. Unfortunately, I don't get much from you but 'stuff' -- I will keep trying.
Hey Grim, don't waste your time with this fellow! We all kow he invents 'stuff' to make himself look important.
That handy round roll of paper is indispensable! I have not seen any software to replace it properly.