def DecodeDragData(dataobj): name, data = _GetDragData(dataobj) if not name: return name, data if name == 'FileName': rv = longpath.short2longpath(data) elif name == 'URL': rv = data elif name == 'Node': rv = string.split(data) assert len(rv) == 2 rv = tuple(map(eval, rv)) elif name == 'Tool': cmdid = eval(data) rv = usercmdui.id2usercmd(cmdid) elif name == 'NodeUID': context, nodeuid = string.split(data) rv = (eval(context), nodeuid) # We cannot convert these back to a node, as we # don't have access to the context here elif name == 'Region': rv = data # UID string elif name == 'Media': rv = data # UID string else: print 'Unknown dragformat', name rv = None return name, rv
def OnPasteFile(self, id, code): filename = Sdk.GetClipboardFileData() if filename: import longpath filename = longpath.short2longpath(filename) x, y = self._DPtoLP(self._popup_point) x, y = self._pxl2rel((x, y), self._canvas) self.onEvent(PasteFile, (x, y, filename))
def dropfile(self,dataobj,effect,x,y): flavor, filename=DecodeDragData(dataobj) assert flavor == 'FileName' if filename: import longpath filename=longpath.short2longpath(filename) x,y=self._DPtoLP((x,y)) x,y = self._pxl2rel((x, y),self._canvas) self.onEvent(WMEVENTS.DropFile,(x, y, filename)) return 1 return 0
def pathname2url(path): import os, sys if sys.platform == 'win32' and os.name != 'ce': import longpath filename = longpath.short2longpath(path) url = _pathname2url(path) type, rest = splittype(url) if not type and rest[:1] == '/': if rest[:3] == '///': url = 'file:' + url else: url = 'file://' + url return url
def __path2url(self, filename): # this method is called also from the drop stuff # so check for UNC names before calling pathname2url # otherwise it will fail. import longpath, MMurl ## import os filename = longpath.short2longpath(filename) ## if os.path.isabs(filename): ## cwd = os.getcwd() ## if os.path.isdir(filename): ## dir, file = filename, os.curdir ## else: ## dir, file = os.path.split(filename) ## # XXXX maybe should check that dir gets shorter! ## while len(dir) > len(cwd): ## dir, f = os.path.split(dir) ## file = os.path.join(f, file) ## if dir == cwd: ## filename = file return MMurl.pathname2url(filename)
# os.path.join(CMIFDIR, r'pylib\audio'), os.path.join(CMIFDIR, r'win32\src\Build'), os.path.join(os.path.split(CMIFDIR)[0], r'python\Lib') ] sys.path[0:0] = CMIFPATH os.environ["CMIF"] = CMIFDIR os.environ["CMIF_USE_WIN32"] = "ON" if not os.environ.has_key('HOME'): os.environ['HOME'] = CMIFDIR # Turn pathnames into their full NT version import longpath for i in range(1, len(sys.argv)): if os.path.exists(sys.argv[i]): sys.argv[i] = longpath.short2longpath(sys.argv[i]) import string import win32api from win32con import * import win32ui import traceback def SafeCallbackCaller(fn, args): try: return apply(fn, args) except SystemExit, rc: # We trap a system exit, and translate it to the "official" way to bring down a GUI. try: rc = int(rc[0])
def fix_argv(): # Turn pathnames into their full NT version for i in range(1, len(sys.argv)): if os.path.exists(sys.argv[i]): sys.argv[i] = longpath.short2longpath(sys.argv[i])