Це відео не доступне.
Перепрошуємо.
Multiple Screens in PyQt5: Switch screens without opening a new window
Вставка
- Опубліковано 18 сер 2024
- Learn how to switch between multiple screens inside one window in PyQt5. Create a PyQt5 GUI with Python with a button that allows you to go to another screen or window.
In this video, you will:
- Use PyQt5 and QtDesigner
- Create an application that has multiple screens
- Go from one screen to another inside the application
For more info:
- Install and Setup PyQt5 and QtDesigner: • Install and Setup PyQt...
- PyQt5 QtDesigner Login and Signup Forms tutorial: for COMPLETE beginners • PyQt5 QtDesigner Login...
Source code: github.com/cod...
Contact me at: code.first.io@gmail.com
*************
*Tags*
PyQt5 tutorial
PyQt5 form
PyQt5 Designer
Qt Designer
Qt GUI tutorial
GUI tutorial Python
Graphical User Interface Python
Python tutorial
Very good tutorial! However for actually moving between the windows that need to be updated, it would be better to use the insertWidget and removeWidget methods. If you keep adding widgets and incrementing the stack, the old widgets are not deleted and the stack will simply continue to grow and use much more memory than it needs to
Do you have a working example of how to do this?
@@kuahara you actually dont have to do anything crazy, just a line under the widget.addWidget add a widget.removeWidget
e.g
line 1: widget.addWidget(screen2)
line 2 :widget.removeWidget(screen1)
in my program, the remove widget stopped the program from consuming too much memory
have a good day
@@drsoosstttm8375 Thanks. I'll check that out later. I started using +1 and -1, but that just moves the index around. It doesn't free up memory. It's been over a week, I don't remember what went wrong when I tried insertWidget per the first commenter.
@@drsoosstttm8375 Could you please provide more details? I suspect that it might be memory-consuming, but I haven't found a solution for it yet.
You are very right thank you, but there are situations as well where you might want to use stacked widgets for example if u have few finite number of screens and u want to work on them while using qt designer, on one window.
FINALLY FOUND A GENUINE TUTORIAL. THANK YOU!
Why you don't have subtracted 1 when moving from screen 2 to 1 in index?
Thank you so much your help, this is the only video I find helpful in this situation ❤❤
This video is helpfull, although I have a question about switching screens. For instance, in this video both of classes are on the same module, right? But in a biggest application, how can I do the switch screen? I have found no way to make swicht screen, which is saved in different modules.
Hey I have a question, doesn't the 2nd method of creating new instances cause memory leaks?
Thank you very much, this video deserves so many likes
Thank you so much, I found this tutorial for a long time and finally, I found it
Thanks for the wonderful explanation. Exactly what I needed.
Hi, thank you very much for this guide. Helped me a lot with PySide6.
Here is a working example of my code which removes the current active Widget to free up memory and then adds a new widget.
KEEP IN MIND:
By doing this you will lose the data of the widget which is being removed. Example of if your first widget is a login screen then you do not want to do this because it will remove their login ID data that the user might have entered, he/she will have to enter everything again. In that instance switching the index will do the trick.
def screen2(self):
s2 = screen2()
widget.removeWidget(wid.currentWidget())
widget.addWidget(s2)
going back to screen 1:
def screen1(self):
s1 = screen1()
widget.removeWidget(wid.currentWidget())
widget.addWidget(s1)
app = QApplication(sys.argv)
widget = QStackedWidget()
s1 = screen1()
widget.addWidget(s1)
widget.setFixedSize(1124, 844)
widget.show()
app.exec()
Thank You, Your explanation is so descriptive, keep going.
Hi I have a question, how do I handle the closeEvent of the QStackedWidget?
When ya adding widgets all time whenever ya switch windows the program use more memory
Shouldn't ya remove widget to get back
Am i wrong?
Thank you... i was looking for something like this!!!!
Thank you for knowing your content, and I have already subscribed to it.
I became another fan who promotes you to my friend in Korea. 💯 감사합니다
I love you so much like you don't even know. THANK YOU THANK YOU
Your tutorial is very good, can you do another tutorial to open 2nd window in mdi area, mdi area when clicking file menu action
Thank you very much! I had a problem that I couldn't switch windows with Controller, after some changes it stopped working. Even though I'm Russian, I understood everything perfectly.
Good information
really useful tutorial thx
👍
Hi, Thank you for the simple and short and informative tutorial
You are choosing Very interesting tutorial subjects!
As a beginner i m straggling with Multi-Window subject, I searched a lot and didn't find the answer!
I made a MainWindow and i need to make a Dialog window opens.. the problem is the Dialog or Dialogs open in a separate window in window Taskbar!! help please
Hi! I think trying to follow the tutorial should help. This way, we go to a different screen without opening a new window in the taskbar! Let me know if you have any more questions
@@codefirstwithhala i watched your video twice! What i need is: i made an App with tabs each tab contains a table (MySql) i need a dialog to insert and modify data when i double click a line in any table (a small dialog window) within the mainWindow not in separate precess
Question, how about i have 3 different python file and i want in my main when i click this button one of my 3 python file will appear
You are fantastic!!!! I loved how well you explained everything and the fact that you focus on functionality.
Hi, thank you for sharing your knowledge, I was realy looking for this lesson, for ather hand, could you tell me please if it is possible to disable the title bar in PQT5? Sorry for my broken english, Iam speaking from Angola and here we speak Portuguese.
You can disable the title bar using
self.window.setWindowFlag(Qt.FramelessWindowHint)
I love youuu,thanks a lot
Very good tutorial
Now I can use this concept to implement tabs feature in my project.(making a web browser btw)
Hi, I tried this program on my mac, but it raises an error. After searching on the internet for a long, came to know that " loadUi " (from PyQt5.uic import loadUi) is not available on mac. So can you make a video on how to do this same program without using loadUi ? It would be very helpful :)
Hi Apoorva, did you find a solution on this issue ?
@@rbgspar0896 I exported the .ui file to .py file and created a different class for changing screen but sometimes it doesn't work as expected. 🙂
@@apo0orva Cool, thanks!
Thank you so much!
my pycharm environment cant find the pyqt5.uic import loadUi, i only installesd pyqt and the tools as python packages
First of all, thank you very much
Just a question
If i try to put the Screen2 thing inside of the function, it says "UnboundLocalError: local variable 'Calculator' referenced before assignment". Did i miss something?
Thank you very much
how to do it if i select more MainWindows in QtDesigner?
Can you teach us how to open the main window screen from this button method. It doesnt open it in that case
How does she have it so that you can edit both windows side by side in the designer?
First of all thank you.
I have a question. You define widget variable at the buttom of your code but you use it in the class above. When I do the same thing, it says "widget not defined".
Can anyone help?
Same here
if you have "widget = QStackedWidget()" in the main function then delete main function and place this peace of code to "if __name__ == "__main__":" (It helped me)
What if there are 100 screens to create? It will load all 100 screens into memory before display....
you is exelent! thank you .
Hey, this is very helpful tutorial, although as I followed through the whole process, my gotoScreen2 function shows error as: "MainWindow object has no attribute gotoScreen2". Please help
please help me
how i passing data between windows
Can you show how to build the App to fill the birthdate?
Hello, where I can found documentation about this?
thanks for this video
Thank you!!
Thank you.
I just wish there's a c++ version of this but for QT6
how to split into two or three python file?
Thank You
thank you
I am an old man who speaks middle American English and I don't hear well. I love your voice and your tutorials hit enough of the topics-subtopics to be of very much use to me (I'm learning Python as a project for myself).
My issue is you talk a little too fast for me to get it all without repeatedly rewinding the video.
Is there a facility whereby I might turn down the playback speed?
When you hover over the video, you can see a settings icon in the bottom right corner. Click on that, then click on playback speed and adjust it to your likings.
So if I don't have QT designer and didn't make those UI designs in the first place, then I can't do this? I was hoping you'd show this with PURE code.
Qt designer is free, you can also use qt creator which is the newer version and it is also free. there are many videos that do the ui design with pure code. Believe me it is not an attactive option. loading the ui is by far the best, it is so easy to make a change or move things around. so it is better for maintenance!
just create a button and call a function from it, the same thing
Nice concept But every time adding new window is not a good idea also it is not closing the previous instance so it will stackup the memory if the user keep doing back and forth. May be destroying the closing window or just moving the index 1 and 2 is required.
Could you please explain it more in detail? Or better, because i am an absolute (I kinda started today with PyQt) beginner, do you know how to avoid stackups?
@@accelwatchingfun9560 I am also a new bee in pyqt. But some how you can go back to array and show it at position 0 and position 1. One should not keep the array incrementing again and again.
@@erbhargavvyas First of all....Damn, that was a quick response. Wish that would happen everytime XD. Secondyl, thank you for the answer. Do you think it is possible to do "-1" and not "+1"?. And third, thank you ^^
@@erbhargavvyas I was thinking the same thing, I'm building a production application right now and I dont know how to get around this, did you find anything by any chance?
@@accelwatchingfun9560 no, that will get you out of range and crash your application
fYi: Sourcecode Link is wrong. I love the fact that the Qt5 Designer is a copy of the Visual Basic 6 Designer, which is the best Editor UI ever, despite beeing over 25 years old.
Машалла
Çok laf az iş