Mercurial > parpg-source
view gui/tabwidget.py @ 1:4912a6f97c52
Various improvements to the build process including support for self-contained builds.
* Note that despite all of these changes PARPG still does not run because asset paths are not standardized,
* Modified the SCons script so that by default running `scons` with no arguments creates a self-contained "build" under a build subdirectory to make in-source testing easier. To install PARPG, use `scons install` instead.
* Got rid of the binary launcher and replaced it with a shell script for unix and a batch script for Windows (batch script is untested). The binary turned out to be too much trouble to maintain.
* Modified the parpg.settings module and parpg.main entry script so that PARPG searches through several default search paths for configuration file(s). PARPG thus no longer crashes if it can't find a configuration file in any particular search path, but will crash it if can't find any configuration files.
* Paths supplied to parpg.main are now appended as search paths for the configuration file(s).
* Changed the default configuration file name to "parpg.cfg" to simplify searches.
* Created the site_scons directory tree where SCons extensions and tools should be placed.
* Created a new SCons builder, CopyRecurse, which can copy only certain files and folders from a directory tree using filters (files and folders that start with a leading dot "." e.g. ".svn" are ignored by default).
* Added the CPython SCons tool (stands for Compile-Python - I didn't name it!), which provides the InstallPython builder for pre-compiling python sources before they are installed. However, it is currently broken and only installs the python sources.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Tue, 31 May 2011 02:46:20 -0700 |
parents | 7a89ea5404b1 |
children | 5b880b8cff6d |
line wrap: on
line source
from fife.extensions.pychan.widgets import VBox, HBox, ScrollArea, Button from fife.extensions.pychan.tools import callbackWithArguments class TabWidget(VBox): def min_size(): def fget(self): return self._min_size def fset(self, min_size): self._min_size = min_size self.view.min_size = min_size self.adaptLayout() return locals() min_size = property(**min_size()) def max_size(): def fget(self): return self._max_size def fset(self, max_size): self._max_size = max_size self.view.max_size = max_size self.adaptLayout() return locals() max_size = property(**max_size()) def opaque(): def fget(self): return self._getOpaque() def fset(self, opaque): self._setOpaque(opaque) self.view.opaque = opaque base_color = self.view.base_color base_red = base_color.r base_green = base_color.g base_blue = base_color.b background_color = self.view.background_color background_red = background_color.r background_green = background_color.g background_blue = background_color.b alpha = 255 if opaque else 0 self.view.base_color = (base_red, base_green, base_blue, alpha) self.view.background_color = (background_red, background_green, background_blue, alpha) return locals() opaque = property(**opaque()) def border_size(): def fget(self): frame = self.findChild(name='frame') return frame.border_size def fset(self, border_size): frame = self.findChild(name='frame') frame.border_size = border_size return locals() border_color = property(**border_size()) def __init__(self, min_size=(0, 0), max_size=(9999, 9999), border_size=1, **kwargs): self._min_size = min_size self._max_size = max_size self.views = {} tab_bar = HBox(name='tabBar') tab_bar.min_size = (0, 20) tab_bar.max_size = (9999, 20) self.view = ScrollArea(name='view') self.view.min_size = self._min_size self.view.max_size = self._max_size self.view.border_size = border_size frame = VBox(name='frame') frame.border_size = border_size frame.opaque = 0 frame.addChild(self.view) VBox.__init__(self, **kwargs) self.padding = 0 VBox.addChild(self, tab_bar) VBox.addChild(self, frame) self.adaptLayout() def addTab(self, text): text = unicode(text) tab = Button(text=text) tab_bar = self.findChild(name='tabBar') tab_bar.addChild(tab) tab.capture(callbackWithArguments(self.showView, text)) self.adaptLayout() def addChild(self, child): name = child.name or unicode(str(child)) self.addTab(name) self.views[name] = child if len(self.views) == 1: # Show the first view by default. self.showView(name) def showView(self, name): view = self.views[name] self.view.content = view self.adaptLayout()