Ejemplo n.º 1
0
 def test_Iteration_Empty(self):
    """Attempts to iterate over no items returns no items"""
    x=Chooser([])
    
    try:
       x.getCurrentChoice()
       self.fail()
    except IndexError:
       self.assert_(True, "Can't iterate over empty")
Ejemplo n.º 2
0
    def test_Iteration_Empty(self):
        """Attempts to iterate over no items returns no items"""
        x = Chooser([])

        try:
            x.getCurrentChoice()
            self.fail()
        except IndexError:
            self.assert_(True, "Can't iterate over empty")
Ejemplo n.º 3
0
 def test_Iteration_backwardsPastStart(self):
    """Backstepping past the start of the set still returns the first item"""
    fruitlist = ["apple","banana","cherry"]
    x=Chooser(fruitlist)
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is first item")
    
    x.gotoPrev()
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is still first item")
Ejemplo n.º 4
0
    def test_Iterate_gotoLast(self):
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        self.assert_(x.getCurrentChoice() == fruitlist[0],
                     "Current choice is correct")
        x.gotoLast()
        self.assert_(x.getCurrentChoice() == fruitlist[2],
                     "Current choice is correct")
        x.gotoLast()
        self.assert_(x.getCurrentChoice() == fruitlist[2],
                     "Current choice is correct")
Ejemplo n.º 5
0
 def test_Iterate_gotoLast(self):
    fruitlist = ["apple","banana","cherry"]
    x=Chooser(fruitlist)
    
    self.assert_(x.getCurrentChoice() == fruitlist[0], "Current choice is correct")
    x.gotoLast()
    self.assert_(x.getCurrentChoice() == fruitlist[2], "Current choice is correct")
    x.gotoLast()
    self.assert_(x.getCurrentChoice() == fruitlist[2], "Current choice is correct")
Ejemplo n.º 6
0
    def test_Iteration_iteratePastEnd(self):
        """Advancing past the end of the set still returns the last item"""
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        x.gotoNext()
        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2], "Current choice is 3rd item")

        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2], "Current choice is 3rd item")
Ejemplo n.º 7
0
   def test_Iteration_iteratePastEnd(self):
      """Advancing past the end of the set still returns the last item"""
      fruitlist = ["apple","banana","cherry"]
      x=Chooser(fruitlist)
      
      x.gotoNext()
      x.gotoNext()
      
      result = x.getCurrentChoice()
      self.assert_(result == fruitlist[2], "Current choice is 3rd item")

      x.gotoNext()
         
      result = x.getCurrentChoice()
      self.assert_(result == fruitlist[2], "Current choice is 3rd item")
Ejemplo n.º 8
0
    def test_Iteration_backwardsPastStart(self):
        """Backstepping past the start of the set still returns the first item"""
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0], "Current choice is first item")

        x.gotoPrev()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0],
                     "Current choice is still first item")
Ejemplo n.º 9
0
## Copyright (C) 2007 British Broadcasting Corporation and Kamaelia Contributors(1)
##     All Rights Reserved.
##
from Kamaelia.Chassis.Carousel import Carousel
from Kamaelia.Chassis.Graphline import Graphline
from Kamaelia.Util.Chooser import Chooser
from Kamaelia.UI.Pygame.Button import Button
from Kamaelia.UI.Pygame.Text import TextDisplayer
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor

files = ["1.txt", "2.txt", "3.txt", "4.txt"]


def makeFileReader(filename):
    return ReadFileAdaptor(filename=filename)


Graphline(NEXT=Button(caption="Next", msg="NEXT", position=(72, 8)),
          PREVIOUS=Button(caption="Previous", msg="PREV", position=(8, 8)),
          CHOOSER=Chooser(items=files),
          READER=Carousel(componentFactory=makeFileReader),
          DISPLAY=TextDisplayer(position=(20, 90),
                                screen_width=800,
                                screen_height=600),
          linkages={
              ("NEXT", "outbox"): ("CHOOSER", "inbox"),
              ("PREVIOUS", "outbox"): ("CHOOSER", "inbox"),
              ("CHOOSER", "outbox"): ("READER", "next"),
              ("READER", "outbox"): ("DISPLAY", "inbox"),
          }).run()
Ejemplo n.º 10
0
#

from Kamaelia.UI.Pygame.Button import Button
from Kamaelia.UI.Pygame.Image import Image
from Kamaelia.Util.Chooser import Chooser
from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.Chassis.PAR import PAR

import os

path = "Slides"
extn = ".gif"
allfiles = os.listdir(path)
files = list()
for fname in allfiles:
    if fname[-len(extn):] == extn:
        files.append(os.path.join(path, fname))

files.sort()

