from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget
import sys
class MyWindow(QMainWindow):
def __init__(self):
super(MyWindow, self).__init__()
screen = QDesktopWidget().screenGeometry()
win_size = (0, 0, 500, 400)
self.setGeometry(*win_size)
self.move(screen.width()//2 - win_size[2]//2, screen.height()//2 - win_size[3]//2)
self.setWindowTitle("Stegophone")
self.initUI()
def initUI(self):
self.button_image_picker = QtWidgets.QPushButton(self)
self.button_image_picker.setText("Pick Image")
self.button_image_picker.clicked.connect(self.file_manager)
def file_manager(self):
dir_path = os.path.dirname(os.path.abspath(__file__))
image_path = dir_path + "\\images"
print("test")
def window():
app = QApplication(sys.argv)
win = MyWindow()
win.show()
sys.exit(app.exec_())
window()```
#๐ Code Crashes on button press, Error: ``Cannot find reference 'connect' in 'pyqtSignal | pyqtSignal
34 messages ยท Page 1 of 1 (latest)
@noble compass
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
Tried updating PyQt5, but it is the latest version
Also shows and internal depreciation for something not in my code though
Makes the window successfully
On click, crashes with error code: Process finished with exit code -1073740791 (0xC0000409)
can you share the full code?
This is the full code
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget
import sys
class MyWindow(QMainWindow):
def __init__(self):
super(MyWindow, self).__init__()
screen = QDesktopWidget().screenGeometry()
win_size = (0, 0, 500, 400)
self.setGeometry(*win_size)
self.move(screen.width()//2 - win_size[2]//2, screen.height()//2 - win_size[3]//2)
self.setWindowTitle("Stegophone")
self.initUI()
def initUI(self):
self.button_image_picker = QtWidgets.QPushButton(self)
self.button_image_picker.setText("Pick Image")
self.button_image_picker.clicked.connect(self.file_manager)
def file_manager(self):
dir_path = os.path.dirname(os.path.abspath(__file__))
image_path = dir_path + "\\images"
print("test")
def window():
app = QApplication(sys.argv)
win = MyWindow()
win.show()
sys.exit(app.exec_())
window()
It's missing the import os, but if I add the import os, it runs fine
I accidentlly imported the wrong lirbrary from a different project...
This is fair
Why the error on .connect then?
And the depreciation?
Well, the code works fine
Now that I imported it correctly
But I'm getting errors that I shouldn't be that don't seem to do anything
Cannot find reference 'connect' yet .connect ran fine?
Issue with PyCharm?
yeah that's fine too. Due to how connect is set up in the class, pycharm doesn't quite follow the reference properly
It's the same for me
that's also not an error, that's a warning
errors break your code
Alright, fair
I'll see if it can't just ignore it, seems to work fine
Danke
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.