ocarina/src/extra/oGtk/window.py

74 lines
1.6 KiB
Python

#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$Mar 14, 2010 10:23:17 PM$"
import gtk
import guibuilder
import ocarina
from oGtk import progbar
from ct import call
class Window(gtk.Window):
def __init__(self, attrs):
gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)
self.quitEvent = ""
self.connect("delete_event", self.onQuit)
size = [240,800]
for a in attrs:
if a == "title":
self.set_title(attrs[a])
elif a == "width":
size[0] = int(attrs[a])
elif a == "height":
size[1] = int(attrs[a])
elif a == "close":
self.quitEvent = attrs[a]
self.resize(size[0], size[1])
#self.show()
def onQuit(self,a,b):
call.exit()
#ocarina.events.start(self.quitEvent)
class LibScanWin(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self.bar = progbar.LibScanBar()
self.add(self.bar)
self.bar.show()
self.show()
class ScrolledWindow(gtk.ScrolledWindow):
def __init__(self,attrs):
gtk.ScrolledWindow.__init__(self)
hscroll = gtk.POLICY_AUTOMATIC
vscroll = gtk.POLICY_AUTOMATIC
for a in attrs:
type = gtk.POLICY_AUTOMATIC
if attrs[a] == "none":
type = gtk.POLICY_NONE
elif attrs[a] == "always":
type = gtk.POLICY_ALWAYS
if a=="hscroll":
hscroll = type
elif a=="vscroll":
vscroll = type
self.set_policy(hscroll,vscroll)
self.show()
def make_window(attrs):return Window(attrs)
def make_scrollwin(attrs):return ScrolledWindow(attrs)
guibuilder.parts["window"] = make_window
guibuilder.parts["scrolled-window"] = make_scrollwin