Created
December 15, 2014 13:57
-
-
Save typemytype/c9ac5349183209a7d3e7 to your computer and use it in GitHub Desktop.
proposal for vanilla.ScrollView to support embedded vanilla.Group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from vanilla import * | |
import vanilla | |
from vanilla.vanillaBase import VanillaError | |
class ScrollView(vanilla.ScrollView): | |
def __init__(self, posSize, nsView, hasHorizontalScroller=True, hasVerticalScroller=True, | |
autohidesScrollers=False, backgroundColor=None, clipView=None, | |
drawsBackground=True): | |
# set a flag if the scrollview is using a vanilla.Group | |
isScrollViewWithGroup = False | |
# only support vanilla.Group object | |
if isinstance(nsView, Group): | |
l, t, w, h = nsView.getPosSize() | |
# only support when the widht and height is a fixed | |
if w <= 0 or h <= 0: | |
raise VanillaError("Embedded Group must have fixed width and height") | |
# store the group | |
isScrollViewWithGroup = nsView | |
# get the nsView from the group | |
nsView = nsView.getNSView() | |
super(self.__class__, self).__init__(posSize, nsView, hasHorizontalScroller, hasVerticalScroller, autohidesScrollers, backgroundColor, clipView, drawsBackground) | |
if isScrollViewWithGroup: | |
# when it is a group set the parent frame... | |
isScrollViewWithGroup._setFrame(((0, 0), (0, 0))) | |
w = Window((400, 400), minSize=(100, 100)) | |
g = Group((0, 0, 300, 1000)) | |
g.l = List((10, 10, -10, 100), ["a", "b", "c"]) | |
g.c = CheckBox((10, 130, -10, 22), "Hello") | |
w.s = ScrollView((0, 0, -0, -0), g) | |
w.open() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment