Beispiel #1
0
 def __init__(self, screen_width=500, screen_height=300, text_height=18,
              background_color = (255,255,200), text_color=(0,0,0), position=(0,0)):
     super(TextDisplayer, self).__init__()
     self.screen_width = screen_width
     self.screen_height = screen_height
     self.text_height = text_height
     self.background_color = background_color
     self.text_color = text_color
     self.position = position
     self.done = False
     
     quithandler = KeyEvent(key_events = {K_ESCAPE : ("escape", "outbox")})
     self.link((quithandler, "outbox"), (self, "_quitevents"))
     self.addChildren(quithandler)
     quithandler.activate()
Beispiel #2
0
def MyGamesEventsComponent(up="p", down="l", left="a", right="s"):
    if len(left) > 1: left = left.upper()
    else: left = left.lower()
    if len(right) > 1: right = right.upper()
    else: right = right.lower()
    if len(up) > 1: up = up.upper()
    else: up = up.lower()
    if len(down) > 1: down = down.upper()
    else: down = down.lower()

    return KeyEvent(outboxes={
        "outbox": "Normal place for message",
        "signal": "Normal place for message",
    },
                    key_events={
                        eval("pygame.K_" + up): ("start_up", "outbox"),
                        eval("pygame.K_" + down): ("start_down", "outbox"),
                        eval("pygame.K_" + left): ("start_left", "outbox"),
                        eval("pygame.K_" + right): ("start_right", "outbox"),
                    },
                    key_up_events={
                        eval("pygame.K_" + up): ("stop_up", "outbox"),
                        eval("pygame.K_" + down): ("stop_down", "outbox"),
                        eval("pygame.K_" + left): ("stop_left", "outbox"),
                        eval("pygame.K_" + right): ("stop_right", "outbox"),
                    })
Beispiel #3
0
    def __init__(self,
                 screen_width=500,
                 screen_height=300,
                 text_height=18,
                 background_color=(255, 255, 200),
                 text_color=(0, 0, 0),
                 position=(0, 0)):
        super(TextDisplayer, self).__init__()
        self.screen_width = screen_width
        self.screen_height = screen_height
        self.text_height = text_height
        self.background_color = background_color
        self.text_color = text_color
        self.position = position
        self.done = False

        quithandler = KeyEvent(key_events={K_ESCAPE: ("escape", "outbox")})
        self.link((quithandler, "outbox"), (self, "_quitevents"))
        self.addChildren(quithandler)
        quithandler.activate()
Beispiel #4
0
                            continue
                        else:
                            changed = True
                            bx, by = positions_dictionary[other]
                            dx = ax - bx
                            dy = ay - by
                            d = int(math.sqrt((dx * dx) + (dy * dy)))
                            distance[(key, other)] = d
            if changed:
                self.send(repr(distance) + "\n",
                          "outbox")  # XXXX Note this is broken
            yield 1


Pipeline(
    KeyEvent(outboxes={"outbox": ""},
             key_events={pygame.K_q: ("start_up", "outbox")}),
    Quitter(),
).activate()

Backplane("PLAYERS").activate()

Pipeline(
    MyGamesEventsComponent(up="p", down="l", left="a", right="s"),
    BasicSprite("cat.png", name="cat", border=40),
    PureTransformer(lambda x: ("Cat ", x)),
    PublishTo("PLAYERS"),
).activate()

