import pygame, sys, datetime, time
def play(song):
pygame.mixer.music.load(song)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
pos = pygame.mixer.music.get_pos()/ 1000
if __name__=='__main__':
# print('run song',sys.argv[0])
if len(sys.argv) > 1:
song = sys.argv[1]
else:
song = 'file.mp3'
pygame.mixer.init(22050, -16, 2, 2048)
pygame.mixer.music.set_volume(2.0)
play(song)
pygame.quit()
def run(song):
import os, sys
pypath = sys.executable
os.spawnv(os.P_DETACH, pypath, ('python', 'sound.py', song))
# print('Main process exiting.')
if __name__=='__main__':
song = 'file.mp3'
run(song)
self.setWindowFlags(QtCore.Qt.ToolTip)
;self.setWindowFlags(WindowStaysOnTopHint)
from docxtpl import DocxTemplate
doc = DocxTemplate("my_word_template.docx")
context = { 'company_name' : "World company" }
doc.render(context)
doc.save("generated_doc.docx")
import ctypes
EnumWindows = ctypes.windll.user32.EnumWindows
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
GetWindowText = ctypes.windll.user32.GetWindowTextW
GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
IsWindowVisible = ctypes.windll.user32.IsWindowVisible
titles = []
def foreach_window(hwnd, lParam):
if IsWindowVisible(hwnd):
length = GetWindowTextLength(hwnd)
buff = ctypes.create_unicode_buffer(length + 1)
GetWindowText(hwnd, buff, length + 1)
titles.append(buff.value)
return True
EnumWindows(EnumWindowsProc(foreach_window), 0)
def main():
print(titles)
for t in titles:
print(t)
return titles
if __name__ == '__main__':
main()
import win32gui
def now():
class_activ_window=win32gui.GetClassName(win32gui.GetForegroundWindow())
if class_activ_window=='my_console': # изменить на реальный класс окна
activ_window='my_consoler'
else:
pass
return activ_window
import get_activ_window
if key == esc and get_activ_window.now() == 'my_console':
check=True
Wind
в метод __init__
добавить QtGui.QShortcut(QtGui.QKeySequence("Shift+Alt+Q"), self, quit)
Wind
добавить метод:def keyPressEvent(self, e):
if int(e.modifiers()) == (QtCore.Qt.ControlModifier + QtCore.Qt.AltModifier):
if e.key() == QtCore.Qt.Key_Q:
self.close_window()