Tuesday, April 29, 2008

A powerful Python Graph lib

In recnet days,I want to add some chart in my application,for example,financial report chart.so I shearch many python chart lib,such as pygooglechart,Flashchart,Matplotlib.In the end,I found matplotlib is what I want,it's a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. and it's power full,also it's docuemnt and example is very readable and exhaustive,so I decided to use it in my project.

Some screenshot:

Insomnia

When the night falls,but I can't sleep.I sit in front of the desktop and write something:) Wait, in the earlier my wife said she feels earth quake,but I don't.Wow...what's happening.Now she's in deep sleeping,what is she dreaming.
Oh,I can't sleep.Why not write some code?
class man:
def insomnia(self):
self.head="ache"
self.lateforwork=True
def sleep(self):
print "go to bed"
while self.tired==True:
print "turn off the light"
print "Zzzzz..."
else:
print "read book"

Monday, April 28, 2008

zip() function,What does that mean and how to use it?

Some time we have the requirement like this,get the element from two lists and print(or process ) them in sequence.For example,we have two list [1,2,3] and [4,5,6] , and we want to implement like build a new list[5,7,9]( [(1+4),(2+5),(3+6)]).how to do it.At before time.we can use the function map():
a=[1,2,3]
b=[4,5,6]
c=[]
for x in map(None,a,b):
c.append(x[0]+x[1])

but it's not a good solution,especially that None argument:)
Now,we have another better choose.zip() function.What's it means?
zip() function will return a list of tuples, where each tuple contains the i-th element from each of the argument sequences. The returned list is truncated in length to the length of the shortest argument sequence.

for example:
a=[1,2,3]
b=[4,5,6]
c=[]
for i in zip(a,b):
c.append(x[0]+x[1])

it's better understand,isn't it?

Sunday, April 27, 2008

A beautiful song from JAY

I love this song.and this vido is really cool,look at its beautiful picture.Wow....

Thursday, April 24, 2008

My new T-Shirt "Tibet is a part of China"

It's cool,isn't it?

A windy day

Today is a windy day in Beijing.I prepare to ride my bike,but the wind is too heavy.What a day,I think.At the last I go to work by bus.I think I'll late.but guess what?I got to work in time.Fantastic!

Wednesday, April 23, 2008

JavaScript menu.show menu between different frame.

Today, I need implement a prototype for our customer.In this implement we need a menu.I put the code here:

main.html

<html>
<head>
<title>different frame menu from MSDN</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<frameset rows="92,*" cols="*" framespacing="4" frameborder="yes" border="4">
<frame src="top.htm" name="topFrame" scrolling="NO" >
<frame src="bottom.htm" name="mainFrame" id="mainFrame">
</frameset>
<noframes><body>

</body></noframes>
</html>

top.htm

<html>
<head>
<title>MSDN example</title>
<script>
var oPopup = window.createPopup();
function richContext()
{
var lefter2 = event.offsetY+0;
var topper2 = event.offsetX+15;
oPopup.document.body.innerHTML = oContext2.innerHTML;
oPopup.show(0, 15, 210, 84, contextobox);
}
</script>
</head>
<body>

asdasd
<span id="contextobox" style=" cursor:hand; margin-left:5px; margin-right:10px; background:#e4e4e4; width:300; height:40; padding:20px;" onmouseover="richContext(); return false" >Right-click inside this box.</span>

<DIV ID="oContext2" STYLE="display:none">
<DIV STYLE="position:relative; top:0; left:0; border:2px solid black; border-top:2px solid #cccccc; border-left:2px solid #cccccc; background:#666666; height:110px; width:207px;">
<DIV STYLE="position:relative; top:0; left:0; background:#cccccc; border:1px solid black; border-top: 1px solid white; border-left:1px solid white; height:20px; color:black; font-family:verdana; font-weight:bold; padding:2px; padding-left:10px; font-size:8pt; cursor:hand" onmouseover="this.style.background='#ffffff'" onmouseout="this.style.background='#cccccc'" onclick="parent.parent.mainFrame.location.href='http://www.microsoft.com';">
   Home</DIV>
<DIV STYLE="position:relative; top:0; left:0; background:#cccccc; border:1px solid black; border-top: 1px solid white; border-left:1px solid white; height:20px; color:black; font-family:verdana; font-weight:bold; padding:2px; padding-left:10px; font-size:8pt; cursor:hand" onmouseover="this.style.background='#ffffff'" onmouseout="this.style.background='#cccccc'" onclick="parent.location.href='http://search.microsoft.com';">
   Search</DIV>
<DIV STYLE="position:relative; top:0; left:0; background:#cccccc; border:1px solid black; border-top: 1px solid white; border-left:1px solid white; height:20px; color:black; font-family:verdana; font-weight:bold; padding:2px; padding-left:10px; font-size:8pt; cursor:hand" onmouseover="this.style.background='#ffffff'" onmouseout="this.style.background='#cccccc'" onclick="parent.location.href='http://www.microsoft.com/ie';">
   Intenet Explorer</DIV>
<DIV STYLE="position:relative; top:0; left:0; background:#cccccc; border:1px solid black; border-top: 1px solid white; border-left:1px solid white; height:20px; color:black; font-family:verdana; font-weight:bold; padding:2px; padding-left:10px; font-size:8pt; cursor:hand" onmouseover="this.style.background='#ffffff'" onmouseout="this.style.background='#cccccc'" onclick="parent.location.href='http://www.microsoft.com/info/cpyright.htm';">
?2001 Microsoft Corporation</DIV>
</DIV>

</body>
</html>

Only one thing is very import.if you want to display your page in mainFrame.you need change the onclick method.the syntax is :

parent.parent.mainFrame.location.href='http://www.microsoft.com';