当前位置: 首页>>代码示例>>Python>>正文


Python Page.current_camera方法代码示例

本文整理汇总了Python中pages.Page.current_camera方法的典型用法代码示例。如果您正苦于以下问题:Python Page.current_camera方法的具体用法?Python Page.current_camera怎么用?Python Page.current_camera使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pages.Page的用法示例。


在下文中一共展示了Page.current_camera方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from pages import Page [as 别名]
# 或者: from pages.Page import current_camera [as 别名]
    def get(self):
        # Establishes p as referring to the Page class
        p = Page()
        # p.title uses the title setter in the Page class to set the value of title, the line below is similar
        p.title = "Encapsulated Calculator"
        p.css = "css/styles.css"

        # c1 uses the Cameras class to assemble an object with the following attributes and sets their values
        # c2=c5 is identical in function
        c1 = Cameras()
        c1.name = "Canon 5d3"
        c1.body_cost = 3000
        c1.lens_cost = 5000
        c1.accessories_cost = 1000
        c1.quality = "High"
        c1.calc_value()

        c2 = Cameras()
        c2.name = "Nikon D800"
        c2.body_cost = 2500
        c2.lens_cost = 1500
        c2.accessories_cost = 200
        c2.quality = "Low"
        c2.calc_value()

        c3 = Cameras()
        c3.name = "Leica M9"
        c3.body_cost = 100
        c3.lens_cost = 500
        c3.accessories_cost = 100
        c3.quality = "Medium"
        c3.calc_value()

        c4 = Cameras()
        c4.name = "Pentax MX1"
        c4.body_cost = 2000
        c4.lens_cost = 200
        c4.accessories_cost = 50
        c4.quality = "High"
        c4.calc_value()

        c5 = Cameras()
        c5.name = "GoPro Hero5 Platinum"
        c5.body_cost = 10000
        c5.lens_cost = 0
        c5.accessories_cost = 10
        c5.quality = "Low"
        c5.calc_value()

        # This establishes a variable that consolisates all c1-c5 objects
        all_these_cameras = [c1, c2, c3, c4, c5]


        # Checks if there is an instance of "cameras" in the request pushed from the browser
        if "cameras" in self.request.GET:
            # Uses a value in the request to determine which cX object I am requesting
            # and sets just that object to the current_camera variable in Page class.
            p.current_camera = all_these_cameras[int(self.request.GET["cameras"])]
            # Writes the entire contents of whole_page variable in Page class to the browser
            self.response.write(p.whole_page)
        else:
            # Writes the info to the browser even if a request hasnt been made.
            self.response.write(p.whole_page)
开发者ID:HeadShotBoom,项目名称:DPWP,代码行数:65,代码来源:main.py


注:本文中的pages.Page.current_camera方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。