本文整理匯總了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()