コード例 #1
0
	def CreateImage(self, sysfilename=None):
		if not sysfilename:
			initialdir = config.preferences.dir_for_bitmap_import
			filename, sysfilename = dialogman.getImportBMFilename(
										initialdir=initialdir, initialfile='')

		if sysfilename:
			try:
				self.canvas.commands.ForceRedraw
				fileptr = open(sysfilename, 'r')
				is_eps = eps.IsEpsFileStart(fileptr.read(256))
				fileptr.close()
				dir, name = os.path.split(filename)
				config.preferences.dir_for_bitmap_import = dir
				if is_eps:
					imageobj = eps.EpsImage(filename=sysfilename)
				else:
					imageobj = image.Image(imagefile=sysfilename)
				self.canvas.PlaceObject(imageobj)
			except IOError, value:
				if type(value) == TupleType:
					value = value[1]
				self.application.MessageBox(title=_("Load Image"),
								message=_("Cannot load %(filename)s:\n"
											"%(message)s") \
								% {'filename':`os.path.split(filename)[1]`,
									'message':value})
コード例 #2
0
 def eps(self, trafo, filename):
     if len(trafo) == 2:
         trafo = Translation(trafo)
     else:
         trafo = apply(Trafo, trafo)
     if not os.path.isabs(filename):
         if self.directory:
             filename = os.path.join(self.directory, filename)
         else:
             filename = os.path.join(os.getcwd(), filename)
     self.append_object(eps.EpsImage(filename=filename, trafo=trafo))