96 lines
1.8 KiB
Python
96 lines
1.8 KiB
Python
#! /usr/bin/python
|
|
|
|
# To change this template, choose Tools | Templates
|
|
# and open the template in the editor.
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$May 13, 2010 10:37:48 AM$"
|
|
|
|
|
|
from gtknodes import Node
|
|
from ct import call
|
|
import gtk
|
|
|
|
|
|
|
|
class Window(Node):
|
|
def __init__(self,elm):
|
|
Node.__init__(self,elm)
|
|
self.part = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
|
self.part.connect("delete_event", self.onquit)
|
|
self.wininit()
|
|
|
|
|
|
def wininit(self):
|
|
self["title"] = "Ocarina 3.0"
|
|
self["width"] = "400"
|
|
self["height"] = "150"
|
|
#self["show"] = "false"
|
|
|
|
self.setattrs()
|
|
|
|
self.part.set_title(self["title"].title())
|
|
self.part.resize(int(self["width"]), int(self["height"]))
|
|
|
|
self.add()
|
|
|
|
|
|
def newContent(self,elm):
|
|
call.write("Window redrawing content!", 2)
|
|
self.elm = elm
|
|
self.init2()
|
|
self.wininit()
|
|
|
|
|
|
def onquit(self,a,b):
|
|
call.exit()
|
|
|
|
|
|
def add(self):
|
|
if len(self.children) == 0:
|
|
return
|
|
# Add the first child to the window
|
|
self.part.add(self.children[0].part)
|
|
|
|
|
|
def clear(self):
|
|
self.part.remove(self.children[0].part)
|
|
|
|
|
|
|
|
|
|
class ScrolledWindow(Node):
|
|
def __init__(self,elm):
|
|
Node.__init__(self,elm)
|
|
self["hscroll"] = "auto"
|
|
self["vscroll"] = "auto"
|
|
self.part = gtk.ScrolledWindow()
|
|
|
|
self.setattrs()
|
|
|
|
hscroll = gtk.POLICY_AUTOMATIC
|
|
if self["hscroll"] == "none":
|
|
hscroll = gtk.POLICY_NONE
|
|
elif self["hscroll"] == "always":
|
|
hscroll = gtk.POLICY_ALWAYS
|
|
|
|
vscroll = gtk.POLICY_AUTOMATIC
|
|
if self["vscroll"] == "none":
|
|
vscroll = gtk.POLICY_NONE
|
|
elif self["vscroll"] == "always":
|
|
vscroll = gtk.POLICY_ALWAYS
|
|
|
|
self.part.set_policy(hscroll, vscroll)
|
|
self.add()
|
|
|
|
|
|
def add(self):
|
|
if len(self.children) == 0:
|
|
return
|
|
|
|
# Add the child to the scrolled window
|
|
child = self.children[0]
|
|
if child["viewport"] == "false":
|
|
self.part.add(child.part)
|
|
else:
|
|
self.part.add_with_viewport(child.part) |