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


Python Window.set_icon方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyglet.window import Window [as 别名]
# 或者: from pyglet.window.Window import set_icon [as 别名]
class Render:

    def __init__(self):
        #Sets up load and render data
        self.blocks_textures = 0
        self.sprites = []
        self.id_position = {"Blue_stone": 4,"Green_stone":3,"Yellow_stone":2,"Red_stone":1,"Stars_1": 0}
        self.block_textures = 0
        self.texture = "Texture Name"
        self.name =  "Map Name"

        #Things loaded from save (defaults)
        self.map_size = 100
        self.block_size = 20
        self.map_data = []

        #Default window
        self.window = 0
        self.camera = [0,0]
        
    def generate_map(self):
        for a in range(self.map_size):
            temp_sprite_list = []
            for b in range(self.map_size):
                #Extracts data
                temp_id = self.map_data[b][a]
                temp_image = self.id_position[temp_id]
                image = self.blocks_textures[int(temp_image)]

                #Creates sprite
                sprite = pyglet.sprite.Sprite(image)
                sprite.scale = 0.4
                sprite.x = self.block_size*a
                sprite.y = self.block_size*b
                temp_sprite_list.append(sprite)
            self.sprites.append(temp_sprite_list)

    def extract_data(self):
        
        #Opens data file and reads it
        location = os.getcwd()+"/Solar Systems/"+str(self.name)
        temp_save = []
        for line in fileinput.input(location+"/Raw_Data.txt"):
            temp_save.append(line)
            
        #Converts raw data for scanning
        self.map_data = []
        for i in temp_save:
            self.map_data.append(i.split())

        #Opens information about map
        creation = open(location+"/Info.txt","r")
        temp_info = creation.read().splitlines()
        creation.close()

        #Calculates direct info from data provided.
        self.map_size = int(temp_info[0].split()[-1])
        self.block_size = int(temp_info[1].split()[-1])
        
    def run(self, name, texture):

        #Sets up name and texture
        self.texture = texture
        self.name = name

        #Sets up images
        self.block_textures = pyglet.image.load(os.getcwd()+"/Resources"+self.texture+"Blocks/Textures.png")
        self.blocks_textures = pyglet.image.ImageGrid(self.block_textures, 5, 1)

        #Reads data
        self.extract_data()

        #Generates tiles and stuff
        self.generate_map()
        
        #Sets up window
        self.window = Window(800,600)
        self.window.set_icon(self.blocks_textures[1])

        #Generates sprites to show at start
        self.screen_render_start(0,0)

        #Runs it
        pyglet.app.run()

    def screen_render_start(self, camerax, cameray):
        render_blocks = (self.window.width//self.block_size, self.window.height//self.block_size)
        for a in self.sprites:
            for b in a:
                b.batch = None
            
        for a in range(render_blocks[0]):
            for b in range(render_blocks[1]):
                try:
                    self.sprites[a+(camerax//self.block_size)][b+(cameray//self.block_size)].batch = render
                except:
                    pass

    def camera_left(self, amount):
        self.camera[0]+=amount
#.........这里部分代码省略.........
开发者ID:JacobWeinbren,项目名称:Space_Project,代码行数:103,代码来源:Display.py


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