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


Python Map.load方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import load [as 别名]

#.........这里部分代码省略.........
                          "default" : u'',
                          "canceltext" : None,
                          "function" : self._select_access_point,
                          },
        }
        # Loop all possible keys (found from defaults)
        for key in defaults.keys():
            if data.has_key(key): # Use the value found from the data
                defaults[key] = data[key]
            elif mandatory.has_key(key) and defaults[key] is None: # Ask mandatory values from the user
                value = None
                if mandatory[key].has_key("function"): # if defined, call the "function"
                    appuifw.note(mandatory[key]["querytext"], 'info')
                    value = mandatory[key]["function"]() # "function" must return a value
                else:
                    while value is None:
                        value = appuifw.query(mandatory[key]["querytext"], 
                                              mandatory[key]["valuetype"], 
                                              mandatory[key]["default"])
                        if value is None and mandatory[key]["canceltext"]: 
                            appuifw.note(mandatory[key]["canceltext"], 'error')
                        elif value is None: # If canceltext is u"", change value None to u""
                            value = u""
                defaults[key] = value
        self.config = defaults
        self.save_config()
        
    def save_config(self):
        f = open(self.config_file, "wt")
        f.write(repr(self.config))
        f.close()

    def reset_config(self):
      if appuifw.query(u'Are you sure you want to delete all settings?', 'query') is True:
        os.remove(self.config_file)
        appuifw.note(u"Done, now you need to restart Sissi!", 'info')
        self.running = False
        self.lock.signal()
        appuifw.app.exit_key_handler = None

    def scanner_handler(self):
      if self.scanner:
        if self.scanner.running:
          self.scanner.stop()
        else:
          self.scanner.start()
      self._update_menu()

    def loop(self):      
      if self.scanner.position.has_key("gps_data"): # first check whether we have a GPS position
        self.cos_api.post(self.scanner.position["gps_data"]["lat"], self.scanner.position["gps_data"]["lon"])
        # if map view is active load a new one
        if self.map.active:
          self.map.load(self.scanner.position["gps_data"]["lat"], self.scanner.position["gps_data"]["lon"])
      elif self.scanner.position.has_key("wlan_data"): # if not then see if we have wlans in the latest scanned position
        wlanlist = self.scanner.position["wlan_data"]["wlanlist"]
        wlanlist.sort(lambda x, y: cmp(y['rxlevel'], x['rxlevel']))
        if len(wlanlist) > 1:          
          self.netmapper.get_location(wlanlist) # fetching calculated location from OpenNetMap
          if self.netmapper.computed_location["latitude"] and self.netmapper.computed_location["longitude"]:
            self.cos_api.post(self.netmapper.computed_location["latitude"], self.netmapper.computed_location["longitude"])
          # if map view is active load a new one
          if self.netmapper.computed_location["latitude"] and self.netmapper.computed_location["longitude"] and self.map.active:
            self.map.load(self.netmapper.computed_location["latitude"], self.netmapper.computed_location["longitude"])
      elif self.scanner.position.has_key("gsm_data"):
        # not yet implemented!!
        pass

    def toggle_map(self):
      if not appuifw.app.body == self.canvas:
        self.map.active = False
        self.activate()
      else:
        self.active = False
        self.map.activate()

    def activate(self):
      self.active = True
      appuifw.app.exit_key_handler = self.exit_key_handler
      try:
        self.canvas
      except:
        self.canvas = appuifw.Canvas(redraw_callback=self.update)
      appuifw.app.body = self.canvas
      self._update_menu()

    def run(self):
        self.lock.wait()
        self.close()

    def exit_key_handler(self):
      if appuifw.query(u"Quit program", 'query') is True:
        self.running = False
        self.scanner.stop()
        self.lock.signal()

    def close(self):
#        positioning.stop_position()
      appuifw.app.exit_key_handler = None
      self.running = False
开发者ID:sizzlelab,项目名称:Ossi,代码行数:104,代码来源:default.py

示例2: Object

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import load [as 别名]
 
    elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT) or libtcod.console_is_key_pressed(libtcod.KEY_KP6):
        player.move(1, 0)

    if key.vk == libtcod.KEY_ENTER and key.lalt:
        # Alt+Enter: toggle fullscreen
        libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())

    elif key.vk == libtcod.KEY_ESCAPE:
        return True

player = Object(con.SCREEN_WIDTH/2, con.SCREEN_HEIGHT/2, '@', libtcod.white)
npc = Object(con.SCREEN_WIDTH/2 - 5, con.SCREEN_HEIGHT/2, '@', libtcod.yellow)
Objects = [npc, player]
Mapdata = Map(133, 66)
Mapdata.load('test.txt')

while not libtcod.console_is_window_closed():

    Mapdata.render(con)    
    con.blit()
    for obj in Objects:
        con.draw(obj)
    con.blit()

    for obj in Objects:
        con.clear(obj)

    libtcod.console_flush()
    exit = handle_keys()
    if exit:
开发者ID:MatrixNymph,项目名称:Prisoner,代码行数:33,代码来源:firstrl.py


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