Python pygame 模块,RESIZABLE 实例源码

我们从Python开源项目中,提取了以下30个代码示例,用于说明如何使用pygame.RESIZABLE

项目:Maps    作者:DarkPurple141    | 项目源码 | 文件源码
def pygame_demo_image():

    # this function is for demoing a default output
    size,polygons,poly_sites,rivers,cities,roads,regions = setup()
    pygame.init()
    pygame.font.init()

    screen = pygame.display.set_mode(size,pygame.RESIZABLE)
    pygame.display.set_caption('Map')
    city_font = pygame.font.SysFont('arial', 20)
    region_font = pygame.font.SysFont('arial', 30)

    simple_render(polygons,poly_sites,rivers,cities,roads,regions,city_font,region_font,flag=True)
    pygame.image.save(screen,'test.png')

    pygame.quit()
项目:PyCut    作者:FOSSRIT    | 项目源码 | 文件源码
def _run_pygame_cb(self, main_fn):
        assert pygame.display.get_surface() is None, "PygameCanvas.run_pygame can only be called once."

        # Preinitialize Pygame with the X window ID.
        assert pygame.display.get_init() == False, "Pygame must not be initialized before calling PygameCanvas.run_pygame."
        os.environ['SDL_WINDOWID'] = str(self._socket.get_id())
        pygame.init()

        # Restore the default cursor.
        self._socket.props.window.set_cursor(None)

        # Initialize the Pygame window.
        r = self.get_allocation()
        pygame.display.set_mode((r.width, r.height), pygame.RESIZABLE)

        # Hook certain Pygame functions with GTK equivalents.
        self.translator.hook_pygame()

        # Run the Pygame main loop.
        main_fn()
        return False
项目:Physics-2.0    作者:rschwa6308    | 项目源码 | 文件源码
def handle_events(*args):
    settings_window, camera, scroll, done, dims, screen, bodies, G, COR = args
    for event in pg.event.get():
        if event.type == pg.VIDEORESIZE:
            width, height = event.w, event.h
            dims, screen = V2(width, height), pg.display.set_mode((width, height), pg.RESIZABLE)
        elif event.type == pg.KEYDOWN:
            scroll.key(event.key, 1)
            camera.key_down(event.key)
        elif event.type == pg.KEYUP:
            scroll.key(event.key, 0)
            camera.key_up(event.key)
        elif event.type == pg.MOUSEBUTTONDOWN:
            handle_mouse(settings_window, camera, event, bodies, dims, G, COR, scroll)
        done |= event.type == pg.QUIT
    return done, dims, screen
项目:eduActiv8    作者:imiolek-ireneusz    | 项目源码 | 文件源码
def fullscreen_toggle(self, info):
        """toggle between fullscreen and windowed version with CTRL + F
        current activity will be reset"""
        self.redraw_needed = [True, True, True]
        if self.config.fullscreen is True:
            self.config.fullscreen = False
            self.size = self.wn_size[:]
            self.screen = pygame.display.set_mode(self.size, pygame.RESIZABLE)
            self.fs_rescale(info)
        else:
            self.config.fullscreen = True
            self.size = self.fs_size[:]
            self.screen = pygame.display.set_mode(self.size, pygame.FULLSCREEN)
            self.fs_rescale(info)

            pygame.display.flip()
项目:HFOSSFinal    作者:AlanLeeson    | 项目源码 | 文件源码
def _run_pygame_cb(self, main_fn):
        assert pygame.display.get_surface() is None, "PygameCanvas.run_pygame can only be called once."

        # Preinitialize Pygame with the X window ID.
        assert pygame.display.get_init() == False, "Pygame must not be initialized before calling PygameCanvas.run_pygame."
        os.environ['SDL_WINDOWID'] = str(self._socket.get_id())
        pygame.init()

        # Restore the default cursor.
        self._socket.props.window.set_cursor(None)

        # Initialize the Pygame window.
        r = self.get_allocation()
        pygame.display.set_mode((r.width, r.height), pygame.RESIZABLE)

        # Hook certain Pygame functions with GTK equivalents.
        self.translator.hook_pygame()

        # Run the Pygame main loop.
        main_fn()
        return False
