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


Python Canvas.move方法代码示例

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


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

示例1: MainWidget

# 需要导入模块: from canvas import Canvas [as 别名]
# 或者: from canvas.Canvas import move [as 别名]
class MainWidget(QtGui.QScrollArea):
	"""
	La clase MainWidget es una derivada de la clase QScrollArea.
	En este widget se pone, centrado, el lienzo del dibujo (Canvas).
	Además, éste es el widget alrededor del cual se centra la MainWindow.
	"""

	def __init__(self, w, h, image, com, color, Parent=None):

		super(MainWidget,self).__init__()

		self.canvas = Canvas(w, h, image, com, color, self)
		self.setWidget(self.canvas)

	def resizeEvent(self, event):

		super(MainWidget,self).resizeEvent(event)
		self.calcNewCanvasGeometry()

	def paintEvent(self, event):

		super(MainWidget,self).paintEvent(event)
		self.calcNewCanvasGeometry()

	def calcNewCanvasGeometry(self):
		g = self.frameGeometry()
		w = g.width()
		h = g.height()
		self.canvas.move( (w-self.canvas.width*self.canvas.zoom)/2, (h-self.canvas.height*self.canvas.zoom)/2 );
		print self.frameGeometry()
开发者ID:aaronsprisma,项目名称:pixelart,代码行数:32,代码来源:mainwidget.py

示例2: MainWidget

# 需要导入模块: from canvas import Canvas [as 别名]
# 或者: from canvas.Canvas import move [as 别名]
class MainWidget(QtGui.QScrollArea):
	"""
	La clase MainWidget es una derivada de la clase QScrollArea.
	En este widget se pone, centrado, el lienzo del dibujo (Canvas).
	Además, éste es el widget alrededor del cual se centra la MainWindow.
	"""

	def __init__(self, w, h, data, com, color, Parent=None):

		super(MainWidget,self).__init__()

		self.com = com
		self.data = data
		self.canvas = Canvas(w, h, data, com, color, self)
		self.parent = Parent

		self.setBackgroundRole(QtGui.QPalette.Dark)
		self.setObjectName("MainWidget")
		self.setWidget(self.canvas)
	
	def resizeEvent(self, event):

		super(MainWidget,self).resizeEvent(event)
		self.calcNewCanvasGeometry()

	def paintEvent(self, event):

		super(MainWidget,self).paintEvent(event)
		self.calcNewCanvasGeometry()

	def calcNewCanvasGeometry(self):
		
		g = self.frameGeometry()
		w = g.width()
		h = g.height()

		if self.canvas.width() < w:
			self.canvas.move( (w-self.data.image.width()*self.data.zoom)/2 , self.canvas.y() )
		if self.canvas.height() < h:
			self.canvas.move( self.canvas.x(), (h-self.data.image.height()*self.data.zoom)/2 )

	def wheelEvent(self, event):

		#super(MainWidget, self).wheelEvent(event)
		
		if self.parent.onClickPalette:
			self.parent.wheelEvent(event)
		else:
			super(MainWidget, self).wheelEvent(event)
开发者ID:MikiLoz92,项目名称:pixs2pics,代码行数:51,代码来源:mainwidget.py

示例3: ScrollArea

# 需要导入模块: from canvas import Canvas [as 别名]
# 或者: from canvas.Canvas import move [as 别名]
class ScrollArea(QtWidgets.QScrollArea):
	"""
	La clase ScrollArea es una derivada de la clase QScrollArea.
	En este widget se pone, centrado, el lienzo del dibujo (Canvas).
	Además, éste es el widget alrededor del cual se centra la MainWindow.
	"""

	def __init__(self, index, context, signals, Parent=None):

		super(ScrollArea,self).__init__(Parent)

		self.context = context
		self.signals = signals
		self.parent = Parent
		self.canvas = Canvas(index, context, signals, self)

		self.index = index

		self.setBackgroundRole(QtGui.QPalette.Dark)
		self.setObjectName("ScrollArea")
		self.setWidget(self.canvas)

		self.signals.zoom.connect(self.calcNewCanvasPosition)
		self.signals.zoom.connect(self.calcNewScrollBarPosition)
		self.signals.imageRemoved.connect(self.setNewIndex)
		self.signals.newImage.connect(self.setNewImageZoom)

		self.startZoom = 0

	def resizeEvent(self, event):

		super(ScrollArea, self).resizeEvent(event)
		self.calcNewCanvasPosition()
		self.calcNewScrollBarPosition()
		if self.startZoom < 2:
			self.startZoom += 1
			self.setNewImageZoom()
		# self.setNewImageZoom() # Zoom dinámico

	def paintEvent(self, event):

		super(ScrollArea, self).paintEvent(event)
		self.calcNewCanvasPosition()

	def calcNewCanvasPosition(self):

		if self.context.imagePos == self.index:

			g = self.frameGeometry()
			w = g.width()
			h = g.height()

			if self.canvas.width() < w:
				self.canvas.move( (w-self.context.getImagePos(self.index).image.width()*self.context.getImagePos(self.index).zoom)/2 , self.canvas.y() )
			if self.canvas.height() < h:
				self.canvas.move( self.canvas.x(), (h-self.context.getImagePos(self.index).image.height()*self.context.getImagePos(self.index).zoom)/2 )

	def calcNewScrollBarPosition(self):

		if self.context.imagePos == self.index:
			self.horizontalScrollBar().setValue((self.horizontalScrollBar().maximum() - self.horizontalScrollBar().minimum()) / 2)
			self.verticalScrollBar().setValue((self.verticalScrollBar().maximum() - self.verticalScrollBar().minimum()) / 2)

	def setNewIndex(self, removedIndex):

		if self.index >= removedIndex:
			self.index -= 1

	def setNewImageZoom(self):

		print("setNewImageZoom")

		g = self.frameGeometry()
		w = g.width()
		h = g.height()

		self.context.images[-1].zoom = min(w/self.context.images[-1].image.width(), h/self.context.images[-1].image.height())
		self.signals.zoom.emit()

	def mousePressEvent(self, event):

		if event.button() == Qt.MiddleButton:
			self.grabPoint = event.pos()
			self.grabPos = self.canvas.pos()

	def mouseMoveEvent(self, event):

		pos = event.pos()
		self.canvas.move(self.grabPos + event.pos() - self.grabPoint)

		"""
		if (self.mapToParent(pos).x() + self.width() - self.grabPoint.x()) > (self.parent.width() ):
			self.canvas.move(self.parent.width()-self.width(), self.y())
		elif (self.mapToParent(pos).x() - self.grabPoint.x()) < 0:
			self.canvas.move(0, self.y())
		if (self.mapToParent(pos).y() + self.height() - self.grabPoint.y()) > (self.parent.height() ):
			self.canvas.move(self.x(), self.parent.height()-self.height())
		elif (self.mapToParent(pos).y() - self.grabPoint.y()) < 0:
			self.canvas.move(self.x(), 0)
		"""
#.........这里部分代码省略.........
开发者ID:MikiLoz92,项目名称:pyqx,代码行数:103,代码来源:scrollarea.py


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