PyQT标签cu

2024-09-29 23:15:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用PyQT库来研究Sonos控制器。

当我更改为netxt或prev track时,标签将使用艺术家、标题和相册信息更新。他们是切断了。有人以前经历过吗?这不是一个长度问题,因为切断似乎在改变。 enter image description here

enter image description here

enter image description here

这是我用以下代码更新标签:

def currentTrackInfo(self):
    currentTrackInfoDict = {}
    currentZone = str(self.cb.currentText())
    deviceDict = self.sonosZonesCoordinatorsIP()
    for key, value in deviceDict.items():
        if value == currentZone:
            device = SoCo(key)
            track = device.get_current_track_info()
            current_title = track['title']
            current_artist = track["artist"]
            current_album = track["album"]

    currentTrackInfoDict.update({"current_title": current_title})
    currentTrackInfoDict.update({"current_artist": current_artist})
    currentTrackInfoDict.update({"current_album": current_album})

    self.artImage()

    return currentTrackInfoDict

def updateTrackInfo(self):
    self.artistlabel.clear
    self.albumlabel.clear
    self.titlelabel.clear
    self.currentTrackInfoDict = self.currentTrackInfo()
    self.artistlabel.setText("{}".format(self.currentTrackInfoDict["current_artist"]))
    self.albumlabel.setText("{}".format(self.currentTrackInfoDict["current_album"]))
    self.titlelabel.setText("{}".format(self.currentTrackInfoDict["current_title"]))

Tags: selfformatalbumtitleartistdefupdatetrack

热门问题