Multiple Screens in PyQt5: Switch screens without opening a new window

  Рет қаралды 92,105

Code First with Hala

Code First with Hala

Күн бұрын

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/codefirstio/Browse...
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

Пікірлер: 77
@the1anonymouse
@the1anonymouse 3 жыл бұрын
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
@kuahara
@kuahara Жыл бұрын
Do you have a working example of how to do this?
@drsoosstttm8375
@drsoosstttm8375 Жыл бұрын
@@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
@kuahara
@kuahara Жыл бұрын
@@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.
@miledmohamed2250
@miledmohamed2250 5 ай бұрын
@@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.
@spinj3307
@spinj3307 2 ай бұрын
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.
@someoneontheinternetuvenev6268
@someoneontheinternetuvenev6268 3 жыл бұрын
FINALLY FOUND A GENUINE TUTORIAL. THANK YOU!
@muhammadali-cv3uq
@muhammadali-cv3uq 3 жыл бұрын
Why you don't have subtracted 1 when moving from screen 2 to 1 in index?
@hussainabbas1341
@hussainabbas1341 2 жыл бұрын
Thank You, Your explanation is so descriptive, keep going.
@Atharva_Vashist
@Atharva_Vashist 3 жыл бұрын
Thank you very much, this video deserves so many likes
@PavanTripathi-rj7bd
@PavanTripathi-rj7bd 9 ай бұрын
Thanks for the wonderful explanation. Exactly what I needed.
@wickedblue3218
@wickedblue3218 3 жыл бұрын
Thank you... i was looking for something like this!!!!
@hungleinh2746
@hungleinh2746 Жыл бұрын
Thank you so much, I found this tutorial for a long time and finally, I found it
@robpersonalteacher4162
@robpersonalteacher4162 2 жыл бұрын
You are fantastic!!!! I loved how well you explained everything and the fact that you focus on functionality.
@nqobiledlamini5253
@nqobiledlamini5253 27 күн бұрын
Thank you so much your help, this is the only video I find helpful in this situation ❤❤
@aNImALzZ217
@aNImALzZ217 3 жыл бұрын
I love you so much like you don't even know. THANK YOU THANK YOU
@pedrowegner9167
@pedrowegner9167 2 жыл бұрын
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.
@-mathsinsinhala8126
@-mathsinsinhala8126 2 жыл бұрын
Your tutorial is very good, can you do another tutorial to open 2nd window in mdi area, mdi area when clicking file menu action
@xlobo9822
@xlobo9822 10 ай бұрын
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. 💯 감사합니다
@someoneontheinternetuvenev6268
@someoneontheinternetuvenev6268 3 жыл бұрын
Hey I have a question, doesn't the 2nd method of creating new instances cause memory leaks?
@Crazy_octo
@Crazy_octo 4 ай бұрын
really useful tutorial thx 👍
@11bomon48
@11bomon48 Жыл бұрын
Thank you so much!
@accelwatchingfun9560
@accelwatchingfun9560 3 жыл бұрын
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?
@timurka0583
@timurka0583 Жыл бұрын
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.
@bryanesquivel6062
@bryanesquivel6062 3 жыл бұрын
Thank you!!
@eyupcvs9249
@eyupcvs9249 Жыл бұрын
I love youuu,thanks a lot
@tattapontippayachan443
@tattapontippayachan443 2 жыл бұрын
Thank you very much
@abdelrahmanfekri8876
@abdelrahmanfekri8876 Жыл бұрын
Very good tutorial
@marcelocardosorabelo3623
@marcelocardosorabelo3623 2 жыл бұрын
you is exelent! thank you .
@mr.morgan1002
@mr.morgan1002 3 жыл бұрын
thanks for this video
@Harsh-se1gx
@Harsh-se1gx 3 жыл бұрын
Thank you.
@tommysellbee
@tommysellbee 2 жыл бұрын
Hi I have a question, how do I handle the closeEvent of the QStackedWidget?
@digitalmachine0101
@digitalmachine0101 3 ай бұрын
Good information
@ayushmaanyadav4069
@ayushmaanyadav4069 2 жыл бұрын
Now I can use this concept to implement tabs feature in my project.(making a web browser btw)
@abilovestotrade
@abilovestotrade Жыл бұрын
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()
@deeparghchatterjee2600
@deeparghchatterjee2600 2 жыл бұрын
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
@SyedDanishTech
@SyedDanishTech 2 жыл бұрын
Thank You
@hokcheunghung7769
@hokcheunghung7769 3 жыл бұрын
thank you
@kayombo1001
@kayombo1001 3 жыл бұрын
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.
@erbhargavvyas
@erbhargavvyas 3 жыл бұрын
You can disable the title bar using self.window.setWindowFlag(Qt.FramelessWindowHint)
@anonymousghost5384
@anonymousghost5384 2 жыл бұрын
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?
@nadirb229
@nadirb229 3 жыл бұрын
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
@codefirstwithhala
@codefirstwithhala 3 жыл бұрын
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
@nadirb229
@nadirb229 3 жыл бұрын
@@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
@juanemiliogarcia1843
@juanemiliogarcia1843 3 жыл бұрын
Hello, where I can found documentation about this?
@abdullahbutt324
@abdullahbutt324 2 жыл бұрын
Can you teach us how to open the main window screen from this button method. It doesnt open it in that case
@diegohernandezestrada4328
@diegohernandezestrada4328 Жыл бұрын
my pycharm environment cant find the pyqt5.uic import loadUi, i only installesd pyqt and the tools as python packages
@uly3213
@uly3213 Жыл бұрын
how to do it if i select more MainWindows in QtDesigner?
@gaburuukun2617
@gaburuukun2617 4 ай бұрын
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
@DyneGadante
@DyneGadante Жыл бұрын
How does she have it so that you can edit both windows side by side in the designer?
@kittytangsze
@kittytangsze 3 жыл бұрын
how to split into two or three python file?
@Oussama-qp2hh
@Oussama-qp2hh Жыл бұрын
please help me how i passing data between windows
@gfrsaaaar4575
@gfrsaaaar4575 2 жыл бұрын
Can you show how to build the App to fill the birthdate?
@orhansrml
@orhansrml 3 жыл бұрын
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?
@sisik96
@sisik96 3 жыл бұрын
Same here
@dimavarchuc2046
@dimavarchuc2046 2 жыл бұрын
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)
@apo0orva
@apo0orva 2 жыл бұрын
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 :)
@rbgspar0896
@rbgspar0896 2 жыл бұрын
Hi Apoorva, did you find a solution on this issue ?
@apo0orva
@apo0orva 2 жыл бұрын
@@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. 🙂
@rbgspar0896
@rbgspar0896 2 жыл бұрын
@@apo0orva Cool, thanks!
@spiffjekey-green4034
@spiffjekey-green4034 9 ай бұрын
I just wish there's a c++ version of this but for QT6
@blueshoreboutique5382
@blueshoreboutique5382 11 ай бұрын
What if there are 100 screens to create? It will load all 100 screens into memory before display....
@erbhargavvyas
@erbhargavvyas 3 жыл бұрын
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.
@accelwatchingfun9560
@accelwatchingfun9560 3 жыл бұрын
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?
@erbhargavvyas
@erbhargavvyas 3 жыл бұрын
@@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.
@accelwatchingfun9560
@accelwatchingfun9560 3 жыл бұрын
@@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 ^^
@someoneontheinternetuvenev6268
@someoneontheinternetuvenev6268 3 жыл бұрын
@@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?
@someoneontheinternetuvenev6268
@someoneontheinternetuvenev6268 3 жыл бұрын
@@accelwatchingfun9560 no, that will get you out of range and crash your application
@rabbitazteca23
@rabbitazteca23 3 жыл бұрын
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.
@alexandarjelenic7718
@alexandarjelenic7718 3 жыл бұрын
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!
@someoneontheinternetuvenev6268
@someoneontheinternetuvenev6268 3 жыл бұрын
just create a button and call a function from it, the same thing
@sky4131
@sky4131 2 жыл бұрын
Машалла
@sherrilblackmon7465
@sherrilblackmon7465 3 жыл бұрын
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?
@gx4
@gx4 3 жыл бұрын
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.
@cinquecento1985
@cinquecento1985 2 жыл бұрын
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.
@mseroglu47
@mseroglu47 3 жыл бұрын
Çok laf az iş
QtDesigner and PyQt5:  The right and wrong way to use them together
37:16
Alan D Moore Codes
Рет қаралды 107 М.
ОСКАР ИСПОРТИЛ ДЖОНИ ЖИЗНЬ 😢 @lenta_com
01:01
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
버블티로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 120 МЛН
How To Open A Second Window - PyQt5 GUI Thursdays #24
13:41
Codemy.com
Рет қаралды 65 М.
How to pass data from one window to another | PyQt5 Tutorial
7:20
PyQt5 QtDesigner Login and Signup Forms tutorial: for COMPLETE beginners
30:47
Code First with Hala
Рет қаралды 107 М.
PyQt5 Designer + Python Stacked Widget Walkthrough
18:22
Jekyll&HydeTutorials
Рет қаралды 39 М.
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 385 М.
PyQt6 Course For Beginners [Python GUI Framework PyQt ]
3:09:20
Parwiz Forogh
Рет қаралды 161 М.
PyQt5 QTableWidget tutorial: Load data, fill tables, format tables [Table Widget]
18:04
3. Python   PyQt Containers and Layouts
12:07
PanoPython
Рет қаралды 1,4 М.
Create Stunning Python GUIs in 10 Minutes With Drag & Drop
11:38
Coding Is Fun
Рет қаралды 21 М.
Tag her 🤭💞 #miniphone #smartphone #iphone #samsung #fyp
0:11
Pockify™
Рет қаралды 38 МЛН
Mastering Picture Editing: Zoom Tools Tutorial
0:52
Photoo Edit
Рет қаралды 505 М.
Todos os modelos de smartphone
0:20
Spider Slack
Рет қаралды 496 М.
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 766 М.
Battery  low 🔋 🪫
0:10
dednahype
Рет қаралды 414 М.
Choose a phone for your mom
0:20
ChooseGift
Рет қаралды 6 МЛН