BUGFIX: actually initialize superclass of BatteryPannel, fix error handling

git-svn-id: http://www.neo1973-germany.de/svn@89 46df4e5c-bc4e-4628-a0fc-830ba316316d
main
kriss 16 years ago
parent b99303cdd9
commit ab9af88105

@ -75,7 +75,7 @@ class BatteryPanel(gtk.VBox):
self.q = self.f.readline().rstrip('\n') self.q = self.f.readline().rstrip('\n')
except(IOError): except(IOError):
print "ERROR: could not read capacity!" print "ERROR: could not read capacity!"
self.q = "0" # self.q = "0"
finally: finally:
self.f.close() self.f.close()
return (int(self.q)) return (int(self.q))
@ -85,12 +85,12 @@ class BatteryPanel(gtk.VBox):
try: try:
self.f = open(self.voltage, 'r') self.f = open(self.voltage, 'r')
self.q = float(self.f.readline().rstrip('\n')) self.q = float(self.f.readline().rstrip('\n'))
self.v = int(self.q)/1000000;
except(IOError): except(IOError):
print "ERROR: could not read voltage!" print "ERROR: could not read voltage!"
self.q = "0" # self.q = "0"
finally: finally:
self.f.close() self.f.close()
self.v = int(self.q)/1000000;
return (self.v) return (self.v)
# Check current status (Charging/Discharging) # Check current status (Charging/Discharging)
@ -141,13 +141,16 @@ class BatteryPanel(gtk.VBox):
# Gtk GUI # Gtk GUI
def __init__(self): def __init__(self):
# init main window # init main window
self.win = self
#self.win.connect("delete_event", self.delete_event) #self.win.connect("delete_event", self.delete_event)
gtk.VBox.__init__(self, False, 0)
self.v = 0;
self.q = 0;
# add a VBox # add a VBox
self.vbox = gtk.VBox(homogeneous=False, spacing=5) self.vbox = gtk.VBox(homogeneous=False, spacing=5)
self.win.add(self.vbox) self.add(self.vbox)
self.vbox.show()
# add a HBox # add a HBox
self.hbox0 = gtk.HBox() self.hbox0 = gtk.HBox()
@ -207,4 +210,4 @@ class BatteryPanel(gtk.VBox):
self.button_1000.show() self.button_1000.show()
# show main window # show main window
self.win.show() self.show_all()

Loading…
Cancel
Save