How to use the pygame.display.set_mode function in pygame

To help you get started, we’ve selected a few pygame examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Impelon / PyGVisuals / examples / bintree-gui / bintree-gui.py View on Github external
"""
    Validation function for an Entry; limits inputs to numbers smaller than 101

    parameters:     str the text to be set
                    str the current text
                    gui.Entry the entry affected
    return values:  boolean is the operation valid
    """
    return not newtext or (newtext.isdigit() and int(newtext) < 101)

#Setting Display#

w = 900
h = 600

screen = pygame.display.set_mode((w, h), 0, 32)
pygame.display.set_caption("Tree-GUI | Python Game")
pygame.mouse.set_visible(1)
pygame.key.set_repeat(50)

background = pygame.Surface((w, h))
background.fill((255, 255, 255))

#Widgets#

des.getDefaultDesign().border     = brd.CompoundBorder(brd.RoundedBorder(3, 3, (150, 190, 255, 200), 8), brd.RoundedBorder(2, 2, (30, 90, 150), 8))
des.getDefaultDesign().background = (120, 160, 200)
w_w                               = 130
w_h                               = 25

w_bg        = gui.Widget(w * 0.8571428571428571 - w_w // 2 - 20, 10, w_w // 2 + w * 0.14285714285714285, h - 20).setBackground((220, 220, 250))
l           = gui.Label(w * 0.8571428571428571 - w_w // 2, 10, w_w, w_h, "Tree-GUI").setBackground((0, 0, 0, 0)).setForeground((50, 50, 50)).setBorder(brd.Border(0, 0))
github gil9red / SimplePyScripts / pygame__examples / move_circle.py View on Github external
__author__ = 'ipetrash'


# pip install pygame
import pygame


FPS = 60
W = 700  # ширина экрана
H = 300  # высота экрана
WHITE = (255, 255, 255)
BLUE = (0, 70, 225)

pygame.init()
screen = pygame.display.set_mode((W, H))
clock = pygame.time.Clock()

# координаты и радиус круга
x = W // 2
y = H // 2
r = 50

step = 4

game_active = True

while True:
    # Получение всех событий
    for event in pygame.event.get():
        # Проверка события "Выход"
        if event.type == pygame.QUIT:
github jerbly / tutorials / pygamelcd / test1.py View on Github external
'''
Created on Jul 12, 2014

@author: jeremyblythe
'''
import pygame
import os
from time import sleep

os.putenv('SDL_FBDEV', '/dev/fb1')
pygame.init()
lcd = pygame.display.set_mode((320, 240))
lcd.fill((255,0,0))
pygame.display.update()
sleep(1)

pygame.mouse.set_visible(False)

lcd.fill((0,0,0))
pygame.display.update()
github fridlington / K11Consult / singleDialDemo.py View on Github external
sys.exit()
            pygame.quit()

        if event.type is KEYDOWN and event.key == K_w:
            pygame.display.set_mode((size),pygame.HWSURFACE | pygame.DOUBLEBUF)

            backgroundX = backgroundWindowedX
            backgroundY = backgroundWindowedY
            needleX = needleWindowedX
            needleY = needleWindowedY
            dial1X = dial1WindowedX
            dial1Y = dial1WindowedY
            screen.fill(0x000000)

        if event.type is KEYDOWN and event.key == K_f:
            pygame.display.set_mode((monitorX,monitorY), FULLSCREEN)

            backgroundX = backgroundFullscreenX
            backgroundY = backgroundFullscreenY
            needleX = needleFullscreenX
            needleY = needleFullscreenY
            dial1X = dial1FullscreenX
            dial1Y = dial1FullscreenY
            screen.fill(0x000000)

    screen.fill(0x000000)

    needleNew = pygame.transform.rotozoom(needle, (120 - (RPM_Value  / 33.33)),1)
    displayValue = fontFifty.render(("%s" % MPH_Value), 1, (255,0,255))
    labelRect = displayValue.get_rect()
    labelRect.centerx = dial1X
    labelRect.centery = dial1Y
github bskari / pi-rc / interactive_control.py View on Github external
def interactive_control(host, port, configuration):
    """Runs the interactive control."""
    pygame.init()
    size = (300, 400)
    screen = pygame.display.set_mode(size)
    # pylint: disable=too-many-function-args
    background = pygame.Surface(screen.get_size())
    clock = pygame.time.Clock()
    black = (0, 0, 0)
    white = (255, 255, 255)
    big_font = pygame.font.Font(None, 40)
    little_font = pygame.font.Font(None, 24)

    pygame.display.set_caption('rc-pi interactive')

    text = big_font.render('Use arrows to move', 1, white)
    text_position = text.get_rect(centerx=size[0] / 2)
    background.blit(text, text_position)
    screen.blit(background, (0, 0))
    pygame.display.flip()
github paparazzi / paparazzi / sw / tools / attitude_viz.py View on Github external
rotate_theta = 0
    try:
        opts, args = getopt.getopt(sys.argv[1:], "t:r:", ["title", "rotate_theta"])
        for o, a in opts:
            if o in ("-t", "--title"):
                window_title = a
            if o in ("-r", "--rotate_theta"):
                rotate_theta = int(a)
    except getopt.error as msg:
        print(msg)
        print("""usage:
-t, --title                   set window title
-r, --rotate_theta           rotate the quaternion by n degrees over the pitch axis (default: 0)
""")
    pygame.init()
    screen = pygame.display.set_mode(SCREEN_SIZE, pygame.OPENGL | pygame.DOUBLEBUF)
    #resize(*SCREEN_SIZE)
    init()
    visualizer = Visualizer(rotate_theta)

    try:
        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    visualizer.OnClose()
                    return
                if event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE:
                    visualizer.OnClose()
                    return
            visualizer.Draw()
            pygame.display.flip()
            time.sleep(.02)
github geek-ai / MAgent / python / magent / renderer / pygame_renderer.py View on Github external
raise NotImplementedError

        if not isinstance(server, BaseServer):
            raise BaseException('property server must be an instance of BaseServer')

        pygame.init()
        pygame.display.init()

        if resolution is None:
            info = pygame.display.Info()
            resolution = info.current_w, info.current_h

        clock = pygame.time.Clock()
        
        if full_screen:
            canvas = pygame.display.set_mode(resolution, pygame.DOUBLEBUF | pygame.FULLSCREEN, 0)
        else:
            canvas = pygame.display.set_mode(resolution, pygame.DOUBLEBUF, 0)

        pygame.display.set_caption('MAgent Renderer Window')
        text_formatter = pygame.font.SysFont(None, text_size, True)
        banner_formatter = pygame.font.SysFont(None, banner_size, True)
        bigscreen_formatter = pygame.font.SysFont(None, bigscreen_size, True)

        map_size, groups, static_info = server.get_info()
        view_position = [map_size[0] / 2 * grid_size - resolution[0] / 2, 
                         map_size[1] / 2 * grid_size - resolution[1] / 2]
        frame_id = 0

        walls  = static_info['wall']

        old_data = None
github fpietka / python-fighter / bin / game.py View on Github external
def __init__(self):
        """
        Initialize the game
        """
        pygame.init()
        self.screen = pygame.display.set_mode(self.size)
        pygame.event.set_allowed([pygame.QUIT, pygame.KEYDOWN, pygame.KEYUP])
        # build background
        path = os.path.dirname(os.path.realpath(__file__))
        self.background = pygame.image.load(
            path + '/../assets/background-1.jpg'
        ).convert()
        self.background = pygame.transform.scale2x(self.background)
        # calculate center
        left = (self.background.get_width() - self.size[0]) / 2
        self.position = [-left, 0]
        self.walking = False
        self.sprites = Sprite().build_spriteset()
github fridlington / K11Consult / dashDemo24bit.py View on Github external
surface5WindowedX = (width / 2) - 310
surface5WindowedY = (height / 2) + 60

surface5X = surface5WindowedX
surface5Y = surface5WindowedY

surface6FullscreenX = (monitorX / 2) + 10
surface6FullscreenY = (monitorY / 2) + 60

surface6WindowedX = (width / 2) + 10
surface6WindowedY = (height / 2) + 60

surface6X = surface6WindowedX
surface6Y = surface6WindowedY

screen = pygame.display.set_mode(size)

surface1 = pygame.Surface((1300,720))
surface2 = pygame.Surface((1000,600))
surface3 = pygame.Surface((340,340))
surface4 = pygame.Surface((340,340))
surface5 = pygame.Surface((300,300))
surface6 = pygame.Surface((300,300))

surface2.set_colorkey(0x0000FF)
surface3.set_colorkey(0x0000FF)
surface4.set_colorkey(0x0000FF)
surface5.set_colorkey(0x0000FF)
surface6.set_colorkey(0x0000FF)

screen.fill(0x000000)
github SBTCVM / SBTCVM-Gen2-9 / vmsystem / UIO_PYGAME_G2x_9.py View on Github external
def dogamode(self, data):
		
		if self.gamode==30:
			self.plotobj.disable()
		
		if self.fscreen:
			if data==0:
				self.gamode=0
				self.screensurf=pygame.display.set_mode((charwidth*self.maxx, charheight*self.maxy), pygame.FULLSCREEN)
				self.screensurf.fill(self.textbg)
				pygame.display.flip()
				self.mousesys.modechange(data)
			if data==30:
				self.gamode=30
				self.screensurf=pygame.display.set_mode((self.plotx, self.ploty), pygame.FULLSCREEN)
				self.plotobj.enable()
				self.screensurf.fill((127, 127, 127))
				pygame.display.flip()
				self.mousesys.modechange(data)
		else:
			if data==0:
				self.gamode=0
				self.screensurf=pygame.display.set_mode((charwidth*self.maxx, charheight*self.maxy))
				self.screensurf.fill(self.textbg)
				pygame.display.flip()