项目:math-hurdler    作者:craigcabrey    | 项目源码 | 文件源码
def _run_pygame_cb(self, main_fn):
        assert pygame.display.get_surface() is None, "PygameCanvas.run_pygame can only be called once."

        # Preinitialize Pygame with the X window ID.
        assert pygame.display.get_init() == False, "Pygame must not be initialized before calling PygameCanvas.run_pygame."
        os.environ['SDL_WINDOWID'] = str(self._socket.get_id())
        pygame.init()

        # Restore the default cursor.
        self._socket.props.window.set_cursor(None)

        # Initialize the Pygame window.
        r = self.get_allocation()
        pygame.display.set_mode((r.width, r.height), pygame.RESIZABLE)

        # Hook certain Pygame functions with GTK equivalents.
        self.translator.hook_pygame()

        # Run the Pygame main loop.
        main_fn()
        return False
项目:sc8pr    作者:dmaccarthy    | 项目源码 | 文件源码
def _pygameMode(self, n): return pygame.RESIZABLE if n is True else int(n)
项目:PyCut    作者:FOSSRIT    | 项目源码 | 文件源码
def main():
    pygame.init()
    pygame.display.set_mode((1200, 900), pygame.RESIZABLE)
    game_instance = PyCut()
    game_instance.run()
项目:Physics-2.0    作者:rschwa6308    | 项目源码 | 文件源码
def init_display():
    pg.init()
    info = pg.display.Info()
    dims = (int(info.current_w * 0.6), int(info.current_h * 0.75))
    os.environ['SDL_VIDEO_CENTERED'] = '1'
    pg.display.set_icon(pg.image.load('AtomIcon.png'))
    screen = pg.display.set_mode(dims, pg.RESIZABLE)
    pg.display.set_caption("Physics Simulator 2.0")
    return screen, V2(dims)
项目:python-kinect    作者:jgerschler    | 项目源码 | 文件源码
def __init__(self):
        pygame.init()

        # Used to manage how fast the screen updates
        self._clock = pygame.time.Clock()

        # Loop until the user clicks the close button.
        self._done = False

        # Used to manage how fast the screen updates
        self._clock = pygame.time.Clock()

        # Kinect runtime object, we want only color and body frames 
        self._kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Infrared)

        # back buffer surface for getting Kinect infrared frames, 8bit grey, width and height equal to the Kinect color frame size
        self._frame_surface = pygame.Surface((self._kinect.infrared_frame_desc.Width, self._kinect.infrared_frame_desc.Height), 0, 24)
        # here we will store skeleton data 
        self._bodies = None

        # Set the width and height of the screen [width, height]
        self._infoObject = pygame.display.Info()
        self._screen = pygame.display.set_mode((self._kinect.infrared_frame_desc.Width, self._kinect.infrared_frame_desc.Height), 
                                                pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)

        pygame.display.set_caption("Kinect for Windows v2 Infrared")
项目:python-kinect    作者:jgerschler    | 项目源码 | 文件源码
def run(self):
        # -------- Main Program Loop -----------
        while not self._done:
            # --- Main event loop
            for event in pygame.event.get(): # User did something
                if event.type == pygame.QUIT: # If user clicked close
                    self._done = True # Flag that we are done so we exit this loop

                elif event.type == pygame.VIDEORESIZE: # window resized
                    self._screen = pygame.display.set_mode(event.dict['size'], 
                                                pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)


            # --- Getting frames and drawing  
            if self._kinect.has_new_infrared_frame():
                frame = self._kinect.get_last_infrared_frame()
                self.draw_infrared_frame(frame, self._frame_surface)
                frame = None

            self._screen.blit(self._frame_surface, (0,0))
            pygame.display.update()

            # --- Go ahead and update the screen with what we've drawn.
            pygame.display.flip()

            # --- Limit to 60 frames per second
            self._clock.tick(60)

        # Close our Kinect sensor, close the window and quit.
        self._kinect.close()
        pygame.quit()
