Re: PyQt5 code not working
I don't know enough Python (yet) to be certain, but the behavior you describe sounds like a scoping issue - that is, the variable holding the new widget you create only exists for the lifetime of the method where it is created and then goes out of scope, at which point the widget is destroyed. This happens in C++ Qt when a widget is declared as a local variable in a method; it is created and then immediately is destroyed when the method exits.
Another possible cause could be because you are replacing your main window with the new one. Qt normally will exit an app when the last top-level widget is destroyed. My understanding of Python is that when variables are reassigned, the object previously assigned to the variable goes out of scope and is scheduled for garbage collection. Try removing the assignment of CreateUser to main in NewUserPressed() and see what happens.