在程序中使用配置文件来灵活的配置一些参数是一件很常见的事情,配置文件的解析并不复杂,在python里更是如此,在官方发布的库中就包含有做这件事情的库,那就是ConfigParser,这里简单的做一些介绍。
ConfigParser解析的配置文件的格式比较象ini的配置文件格式,就是文件中由多个section构成,每个section下又有多个配置项,比如:
[db]
db_host=127.0.0.1
db_port=3306
db_user=root
db_pass=password
[concurrent]
thread=10
processor=20
假设上面的配置文件的名字为test.conf。里面包含两个section,一个是db, 另一个是concurrent, db里面还包含有4项,concurrent里面有两项。这里来做做解析:
ConfigParser解析的配置文件的格式比较象ini的配置文件格式,就是文件中由多个section构成,每个section下又有多个配置项,比如:
引用
[db]
db_host=127.0.0.1
db_port=3306
db_user=root
db_pass=password
[concurrent]
thread=10
processor=20
假设上面的配置文件的名字为test.conf。里面包含两个section,一个是db, 另一个是concurrent, db里面还包含有4项,concurrent里面有两项。这里来做做解析:
Hyperlinks
AppSnap displays the website of an application amongst other details. It would be ideal to open the link in the default browser when clicked. Luckily for us, wxPython has a widget just for this.
Let’s create a hyperlink:
# Create hyperlink on an existing panel widget
link = wx.lib.hyperlink.HyperLinkCtrl(parent=panel, pos=(225, 60))
For starters, let’s initialize the link.
# Initialize the hyperlink
link.SetURL(URL=”)
link.SetLabel(label=”)
link.SetToolTipString(tip=”)
AppSnap displays the website of an application amongst other details. It would be ideal to open the link in the default browser when clicked. Luckily for us, wxPython has a widget just for this.
Let’s create a hyperlink:
# Create hyperlink on an existing panel widget
link = wx.lib.hyperlink.HyperLinkCtrl(parent=panel, pos=(225, 60))
For starters, let’s initialize the link.
# Initialize the hyperlink
link.SetURL(URL=”)
link.SetLabel(label=”)
link.SetToolTipString(tip=”)