项目:python-kinect    作者:jgerschler    | 项目源码 | 文件源码
def __init__(self):
        pygame.init()

        # Used to manage how fast the screen updates
        self._clock = pygame.time.Clock()

        # Set the width and height of the screen [width, height]
        self._infoObject = pygame.display.Info()
        self._screen = pygame.display.set_mode((self._infoObject.current_w >> 1, self._infoObject.current_h >> 1), 
                                               pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)

        pygame.display.set_caption("Kinect for Windows v2 Body Game")

        # Loop until the user clicks the close button.
        self._done = False

        # Used to manage how fast the screen updates
        self._clock = pygame.time.Clock()

        # Kinect runtime object, we want only color and body frames 
        self._kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Color | PyKinectV2.FrameSourceTypes_Body)

        # back buffer surface for getting Kinect color frames, 32bit color, width and height equal to the Kinect color frame size
        self._frame_surface = pygame.Surface((self._kinect.color_frame_desc.Width, self._kinect.color_frame_desc.Height), 0, 32)

        # here we will store skeleton data 
        self._bodies = None
项目:python-kinect    作者:jgerschler    | 项目源码 | 文件源码
def __init__(self):
        pygame.init()
        pygame.mixer.init()

        self.beep_sound = pygame.mixer.Sound('audio\\beep.ogg')
        self.buzz_sound = pygame.mixer.Sound('audio\\buzz.ogg')
        self._infoObject = pygame.display.Info()
        self._screen = pygame.display.set_mode((self._infoObject.current_w >> 1,
                                                self._infoObject.current_h >> 1),
                                               pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)

        pygame.display.set_caption("Kinect Game Framework Test")

        self.finished = False
        self._clock = pygame.time.Clock()
        self._kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Color |
                                                       PyKinectV2.FrameSourceTypes_Body)
        self._frame_surface = pygame.Surface((self._kinect.color_frame_desc.Width,
                                              self._kinect.color_frame_desc.Height), 0, 32)
        self._bodies = None

        self.score = 0

        self.vocab_dict = {"beach":"playa", "desert":"desierto", "forest":"bosque",
                           "jungle":"selva", "hill":"loma", "island":"isla",
                           "lake":"lago", "mountain":"montaña", "ocean":"oceano",
                           "river":"rio", "valley":"valle", "basin":"cuenca",
                           "volcano":"volcano", "waterfall":"cascada", "creek":"arroyo"}

        self._frame_surface.fill((255, 255, 255))
项目:eduActiv8    作者:imiolek-ireneusz    | 项目源码 | 文件源码
def on_resize(self, size, info):
        if android is None:
            # pygame.event.set_blocked(pygame.VIDEORESIZE)
            repost = False
            if size[0] < self.config.size_limits[0]:
                size[0] = self.config.size_limits[0]
                repost = True
            if size[0] > self.config.size_limits[2]:
                size[0] = self.config.size_limits[2]
                repost = True

            if size[1] < self.config.size_limits[1]:
                size[1] = self.config.size_limits[1]
                repost = True
            if size[1] > self.config.size_limits[3]:
                size[1] = self.config.size_limits[3]
                repost = True

            if size != self.fs_size or self.config.platform == "macos":
                self.wn_size = size[:]
                self.size = size[:]
            self.config.settings["screenw"] = self.size[0]
            self.config.settings["screenh"] = self.size[1]
            self.screen = pygame.display.set_mode(self.size, pygame.RESIZABLE)

            self.fs_rescale(info)
            self.config.settings_changed = True
            self.config.save_settings(self.db)
            # pygame.event.set_allowed(pygame.VIDEORESIZE)
            if repost:
                pygame.event.post(
                    pygame.event.Event(pygame.VIDEORESIZE, size=self.size[:], w=self.size[0], h=self.size[1]))

        if android is not None:
            self.size = self.android_screen_size[:]
        self.info.rescale_title_space()
