本文整理汇总了Python中screen.Screen类的典型用法代码示例。如果您正苦于以下问题:Python Screen类的具体用法?Python Screen怎么用?Python Screen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Screen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_time
def start_time(self, t):
# get start time and set current CB objects (and their change times)
Screen.start_time(self, t)
self._last_CB_change_time_left = t
self._last_CB_change_time_right = t
self._current_CB_left = self.CB_cycle_left.next()
self._current_CB_right = self.CB_cycle_right.next()
示例2: __init__
def __init__(self,name):
Screen.__init__(self,name)
self.screen.fill([0,0,0]) # just black, no graphic background image
# go ahead and calculate the time display/buttons
self.buttonHeight = self.height/3
self.buttonPadding = self.width/25
self.matchImage, self.autoImage, self.teleopImage, self.endGameImage = self.numberImages(self.buttonHeight)
self.buttonWidth = self.matchImage.get_width()
self.matchPos, self.autoPos, self.teleopPos, self.endGamePos = self.numberPositions(self.buttonHeight,
self.buttonWidth,
self.buttonPadding)
self.matchButton = self.buttons((self.buttonWidth,self.buttonHeight),self.matchPos,
graphic=self.matchImage, callback=self.editMatchNumber,gpio=HARDWARE.button.NW)
self.autoButton = self.buttons((self.buttonWidth,self.buttonHeight),self.autoPos,
graphic=self.autoImage, callback=self.editAutoNumber,gpio=HARDWARE.button.SW)
self.teleopButton = self.buttons((self.buttonWidth,self.buttonHeight),self.teleopPos,
graphic=self.teleopImage, callback=self.editTeleopNumber,gpio=HARDWARE.button.NE)
self.endGameButton = self.buttons((self.buttonWidth,self.buttonHeight),self.endGamePos,
graphic=self.endGameImage, callback=self.editEndGameNumber,gpio=HARDWARE.button.SE)
self.ButtonS = self.buttons(bgcolor = (0,0,255), callback=self.done,
**Button.standardButton("S","Done",self.screen))
示例3: __init__
def __init__(self, game, materials, newMaterials, money):
self.money = money
self.game = game
self.materials = materials
self.newMaterials = newMaterials
self.constantLabels = []
self.shownItems = []
self.mixScreenButton = MatSciGame.MixScreenButton("mixScreen","img/MixingButton.png", pygame.Rect(900, 300, 300, 75),MatSciGame.ForceScreenButton.clicked, self.game)
self.constantLabels.append(ScreenText("moneyText", "Money = " + str(self.money), pygame.Rect(900, 0, 300, 75), pygame.font.SysFont("Arial", 40)))
self.Notificationlabels = []
self.infoLabels = []
self.actors = self.constantLabels + self.shownItems
self.buttons = [self.mixScreenButton]
Screen.__init__(self, self.buttons, self.actors, "img/bookOpen.png")
示例4: __init__
def __init__(self, **args):
self.choice = self.nextchoice = 0
self.choices = [i.upper() for i in ['Arcade', 'VS Mode', 'Training', 'Options', 'Exit']]
self.done = False
keycond = lambda: not self.done
Screen.__init__(self, 'system/title', keycond=keycond, **args)
self.incx = 0
示例5: clear
def clear(self, color, i=None):
""" Clear the subscreen at index i.
"""
if i != None:
pygame.draw.rect(self.screen, color, self.rect(i))
else:
Screen.clear(self, color)
示例6: do
def do(self):
self.done = False
Screen.do(self)
areavars2conf = {'nrounds':'NUMBER OF ROUNDS', 'maxt':'TIMER', 'ailevel':'AI DIFFICULTY',
'musicvol':'MUSIC VOLUME', 'sfxvol':'SFX VOLUME'}
for k, v in areavars2conf:
self.area.__dict__[k] = self.setting(v)
示例7: toolClicked
def toolClicked(self,tools,parts):
self.tools.database = database
self.screen.Notificationlabels.append(ScreenText("text1", database, pygame.Rect(100, 3*WINDOWHEIGHT/4, 200, 50), font1))
passn
Screen.__init__(self, self.buttons, self.actors, (128,0,0))
示例8: __init__
def __init__(self, game, tools, parts):
self.game = game
self.tools = tools
self.parts = parts
Screen.__init__(self, self.buttons, self.actors, (0,128,0))
示例9: __init__
def __init__(self,name):
Screen.__init__(self,name)
self.titleImage = pygame.image.load("Media/ChapFCS-title.gif").convert()
self.titlePosition = ((self.screen.get_width()-self.titleImage.get_width())/2,
(self.screen.get_height()/4))
self.tablePosition = (100,175)
self.screen.fill([0,0,0]) # just black, no graphic background image
self.ButtonNW = self.buttons(bgcolor = (0,0,255), callback=self.systemOptions,
**Button.standardButton("NW",["System","Options"],self.screen))
self.ButtonNE = self.buttons(bgcolor = (0,0,255), callback=self.matchOptions,
**Button.standardButton("NE",["Field","Options"],self.screen))
self.ButtonSE = self.buttons(bgcolor = (0,0,255), callback=self.about,
**Button.standardButton("SE","About",self.screen))
self.ButtonS = self.buttons(bgcolor = (255,255,255), callback=self.nextMatch, lcolor = (0,0,0),
**Button.standardButton("S",["Next","Match"],self.screen))
self.dataTable = self.tables(fontsize=20,font="monospace")
self.dataTable.addData("Field Name: ",align="right")
self.dataTable.addData(Settings.fieldName, bold=True, name="fieldName",bgcolor=(50,50,50),callback=self.setFieldName)
self.dataTable.endRow()
self.dataTable.addData("Next Match: ", align="right")
self.dataTable.addData(Settings.matchNumber,name="match",callback=self.setMatchNumber,bold=True)
self.dataTable.endRow()
# put out the title
self.screen.blit(self.titleImage,self.titlePosition)
self.dataTable.position = self.tablePosition
示例10: __init__
def __init__(self, robot, game):
self.robot = robot
self.game = game
self.startPosition = (400,400)
start = BuildButton("tobuildscreen", pygame.Rect(scrright-200, scrbottom-100, 200, 100), "img/back_button_big.png", BuildButton.clicked, self)
buy = BuyButton("buythings", pygame.Rect(500, scrbottom-140, 400,150), "img/buy_button.png", BuyButton.clicked, self)
font1 = pygame.font.SysFont("Arial", 40)
self.moneyLabel = ScreenText("moneytext", "Money: "+str(self.robot.money), pygame.Rect(WINDOWWIDTH-225, 0, 200, 50), font1)
motorLabel = planes.Plane("motorLabel", pygame.Rect(scrleft,scrtop,170,50), draggable=False, grab=False)
motorLabel.image = pygame.image.load("img/motorupgrade_label.png")
mu1 = MotorUpgrade("mu1", pygame.Rect(scrleft,scrtop+60,50,50), "img/motorupgrade_1.png", 100, 0.3, 1, self)
mu2 = MotorUpgrade("mu2", pygame.Rect(scrleft+60,scrtop+60,50,50), "img/motorupgrade_2.png", 200, 0.2, 2, self)
mu3 = MotorUpgrade("mu3", pygame.Rect(scrleft+120,scrtop+60,50,50), "img/motorupgrade_3.png", 300, 0.1, 3, self)
self.shoppingcart = ShoppingCart("shoppingcart", pygame.Rect(350,50,800,600), self)
self.shoppingcart.image = pygame.image.load("img/shoppingcart.png")
bumperLabel = planes.Plane("bumperLabel", pygame.Rect(scrleft, mu3.rect.bottom + 30, 170, 50), draggable=False, grab=False)
bumperLabel.image = pygame.image.load("img/bumperupgrade_label.png")
bu1 = BumperUpgrade("bu1", pygame.Rect(scrleft, bumperLabel.rect.bottom + 10, 50, 50), "img/bumperupgrade_1.png", 100, 7, 1, self)
bu2 = BumperUpgrade("bu2", pygame.Rect(scrleft+60, bumperLabel.rect.bottom + 10, 50, 50), "img/bumperupgrade_2.png", 200, 5, 2, self)
bu3 = BumperUpgrade("bu3", pygame.Rect(scrleft+120, bumperLabel.rect.bottom + 10, 50, 50), "img/bumperupgrade_3.png", 300, 3, 3, self)
self.costInCartlabel = ScreenText("costincart", "Cost in Cart: 0", pygame.Rect(500, 50, 400, 50), font1)
buttons = [start, buy]
self.upgrades = [mu1, mu2, mu3, bu1, bu2, bu3]
self.actorsWithoutDesc = [self.shoppingcart, motorLabel, bumperLabel, self.moneyLabel, self.costInCartlabel] + self.upgrades
self.actors = self.actorsWithoutDesc
Screen.__init__(self,buttons,self.actors,BLACK)
示例11: setup
def setup(self,
nrows,
nrows_center = 1,
check_width = None,
check_width_center = 0.5,
check_color1 = 'white',
check_color2 = 'black',
screen_background_color = 'neutral-gray',
show_fixation_dot = False,
flash_rate_left = DEFAULT_FLASH_RATE,
flash_rate_right = DEFAULT_FLASH_RATE,
flash_rate_center = DEFAULT_FLASH_RATE,
#rate_compensation = None,
vsync_patch = None,
):
Screen.setup(self,
background_color = screen_background_color,
vsync_patch = vsync_patch,
)
#run colors through filter to catch names and convert to RGB
check_color1 = COLORS.get(check_color1, check_color1)
check_color2 = COLORS.get(check_color2, check_color2)
# set checkerboard-related attributes
if check_width is None:
check_width = 2.0/nrows #fill whole screen
self.board_width = check_width*nrows
self.board_width_center = check_width_center * nrows_center
self.nrows = nrows
self.CB1 = CheckerBoard(nrows, check_width, color1 = check_color1, color2 = check_color2, show_fixation_dot = show_fixation_dot)
self.CB2 = CheckerBoard(nrows, check_width, color1 = check_color2, color2 = check_color1, show_fixation_dot = show_fixation_dot) #reversed pattern
self.CB1_center = CheckerBoard(nrows_center, check_width_center, color1 = check_color1, color2 = check_color2, show_fixation_dot = False)#show_fixation_dot)
self.CB2_center = CheckerBoard(nrows_center, check_width_center, color1 = check_color2, color2 = check_color1, show_fixation_dot = False)#show_fixation_dot)
self.CB_cycle_left = itertools.cycle((self.CB1,self.CB2))
self.CB_cycle_right = itertools.cycle((self.CB1,self.CB2))
self.CB_cycle_center = itertools.cycle((self.CB1_center,self.CB2_center))
# set time-related attributes
self._last_CB_change_time_left = None
self._last_CB_change_time_right = None
self._last_CB_change_time_center = None
self.flash_rate_left = flash_rate_left
self.flash_interval_left = 1.0/flash_rate_left
self.flash_rate_right = flash_rate_right
self.flash_interval_right = 1.0/flash_rate_right
self.flash_rate_center = flash_rate_center
self.flash_interval_center = 1.0/flash_rate_center
#self.rate_compensation = rate_compensation
# get useful coordinate values for checkerboard rendering locations
self.xC, self.yC = (-0.5*self.board_width,-0.5*self.board_width)
self.xL, self.yL = (self.xC - 0.7*self.screen_right, self.yC)
self.xR, self.yR = (self.xC + 0.7*self.screen_right, self.yC)
# some lists for checking things
self.vals = itertools.cycle((1,0))
self.t_list = []
self.val_list = []
self.vals_current = self.vals.next()
示例12: render
def render(self):
# do general OpenGL stuff as well as FixationCross and Vsync Patch if needed
Screen.render(self)
# translate to position of left board and render
gl.glLoadIdentity()
gl.glTranslatef(self.xC, self.yC, 0.0)
self._current_CB.render()
示例13: setup
def setup(self,
nrows,
check_width = None,
check_color1 = 'white',
check_color2 = 'black',
screen_background_color = 'neutral-gray',
fixation_dot_color = False,
pos_x = None,
pos_y = None,
vsync_value = None,
vsync_patch = "bottom-right",
):
Screen.setup(self,
background_color = screen_background_color,
vsync_value = vsync_value,
vsync_patch = vsync_patch,
)
self.CB = CheckerBoard(nrows = nrows,
check_width = check_width,
color1 = check_color1,
color2 = check_color2,
fixation_dot_color = fixation_dot_color
)
if pos_x is None:
pos_x = -0.5*self.CB.board_width
if pos_y is None:
pos_y = -0.5*self.CB.board_width
self.pos_x = pos_x
self.pos_y = pos_y
示例14: __init__
def __init__(self, **args):
self.choices = ['RETURN', 'P1 CONTROLS', 'P2 CONTROLS', 'MUSIC VOLUME', 'SFX VOLUME', 'AI DIFFICULTY',
'SHOW HITBOXES', 'NUMBER OF ROUNDS', 'TIMER']
self.extra = {}
self.extra['MUSIC VOLUME'] = self.extra['SFX VOLUME'] = [0, 25, 50, 75 ,100]
self.extra['NUMBER OF ROUNDS'] = [1, 3, 5]
self.extra['SHOW HITBOXES'] = ['YES', 'NO']
self.extra['AI DIFFICULTY'] = ['GIANCARLO', 'VERY EASY', 'EASY', 'NORMAL', 'HARD', 'VERY HARD']
self.extra['TIMER'] = [20, 30, 45, 99]
self.config = {}
self.config['MUSIC VOLUME'] = 2
self.config['SHOW HITBOXES'] = 0
self.config['SFX VOLUME'] = 2
self.config['NUMBER OF ROUNDS'] = 2
self.config['AI DIFFICULTY'] = 3
self.config['TIMER'] = 2
self.volume = 50
self.nrounds = 2
keycond = lambda: not self.done
Screen.__init__(self, 'system/title', keycond=keycond, **args)
self.f = self.area.font['metal']
self.incx = 0
self.x, self.y = 8, 8
self.choice = 0
self.setting = lambda configname: self.extra[configname][self.config[configname]]
示例15: __init__
def __init__(self, shell, filename, **kwds):
text = get_text(filename)
text_pages = text.split("\nPAGE\n")
pages = []
page_size = (0, 0)
for text_page in text_pages:
lines = text_page.strip().split("\n")
page = Page(self, lines[0], lines[1:])
pages.append(page)
page_size = maximum(page_size, page.size)
self.pages = pages
bf = self.button_font
b1 = Button("Prev Page", font=bf, action=self.prev_page)
b2 = Button("Menu", font=bf, action=self.go_back)
b3 = Button("Next Page", font=bf, action=self.next_page)
b = self.margin
page_rect = Rect((b, b), page_size)
gap = (0, 18)
b1.topleft = add(page_rect.bottomleft, gap)
b2.midtop = add(page_rect.midbottom, gap)
b3.topright = add(page_rect.bottomright, gap)
Screen.__init__(self, shell, **kwds)
self.size = add(b3.bottomright, (b, b))
self.add(b1)
self.add(b2)
self.add(b3)
self.prev_button = b1
self.next_button = b3
self.set_current_page(0)