【发布时间】:2021-02-01 16:23:33
【问题描述】:
我正在尝试使用 PyQt5 在 python 中制作小程序。 该程序将有两个按钮,中间有一个标签。当鼠标移过标签时,我想调用一个 def,以更改按钮的颜色并从特定扬声器(左或右)播放声音
我尝试了 pygame,关注了一些帖子,但没有。声音在两个声道中播放。
import time
import pygame
pygame.mixer.init(44100, -16,2,2048)
channel1 = pygame.mixer.Channel(0) # argument must be int
channel2 = pygame.mixer.Channel(1)
print('OkkK')
soundObj = pygame.mixer.Sound('Aloe Blacc - Wake Me Up.wav')
channel2.play(soundObj)
soundObj.set_volume(0.2)
time.sleep(6) # wait and let the sound play for 6 second
soundObj.stop()
有没有办法解决这个问题并选择左右扬声器?
另外,有没有办法在鼠标悬停标签时调用 def?
【问题讨论】:
-
我们对代码块使用反引号 (
`),而不是撇号 (')
标签: python pygame onmouseover