Pipeline(
    PAR(
        Button(caption="Next", msg="NEXT", position=(72, 8)),
        Button(caption="Previous", msg="PREV", position=(8, 8)),
        Button(caption="First", msg="FIRST", position=(256, 8)),
        Button(caption="Last", msg="LAST", position=(320, 8)),
    ),
    Chooser(items=files),
    Image(size=(800, 600), position=(8, 48)),
).run()
Ejemplo n.º 11
0
         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),
 PRIMARYDISPLAYFADER=BounceRange(255, 0, -10),  # Initially we want to fade
 PRIMARYDISPLAY=Image(
     size=(800, 600),
     position=(0, 0),
     displayExtra={"transparency": (255, 255, 255)},
 ),
 SECONDARYSLIDES=Chooser(items=SecondarySlides),
 SECONDARYDISPLAYFADER=BounceRange(255, 0,
                                   -10),  # Initially we want to fade
 SECONDARYDISPLAY=Image(
     size=(800, 600),
     position=(0, 0),
     displayExtra={"transparency": (255, 255, 255)},
 ),
 GRAPHSLIDES=Pipeline(
Ejemplo n.º 12
0
 def test_Iteration_iterateForwards(self):
    """Iterating forwards advances forwards through the set"""
    fruitlist = ["apple","banana","cherry"]
    x=Chooser(fruitlist)
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is first item")
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is still first item")
    
    x.gotoNext()
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[1], "Current choice is second item")
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[1], "Current choice is still second item")
    
    x.gotoNext()
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[2], "Current choice is 3rd item")
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[2], "Current choice is still 3rd item")
Ejemplo n.º 13
0
 def test_Instantiate_NoArgs(self):
     "__init__ - Creating empty chooser is fine"
     x = Chooser()
     self.assert_(iter_eq(x.items, []),
                  "__init__ list of items stored internally")
Ejemplo n.º 14
0
 def test_Instantiate_ArgList(self):
     "__init__ - Creating, passing list is fine"
     fruitlist = ["apple", "banana", "cherry"]
     x = Chooser(fruitlist)
     self.assert_(iter_eq(x.items, fruitlist),
                  "__init__ list of items stored internally")
Ejemplo n.º 15
0
 def test_Instantiate_ArgIterator(self):
     "__init__ - Creating, passing iterator is fine"
     x = Chooser(xrange(0, 5))
     self.assert_(iter_eq(x.items, xrange(0, 5)),
                  "__init__ right number of items")
Ejemplo n.º 16
0
    def test_Iterate_forwardsBackwardsForwards(self):
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        self.assert_(x.getCurrentChoice() == fruitlist[0],
                     "Current choice is correct")
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[1],
                     "Current choice is correct")
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[2],
                     "Current choice is correct")
        x.gotoPrev()
        self.assert_(x.getCurrentChoice() == fruitlist[1],
                     "Current choice is correct")
        x.gotoPrev()
        self.assert_(x.getCurrentChoice() == fruitlist[0],
                     "Current choice is correct")
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[1],
                     "Current choice is correct")
Ejemplo n.º 17
0
# -------------------------------------------------------------------------
#

from Kamaelia.UI.Pygame.Button import Button
from Kamaelia.Util.Chooser import Chooser
from Kamaelia.Visualisation.PhysicsGraph.lines_to_tokenlists import lines_to_tokenlists
from Kamaelia.Visualisation.PhysicsGraph.TopologyViewer import TopologyViewer
from Kamaelia.Chassis.Pipeline import Pipeline

graph = """\

ADD NODE TCPClient TCPClient auto -
ADD NODE VorbisDecode VorbisDecode auto -
ADD NODE AOPlayer AOPlayer auto -
ADD LINK TCPClient VorbisDecode
ADD LINK VorbisDecode AOPlayer
ADD NODE Multicast_Transceiver Multicast_Transceiver auto -
ADD NODE detuple detuple auto -
ADD LINK Multicast_Transceiver detuple
DEL NODE TCPClient
ADD LINK detuple VorbisDecode
DEL ALL
""".split("\n")

Pipeline(
     Button(caption="Next", msg="NEXT", position=(72,8)),
     Chooser(items = graph),
     lines_to_tokenlists(),
     TopologyViewer(transparency = (255,255,255), showGrid = False),
).run()
Ejemplo n.º 18
0
    def test_Iteration_iterateForwards(self):
        """Iterating forwards advances forwards through the set"""
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0], "Current choice is first item")
        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0],
                     "Current choice is still first item")

        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[1], "Current choice is second item")
        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[1],
                     "Current choice is still second item")

        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2], "Current choice is 3rd item")
        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2],
                     "Current choice is still 3rd item")
Ejemplo n.º 19
0
path = "Slides"
extn = ".gif"
#files = os.listdir(path)
#files = [ os.path.join(path,fname) for fname in files if fname[-len(extn):]==extn ]
#files.sort()

allfiles = os.listdir(path)
files = list()
for fname in allfiles:
    if fname[-len(extn):] == extn:
        files.append(os.path.join(path, fname))

files.sort()

Graphline(CHOOSER=Chooser(items=files),
          IMAGE=Image(size=(800, 600), position=(0, 0)),
          NEXT=Button(caption="Next",
                      msg="NEXT",
                      position=(64, 0),
                      transparent=True),
          PREVIOUS=Button(caption="Previous",
                          msg="PREV",
                          position=(0, 0),
                          transparent=True),
          FIRST=Button(caption="First",
                       msg="FIRST",
                       position=(256, 0),
                       transparent=True),
          LAST=Button(caption="Last",
                      msg="LAST",
Ejemplo n.º 20
0
   def test_Iterate_forwardsBackwardsForwards(self):
      fruitlist = ["apple","banana","cherry"]
      x=Chooser(fruitlist)

      self.assert_(x.getCurrentChoice() == fruitlist[0], "Current choice is correct")
      x.gotoNext()
      self.assert_(x.getCurrentChoice() == fruitlist[1], "Current choice is correct")
      x.gotoNext()
      self.assert_(x.getCurrentChoice() == fruitlist[2], "Current choice is correct")
      x.gotoPrev()
      self.assert_(x.getCurrentChoice() == fruitlist[1], "Current choice is correct")
      x.gotoPrev()
      self.assert_(x.getCurrentChoice() == fruitlist[0], "Current choice is correct")
      x.gotoNext()
      self.assert_(x.getCurrentChoice() == fruitlist[1], "Current choice is correct")