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


Python Block.load方法代码示例

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


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

示例1: paste

# 需要导入模块: from CNC import Block [as 别名]
# 或者: from CNC.Block import load [as 别名]
	def paste(self, event=None):
		try: clipboard = self.selection_get(selection='CLIPBOARD')
		except: return

		ypos = self.yview()[0]
		# paste them after the last selected item
		# bid,lid push them to self so it can be accessed from addLines()
		# python3 might fix this with the inner scope
		try:
			self.__bid, self.__lid = self._items[self.curselection()[-1]]
		except:
			try:
				self.__bid, self.__lid = self._items[-1]
			except:
				self.__bid = 0
				self.__lid = None

		selitems = []
		undoinfo = []

		def addLines(lines):
			for line in lines.splitlines():
				# Create a new block
				if self.__lid is None:
					self.__bid += 1
					self.__lid = sys.maxint
					block = Block()
					undoinfo.append(self.gcode.addBlockUndo(self.__bid,block))
					selitems.append((self.__bid, None))
				else:
					block = self.gcode.blocks[self.__bid]

				if self.__lid == sys.maxint:
					selitems.append((self.__bid, len(block)))
				else:
					self.__lid += 1
					selitems.append((self.__bid, self.__lid))
				undoinfo.append(self.gcode.insLineUndo(self.__bid, self.__lid, line))

		try:
			# try to unpickle it
			unpickler = pickle.Unpickler(StringIO(clipboard))
			try:
				while True:
					obj = unpickler.load()
					if isinstance(obj,tuple):
						block = Block.load(obj)
						self.__bid += 1
						undoinfo.append(self.gcode.addBlockUndo(self.__bid, block))
						selitems.append((self.__bid,None))
						self.__lid = None
					else:
						addLines(obj)
			except EOFError:
				pass
		except pickle.UnpicklingError:
			# Paste as text
			addLines(clipboard)

		if not undoinfo: return

		self.gcode.addUndo(undoinfo)

		self.selection_clear(0,END)
		self.fill()
		self.yview_moveto(ypos)
		self.select(selitems, clear=True)

		#self.selection_set(ACTIVE)
		#self.see(ACTIVE)
		self.app.event_generate("<<Modified>>")
开发者ID:paranormalactivities,项目名称:bCNC,代码行数:73,代码来源:CNCList.py


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