Python 3.10 Pyqt5标签赢得了更改' setPixmap'需要时
我目前正在运行python 3.10,并且在比赛/案例中并有一个奇怪的结果。让我解释一下:
class Test(QtWidgets.QMainWindow):
def __init__(self):
super(Test, self).__init__()
# comboBox changes = image gets displayed on app 'WORKING'
self.comboBoxIS.currentTextChanged.connect(partial(self.loadIsCombo, Testing=False))
# Clicking 'Test' button to see if image is on the screen. At this point is on the app so technically it is.
self.pushButtonIS_2.clicked.connect(partial(self.loadIsCombo, Testing=True))
def bufferIsCombo(self, Testing=False):
selectedItem = self.comboBoxIS.currentText()
bufferImg = 'resources/ui/buffering.png'
match selectedItem:
case "Test 1":
img = config['Test1']['Test1a']
imgConf = config['Test1'].getfloat('Test1b')
self.labelIS2.setText(str(imgConf))
self.labelISConfig.setPixmap(QtGui.QPixmap(img))
self.pushButtonIS_2.setEnabled(True) # Enable test button
if Testing:
# Since the app contains the image i want to change it to another 'buffering'
self.labelISConfig.setPixmap(QtGui.QPixmap(bufferImg))
# This setPixmap wont get applied until handler returns but by that time is to late.
# imageSearchTest() come back as false positibe because it was on the application
functions.imageSearchTest()
case "Test 2":
pass
case "Test 20":
pass
一切正常运行,直到我遇到IF TESTING:strate for the if testing:statem 。新的self.labelisconfig.setpixmap(qtgui.qpixmap(bufferimg))
在函数image> images eraperechtest
之后才会更改。
问题是我在应用程序上显示该图像并运行图像搜索功能,因此它给了我误报,因为它在应用程序上找到了图像。为了解决此问题,我想将标签PixMap更改为DIF映像Bufferimg
在功能开始运行之前,我不会得到那个假阳性。
I'm currently running python 3.10 and within a match/case and having a weird outcome. Let me explain:
class Test(QtWidgets.QMainWindow):
def __init__(self):
super(Test, self).__init__()
# comboBox changes = image gets displayed on app 'WORKING'
self.comboBoxIS.currentTextChanged.connect(partial(self.loadIsCombo, Testing=False))
# Clicking 'Test' button to see if image is on the screen. At this point is on the app so technically it is.
self.pushButtonIS_2.clicked.connect(partial(self.loadIsCombo, Testing=True))
def bufferIsCombo(self, Testing=False):
selectedItem = self.comboBoxIS.currentText()
bufferImg = 'resources/ui/buffering.png'
match selectedItem:
case "Test 1":
img = config['Test1']['Test1a']
imgConf = config['Test1'].getfloat('Test1b')
self.labelIS2.setText(str(imgConf))
self.labelISConfig.setPixmap(QtGui.QPixmap(img))
self.pushButtonIS_2.setEnabled(True) # Enable test button
if Testing:
# Since the app contains the image i want to change it to another 'buffering'
self.labelISConfig.setPixmap(QtGui.QPixmap(bufferImg))
# This setPixmap wont get applied until handler returns but by that time is to late.
# imageSearchTest() come back as false positibe because it was on the application
functions.imageSearchTest()
case "Test 2":
pass
case "Test 20":
pass
Everything works well until I run into the if Testing: statement. The new self.labelISConfig.setPixmap(QtGui.QPixmap(bufferImg))
will not change until after the function imagesearchTest
.
The issue with that is I'm displaying that image on my application and running an image search function so it gives me a false positive because it finds the image on the application. To fix this I would like to change the label pixmap to a dif image bufferImg
before the function starts running so I don't get that false positive.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论