Pipeline(
    MyGamesEventsComponent(up="up", down="down", left="left", right="right"),
    BasicSprite("mouse.png", name="mouse", border=40),
Beispiel #5
0
for fname in allfiles:
    if fname[-len(extn):] == extn:
        files.append(os.path.join(path, fname))

files.sort()

g = Graphline(
    CHOOSER=Chooser(items=files),
    IMAGE=Image(size=(800, 600), position=(8, 48)),
    NEXT=Button(caption="Next", msg="NEXT", position=(72, 8)),
    PREVIOUS=Button(caption="Previous", msg="PREV", position=(8, 8)),
    FIRST=Button(caption="First", msg="FIRST", position=(256, 8)),
    LAST=Button(caption="Last", msg="LAST", position=(320, 8)),
    RANDOM=Button(caption="Random", msg="RANDOM", position=(500, 8)),
    #KeyEvent stuff
    keys=KeyEvent(key_events={K_esc: (shutdownMicroprocess(), "outbox")}),
    output=ConsoleEchoer(),
    linkages={
        ("NEXT", "outbox"): ("CHOOSER", "inbox"),
        ("PREVIOUS", "outbox"): ("CHOOSER", "inbox"),
        ("FIRST", "outbox"): ("CHOOSER", "inbox"),
        ("LAST", "outbox"): ("CHOOSER", "inbox"),
        ("RANDOM", "outbox"): ("CHOOSER", "inbox"),
        ("CHOOSER", "outbox"): ("IMAGE", "inbox"),
        #	("keys", "outbox") : ("output", "inbox")
        ("keys", "outbox"): ("IMAGE", "control")
    })

g.run()

# 6 May 2007 -- escape message isn't being sent to Chooser inbox
Beispiel #6
0
pygamedisplay = PygameDisplay(width=1024, height=768, fullscreen=1)
pygamedisplay.activate()
PygameDisplay.setDisplayService(pygamedisplay)

Graphline(
     EXIT = ExceptionRaiser("FORCED SYSTEM QUIT"),
     MOUSE = Multiclick(caption="", 
                        position=(0,0), 
                        transparent=True,
                        msgs = [ "", "NEXT", "FIRST", "PREV", "PREV","NEXT" ],
                        size=(1024,768)),
     KEYS = KeyEvent(outboxes = { "slidecontrol" : "Normal place for message",
                                  "shutdown" : "Place to send some shutdown messages",
                                  "trace" : "Place for trace messages to go",
                                },
                     key_events = {112: ("PREV", "slidecontrol"), 
                                   110: ("NEXT","slidecontrol"),
                                   113: ("QUIT", "shutdown"),
                                  }),
     SPLITTER = Splitter(outboxes = {"totimer" : "For sending copies of key events to the timer",
                                     "tochooser" : "This is the primary location for key events",
                                    }),
     TIMER = TimeRepeatMessage("NEXT",0.02),
     FILES = Chooser(items = files, loop=True),
     DISPLAY = Image(size=(1024,768), 
                     position=(0,0), 
                     maxpect=(1024,768) ),
     linkages = {
        ("TIMER", "outbox") : ("FILES", "inbox"),

        ("MOUSE", "outbox") : ("SPLITTER", "inbox"),
Beispiel #7
0
    drag blobs  : left click
    Fade in/out : h

"""

Graphline(
    KEYS=KeyEvent(
        outboxes={
            "primaryslidefadesignal": "Normal place for message",
            "graphfadesignal": "Normal place for message",
            "secondaryslidefadesignal": "Normal place for message",
            "graphcontrol": "Sends a 'next' message to the slide control",
            "primaryslidecontrol": "Keyboard control",
            "secondaryslidecontrol": "Keyboard control",
        },
        key_events={
            pygame.K_g: ("TOGGLE", "primaryslidefadesignal"),  # Toggle Fade
            pygame.K_h: ("TOGGLE", "graphfadesignal"),  # Toggle Fade
            pygame.K_j: ("TOGGLE", "secondaryslidefadesignal"),  # Toggle Fade
            pygame.K_PAGEDOWN:
            ("NEXT", "graphcontrol"),  # Advance "graph slides"
            pygame.K_RETURN:
            ("NEXT", "secondaryslidecontrol"),  # Advance slides
            pygame.K_SPACE: ("NEXT", "primaryslidecontrol"),  # Advance slides
            pygame.K_BACKSPACE: ("PREV", "slidecontrol"),  # Advance slides
        }),
    MOUSECLICKS=Multiclick(caption="",
                           position=(50, 50),
                           transparent=True,
                           msgs=["", "", "PREV", "NEXT", "PREV", "NEXT"],
                           size=(700, 500)),
    PRIMARYSLIDES=Chooser(items=PrimarySlides),