Closed Pickaxe233 closed 1 year ago
Most likely and issue with missing stub info for 'clicked'
sorry my misoperation
Most likely and issue with missing stub info for 'clicked'
So could you please tell me how to solve it or am I able to solve it?
@Pickaxe233, could you please provide a minimal, self-contained code snippet? Your code sample references symbols that are presumably imported from a library or are defined elsewhere in your code. If imported, include the import statements. And if they are coming from a library, please specify the version of the library and whether you have any type stubs installed.
@Pickaxe233, could you please provide a minimal, self-contained code snippet? Your code sample references symbols that are presumably imported from a library or are defined elsewhere in your code. If imported, include the import statements. And if they are coming from a library, please specify the version of the library and whether you have any type stubs installed.
By the way I'm using Python 3.11.0 now, but it seems doesn't affect this problem the bolded codes in the following codes are wrongly highlighted codes
self.pushButton.clicked.connect(self.search) self.pushButton_2.clicked.connect(self.voice1) self.pushButton_3.clicked.connect(self.voice2) self.pushButton_4.clicked.connect(lambda:self.pic(0)) self.pushButton_5.clicked.connect(lambda:self.pic(1)) self.actionConfigrations.triggered.connect(self.configs) self.lineEdit.returnPressed.connect(self.search) self.listWidget.customContextMenuRequested.connect(self.copy) self.listWidget_2.customContextMenuRequested.connect(self.copy1) self.textBrowser.customContextMenuRequested.connect(self.copy2) self.checkBox.stateChanged.connect(lambda:self.pic(2)) self.pushButton_6.clicked.connect(self.translate) self.pushButton_7.clicked.connect(self.clear)
Here's all imports
import json
import requests
import datetime
import sys
import re
import cn2an
import Threads
import config
from borax.calendars.lunardate import LunarDate
from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox, QMenu
from PySide6.QtGui import QImage, QPixmap, QFont, QFontDatabase
from ui_dict import Ui_MainWindow #It's converted from .ui file
from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput, QMediaDevices, QAudioDevice
from PySide6.QtCore import Qt, QSize, QUrl
And all methods or others I have referenced haven't highlights, for example
def clear(self):
self.plainTextEdit.clear()
self.textBrowser.clear()
except for methods include Threads.voiceThread(t=0)
, and Threads.voiceThread(t=0)
itself is highlighted wrongly, like:
It's from Threads.py, but there aren't highlights in the whole file.
from PySide6.QtCore import QThread, Signal
class voiceThread(QThread):
finishSignal = Signal(int)
def __init__(self, t, parent=None):
super(voiceThread, self).__init__(parent)
self.t = t
def run(self):
self.finishSignal.emit(int(self.t))
Thank you for the additional info.
Threads.voiceThread(t=0)
seems to work for me after import Threads
if you go to definition
on Threads
in the statement Threads.voiceThread
where does it take you?
Thank you for the additional info.
Threads.voiceThread(t=0)
seems to work for me afterimport Threads
if you
go to definition
onThreads
in the statementThreads.voiceThread
where does it take you?
It takes me to the file Threads.py
can you paste the actual error text.. and also show me how you r importing "Threads"? ie. import Threads
can you paste the actual error text.. and also show me how you r importing "Threads"? ie.
import Threads
The actual error text:
Cannot access member "clicked" for type "QPushButton" Member "clicked" is unknown
And I just use import Threads
for importing
@Pickaxe233, could you please provide a minimal, self-contained code snippet that demonstrates the problem you're seeing? Screen shots and incomplete code samples are not very useful in diagnosing issues like this.
@Pickaxe233, could you please provide a minimal, self-contained code snippet that demonstrates the problem you're seeing? Screen shots and incomplete code samples are not very useful in diagnosing issues like this.
In main.py
:
from ui_main import Ui_MainWindow
#ui_main.py is main.ui's coverted version
from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.QtCore import QUrl
class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.player = QMediaPlayer()
self.audio = QAudioOutput()
self.audio.setVolume(1)
self.player.setAudioOutput(self.audio)
self.pushButton_2.clicked.connect(self.voice1)
def voice(self,num):
a = ""
match num:
case 0:
a = "http://dict.youdao.com/dictvoice?type=1&audio="
case 1:
a = "http://dict.youdao.com/dictvoice?type=0&audio="
self.player.setSource(QUrl(a+self.lineEdit.text()))
self.player.play()
self.thread.terminate()
def voice1(self):
self.thread = Threads.Thread(t=0)
self.thread.finishSignal.connect(self.voice)
self.thread.start()
And in Threads.py
:
from PySide6.QtCore import QThread, Signal
class Thread(QThread):
finishSignal = Signal(int)
def __init__(self, t, parent=None):
super(msgThread, self).__init__(parent)
self.t = t
def run(self):
self.finishSignal.emit(int(self.t))
Additional, it always highlights on clicked
whatever what method is connected
This is not a self-contained, minimal code snippet. It references a file called ui_main
and symbols msgThread
, QMediaPlayer
, QAudioOutput
, Ui_MainWindow
. Without understanding how these symbols are defined, we won't be able to repro the problem you're seeing. Please take another shot at producing a self-contained, minimal code sample that exhibits the problem.
It looks like you're using the library PySide6
. Which version of the library do you have installed? Have you tried upgrading to the latest version?
My PySide6 is the latest, and I have the same problem in PyQt5.
And here's ui_main.py.txt, it's converted from qt .ui file by an extension called Qt for Python. Ui_MainWindow
is included in it.
The msgThread
is same as the Thread
up there, only differs the class name.
For QMediaPlayer
QAudioOutput
, I 'm sorry that I don't know how to take shot. They are a part of PySide6.
I have the same error (in a sense) with PySide6 6.4.2 (made sure its upgraded) I'm using VSC version 1.75.0.
The clicked in button.clicked.connect(self.the_button_was_clicked)
gives the warning "Cannot access member "clicked" for type "QPushButton" Member "clicked" is unknown"
Which the code still functions when ran, I just do not like seeing errors where there shouldn't be one.
import sys
from PySide6.QtCore import QSize
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("My App")
self.setFixedSize(QSize(400, 300))
button = QPushButton("Press Me!")
button.setCheckable(True)
button.clicked.connect(self.the_button_was_clicked)
self.setCentralWidget(button)
def the_button_was_clicked(self):
print("Clicked!")
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
This looks to be a bug in the PySide6 package. It ships with integrated type stub files, but the type stub definitions don't include any definition for an attribute called clicked
. Please report the bug to the maintainers of PySide6.
This looks to be a bug in the PySide6 package. It ships with integrated type stub files, but the type stub definitions don't include any definition for an attribute called
clicked
. Please report the bug to the maintainers of PySide6.
OK, I'll report it. Sorry for bothering you.
For anyone finding this Issue, this problem seems to be fixed with version 6.5.0 of PySide6 that was released 4th of April 2023.
Environment data
Python version (& distribution if applicable, e.g. Anaconda): 3.10.8
Expected behaviour
extension sets correct syntax highlighting
Actual behaviour
extension can't find QPushButton class's clicked method
Code Snippet / Additional information
It's kind of like #884, and if I run the full script, everything is working as expected, but extension sets wrong syntax highlighting, and I'm using PySide6