#๐Ÿ”’ My GUI freezes every time I run a function

21 messages ยท Page 1 of 1 (latest)

exotic saddleBOT
#

@abstract cliff

Python help channel opened

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.

abstract cliff
#

Hey, so the problem is that my function has to use internet to load some info, and while it is loading the GUI freezes

#

ask if you need me to explain what a part of the code does

prime sphinx
#

!paste -- Send the code here.

exotic saddleBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

abstract cliff
#

even tho it is 168kb

abstract cliff
#

yep

prime sphinx
# prime sphinx Ah, PyQt, I see.

My first suggestion would be to not use uic since the code it generates is frankly... quite bad. Instead, use QtUic to load your UI directly (I think that's how it's called in PyQt?).

desert wedge
#

This is generally why I avoid qt designer

abstract cliff
prime sphinx
#

Basically, use threads. In PyQt/PySide, there's QThread for this plus a nice interface around it called QRunnable.

abstract cliff
prime sphinx
# abstract cliff But I cant do that now, I changed wayyy too much of the code

Even if you want to use uic, this is not the correct way of doing it.
You aren't supposed to modify its outputs as implied by the comment:

# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.

You are supposed to have a separate file for the UI you generated and a separate file that loads it into your actual application.

from PyQt5.QtWidgets import QMainWindow
from .uic_file import Ui_MainWindow # or whatever it's called

class Window(QMainWindow, Ui_MainWindow):
  def __init__(self) -> None:
    super().__init__() # add the actual logic for the UI

There's also loading the UI directly through uic although that loses the autocomplete benefits.

#

Qt Designer is useful only if you know how to use it properly and if the thing you're looking for is a quick UI and you only care about app logic. If you're looking into learning the inner workings of Qt, I would stay away from it (and once you learn enough Qt, you might even find that easier than Designer).

exotic saddleBOT
#
Python help channel closed

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.