Skip to content

Instantly share code, notes, and snippets.

@iamevn
Created Aug 3, 2016
Embed
What would you like to do?
#! /usr/bin/env python
# created by someone who needs to learn how python even works
# released March 2015 under the WTFPL version 2
# you're gonna need PyQt4, also this definitely works in python 3, no clue about 2
import sys, time, tempfile, base64
from PyQt4 import QtGui, QtCore, Qt
app = QtGui.QApplication(sys.argv)
label = QtGui.QLabel()
tmp = tempfile.NamedTemporaryFile(suffix='.png')
encoded_image = b"""\
iVBORw0KGgoAAAANSUhEUgAAAKoAAACqBAMAAADPWMmxAAAAElBMVEX///////+oqKgAAABgYGCv
r6/iUBU/AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAH
dElNRQffARITMQlJLRDBAAADZ0lEQVRo3tXZ63nrIAwG4K6gFb4VvIIGyB/vv0oBY5uLMOAY4fD0
nDZu+iYRAgT+W+L2+Xukqai+vVOlswFgfkYuq+sz6qnzt32npkb0L6hO5ruuvnrfnaHu8I+ot9xp
6g13orq5v6ISdQVhstoVhBmqgRjhozHq+oDKxjT/ziC0LpD6KhxoqPNSY3rNUmO2LQ9Gq3EWeQ73
2MFqmkWbxrvUx45VhSyyj44Q9LEaasKy16zKPexoVcgiqy1eX9DBDlflLDLX/eYjCs1niLq2qkIW
Yd/Smc6MRkjlzY5VC1l07kBNHOIBMlGVs2gLgZ0kyUw+zexgtZBF7jGZ6wyEA+G6v75Q1xZVziKf
aObj269wTr+qOL5R15aVW84i8xqup2B/pMb+Gq4WsmixHcVkVeZGdrhayCIXAmxtSQrRMeraoBay
yLyCbTYAS1wyFUMwXrVVkZRFbEn/Opav95eCGmVReNkeTB7kFo/LLNBQS1m0WNT3GfxPuAiBhuqy
iNwX4sVvfy06/nMsT1RNL9kcci3MeLhfHODJyiHQUYn3sZqqcLNOqvI8NRqPkXokf6zKuaWhgvY/
S1hENyvCJ/Egda2oOJJr+5iFaCCcEcUQDFQBBNObXUpgp+6CmlzQVHG2PbGwjVdQmcVlVfCEmicB
EKsI0gel8RGxUneNV9N1OXUg/3qSWpxdAjhzeZC6VtSL7gnnlng2ykOgrAqoK+4pZ2erArrvRTOW
J6ioff5lO5FAMnLz7hqjBlN2pvqb0r7cWPxDIQRqqvSxfQGxLYvb0bTbHvkDiTQEPEj9VFfuXWU+
utHBnqU8BNlppIaK8PuCvPmzSVRSS0GlqrofVL9NDXorU3E9DDTV8LQhUcWCmWerErtvmxBn4wQV
6felEIBwIpJuS0xQj8kwDUD4FKnQGK9CqNs4dMMD1GhCUlch79kON7pnMlct1sPw5+gs7ZSmqFdb
NhIK0XhRUlVBdLnPKG44AW21VhG/SEVnACgtSvXUQtZcoJW6WE1Fp2pZNbU7APnbmKSiW6VZKlrU
7I3MUunNKlX28NVDHXq1mjyNf0r9DFH/KjNhq4qL273j1O61MPujWSr1dxfU1OKZ/RtV+lZlLRWV
pa5ev0kneo+o6ekj6GtVONUdooLuqSB9tbrQNaD5yf4Q9R9ZyPV32s4KtwAAAABJRU5ErkJggg==""" # ;^)
decoded_image = base64.b64decode(encoded_image)
tmp.write(decoded_image)
tmp.flush()
pixmap = QtGui.QPixmap(tmp.name)
label.setPixmap(pixmap)
label.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Dialog)
label.setFocusPolicy(QtCore.Qt.NoFocus)
label.setAttribute(QtCore.Qt.WA_TranslucentBackground)
label.setAttribute(QtCore.Qt.WA_ShowWithoutActivating)
label.setAttribute(QtCore.Qt.WA_X11DoNotAcceptFocus)
label.setStyleSheet("background-color:transparent;")
label.show()
label.hide()
class state: # ;^))
moveRight = True
init= False
sleep = 50
d = QtGui.QApplication.desktop().screenGeometry()
def move():
dx = state.d.x()
dy = state.d.y()
dw = state.d.width()
dh = state.d.height()
w = label.width()
h = label.height()
if (not state.init):
label.show()
state.d = QtGui.QApplication.desktop().screenGeometry()
dx = state.d.x()
dy = state.d.y()
dw = state.d.width()
dh = state.d.height()
w = label.width()
h = label.height()
label.move(dx - w, dy + dh)
state.init = True
elif(state.moveRight):
x = label.pos().x() + 1
y = label.pos().y() - 1
label.move(x, y)
if (x == dx and y == dy + dh - h):
state.moveRight = False
elif(state.sleep > 0):
state.sleep = state.sleep - 1
else:
x = label.pos().x() - 1
y = label.pos().y() + 1
label.move(x, y)
if (x == dx - w and y == dy + dh):
app.exit()
timer = QtCore.QTimer()
timer.setInterval(25)
timer.timeout.connect(move)
timer.start()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment