Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Spyder "custom IPython" dosn't work correctly #21663

Closed
GitKia1392 opened this issue Dec 31, 2023 · 5 comments
Closed

The Spyder "custom IPython" dosn't work correctly #21663

GitKia1392 opened this issue Dec 31, 2023 · 5 comments

Comments

@GitKia1392
Copy link

GitKia1392 commented Dec 31, 2023

The thing is that no-one uses the old "Python 3.8" anymore(its the default btw) and plus, when i changed it to Python 3.11.5
it won't work; in VSCode I tried the EXACT same code and it worked unlike it wouldn't in Spyder
Here's my code

import sys
import platform
import time
import ExecutableBuilder
from PyQt5.QtWidgets import QApplication as qapp, QMainWindow as qmain, QLabel as qlab, QVBoxLayout as qvbox, QWidget, QPushButton, QInputDialog
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import QEvent as qeve
import subprocess as sp

app = qapp(sys.argv)

class Install(qmain):
    def __init__(self):
        super().__init__()
        self.setWindowIcon(QIcon(r"K:\Dont_Bother\Icon-Taskbar-window.png"))

        if platform.system() != "Windows":
            # If your OS isn't Windows it will execute this code:
            self.setWindowTitle('--NotWindowsError')
            self.setGeometry(100, 100, 800, 600)  # Adjusted size

            # Create a central widget to hold the layout
            central_widget = QWidget(self)

            layout = qvbox()
            label = qlab(f"OS must be Windows 10, 8.1 or 11, this OS is using {platform.system()}")
            layout.addWidget(label)

            # Set the layout for the central widget
            central_widget.setLayout(layout)

            # Set the central widget for the main window
            self.setCentralWidget(central_widget)
        else:
            # If your OS is Windows it will execute this code:
            self.setWindowTitle('Dont_Bother')
            self.setGeometry(100, 100, 800, 600)  # Adjusted size

            central_widget = QWidget(self)

            layout = qvbox()
            label = qlab("OS is windows... Do you wish to continue?")
            layout.addWidget(label)

            # Create a function to handle the user's input
            def handle_input():
                user_input, ok = QInputDialog.getText(self, 'Input', 'Do you wish to continue? (yes/no)')
                if ok and user_input.lower() == "yes":
                    sp.run(ExecutableBuilder)
                else:
                    sys.exit()

            # if the user wants to continue.
            button = QPushButton("Continue to Dont_Bother?")
            button.clicked.connect(handle_input)

            layout.addWidget(button)

            central_widget.setLayout(layout)

            self.setCentralWidget(central_widget)

# Create an instance of the Install class
install_window = Install()

# Show the window
install_window.show()

# Start the application's event loop
sys.exit(app.exec_())
@ccordoba12
Copy link
Member

Hey @GitKia1392, thanks for reporting. Why does your code not work? What problem are you seeing in Spyder?

@GitKia1392
Copy link
Author

Wassup @ccordoba12. My code works flawlessly in VS Code.
The problem is the performance; Its very laggy in comparison to VS Code

The main problem is probably becuz of How big spyder is.

@ccordoba12
Copy link
Member

The main problem is probably becuz of How big spyder is.

That has nothing to do with it.

The problem is the performance; Its very laggy in comparison to VS Code

Please follow the instructions posted in this page to see if that helps:

https://github.com/spyder-ide/spyder/wiki/How-to-run-PyQt-applications-within-Spyder

@GitKia1392
Copy link
Author

GitKia1392 commented Jan 9, 2024

Did fix the problem a little but when with the new code:

from sys import exit, argv
import platform
import time
from PyQt5.QtWidgets import QApplication as qapp, QMainWindow as qmain, QLabel as qlab, QVBoxLayout as qvbox, QWidget, QPushButton, QInputDialog
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import QEvent as qeve
import subprocess as sp

app = qapp(argv)

class Install(qmain):
    def __init__(self):
        super().__init__()
        self.setWindowIcon(QIcon(r"K:\Dont_Bother\Icon-Taskbar-window.png"))

        if platform.system() != "Windows":
            # If your OS isn't Windows it will execute this code:
            self.setWindowTitle('--NotWindowsError')
            self.setGeometry(100, 100, 800, 600)  # Adjusted size

            # Create a central widget to hold the layout
            central_widget = QWidget(self)

            layout = qvbox()
            label = qlab(f"OS must be Windows 10, 8.1 or 11, this OS is using {platform.system()}")
            layout.addWidget(label)

            # Set the layout for the central widget
            central_widget.setLayout(layout)

            # Set the central widget for the main window
            self.setCentralWidget(central_widget)
        else:
            # If your OS is Windows it will execute this code:
            self.setWindowTitle('Dont_Bother')
            self.setGeometry(100, 100, 800, 600)  # Adjusted size

            central_widget = QWidget(self)

            layout = qvbox()
            label = qlab("OS is windows... Do you wish to continue?")
            layout.addWidget(label)

            # Create a function to handle the user's input
            def handle_input():
                user_input, ok = QInputDialog.getText(self, 'Input', 'Do you wish to continue? (yes/no)')
                if ok and user_input.lower() == "yes":
                    exit()
                else:
                    exit()

            # if the user wants to continue.
            button = QPushButton("Continue to Dont_Bother?")
            button.clicked.connect(handle_input)

            layout.addWidget(button)

            central_widget.setLayout(layout)

            self.setCentralWidget(central_widget)

# Create an instance of the Install class
install_window = Install()

# Show the window
install_window.show()

# Start the application's event loop
exit(app.exec_())

When i try to exit the app it doesn't let me and it says oh 'PyThOn IsN't ReSpOnDiNg!'

That has nothing to do with it.
I'm still pretty sure it has got SOMETHING to do with it at lest.

Thanks
Me

@ccordoba12
Copy link
Member

ccordoba12 commented Jan 21, 2024

Please change the last line of your code

exit(app.exec_())

to be

app.exec_()

That should fix your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants