Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pgutest1.py
diff options
context:
space:
mode:
authorTony Anderson <tony_anderson@usa.net>2009-06-22 14:04:24 (GMT)
committer Tony Anderson <tony_anderson@usa.net>2009-06-22 14:04:24 (GMT)
commit6eb30b09566a53ef510532f2a1705d7fc22985a8 (patch)
treed52765c093219f91d07f030ed597f9491a7f8493 /pgutest1.py
initial commit
Diffstat (limited to 'pgutest1.py')
-rw-r--r--pgutest1.py148
1 files changed, 148 insertions, 0 deletions
diff --git a/pgutest1.py b/pgutest1.py
new file mode 100644
index 0000000..5932477
--- /dev/null
+++ b/pgutest1.py
@@ -0,0 +1,148 @@
+class CurrentQuestion:
+ id = 0
+ prompt = u''
+ response = u''
+ imgfn = u''
+ sndfn = u''
+ map = u''
+ answer_link = u''
+
+import pygame
+from pygame.locals import *
+
+# the following line is not needed if pgu is installed
+import sys; sys.path.insert(0, "..")
+
+from pgu import gui
+
+cq = CurrentQuestion()
+
+class EditDialog(gui.Dialog):
+ def __init__(self, editsave, cq):
+ title = gui.Label("Edit Question")
+
+ t = gui.Table()
+ self.form = gui.Form()
+
+ t.tr()
+ saveButton = gui.Button("Save")
+ saveButton.connect(gui.CLICK, editsave, cq)
+ t.td(saveButton,colspan=3)
+
+ t.tr()
+ t.td(gui.Label("Prompt: "))
+ t.td(gui.Input(name = 'prompt', value = cq.prompt),colspan=3)
+
+ t.tr()
+ t.td(gui.Label("Response: "))
+ t.td(gui.Input(name = 'response', value = cq.response),colspan=3)
+
+ t.tr()
+ t.td(gui.Label("Image: "))
+ t.td(gui.Input(name = 'image', value = cq.imgfn),colspan=3)
+
+ t.tr()
+ t.td(gui.Label("Sound: "))
+ t.td(gui.Input(name = 'suound', value = cq.sndfn),colspan=3)
+
+ t.tr()
+ t.td(gui.Label("Map: "))
+ t.td(gui.Input(name = 'map', value = cq.map),colspan=3)
+
+ t.tr()
+ t.td(gui.Label("Answer_link: "))
+ t.td(gui.Input(name = 'answer_link', value = cq.answer_link),colspan=3)
+
+ gui.Dialog.__init__(self,title,t)
+
+
+class ImageQuizActivity:
+ user_name = u"chris"
+
+ def game(self):
+ global edit_d
+ clock = pygame.time.Clock()
+ cq.prompt = "prompt"
+ cq.response = "response"
+ cq.imgfn = "image"
+ cq.sndfn = "sound"
+ cq.map = "map"
+ cq.answer_link = "answerlink"
+ app = gui.App()
+
+ c = gui.Container(width=800, height=600
+
+ lbl = gui.Label("This is the main surface")
+ c.add(lbl,0,500)
+ app.init(c)
+
+ #edit_d = EditDialog(editsave, cq)
+ #edit_d.open()
+
+ # Pygame event loop.
+ while True:
+ clock.tick(20)
+ app.paint(self.screen)
+ pygame.display.update()
+
+ for event in [ pygame.event.wait() ] + pygame.event.get( ):
+ self.input(event)
+ app.event(event)
+
+ # Handle a pygame event
+ def exit_all(self):
+ global edit_d
+ form = edit_d.form
+ cq.prompt = form['prompt'].value
+ cq.response = form['response'].value
+ cq.imgfn = form['image'].value
+ cq.sndfn = form['sound'].value
+ cq.map = form['map'].value
+ cq.answer_link = form['answer_link'].value
+ print 'prompt', cq.prompt
+ print 'response', cq.response
+ print 'image', cq.imgfn
+ print 'sound', cq.sndfn
+ print 'map', cq.map
+ print 'answer_link', cq.answer_link
+# plugger.close_plugins()
+# time.sleep(3)
+ sys.exit(0)
+
+ def input(self, event):
+ if event.type == QUIT:
+ self.exit_all()
+
+ elif event.type == MOUSEBUTTONUP:
+# display.check_click(event.pos)
+ pass
+
+ elif event.type == KEYUP:
+ if event.key == 113: # 'q'
+ self.exit_all()
+ elif event.key == 102: # 'f'
+ pygame.display.toggle_fullscreen()
+
+# elif event.type == MOUSEMOTION:
+# pass
+
+# else:
+# x = event.type
+# display.show_tool_tip((200, 10), "%i" % int(x))
+# pygame.display.update()
+
+
+ def __init__(self):
+ # Fire Up Display
+ self.window = pygame.display.set_mode((1200, 825))
+ pygame.display.set_caption('PGU test')
+
+ # Init Surface
+ self.screen = pygame.display.get_surface()
+ self.game()
+
+def main():
+ ImageQuiz = ImageQuizActivity()
+
+if __name__ == "__main__" or __name__ == "ImageQuiz":
+ main()