Hi Maja, Try this, and see annotations. ...it's a simple script to display text over one of my favorite internet memes. ( I got the image at http://mypetjawa.mu.nu/archives/picard-facepalm.jpg ) ...if anything is still unclear, we can go from here. -Dave Bissig WSU-SOM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ####### import stuff ## (biolerplate) import VisionEgg from VisionEgg import * VisionEgg.start_default_logging(); VisionEgg.watch_exceptions() from VisionEgg.Core import * from VisionEgg.Textures import * from VisionEgg.Text import * import pygame ####### open a Vision Egg window ## (biolerplate) refresh_rate = 120 screen_width = 921 screen_height = 606 bits_per_pixel = 16 def __VEggConfig(): VisionEgg.start_default_logging(); VisionEgg.watch_exceptions() VisionEgg.config.VISIONEGG_GUI_INIT = 0 VisionEgg.config.VISIONEGG_FRAMELESS_WINDOW = 1 VisionEgg.config.VISIONEGG_FULLSCREEN = 0 VisionEgg.config.VISIONEGG_MONITOR_REFRESH_HZ = refresh_rate VisionEgg.config.VISIONEGG_SCREEN_W = screen_width VisionEgg.config.VISIONEGG_SCREEN_H = screen_height VisionEgg.config.VISIONEGG_PREFERRED_BPP = bits_per_pixel ###### make a couple of simple modules ## WaitAround, here, just closes the window when you hit ESC, or ## (owing to its use of CheckMousePosition(xpos,ypos) ) when you ## click on the image with your mouse. def WaitAround(): waiting=0 while waiting != 1: for event in pygame.event.get(): if event.type == pygame.locals.MOUSEBUTTONDOWN: xpos,ypos = pygame.mouse.get_pos() CheckMousePosition(xpos,ypos) # given the coordinates and command set up in CheckMousePosition # this causes the Vision Egg window to close if it's clicked. waiting=1 elif event.type == pygame.locals.KEYDOWN: if event.key == pygame.locals.K_ESCAPE: screen.close() screen.close() raise SystemExit def CheckMousePosition(xpos,ypos,SEEdir): ## you could add different locations here (with elif) to define several functions, based ## on the location of mousedown. (like a simple imagemap of old website design fame). if xpos >= 0 and xpos <=0 and ypos >= 606 and ypos <=921: screen.close() screen.close() raise SystemExit ########### Next four lines are boilerplate. __VEggConfig() screen = get_default_screen() screen.parameters.bgcolor = (1.0,1.0,1.0) pygame.mouse.set_cursor(*pygame.cursors.arrow) ## OK, now set up the main loop. mk=0 while mk != 1: ## basic TextureStimulus command for showing an image. back=TextureStimulus(texture=Texture('picard-facepalm.jpg'),position=(0,(screen_height-0)),anchor='upperleft') ## draw the viewport. background=VisionEgg.Core.Viewport(screen=screen,size=screen.size,stimuli=[back]) bunchOtext1 = Text(text="Click image to",color=(1,1,0.8),position=(150,(screen_height-230)),font_size=40,anchor='center') bunchOtext2 = Text(text="disengage facepalm",color=(1,1,0.8),position=(150,(screen_height-270)),font_size=40,anchor='center') ## we alread called VisionEgg.Core.Viewport() to make the background image veiwport ## , and we'll now use it again to make the text viewport. ...not sure what the consequences ## are for having "overlapping" things crammed into the same viewport... I suggest avoiding it. ## and anyways, splitting things into different viewports gives you control over what's drawn first, ## or if you're drawing something over a consistent background, may let you run things ## a bit quicker (just defining the background viewport once, in stead of over ## and over again in a loop). ### anyways... ### make the text's viewport: textPort = VisionEgg.Core.Viewport(screen=screen, size=screen.size, stimuli=[bunchOtext1,bunchOtext2]) ## ## ########## now, we draw everything to the buffer.########## ## first clear anything in the buffer already. screen.clear() ## draw the background background.draw() ## draw with text textPort.draw() ######## NOTE: if you changed the order, like this: # textPort.draw() # background.draw() ######## you would have drawn the text, then drawn the image on top, so no text would show up. ## now, swap the buffers (whatever is on screen now goes to buffer, and the stuff we ## just drew to the buffer is shown on screen). VisionEgg.Core.swap_buffers() pygame.mouse.set_visible(True) WaitAround() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On Sun, Aug 23, 2009 at 4:08 PM, Maja K <maja_ka@xxxxxxxxxxx> wrote: > Hello Everybody, :-) > I am having some troubles with displaying of my viewports and would really > appreciate if someone could help me. > My problem is that I made presentation which includes text viewport. I also > created another presentation which includes two viewports - one with the > stimulus (of some object I created) and second of another text viewport. > > Each of the viewports when run separately work well, however when I try to > run first presentation and after it the second one, the second one runs, but > it does not display on the screen. Also when i run the presentation with two > viewports only the one added as the second one displays on the screen. > I would really appreciate if someone could tell me what I am doing wrong. > > best wishes to you all, > Maja > > ------------------------------ > With Windows Live, you can organize, edit, and share your photos. Click > here. <http://www.windowslive.com/Desktop/PhotoGallery> >