项目:HFOSSFinal    作者:AlanLeeson    | 项目源码 | 文件源码
def run(self):
        self.screen = pygame.display.get_surface()

        while self.running:
            # Pump GTK messages.


            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    return
                elif event.type == pygame.VIDEORESIZE:
                    pygame.display.set_mode(event.size, pygame.RESIZABLE)
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_LEFT: 
                        self.currentPlayState = self.playStates.Paused


            # Clear Display
            self.screen.fill(self.white)

            options = { 0 : self.drawMenuState,
                        1 : self.drawPlayState,
                        2 : self.drawInstructionState
            }
            options[self.currentPlayState]()

            # Flip Display
            pygame.display.flip()

            # Try to stay at 30 FPS
            self.clock.tick(30)





# This function is called when the game is run directly from the command line:
# ./TestGame.py
项目:HFOSSFinal    作者:AlanLeeson    | 项目源码 | 文件源码
def main():
    pygame.init()
    pygame.display.set_mode((1200, 900), pygame.RESIZABLE)
    game = BalancingAct()
    game.run()
项目:matrix    作者:bitcraft    | 项目源码 | 文件源码
def init_screen(width, height):
    global screen_size

    screen_size = width, height
    return pygame.display.set_mode(screen_size, pygame.RESIZABLE)
项目:Heap-Project-1    作者:stacompsoc    | 项目源码 | 文件源码
def start(self):
        """Initialize graphics."""
        pygame.init()
        pygame.mixer.quit()
        info = pygame.display.Info()
        self.width, self.height = info.current_w, info.current_h - 60
        self.screen = pygame.display.set_mode(
            (self.width, self.height),
            pygame.RESIZABLE
        )
        print(os.path.dirname(os.path.realpath(__file__)))
        self.surficon = pygame.image.load(ICONPATH).convert_alpha()
项目:model-converter-python    作者:tforgione    | 项目源码 | 文件源码
def resize(width, height):
    length = min(width, height)
    offset = int( math.fabs(width - height) / 2)

    # Ugly AF
    pg.display.set_mode((width, height), pg.DOUBLEBUF | pg.RESIZABLE | pg.OPENGL)

    if width < height:
        gl.glViewport(0, offset, length, length)
    else:
        gl.glViewport(offset, 0, length, length)
项目:fruit    作者:felko    | 项目源码 | 文件源码
def create(cls, size, resizable=True):
        """
        Instantiate the window at a given size.
        """

        surface = Surface(size)

        flag = 0

        if resizable:
            flag = pygame.RESIZABLE

        surface._surface = pygame.display.set_mode(tuple(size), flag)
        return cls(surface)
项目:math-hurdler    作者:craigcabrey    | 项目源码 | 文件源码
def main():
    pygame.init()
    pygame.display.set_mode((0, 0), pygame.RESIZABLE)
    game = MathHurdler()
    game.run()
项目:DungeonTableMap    作者:ShadowApex    | 项目源码 | 文件源码
def init_screen(width, height):
    global temp_surface
    screen = pygame.display.set_mode((width, height), pygame.RESIZABLE)
    temp_surface = pygame.Surface((width / 2, height / 2)).convert()
    return screen
