/[ascend]/trunk/pygtk/interface/preferences.py
ViewVC logotype

Diff of /trunk/pygtk/interface/preferences.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 132 by johnpye, Wed Dec 21 00:14:13 2005 UTC revision 172 by johnpye, Sat Jan 7 10:06:13 2006 UTC
# Line 1  Line 1 
1  # Preferences module for ASCPY.  # Preferences module for ASCPY.
2    
3  import ConfigParser, os  import ConfigParser, os
4    import re
5    
6  class Preferences:  class Preferences:
7      __sharedstate = {}      __sharedstate = {}
# Line 25  class Preferences: Line 26  class Preferences:
26              f = open(self.fname, "w");              f = open(self.fname, "w");
27              self.ini.write( f );              self.ini.write( f );
28    
29        def getGeometry(self,displayname,key):
30            try:
31                _g = self.ini.get("Geometry:"+displayname,key)
32            except ConfigParser.NoSectionError:
33                return None
34            except ConfigParser.NoOptionError:
35                return None
36            _p = re.compile('^\s*(\d+)[Xx](\d+)\+(\d+)\+(\d+)\s*$');
37    
38            _m = _p.match(_g)
39            print "MATCH: ",_m.groups()
40            return  tuple(int(i) for i in _m.groups())
41    
42        def setGeometry(self,displayname,key,width,height,top,left):
43            if not self.ini.has_section("Geometry:"+displayname):
44                self.ini.add_section("Geometry:"+displayname)
45            self.ini.set("Geometry:"+displayname,key, "%dx%d+%d+%d" % (width, height, top, left) );
46    
47      def getPreferredUnits(self,key):      def getPreferredUnits(self,key):
48          try:          try:
49              _u = self.ini.get("PreferredUnits",key);              _u = self.ini.get("PreferredUnits",key);
50          except ConfigParser.NoSectionError:          except ConfigParser.NoSectionError:
51              return None;              return None
52          except ConfigParser.NoOptionError:          except ConfigParser.NoOptionError:
53              return None;              return None
54          return _u;          return _u
55    
56      def setPreferredUnits(self,key,val):      def setPreferredUnits(self,key,val):
57          if not self.ini.has_section("PreferredUnits"):          if not self.ini.has_section("PreferredUnits"):

Legend:
Removed from v.132  
changed lines
  Added in v.172

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22