add initial empty Window class

This commit is contained in:
Josh Holtrop 2011-07-06 15:55:35 -04:00
commit 1b4a150dca
2 changed files with 59 additions and 0 deletions

17
Window.py Executable file
View File

@ -0,0 +1,17 @@
import gtk
class Window(object):
def __init__(self):
self.window = gtk.Window()
self.window.set_decorated(False)
self.window.connect('destroy', self.destroy_event)
self.window.show_all()
def run(self):
gtk.main()
def destroy_event(self):
gtk.main_quit()
return False

42
pygtk-imap-chk.py Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env python
import sys
import gtk
import imaplib
from Window import *
def get_config(fname):
conf = {}
if os.path.isfile(fname):
try:
f = open(fname, 'r')
contents = f.read()
f.close()
exec(contents, conf)
except:
pass
return conf
def save_config(fname, conf):
if os.path.isfile(fname):
fh = open(fname, 'r')
old_config = fh.read()
fh.close()
else:
old_config = ''
new_config = ''
conf_ents = filter(lambda x: not x.startswith('_'), conf)
for s in map(lambda x: x + ' = ' + repr(conf[x]) + '\n', conf_ents):
new_config += s
if old_config != new_config:
fh = open(fname, 'w')
fh.write(new_config)
fh.close()
def main(argv):
window = Window()
window.run()
if __name__ == "__main__":
sys.exit(main(sys.argv))