view clients/pychan_demo/dynamic.py @ 372:e94cd7d1dab6

Changed some of the adaptLayout calls in object selector. This should fix the bug where the objectselector shrinks when a new object is selected. If previewmode is enabled or there are other heavy widgets attached to the root widget, there will probably be a brief lag while the widgets get updated.
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 20 Nov 2009 00:41:56 +0000
parents dfd48d49c044
children
line wrap: on
line source

# -*- coding: utf-8 -*-

import pychan
from pychan_test import PyChanExample

class DynamicExample(PyChanExample):
	def __init__(self):
		super(DynamicExample,self).__init__('gui/dynamic.xml')
		
	def start(self):
		self.widget = pychan.loadXML(self.xmlFile)
		self.widget.mapEvents({
			'okButton'   :self.stop,
			'addButton'  :self.addLabel,
		})
		self.labelBox = self.widget.findChild(name="labelBox")
		self.widget.show()

	def addLabel(self):
		# Code to check text wrapping code in FIFE
		label = pychan.widgets.Label(max_size=(200,1000),wrap_text=True)
		label.text = self.widget.collectData('labelText')
		label.capture(self.removeLabel)
		self.labelBox.addChild( label )
		self.widget.adaptLayout()
		
	def removeLabel(self,widget=None):
		widget.parent.removeChild(widget)
		self.widget.adaptLayout()