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

  Рет қаралды 94,651

Code First with Hala

Code First with Hala

Күн бұрын

Пікірлер: 79
@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 8 ай бұрын
@@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 5 ай бұрын
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.
@muhammadali-cv3uq
@muhammadali-cv3uq 3 жыл бұрын
Why you don't have subtracted 1 when moving from screen 2 to 1 in index?
@James-in4ow
@James-in4ow 27 күн бұрын
that is what I thought, +1 on screen didn't work for me, I had to -1 on window2
@durgakarwa9102
@durgakarwa9102 7 күн бұрын
very useful information. I have a question: if I want to add a second screen to the first screen's lineEdit , how can I do that?
@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()
@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.
@someoneontheinternetuvenev6268
@someoneontheinternetuvenev6268 3 жыл бұрын
FINALLY FOUND A GENUINE TUTORIAL. THANK YOU!
@-mathsinsinhala8126
@-mathsinsinhala8126 3 жыл бұрын
Your tutorial is very good, can you do another tutorial to open 2nd window in mdi area, mdi area when clicking file menu action
@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?
@someoneontheinternetuvenev6268
@someoneontheinternetuvenev6268 3 жыл бұрын
Hey I have a question, doesn't the 2nd method of creating new instances cause memory leaks?
@abdelrahmanfekri8876
@abdelrahmanfekri8876 Жыл бұрын
Very good tutorial
@11bomon48
@11bomon48 Жыл бұрын
Thank you so much!
@tommysellbee
@tommysellbee 3 жыл бұрын
Hi I have a question, how do I handle the closeEvent of the QStackedWidget?
@bryanesquivel6062
@bryanesquivel6062 3 жыл бұрын
Thank you!!
@ayushmaanyadav4069
@ayushmaanyadav4069 2 жыл бұрын
Now I can use this concept to implement tabs feature in my project.(making a web browser btw)
@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)
@aNImALzZ217
@aNImALzZ217 3 жыл бұрын
I love you so much like you don't even know. THANK YOU THANK YOU
@gaburuukun2617
@gaburuukun2617 6 ай бұрын
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
@blueshoreboutique5382
@blueshoreboutique5382 Жыл бұрын
What if there are 100 screens to create? It will load all 100 screens into memory before display....
@apo0orva
@apo0orva 3 жыл бұрын
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 3 жыл бұрын
Hi Apoorva, did you find a solution on this issue ?
@apo0orva
@apo0orva 3 жыл бұрын
@@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 3 жыл бұрын
@@apo0orva Cool, thanks!
@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
@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
@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?
@hokcheunghung7769
@hokcheunghung7769 3 жыл бұрын
thank you
@Atharva_Vashist
@Atharva_Vashist 3 жыл бұрын
Thank you very much, this video deserves so many likes
@wickedblue3218
@wickedblue3218 3 жыл бұрын
Thank you... i was looking for something like this!!!!
@digitalmachine0101
@digitalmachine0101 6 ай бұрын
Good information
@eyupcvs9249
@eyupcvs9249 Жыл бұрын
I love youuu,thanks a lot
@xlobo9822
@xlobo9822 Жыл бұрын
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. 💯 감사합니다
@nqobiledlamini5253
@nqobiledlamini5253 3 ай бұрын
Thank you so much your help, this is the only video I find helpful in this situation ❤❤
@diegohernandezestrada4328
@diegohernandezestrada4328 2 жыл бұрын
my pycharm environment cant find the pyqt5.uic import loadUi, i only installesd pyqt and the tools as python packages
@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.
@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)
@DyneGadante
@DyneGadante Жыл бұрын
How does she have it so that you can edit both windows side by side in the designer?
@uly3213
@uly3213 Жыл бұрын
how to do it if i select more MainWindows in QtDesigner?
@spiffjekey-green4034
@spiffjekey-green4034 Жыл бұрын
I just wish there's a c++ version of this but for QT6
@gfrsaaaar4575
@gfrsaaaar4575 2 жыл бұрын
Can you show how to build the App to fill the birthdate?
@Crazy_octo
@Crazy_octo 7 ай бұрын
really useful tutorial thx 👍
@Oussama-qp2hh
@Oussama-qp2hh 2 жыл бұрын
please help me how i passing data between windows
@PavanTripathi-rj7bd
@PavanTripathi-rj7bd 11 ай бұрын
Thanks for the wonderful explanation. Exactly what I needed.
@tattapontippayachan443
@tattapontippayachan443 2 жыл бұрын
Thank you very much
@marcelocardosorabelo3623
@marcelocardosorabelo3623 2 жыл бұрын
you is exelent! thank you .
@hungleinh2746
@hungleinh2746 Жыл бұрын
Thank you so much, I found this tutorial for a long time and finally, I found it
@SyedDanishTech
@SyedDanishTech 2 жыл бұрын
Thank You
@deeparghchatterjee2600
@deeparghchatterjee2600 3 жыл бұрын
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
@hussainabbas1341
@hussainabbas1341 2 жыл бұрын
Thank You, Your explanation is so descriptive, keep going.
@juanemiliogarcia1843
@juanemiliogarcia1843 3 жыл бұрын
Hello, where I can found documentation about this?
@mseroglu47
@mseroglu47 3 жыл бұрын
Çok laf az iş
@kittytangsze
@kittytangsze 3 жыл бұрын
how to split into two or three python file?
@Harsh-se1gx
@Harsh-se1gx 3 жыл бұрын
Thank you.
@mr.morgan1002
@mr.morgan1002 3 жыл бұрын
thanks for this video
@sky4131
@sky4131 2 жыл бұрын
Машалла
@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
@robpersonalteacher4162
@robpersonalteacher4162 2 жыл бұрын
You are fantastic!!!! I loved how well you explained everything and the fact that you focus on functionality.
@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
@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.
@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.
QtDesigner and PyQt5:  The right and wrong way to use them together
37:16
Alan D Moore Codes
Рет қаралды 108 М.
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 42 МЛН
Please Help This Poor Boy 🙏
00:40
Alan Chikin Chow
Рет қаралды 23 МЛН
The joker favorite#joker  #shorts
00:15
Untitled Joker
Рет қаралды 30 МЛН
ОТОМСТИЛ МАМЕ ЗА ЧИПСЫ🤯#shorts
00:44
INNA SERG
Рет қаралды 4,8 МЛН
How to use Qt Layouts
19:18
Velcode
Рет қаралды 94 М.
How To Open A Second Window - PyQt5 GUI Thursdays #24
13:41
Codemy.com
Рет қаралды 67 М.
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
Рет қаралды 111 М.
PyQt5 Designer + Python Stacked Widget Walkthrough
18:22
Jekyll&HydeTutorials
Рет қаралды 40 М.
3. Python   PyQt Containers and Layouts
12:07
PanoPython
Рет қаралды 2,2 М.
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 42 МЛН