def __init__(self, app): super(Interface, self).__init__(app) backdrop = pygame.Surface(app.screenManager.scaledSize) backdrop.fill((128, 0, 128)) i1 = prompt.InputBox(self.app, Area((40, 40), (300, 50)), 'Mouse Over', font=Font("KLEPTOCR.TTF", 36)) i1.onClick.addListener(self.setFocus) i2 = prompt.InputBox(self.app, Area((340, 140), (200, 50)), 'Mouse Over', font=Font("KLEPTOCR.TTF", 36)) i2.onClick.addListener(self.setFocus) h1 = hint.Hint(self.app, "You absolutely\nRULE!", i1, Font("KLEPTOCR.TTF", 24)) h2 = hint.Hint(self.app, "Like, amazingly so!! TROSNOTH!@!!@!", i2, Font("KLEPTOCR.TTF", 24)) h3 = hint.Hint( self.app, "A secret!\nWell done, you have found a magical land of wonder and amazement!! \nYou win absolutely nothing, but at least you have a good story to tell now.", pygame.Rect(500, 400, 100, 50), Font("KLEPTOCR.TTF", 24)) self.elements = [ elements.PictureElement(app, backdrop), i1, h1, i2, h2, h3 ]
def __init__(self, app): super(Interface, self).__init__(app) backdrop = pygame.Surface(app.screenManager.scaledSize) backdrop.fill((128, 0, 128)) t1 = table.Table(app, Location( FullScreenAttachedPoint( (-10, -10), 'bottomright'), 'bottomright'), rows=4, columns=2) t1[0][0].setText("Hello") t1[0][0].style.font = Font('FreeSans.ttf', 16) t1[1][1].setText("There") t1[1][1].style.foreColour = (0, 232, 0) t1[1][1].style.textAlign = 'center' t1[1][1].style.hasShadow = True t1[1][1].style.shadowColour = (0, 0, 255) t1[1][2].style.backColour = (232, 0, 0) t1[1][2].style.font = Font('FreeSans.ttf', 50) t1[1][2].setText("TOO BIG!!") t1[1][2].style.foreColour = (255, 255, 255) t1.getRow(1).setHeight(100) t1.getRow(3).setHeight(ScaledScalar(60)) t1.setBorderWidth(7) self.elements = [t1]
def __init__(self, app): super(Interface, self).__init__(app) backdrop = pygame.Surface(app.screenManager.scaledSize) backdrop.fill((128, 0, 128)) s1 = slider.Slider(app, ScaledArea(100, 100, 400, 60)) #s1.setRange(50,150) t1 = elements.TextElement(app, "100", Font(None, 60), ScaledLocation(100, 200)) t2 = elements.TextElement(app, "100", Font(None, 60), ScaledLocation(550, 100)) onSlide = lambda x: t1.setText("%.1f" % x) onChange = lambda x: t2.setText("%.1f" % x) s1.onSlide.addListener(onSlide) s1.onValueChanged.addListener(onChange) self.elements = [elements.PictureElement(app, backdrop), s1, t1, t2]
def __init__(self, app, pos, rows=None, columns=None, topPadding=0): defaultStyle = TableStyle() defaultStyle.backColour = (255, 255, 255) defaultStyle.padding = (5, 5) defaultStyle.foreColour = (0, 0, 0) defaultStyle.hoverColour = (0, 0, 0) defaultStyle.font = Font('FreeSans.ttf', 36) defaultStyle.textAlign = 'topleft' defaultStyle.hasShadow = False defaultStyle.shadowColour = colours.shadowDefault super(Table, self).__init__(app, defaultStyle) self.pos = pos self.topPadding = topPadding self._columns = [] self._rows = [] self.elements = self._columns # Style Settings: self._borderColour = (192, 192, 192) self._borderWidth = 10 self._defaultWidth = 200 self.setDefaultHeight(Value(60)) if rows is not None: self.addRows(rows) if columns is not None: self.addEmptyColumns(columns) self._sizes = {} self._appSize = None app.screenManager.onResize.addListener(self.appResized)
def __init__(self, app, tabContainer): super(EpilepticTab, self).__init__(app, str(randint(0,1000))) self.val = 4 self.l = ['hello', self.val] getColour = lambda item: ((255,0,0), (0,255,255))['4' in str(item)] font = Font("KLEPTOCR.TTF", 50) self.s = statList.StatList(app, Location(AttachedPoint((10,100), tabContainer._getTabRect)), self.l, font, colourFunction = getColour) self.s.setVisible() addTabFunction = lambda sender: tabContainer.addTab(EpilepticTab(app, tabContainer)) closeTabFunction = lambda sender: tabContainer.removeTab(self) button = elements.TextButton(app, Location(AttachedPoint((200,50), tabContainer._getTabRect)), "Click for new Tab", font, (0,128,0), (0,255,0)) button.onClick.addListener(addTabFunction) otherButton = elements.TextButton(app, Location(AttachedPoint((200,90), tabContainer._getTabRect)), "Close This Tab", font, (128,0,0), (255,0,0)) otherButton.onClick.addListener(closeTabFunction) f = lambda: self.s.setVisible(not self.s.getVisibility()) h = hotkey.Hotkey(app, pygame.K_s, 0) h.onTriggered.addListener(f) # TODO: add a backdrop self.elements += [self.s, button, otherButton, h]
def __init__(self, app): super(Interface, self).__init__(app) backdrop = pygame.Surface(app.screenManager.scaledSize) backdrop.fill((128,0,128)) con = console.TrosnothInteractiveConsole(app, Font(None, 18), Area((0, 200), (500, 200))) con.interact().addCallback(self.done) self.elements = [elements.PictureElement(app, backdrop), con] self.setFocus(con)
def initFonts(self): fontData = self._getFontData() for fontName, defaultDetails in DEFAULT_FONTS.items(): if fontName in fontData: fontFile, size, bold = fontData[fontName] else: fontFile, size, bold = defaultDetails.unpack() if fontName in UNSCALED_FONTS: font = Font(fontFile, size, bold) else: font = ScaledFont(fontFile, size, bold) self.app.fonts.addFont(fontName, font)
def __init__(self, app): super(Interface, self).__init__(app) backdrop = pygame.image.load('Awesome Leaders.jpg').convert() x, y = backdrop.get_size() size = Size(x, y) sc1 = scrollableCanvas.ScrollableCanvas(app, ScaledLocation(20,20), size, ScaledSize(200,200)) sc2 = scrollableCanvas.ScrollableCanvas(app, ScaledLocation(230,20), size, ScaledSize(200,y+scrollableCanvas.ScrollBar.defaultWidth)) sc3 = scrollableCanvas.ScrollableCanvas(app, ScaledLocation(440,20), size, ScaledSize(x,y)) sc4 = scrollableCanvas.ScrollableCanvas(app, ScaledLocation(20,530), size, ScaledSize(x+scrollableCanvas.ScrollBar.defaultWidth, 200)) #sc5 = scrollableCanvas.ScrollableCanvas(app, ScaledLocation(20,530), size, ScaledSize(x+scrollableCanvas.ScrollBar.defaultWidth, y)) self.elements = [sc1, sc2, sc3, sc4]#, sc5] font = Font("KLEPTOCR.TTF", 30) onclick = lambda sender: self.app.screenManager.setScreenProperties((1680, 1050), 0, "Testing") for sc in self.elements: sc.elements = [elements.PictureElement(app, backdrop, Location(scrollableCanvas.ScrollableCanvasAttachedPoint(sc, (0,0)), 'topleft')), elements.TextButton(app, Location(scrollableCanvas.ScrollableCanvasAttachedPoint(sc, (20,20))), "Hello", font, (0,128,0), (0,0,128), onClick = onclick)]
def __init__(self, app): super(Interface, self).__init__(app) bg = pygame.surface.Surface((1024,768)) bg.fill((255,255,0)) font = Font("KLEPTOCR.TTF", 30) tc = tabContainer.TabContainer(app, ScaledArea(10,10, 1004, 748), font, (0,128,0)) background = SizedImage('Awesome Leaders.jpg', tabContainer.TabSize(tc)) for x in range(0,1): t1 = tab.Tab(app, "Hellooooooooo") t1.elements = [elements.PictureElement(app, background, Location(AttachedPoint((0,0),tc._getTabRect,'topleft'),'topleft'))] t2 = NewTab(app, tc) t3 = EpilepticTab(app, tc) tc.addTab(t1) tc.addTab(t2) tc.addTab(t3) #tc._setTabHeaderDimensions(3,36,24,200) self.elements = [elements.Backdrop(app, bg), tc]
def __init__(self, app): super(Interface, self).__init__(app) backdrop = pygame.Surface(app.screenManager.scaledSize) backdrop.fill((128, 0, 128)) self.val = 4 self.l = ['hello', self.val] getColour = lambda item: ((255, 0, 0), (0, 255, 255))[str(item).startswith('h')] font = Font("KLEPTOCR.TTF", 30) self.s = statList.StatList(app, Location((550, 400), 'bottomright'), self.l, font, colourFunction=getColour, align='right') self.s.setVisible() f = lambda: self.s.setVisible(not self.s.getVisibility()) h = hotkey.Hotkey(app, pygame.K_s, 0) h.onTriggered.addListener(f) self.elements = [elements.PictureElement(app, backdrop), self.s, h]