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__)

你可能感兴趣的:(object,properties,python,layout,Constructor,wxPython)