易截截图软件、单文件、免安装、纯绿色、仅160KB

python 练手


可以播放大部分的音视频.
demo download:  http://www.sandy1219.com/python/media.rar
playMP3.py
# -*- coding: utf-8 -*-
import wx;
import wx.media;
import os;
import SPrint;
import mediaStateBar;
import mediaList;
import SaveLog;
import MediaItem;
woldcart = "media files|*.*|avi|*.avi|rmvb|*.rmvb|rm|*.rm|wma|*.wma|mp3|*.mp3";
class MediaFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,wx.NewId(),u"媒体播放器",pos=wx.DefaultPosition,size=(500,500));
self.media = '';
try:
self.media = wx.media.MediaCtrl(self,style=wx.SIMPLE_BORDER,
#szBackend=wx.media.MEDIABACKEND_DIRECTSHOW
#szBackend=wx.media.MEDIABACKEND_QUICKTIME
#szBackend=wx.media.MEDIABACKEND_WMP10
);
self.media.Bind(wx.media.EVT_MEDIA_LOADED,self.mediaLoaded);
self.media.Bind(wx.media.EVT_MEDIA_STATECHANGED,self.mediaStateChange)
except NotImplementedError:
self.Destroy()
raise;
self.listView = '';
self.item = MediaItem.MediaItem();
self.sb = mediaStateBar.MediaStateBar(self);
self.SetStatusBar(self.sb);
self.log = SaveLog.SaveLog();
#self.log.test();
self.menu = wx.Menu()
self.openMenu = self.menu.Append(wx.NewId(),u"打开文件");
self.Bind(wx.EVT_MENU,self._openFile,self.openMenu);
self.quitMenu = self.menu.Append(wx.NewId(),u"退出");
self.Bind(wx.EVT_MENU,self.quit,self.quitMenu);
self.viewMenu = wx.Menu();
self.listMenu = self.viewMenu.Append(wx.NewId(),u"打开播放列表");
self.Bind(wx.EVT_MENU,self.openList,self.listMenu);
self.loadListMenu = self.viewMenu.Append(wx.NewId(),u"加载播放列表");


相关文档:

Python:FriendFeed的Tornado Web Server

代码很简单,不到5k行。但是思路挺好的,改成non-blocking了之后效率就是能提高不少,特别是考虑到现代的web app都需要和其他的
HTTP服务器通信,blocking的代价太大了。 Tornado is an open source version of the scalable, non-blocking web server and tools that power FriendFeed. The FriendFeed application ......

Python入门的36个例子 之 23

源代码下载:下载地址在这里
# 026
aList = ['1','2','3','4']
aListCopy = aList # 其实,这里仅仅复制了一个引用
del aList[0]
print aList
print aListCopy # 两个引用指向了了同一个对象,所以打印结果一样
aListCopy = aList[:] # 这是复制整个对象的有效方法
del aList[0]
print aList
print aListCopy
......

Python入门的36个例子 之 24

# 027
toolName = 'Google'
if toolName.startswith('Go'):
print 'The tool\'s name starts with \"Go\".'
if 'oo' in toolName:
print 'The tool\'s name contains the stirng "oo".'
print toolName.find('gl') # 返回首次出现“gl”字符串的索引
if toolName.find('Baidu ......

Python入门的36个例子 之 29

源代码下载:下载地址在这里
# 033
class Person:
age = 22
def sayHello(self): # 方法与函数的区别在于需要一个self参数
print 'Hello!'
# end of def
# end of class # 这是我良好的编程风格
p = Person()
print p.age
p.sayHello()

output:
22
Hello! ......

Python入门的36个例子 之 36

# 040
import time
try:
f = file('040_Finally.py')
while True:
line = f.readline()
if len(line) == 0:
break
time.sleep(0.33)
print line,
# end of while
finally:
f.close()
print 'Closed the file.'
# end of try
output:
> ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号