Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyCharm question
#1
Help! Pycharm won't run my code!

I have "main.py" open and when I run it, it doesn't reflect my changes/edits.

Here's the code, it's a bit of a mess as I'm working through some experiments/examples.

import sys
import random
from PySide6 import QtCore, QtWidgets, QtGui


class MyWidget(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        #self.button_add_user = QtWidgets.QPushButton("Add User")
        #self.layout = QtWidgets.QVBoxLayout(self)


    #https://doc.qt.io/qt-5/qvboxlayout.html#details

        # QWidgetwindow = new QWidget
        # self.button1 = QPushButton("One")
        # self.button2 = nQPushButton("Two")
        # self.button3 = QPushButton("Three")
        # self.button4 = QPushButton("Four")
        # self.button5 = QPushButton("Five")
        #
        # self.layout = QVBoxLayout(self)
        #
        # self.layout.addWidget(self.button1)
        # self.layout.addWidget(self.button2)
        # self.layout.addWidget(self.button3)
        # self.layout.addWidget(self.button4)
        # self.layout.addWidget(self.button5)

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

        self.button = QtWidgets.QPushButton("Press me!")
        self.text = QtWidgets.QLabel("Hello World", alignment=QtCore.Qt.AlignCenter)
        #self.button2 = QtWidgets.QPushButton("Press me!")


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

        self.layout.addWidget(self.button2)

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

    @QtCore.Slot()
    def magic(self):
        self.text.setText(random.choice(self.hello))
So, say if I change the button's text to "Click me!", it doesn't run it, it seems to run a different version.

image-2022-04-17-202404291
Reply
#2
Try CTRL-SHIFT-F10. If that works, then the next time you run, you can use SHIFT-F10 or click the run button. You can also see these options if you right click on the file's tab.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Newbie question about switching between files - Python/Pycharm Busby222 3 594 Oct-15-2023, 03:16 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020