本文整理汇总了Python中MapList.MapList.new_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python MapList.new_from_file方法的具体用法?Python MapList.new_from_file怎么用?Python MapList.new_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapList.MapList
的用法示例。
在下文中一共展示了MapList.new_from_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_clicked
# 需要导入模块: from MapList import MapList [as 别名]
# 或者: from MapList.MapList import new_from_file [as 别名]
def import_clicked(self, button, other=None, *data):
chooser = Gtk.FileChooserDialog(title=_("Open File"), action=Gtk.FileChooserAction.OPEN, \
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
filtr = Gtk.FileFilter ()
filtr.set_name(_('MAPZ Compressed Map (*.mapz)'))
filtr.add_pattern('*.mapz')
chooser.add_filter(filtr)
response = chooser.run()
if response == Gtk.ResponseType.OK:
filename = chooser.get_filename()
tf = tarfile.open(filename)
mapname = utils.get_save_dir() + tf.getnames()[0]
tf.extractall(utils.get_save_dir())
tf.close()
map = MapList.new_from_file(mapname)
map.filename = mapname
chooser.destroy()
示例2: import_clicked
# 需要导入模块: from MapList import MapList [as 别名]
# 或者: from MapList.MapList import new_from_file [as 别名]
def import_clicked(self, button, other=None, *data):
chooser = gtk.FileChooserDialog(title=_("Open File"), action=gtk.FILE_CHOOSER_ACTION_OPEN, \
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
filtr = gtk.FileFilter ()
filtr.set_name(_('MAPZ Compressed Map (*.mapz)'))
filtr.add_pattern('*.mapz')
chooser.add_filter(filtr)
response = chooser.run()
if response == gtk.RESPONSE_OK:
filename = chooser.get_filename()
tf = tarfile.open(filename)
mapname = os.path.join (utils.get_save_dir (), tf.getnames()[0])
tf.extractall(utils.get_save_dir())
tf.close()
map = MapList.new_from_file(mapname)
map.filename = mapname
chooser.destroy()