项目:pyweather    作者:rbischoff    | 项目源码 | 文件源码
def __init__(self, drivers=DEFAULT_DRIVERS, size=DEFAULT_SIZE, screen_type=DEFAULT_SCREEN, borders=(5, 5),
                 border_width=3, line_color=(255, 255, 255), font='freesans', font_color=(255, 255, 255),
                 icons=ICON_DICTIONARY):
        """DisplayDriver class is the class that build the base display for use in the weather
        app.  Argument descriptions: drivers is a tuple of strings with available SDL_VIDEODRIVER
        environmental varaibles; size is a tuple of two integers describing the x, y size of the
        screen; screen_type is a string value that corresponds to the pygame constants for
        dispay.set_mode
        """

        formats = {'no_frame': pygame.NOFRAME, 'full_screen': pygame.FULLSCREEN, 'double_buff': pygame.DOUBLEBUF,
                   'hw_surface': pygame.HWSURFACE, 'open_GL': pygame.OPENGL, 'resizable': pygame.RESIZABLE}

        self._system_data = SystemData()
        self._display_instance = None
        self._drivers = drivers
        self._size = size
        self._borders = borders
        self._border_width = border_width
        self._line_color = line_color
        self._font = font
        self._font_color = font_color
        self._format = formats[screen_type]
        self._icons = icons
        self._base_dir = os.getcwd() + ICON_BASE_DIR
        self._scale_icons = True
        self._xmax = self._size[0] - self._borders[0]
        self._ymax = self._size[1] - self._borders[1]
        self._av = 1
        self._av_time = 1
        self._screen = None
        self._blits = []
项目:Maps    作者:DarkPurple141    | 项目源码 | 文件源码
def testVoronoi():

    size,polygons,poly_site,river_list,city_sites,road_list,regions = setup(main_island_shape_seed=None)

    pygame.init()
    pygame.font.init()
    city_font = pygame.font.SysFont('cardinal', 20) #cardinal
    region_font = pygame.font.SysFont('cardinal', 30)

    GAMEOVER = False
    clock = pygame.time.Clock()

    screen = pygame.display.set_mode(size,pygame.RESIZABLE)
    screen.fill((255,255,255))
    pygame.display.set_caption('Voronoi')
    pygame.draw.rect(screen,(255,0,0),[384,320,32,32],0)
    curr = Floating(384,320)

    poly = polyDict = False
    count = 0
    first = False
    pre_render(polygons,poly_site)
    render_rivers(river_list)
    render_roads(road_list)
    bg = v_fx(screen)
    while not GAMEOVER:
        # --- Main event loop for event handling
        action = False
        for e in pygame.event.get(): # User did something
            action = True
            if e.type == pygame.QUIT: # If user clicked close
                GAMEOVER = True
            elif e.type == pygame.MOUSEBUTTONUP:
                x,y = pygame.mouse.get_pos()
                found = False
                """
                for p in polygons:
                    if p.inside_polygon(x,y) and not found:
                        pts = [i.get_cords() for i in p.vertices]
                        pygame.draw.polygon(screen,(40,40,40),pts)
                        found = True
                    else:
                        p.draw()
                """
        if action:
            for p in polygons:
                p.draw()
            render_rivers(river_list)
            render_roads(road_list)
            render_cities(city_sites,city_font)
            render_regions(regions,region_font)

        pygame.display.update()
        #print(pygame.image.tostring(screen,"RGB"))
        # --- Limit to 5 frames per second
        clock.tick(5)

        if not polyDict:
            polyDict = not polyDict

    pygame.quit()
