Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from pynput import keyboard
- from PyQt5.QtCore import Qt
- from PyQt5.QtWidgets import QApplication, QLabel, QMainWindow
- class MainWindow(QMainWindow):
- def __init__(self):
- super().__init__()
- self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
- self.setGeometry(100, 100, 128, 128)
- self.setAttribute(Qt.WA_TranslucentBackground)
- self.setStyleSheet("background: transparent;")
- self.muted = False
- self.label = QLabel("Unmuted", self)
- self.label.setAlignment(Qt.AlignCenter)
- self.label.setStyleSheet("color: white; font: bold 20px;")
- self.setCentralWidget(self.label)
- self.hotkey_listener = keyboard.GlobalHotKeys({
- '=': self.toggle_mute,
- '<alt>+q': self.quit
- })
- self.hotkey_listener.start()
- def toggle_mute(self):
- self.muted = not self.muted
- if self.muted:
- self.label.setText("Muted")
- else:
- self.label.setText("Unmuted")
- def quit(self):
- self.hotkey_listener.stop()
- self.close()
- def mousePressEvent(self, event):
- if event.button() == Qt.LeftButton:
- self.drag_position = event.globalPos() - self.frameGeometry().topLeft()
- event.accept()
- def mouseMoveEvent(self, event):
- if event.buttons() == Qt.LeftButton:
- self.move(event.globalPos() - self.drag_position)
- event.accept()
- if __name__ == '__main__':
- app = QApplication(sys.argv)
- main_window = MainWindow()
- main_window.show()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement