Size: 156
Comment:
|
Size: 1891
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
flyaflya,喜欢写程序,玩游戏,擅长游戏开发,熟悉C++和python。目前在用pygame开发桌面游戏。 == pygame == |
flyaflya,喜欢写程序,玩游戏 邮件:http://services.nexodyne.com/email/icon/32BxjaIWXUob/DyHImL4%3D/R01haWw%3D/0/image.png = python = == 代码段 == === ini类 === 一个好用的ini类,像使用dict一样简单易用。 {{{ #!python import ConfigParser import string class IniSettings(dict): def __init__(self, filename): self.filename = filename self.__loadConfig() # Load the ini file into a dictionarie def __loadConfig(self): self.clear() cp = ConfigParser.ConfigParser() cp.read(self.filename) for sec in cp.sections(): settings={} name = string.lower(sec) for opt in cp.options(sec): settings[string.lower(opt)] = string.strip(cp.get(sec, opt)) self.__setitem__(name,settings) def reload(self): """Reload the config file""" self.settings = self.__loadConfig() def save(self): """save the config file""" inifile = open(self.filename, 'w') for group in self.keys(): inifile.write("\n["+group+"]\n") for key in self[group].keys(): inifile.write(str(key)+"="+str(self[group][key])+"\n") if __name__ == '__main__': settings = IniSettings('settings.ini') settings["t"]["tt"] = "ddd" settings.save() }}} == wxpython == === 换肤的实现 === 简单测试: attachment:skintest.jpg attachment:skintest2.jpg 说明对wxpython程序换肤是可行的,需要作进一步实验... attachment:skintest3.jpg 如果只用通用控件(不用Panel),可以实现完美换肤.... attachment:skinnewedit.jpg 对newedit进行换肤,好玩.... [[Include(pygame)]] [[Include(DesignPattern)]] == 扩展与嵌入 == ["Swig"] - 强悍的库扩展工具 |
个人介绍
flyaflya,喜欢写程序,玩游戏
邮件:http://services.nexodyne.com/email/icon/32BxjaIWXUob/DyHImL4%3D/R01haWw%3D/0/image.png
python
代码段
ini类
一个好用的ini类,像使用dict一样简单易用。
1 import ConfigParser
2 import string
3
4 class IniSettings(dict):
5 def __init__(self, filename):
6 self.filename = filename
7 self.__loadConfig()
8 # Load the ini file into a dictionarie
9 def __loadConfig(self):
10 self.clear()
11 cp = ConfigParser.ConfigParser()
12 cp.read(self.filename)
13 for sec in cp.sections():
14 settings={}
15 name = string.lower(sec)
16 for opt in cp.options(sec):
17 settings[string.lower(opt)] = string.strip(cp.get(sec, opt))
18 self.__setitem__(name,settings)
19
20 def reload(self):
21 """Reload the config file"""
22 self.settings = self.__loadConfig()
23
24 def save(self):
25 """save the config file"""
26 inifile = open(self.filename, 'w')
27 for group in self.keys():
28 inifile.write("\n["+group+"]\n")
29 for key in self[group].keys():
30 inifile.write(str(key)+"="+str(self[group][key])+"\n")
31
32
33 if __name__ == '__main__':
34 settings = IniSettings('settings.ini')
35 settings["t"]["tt"] = "ddd"
36 settings.save()
wxpython
换肤的实现
简单测试:
attachment:skintest.jpg attachment:skintest2.jpg
说明对wxpython程序换肤是可行的,需要作进一步实验...
attachment:skintest3.jpg
如果只用通用控件(不用Panel),可以实现完美换肤....
attachment:skinnewedit.jpg
对newedit进行换肤,好玩....
Include(pygame) Include(DesignPattern)
扩展与嵌入
["Swig"] - 强悍的库扩展工具