from PyQt5.Qt import *
import sys
from text import Ui_MainWindow
class Window(QMainWindow):
def __init__(self, parent=None, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setWindowFlags(Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_TranslucentBackground)
def mousePressEvent(self, evt):
if evt.button() == Qt.LeftButton:
self.switch = True
else:
self.switch = False
self.mouse_x = evt.globalX()
self.mouse_y = evt.globalY()
self.window_x = self.x()
self.window_y = self.y()
def mouseMoveEvent(self, evt):
if self.switch:
move_x = evt.globalX() - self.mouse_x
move_y = evt.globalY() - self.mouse_y
vector_x = self.window_x + move_x
vector_y = self.window_y + move_y
self.move(vector_x, vector_y)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())