项目:Projects    作者:it2school    | 项目源码 | 文件源码
def todo_test_set_mode(self):

        # __doc__ (as of 2008-08-02) for pygame.display.set_mode:

          # pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface
          # initialize a window or screen for display
          # 
          # This function will create a display Surface. The arguments passed in
          # are requests for a display type. The actual created display will be
          # the best possible match supported by the system.
          # 
          # The resolution argument is a pair of numbers representing the width
          # and height. The flags argument is a collection of additional
          # options.  The depth argument represents the number of bits to use
          # for color.
          # 
          # The Surface that gets returned can be drawn to like a regular
          # Surface but changes will eventually be seen on the monitor.
          # 
          # If no resolution is passed or is set to (0, 0) and pygame uses SDL
          # version 1.2.10 or above, the created Surface will have the same size
          # as the current screen resolution. If only the width or height are
          # set to 0, the Surface will have the same width or height as the
          # screen resolution. Using a SDL version prior to 1.2.10 will raise an
          # exception.
          # 
          # It is usually best to not pass the depth argument. It will default
          # to the best and fastest color depth for the system. If your game
          # requires a specific color format you can control the depth with this
          # argument. Pygame will emulate an unavailable color depth which can
          # be slow.
          # 
          # When requesting fullscreen display modes, sometimes an exact match
          # for the requested resolution cannot be made. In these situations
          # pygame will select the closest compatable match. The returned
          # surface will still always match the requested resolution.
          # 
          # The flags argument controls which type of display you want. There
          # are several to choose from, and you can even combine multiple types
          # using the bitwise or operator, (the pipe "|" character). If you pass
          # 0 or no flags argument it will default to a software driven window.
          # Here are the display flags you will want to choose from:
          # 
          #    pygame.FULLSCREEN    create a fullscreen display
          #    pygame.DOUBLEBUF     recommended for HWSURFACE or OPENGL
          #    pygame.HWSURFACE     hardware accelerated, only in FULLSCREEN
          #    pygame.OPENGL        create an opengl renderable display
          #    pygame.RESIZABLE     display window should be sizeable
          #    pygame.NOFRAME       display window will have no border or controls

        self.fail()
项目:python-kinect    作者:jgerschler    | 项目源码 | 文件源码
def run(self):
        # -------- Main Program Loop -----------
        while not self._done:
            # --- Main event loop
            for event in pygame.event.get(): # User did something
                if event.type == pygame.QUIT: # If user clicked close
                    self._done = True # Flag that we are done so we exit this loop

                elif event.type == pygame.VIDEORESIZE: # window resized
                    self._screen = pygame.display.set_mode(event.dict['size'], 
                                               pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)

            # --- Game logic should go here

            # --- Getting frames and drawing  
            # --- Woohoo! We've got a color frame! Let's fill out back buffer surface with frame's data 
            if self._kinect.has_new_color_frame():
                frame = self._kinect.get_last_color_frame()
                self.draw_color_frame(frame, self._frame_surface)
                frame = None

            # --- Cool! We have a body frame, so can get skeletons
            if self._kinect.has_new_body_frame(): 
                self._bodies = self._kinect.get_last_body_frame()

            # --- draw skeletons to _frame_surface
            if self._bodies is not None: 
                for i in range(0, self._kinect.max_body_count):
                    body = self._bodies.bodies[i]
                    if not body.is_tracked: 
                        continue 

                    joints = body.joints 
                    # convert joint coordinates to color space 
                    joint_points = self._kinect.body_joints_to_color_space(joints)
                    self.draw_body(joints, joint_points, SKELETON_COLORS[i])

            # --- copy back buffer surface pixels to the screen, resize it if needed and keep aspect ratio
            # --- (screen size may be different from Kinect's color frame size) 
            h_to_w = float(self._frame_surface.get_height()) / self._frame_surface.get_width()
            target_height = int(h_to_w * self._screen.get_width())
            surface_to_draw = pygame.transform.scale(self._frame_surface, (self._screen.get_width(), target_height));
            self._screen.blit(surface_to_draw, (0,0))
            surface_to_draw = None
            pygame.display.update()

            # --- Go ahead and update the screen with what we've drawn.
            pygame.display.flip()

            # --- Limit to 60 frames per second
            self._clock.tick(60)

        # Close our Kinect sensor, close the window and quit.
        self._kinect.close()
        pygame.quit()
项目:AIFun    作者:Plottel    | 项目源码 | 文件源码
def todo_test_set_mode(self):

        # __doc__ (as of 2008-08-02) for pygame.display.set_mode:

          # pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface
          # initialize a window or screen for display
          # 
          # This function will create a display Surface. The arguments passed in
          # are requests for a display type. The actual created display will be
          # the best possible match supported by the system.
          # 
          # The resolution argument is a pair of numbers representing the width
          # and height. The flags argument is a collection of additional
          # options.  The depth argument represents the number of bits to use
          # for color.
          # 
          # The Surface that gets returned can be drawn to like a regular
          # Surface but changes will eventually be seen on the monitor.
          # 
          # If no resolution is passed or is set to (0, 0) and pygame uses SDL
          # version 1.2.10 or above, the created Surface will have the same size
          # as the current screen resolution. If only the width or height are
          # set to 0, the Surface will have the same width or height as the
          # screen resolution. Using a SDL version prior to 1.2.10 will raise an
          # exception.
          # 
          # It is usually best to not pass the depth argument. It will default
          # to the best and fastest color depth for the system. If your game
          # requires a specific color format you can control the depth with this
          # argument. Pygame will emulate an unavailable color depth which can
          # be slow.
          # 
          # When requesting fullscreen display modes, sometimes an exact match
          # for the requested resolution cannot be made. In these situations
          # pygame will select the closest compatable match. The returned
          # surface will still always match the requested resolution.
          # 
          # The flags argument controls which type of display you want. There
          # are several to choose from, and you can even combine multiple types
          # using the bitwise or operator, (the pipe "|" character). If you pass
          # 0 or no flags argument it will default to a software driven window.
          # Here are the display flags you will want to choose from:
          # 
          #    pygame.FULLSCREEN    create a fullscreen display
          #    pygame.DOUBLEBUF     recommended for HWSURFACE or OPENGL
          #    pygame.HWSURFACE     hardware accelerated, only in FULLSCREEN
          #    pygame.OPENGL        create an opengl renderable display
          #    pygame.RESIZABLE     display window should be sizeable
          #    pygame.NOFRAME       display window will have no border or controls

        self.fail()
项目:TonsleyLEDManager    作者:JonnoFTW    | 项目源码 | 文件源码
def show(Runner, arg=None, fps=24, rows=17, cols=165, scale=8, withArgs=False):
    import pygame, sys
    FPS = fps
    fpsClock = pygame.time.Clock()

    board_dimensions = (cols, rows)
    #yep
    disp_size = (cols * scale, rows * scale)
    pygame.init()
    screen_opts =  pygame.RESIZABLE | pygame.DOUBLEBUF
    screen = pygame.display.set_mode(disp_size, screen_opts)
    changed = False
    if arg is None:
        runner = Runner(board_dimensions)
    else:
        runner = Runner(board_dimensions, arg)
    font = pygame.font.Font('slkscr.ttf', 32)
    while True:
        events = pygame.event.get()
        for e in events:
            if e.type == pygame.QUIT:
                sys.exit()
            if e.type == pygame.VIDEORESIZE:
                disp_size = e.dict['size']
                screen = pygame.display.set_mode(disp_size, screen_opts)
        screen.fill((0, 0, 0))
        # draw the pixels
        txts = ["FPS: {0:.2f}".format(fpsClock.get_fps())]
        if withArgs:
            pixels, txt = runner.run(events)
            txts.append(txt)
        else:
            pixels = runner.run()
            if type(pixels) is tuple:
                pixels, txt = pixels
                txts.append(txt)

        temp_surface = pygame.Surface(board_dimensions)
        pygame.surfarray.blit_array(temp_surface, pixels)
        pygame.transform.scale(temp_surface, disp_size, screen)
        i = 1
        for txt in txts:
            for line in txt.splitlines():
                screen.blit(font.render(line.replace('[', '').replace(']', '').strip(), 1, (255, 255, 255)),
                            (30, 30 * i))
                i += 1

        pygame.display.flip()
        fpsClock.tick(FPS)
