[Python] Pyside environment variable doesn't apply in Pycharm's run configuration

Discussão em 'Python' iniciado por Stack, Setembro 4, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to diagnose missing Slot decorators as specified in the end of the section https://doc.qt.io/qtforpython-6/tutorials/basictutorial/signals_and_slots.html#the-slot-class. I was able to activate this functionality when set the variable and run program from terminal. But I couldn't achieve this when set the variable in run configuration and launched from PyCharm.

    This is my program:

    import random
    import sys

    from PySide6.QtCore import Qt
    from PySide6.QtWidgets import QApplication, QLabel, QPushButton, QVBoxLayout, QWidget


    class MyWidget(QWidget):
    def __init__(self):
    super().__init__()

    self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]

    self.button = QPushButton("Click me!")
    self.text = QLabel("Hello World", alignment=Qt.AlignmentFlag.AlignCenter)

    self.layout = QVBoxLayout(self)
    self.layout.addWidget(self.text)
    self.layout.addWidget(self.button)

    self.button.clicked.connect(self.magic)

    def magic(self):
    self.text.setText(random.choice(self.hello))


    if __name__ == "__main__":
    app = QApplication([])

    widget = MyWidget()
    widget.resize(800, 600)
    widget.show()

    sys.exit(app.exec())


    These are the environment variables of run configuration: [​IMG]

    What am I doing wrong?

    Continue reading...

Compartilhe esta Página