python tips

1) sizer.Layout()
[wxPython]
After adding window to or removing window from sizer, Layout() can help to recalculate the children's layout. (Sometimes auto recalculation takes no effect.) Another function to be payed attention to is sizer.Fit(), which will recalculate the children's layout according to their minimal size.

2)os.path.join()
[python]
os.path.join() helps to join paths when manipulating files or directories. It's operation system independent. It will determine the path separator automatically. os.sep is '//' in windows operating system, and it is '/' in UNIX operating systems.

3)unicode(), str.encode()
[python]
unicode() return the unicode str represented object.
str.encode() encode the str using specified encodeing type.
result=unicode(result,'utf-8')
content=content.encode('utf_8')

4)wx.calender.CalendarCtrl.setAttr(day, attr)
[wxPython]
The input param of setAttr() is an attr object. The object cannot be reused. Once it is set to some day, it cannot be set to other days. A new attr object is needed for a new day.

5)save wx.Font object
[wxPython]
wx.Font object cannot be serialized using cPickle module. It can be serialized according to it's constructor method. Through saving the properties of wx.Font object, we saves the wx.Font object. The properties are followd:
font_pointSize 
font_family  
font_style  
font_weight  
font_underline 
font_face     
font_encoding 

 

6)get the path where the running script locates

def getScriptPath():
    return os.path.dirname(__file__)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值