项目:Camera2TCP    作者:kevinkit    | 项目源码 | 文件源码
def __init__(self, host, port,camtype="webcam",ID=0,image_name='lena.png',change=True,Debug=True):
        self.host = host
        self.port = port
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.sock.bind((self.host, self.port))
        self.comThreads = []
        self.alive = True;
        self.RGB0 = [];
        self.Depth = [];
        self.Body = [];
        self.camtype = camtype;
        self.ret = False;
        self.log = "test"
        self.HDRGB = [];
        self.imageName = image_name;
        self.change = change;
        self.sys_random = random.SystemRandom();
        #Assuming 8bit pic
        self.cnt = 0;
        self.trip = 0;
        self.Debug = Debug

        self.send_counter = 0;
        self.rgb_cnt = 0;
        #Locks
        self.Lock  = threading.Lock()

        if self.Debug:
            self.img = cv2.imread(self.imageName); #This one will be altered!
            self.orig_img = cv2.imread(self.imageName); #This one will be the same
            self.ImageT = threading.Thread(target=self.imagechanger)
            self.ImageT.start()
            self.height,self.width,self.channel = self.img.shape;
            self.x_pos = random.randint(10,self.width);
            self.y_pos = random.randint(10,self.height);
            if self.ImageT.isAlive():
                self.log = "height: " + str(self.height)
        if Kinect:
            pygame.init()


            #Used to manage how fast the screen updates
            self._clock = pygame.time.Clock()
            self._done = False;
            self._infoObject = pygame.display.Info()
            self._screen = pygame.display.set_mode((self._infoObject.current_w >> 1, self._infoObject.current_h >> 1),
                                       pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)



            # Kinect runtime object, we want only color and body frames
            self._kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Color | PyKinectV2.FrameSourceTypes_Body | PyKinectV2.FrameSourceTypes_Depth | PyKinectV2.FrameSourceTypes_Infrared)
            # back buffer surface for getting Kinect color frames, 32bit color, width and height equal to the Kinect color frame size
            self._frame_surface = pygame.Surface((self._kinect.color_frame_desc.Width, self._kinect.color_frame_desc.Height), 0, 32)
            # here we will store skeleton data
            self._bodies = None

        if camtype == "webcam":

            self.cap = cv2.VideoCapture(ID)
项目:KinectHowOld    作者:crwilcox    | 项目源码 | 文件源码
def __init__(self):
        pygame.init()


        # Used to manage how fast the screen updates
        self._clock = pygame.time.Clock()

        # Set the width and height of the screen [width, height]
        self._infoObject = pygame.display.Info()
        self._screen = pygame.display.set_mode(
            (self._infoObject.current_w >> 1, self._infoObject.current_h >> 1),
            pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.RESIZABLE, 32
        )

        pygame.display.set_caption("Guess your Age!")

        # Loop until the user clicks the close button.
        self._done = False

        # Kinect runtime object, we want only color and body frames
        if PyKinectRuntime and USE_KINECT:
            self._kinect = PyKinectRuntime.PyKinectRuntime(
                PyKV2.FrameSourceTypes_Color |
                PyKV2.FrameSourceTypes_Body
            )
            frame_dimension = (
                self._kinect.color_frame_desc.Width,
                self._kinect.color_frame_desc.Height
            )
        else:
            self._kinect = None
            frame_dimension = 800, 600

        # back buffer surface for getting Kinect color frames, 32bit color,
        # width and height equal to the Kinect color frame size
        self._frame_surface = pygame.Surface(frame_dimension, 0, 32)

        # here we will store skeleton data
        self._bodies = None
        self._stored_bodies = {}

        self._faces = []
        self._face_bodies = []

        self._update_oxford = 0
        self.python_logo_image = pygame.image.load('pylogo.png')
        self.msft_logo_image = pygame.image.load('microsoftlogo.png')

        self.bg_color = pygame.Color(55, 117, 169)