本文整理汇总了Python中pages.Page.loud_noises方法的典型用法代码示例。如果您正苦于以下问题:Python Page.loud_noises方法的具体用法?Python Page.loud_noises怎么用?Python Page.loud_noises使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pages.Page
的用法示例。
在下文中一共展示了Page.loud_noises方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from pages import Page [as 别名]
# 或者: from pages.Page import loud_noises [as 别名]
def get(self):
# Establishes variables to allow interaction with designated class.
a1 = Snake()
a2 = Bird()
a3 = Person()
# Stores all animals defined in object
self.animals = [a1, a2, a3]
# Defines p as referring to Page class
p = Page()
# Runs the update command on page to concatinate the first pages info
p.update()
# Listens for an occurance of animal in the browsers request. Essentially listening for a button click
if "animal" in self.request.GET:
# Sets current animals value based on which request was made
p.current_animal = self.animals[int(self.request.GET["animal"])]
# Changes the Title of the page to match the selected animal
p.title = self.animals[int(self.request.GET["animal"])].name
# plays the sound specific for that animal
p.loud_noises = self.animals[int(self.request.GET["animal"])].sound
# Writes contents of whole page to the browser. The update function assembles this
self.response.write(p.whole_page)
else:
self.response.write(p.whole_page)