summaryrefslogtreecommitdiff
path: root/qt-recordmydesktop/src/rmdSelect.py
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-04-27 02:45:30 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-04-27 02:45:30 +0000
commitbabee5fe38026e5b6210fa381aace3a19a89785f (patch)
treef9b6d82d7373c81c7420acdbb8c692bbff57fe2b /qt-recordmydesktop/src/rmdSelect.py
parentde6c6f26c88d6f961f9e450edb337510d7c893f9 (diff)
This commit was generated by cvs2svn to compensate for changes in r312,
which included commits to RCS files with non-trunk default branches. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@313 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'qt-recordmydesktop/src/rmdSelect.py')
-rw-r--r--qt-recordmydesktop/src/rmdSelect.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/qt-recordmydesktop/src/rmdSelect.py b/qt-recordmydesktop/src/rmdSelect.py
new file mode 100644
index 0000000..6a2264c
--- /dev/null
+++ b/qt-recordmydesktop/src/rmdSelect.py
@@ -0,0 +1,84 @@
+#/******************************************************************************
+#* qt-recordMyDesktop *
+#*******************************************************************************
+#* *
+#* Copyright (C) 2007 John Varouhakis *
+#* *
+#* *
+#* This program is free software; you can redistribute it and/or modify *
+#* it under the terms of the GNU General Public License as published by *
+#* the Free Software Foundation; either version 2 of the License, or *
+#* (at your option) any later version. *
+#* *
+#* This program is distributed in the hope that it will be useful, *
+#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+#* GNU General Public License for more details. *
+#* *
+#* You should have received a copy of the GNU General Public License *
+#* along with this program; if not, write to the Free Software *
+#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+#* *
+#* *
+#* *
+#* For further information contact me at johnvarouhakis@gmail.com *
+#******************************************************************************/
+
+from PyQt4 import QtGui,QtCore
+
+class QtAreaSelector(QtGui.QLabel):
+ def __init__(self,area_return):
+ self.area_return=area_return
+ QtGui.QLabel.__init__(self,None,QtCore.Qt.WindowStaysOnTopHint)
+ self.x1=self.y1=-1
+ self.x2=self.y2=0
+ self.pix=QtGui.QPixmap.grabWindow(QtGui.QApplication.desktop().winId())
+ siz=QtGui.QApplication.desktop().screenGeometry()
+ (self.width, self.height)=(siz.width(),siz.height())
+ def paintEvent(self, event):
+ painter = QtGui.QPainter(self)
+ painter.drawPixmap(0,0,self.pix)
+ if self.x1 >= 0:
+ x = min(self.x1, self.x2)
+ y = min(self.y1, self.y2)
+ w = max(self.x1, self.x2) - x
+ h = max(self.y1, self.y2) - y
+ painter.fillRect(x,y,w,h,QtGui.QBrush(QtCore.Qt.red,QtCore.Qt.CrossPattern))
+ def mouseMoveEvent(self, event):
+ if self.x1 >= 0:
+ rect = QtCore.QRect()
+ rect.x = min(self.x1, min(self.x2, event.x() + 1))
+ rect.width = max(self.x1, max(self.x2, event.x() + 1)) - rect.x
+ rect.y = min(self.y1, min(self.y2, event.y() + 1))
+ rect.height = max(self.y1, max(self.y2, event.y() + 1)) - rect.y
+
+ self.x2 = event.x() + 1
+ self.y2 = event.y() + 1
+ self.update()
+ def mouseReleaseEvent(self, event):
+ if event.button() == 1 and self.x1 >= 0:
+ self.x2 = event.x() + 1
+ self.y2 = event.y() + 1
+ self.area_return[0]=min(int(self.x1),int(self.x2))
+ self.area_return[1]=min(int(self.y1),int(self.y2))
+ self.area_return[2]=max(int(self.x1),int(self.x2))
+ self.area_return[3]=max(int(self.y1),int(self.y2))
+ self.close()
+ def mousePressEvent(self, event):
+ if event.button() != 1:
+ self.x1 = self.y1 = -1
+ self.close()
+ self.x1 = event.x()
+ self.y1 = event.y()
+
+
+if __name__ == "__main__":
+ import sys
+ p=[[-1,-1,-1,-1]]
+ app=QtGui.QApplication(sys.argv)
+ w = QtAreaSelector(p[0])
+ w.showFullScreen()
+ app.exec_()
+ print p[0]
+
+
© All Rights Reserved