Ejemplo n.º 1
0
from trosnoth.gui.app import Application
from trosnoth.gui.framework import (framework, elements,
        console)
from trosnoth.gui.fonts.font import Font
from trosnoth.gui.common import Area
import pygame

class Interface(framework.CompoundElement):
    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 done(self, component):
        print('Done!!!')
        self.app.stop()


size = (600,450)

if __name__ == '__main__':
    a = Application(size, 0, "Testing", Interface)
    a.run_twisted()
Ejemplo n.º 2
0
        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
        ]


size = (600, 450)

if __name__ == '__main__':
    a = Application(size, 0, "Testing", Interface)
    a.run()
Ejemplo n.º 3
0
                     ])
        menu0 = Menu(name='Main',
                     items=[
                         MenuItem('File', lambda: menuMan.showMenu(menu1)),
                         MenuItem('Blah')
                     ])
        menuMan.setDefaultMenu(menu0)

        self.menu = MenuDisplay(self.app,
                                location=Location((300, 400), 'bottomleft'),
                                size=(200, 200),
                                font=pygame.font.Font(None, 28),
                                manager=menuMan,
                                titleColour=(255, 255, 0),
                                stdColour=(255, 255, 128),
                                hvrColour=(128, 255, 255),
                                backColour=(0, 64, 192),
                                autosize=True,
                                hidable=True)

        self.elements = [backdrop, self.menu]


if __name__ == '__main__':
    screenSize = (920, 690)
    graphicsOptions = 0
    caption = 'Trosnoth Menu Test Program'

    app = Application(screenSize, graphicsOptions, caption, Interface)
    app.run()