How to close a window and open a new window with a button click?How to hide close button in WPF window?How to prevent a dialog from closing when a button is clickedGetting a Blank Progress bar window pyqt 5Cannot close Dialog on Python PyQt4PyQt5 Having trouble opening up multiple windows of the same applicationmultiple gui python qt and switch between themHow to stop second PyQt5 QMainWindow from closing?PyQt5 - Close QDialog window with cancel buttonDynamically add rows and columns in QTable in pyQT5PyQt - How to link and update the label from edit Window to my main window

Is this artwork (used in a video game) real?

what relax command means?

Can a Resident Assistant be told to ignore a lawful order?'

Is the purpose of sheet music to be played along to? Or a guide for learning and reference during playing?

Is straight-up writing someone's opinions telling?

Did Voldemort kill his father before finding out about Horcruxes?

What is the point of a constraint expression on a non-templated function?

Pi 3 B+ no audio device found

How would you say "Sorry, that was a mistake on my part"?

Why is Katakana not pronounced Katagana?

Why does "git status" show I'm on the master branch and "git branch" does not in a newly created repository?

Alphanumeric Line and Curve Counting

Which GPUs to get for Mathematical Optimization (if any...)?

Does this sentence I constructed with my junior high school latin work? I write online advertising and want to come off as snobby as possible

Optimising the Selection of MaxValue in Association

What happens if a company buys back all of its shares?

Did 007 exist before James Bond?

How could an animal "smell" carbon monoxide?

How to color a tag in a math equation?

Why did Steve Rogers choose this character in Endgame?

Increasing muscle power without increasing volume

Use chown -R while excluding one or two files

Is it rude to refer to janitors as 'floor people'?

How can the electric potential be zero at a point where the electric field isn't, if that field can give a test charge kinetic energy?



How to close a window and open a new window with a button click?


How to hide close button in WPF window?How to prevent a dialog from closing when a button is clickedGetting a Blank Progress bar window pyqt 5Cannot close Dialog on Python PyQt4PyQt5 Having trouble opening up multiple windows of the same applicationmultiple gui python qt and switch between themHow to stop second PyQt5 QMainWindow from closing?PyQt5 - Close QDialog window with cancel buttonDynamically add rows and columns in QTable in pyQT5PyQt - How to link and update the label from edit Window to my main window






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm creating a program with PyQt5 and have made to .py files for two windows. One is a logIn window and the other is the mainWindow. To open the program a separate program, main.py, will call a subroutine in the logInWindow.py to open that window up. There is a button there that when clicked is supposed to close the logIn window and open up the mainWindow.py by calling it. The main window opens up fine but the logIn window doesn't close. I need it so that the logIn window closes once the mainWindow is open. It doesn't matter if it does it before, during or after the mainWindow is open but as long as it does. I also need to be able to pass a value from the logInWindow to the mainWindow because of other parts of the program. I've made a simplified version of the code below.



I tried using things such as QtWidgets.QDialog().close() (which were recognised by the code) but didn't actually do anything. The only thing that closed it was sys.exit() but that shut the whole thing down before the line code to open the mainWindow.



#main.py
import logInWindow

var1 = input("Start: ")
if var1 == 'y':
logInWindow.openUp()


#logInWindow.py
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import mainWindow

class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 135)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(110, 50, 161, 32))
self.pushButton.setBaseSize(QtCore.QSize(161, 32))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.buttonClick)

self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)

def buttonClick(self):
#code to close logInWindow here
needsToBePassed = 'This is the main window.'
mainWindow.openUp2(needsToBePassed)

def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "logInWindow"))
self.pushButton.setText(_translate("Dialog", "open mainWindow"))

def openUp():
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())


#mainWindow.py
from PyQt5 import QtCore, QtGui, QtWidgets
import sys

def openUp2(passed):
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(110, 130, 151, 16))
self.label.setObjectName("label")

self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)

def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "mainWindow"))
self.label.setText(_translate("Dialog", passed))

Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.exec_()


If anyone could help me out that'd be great! Also if it's a few lines of code instead of changing how the code works, that'd be better but either would do.










share|improve this question




























    0















    I'm creating a program with PyQt5 and have made to .py files for two windows. One is a logIn window and the other is the mainWindow. To open the program a separate program, main.py, will call a subroutine in the logInWindow.py to open that window up. There is a button there that when clicked is supposed to close the logIn window and open up the mainWindow.py by calling it. The main window opens up fine but the logIn window doesn't close. I need it so that the logIn window closes once the mainWindow is open. It doesn't matter if it does it before, during or after the mainWindow is open but as long as it does. I also need to be able to pass a value from the logInWindow to the mainWindow because of other parts of the program. I've made a simplified version of the code below.



    I tried using things such as QtWidgets.QDialog().close() (which were recognised by the code) but didn't actually do anything. The only thing that closed it was sys.exit() but that shut the whole thing down before the line code to open the mainWindow.



    #main.py
    import logInWindow

    var1 = input("Start: ")
    if var1 == 'y':
    logInWindow.openUp()


    #logInWindow.py
    from PyQt5 import QtCore, QtGui, QtWidgets
    import sys
    import mainWindow

    class Ui_Dialog(object):
    def setupUi(self, Dialog):
    Dialog.setObjectName("Dialog")
    Dialog.resize(400, 135)
    self.pushButton = QtWidgets.QPushButton(Dialog)
    self.pushButton.setGeometry(QtCore.QRect(110, 50, 161, 32))
    self.pushButton.setBaseSize(QtCore.QSize(161, 32))
    self.pushButton.setObjectName("pushButton")
    self.pushButton.clicked.connect(self.buttonClick)

    self.retranslateUi(Dialog)
    QtCore.QMetaObject.connectSlotsByName(Dialog)

    def buttonClick(self):
    #code to close logInWindow here
    needsToBePassed = 'This is the main window.'
    mainWindow.openUp2(needsToBePassed)

    def retranslateUi(self, Dialog):
    _translate = QtCore.QCoreApplication.translate
    Dialog.setWindowTitle(_translate("Dialog", "logInWindow"))
    self.pushButton.setText(_translate("Dialog", "open mainWindow"))

    def openUp():
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())


    #mainWindow.py
    from PyQt5 import QtCore, QtGui, QtWidgets
    import sys

    def openUp2(passed):
    class Ui_Dialog(object):
    def setupUi(self, Dialog):
    Dialog.setObjectName("Dialog")
    Dialog.resize(400, 300)
    self.label = QtWidgets.QLabel(Dialog)
    self.label.setGeometry(QtCore.QRect(110, 130, 151, 16))
    self.label.setObjectName("label")

    self.retranslateUi(Dialog)
    QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
    _translate = QtCore.QCoreApplication.translate
    Dialog.setWindowTitle(_translate("Dialog", "mainWindow"))
    self.label.setText(_translate("Dialog", passed))

    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.exec_()


    If anyone could help me out that'd be great! Also if it's a few lines of code instead of changing how the code works, that'd be better but either would do.










    share|improve this question
























      0












      0








      0


      1






      I'm creating a program with PyQt5 and have made to .py files for two windows. One is a logIn window and the other is the mainWindow. To open the program a separate program, main.py, will call a subroutine in the logInWindow.py to open that window up. There is a button there that when clicked is supposed to close the logIn window and open up the mainWindow.py by calling it. The main window opens up fine but the logIn window doesn't close. I need it so that the logIn window closes once the mainWindow is open. It doesn't matter if it does it before, during or after the mainWindow is open but as long as it does. I also need to be able to pass a value from the logInWindow to the mainWindow because of other parts of the program. I've made a simplified version of the code below.



      I tried using things such as QtWidgets.QDialog().close() (which were recognised by the code) but didn't actually do anything. The only thing that closed it was sys.exit() but that shut the whole thing down before the line code to open the mainWindow.



      #main.py
      import logInWindow

      var1 = input("Start: ")
      if var1 == 'y':
      logInWindow.openUp()


      #logInWindow.py
      from PyQt5 import QtCore, QtGui, QtWidgets
      import sys
      import mainWindow

      class Ui_Dialog(object):
      def setupUi(self, Dialog):
      Dialog.setObjectName("Dialog")
      Dialog.resize(400, 135)
      self.pushButton = QtWidgets.QPushButton(Dialog)
      self.pushButton.setGeometry(QtCore.QRect(110, 50, 161, 32))
      self.pushButton.setBaseSize(QtCore.QSize(161, 32))
      self.pushButton.setObjectName("pushButton")
      self.pushButton.clicked.connect(self.buttonClick)

      self.retranslateUi(Dialog)
      QtCore.QMetaObject.connectSlotsByName(Dialog)

      def buttonClick(self):
      #code to close logInWindow here
      needsToBePassed = 'This is the main window.'
      mainWindow.openUp2(needsToBePassed)

      def retranslateUi(self, Dialog):
      _translate = QtCore.QCoreApplication.translate
      Dialog.setWindowTitle(_translate("Dialog", "logInWindow"))
      self.pushButton.setText(_translate("Dialog", "open mainWindow"))

      def openUp():
      import sys
      app = QtWidgets.QApplication(sys.argv)
      Dialog = QtWidgets.QDialog()
      ui = Ui_Dialog()
      ui.setupUi(Dialog)
      Dialog.show()
      sys.exit(app.exec_())


      #mainWindow.py
      from PyQt5 import QtCore, QtGui, QtWidgets
      import sys

      def openUp2(passed):
      class Ui_Dialog(object):
      def setupUi(self, Dialog):
      Dialog.setObjectName("Dialog")
      Dialog.resize(400, 300)
      self.label = QtWidgets.QLabel(Dialog)
      self.label.setGeometry(QtCore.QRect(110, 130, 151, 16))
      self.label.setObjectName("label")

      self.retranslateUi(Dialog)
      QtCore.QMetaObject.connectSlotsByName(Dialog)

      def retranslateUi(self, Dialog):
      _translate = QtCore.QCoreApplication.translate
      Dialog.setWindowTitle(_translate("Dialog", "mainWindow"))
      self.label.setText(_translate("Dialog", passed))

      Dialog = QtWidgets.QDialog()
      ui = Ui_Dialog()
      ui.setupUi(Dialog)
      Dialog.exec_()


      If anyone could help me out that'd be great! Also if it's a few lines of code instead of changing how the code works, that'd be better but either would do.










      share|improve this question














      I'm creating a program with PyQt5 and have made to .py files for two windows. One is a logIn window and the other is the mainWindow. To open the program a separate program, main.py, will call a subroutine in the logInWindow.py to open that window up. There is a button there that when clicked is supposed to close the logIn window and open up the mainWindow.py by calling it. The main window opens up fine but the logIn window doesn't close. I need it so that the logIn window closes once the mainWindow is open. It doesn't matter if it does it before, during or after the mainWindow is open but as long as it does. I also need to be able to pass a value from the logInWindow to the mainWindow because of other parts of the program. I've made a simplified version of the code below.



      I tried using things such as QtWidgets.QDialog().close() (which were recognised by the code) but didn't actually do anything. The only thing that closed it was sys.exit() but that shut the whole thing down before the line code to open the mainWindow.



      #main.py
      import logInWindow

      var1 = input("Start: ")
      if var1 == 'y':
      logInWindow.openUp()


      #logInWindow.py
      from PyQt5 import QtCore, QtGui, QtWidgets
      import sys
      import mainWindow

      class Ui_Dialog(object):
      def setupUi(self, Dialog):
      Dialog.setObjectName("Dialog")
      Dialog.resize(400, 135)
      self.pushButton = QtWidgets.QPushButton(Dialog)
      self.pushButton.setGeometry(QtCore.QRect(110, 50, 161, 32))
      self.pushButton.setBaseSize(QtCore.QSize(161, 32))
      self.pushButton.setObjectName("pushButton")
      self.pushButton.clicked.connect(self.buttonClick)

      self.retranslateUi(Dialog)
      QtCore.QMetaObject.connectSlotsByName(Dialog)

      def buttonClick(self):
      #code to close logInWindow here
      needsToBePassed = 'This is the main window.'
      mainWindow.openUp2(needsToBePassed)

      def retranslateUi(self, Dialog):
      _translate = QtCore.QCoreApplication.translate
      Dialog.setWindowTitle(_translate("Dialog", "logInWindow"))
      self.pushButton.setText(_translate("Dialog", "open mainWindow"))

      def openUp():
      import sys
      app = QtWidgets.QApplication(sys.argv)
      Dialog = QtWidgets.QDialog()
      ui = Ui_Dialog()
      ui.setupUi(Dialog)
      Dialog.show()
      sys.exit(app.exec_())


      #mainWindow.py
      from PyQt5 import QtCore, QtGui, QtWidgets
      import sys

      def openUp2(passed):
      class Ui_Dialog(object):
      def setupUi(self, Dialog):
      Dialog.setObjectName("Dialog")
      Dialog.resize(400, 300)
      self.label = QtWidgets.QLabel(Dialog)
      self.label.setGeometry(QtCore.QRect(110, 130, 151, 16))
      self.label.setObjectName("label")

      self.retranslateUi(Dialog)
      QtCore.QMetaObject.connectSlotsByName(Dialog)

      def retranslateUi(self, Dialog):
      _translate = QtCore.QCoreApplication.translate
      Dialog.setWindowTitle(_translate("Dialog", "mainWindow"))
      self.label.setText(_translate("Dialog", passed))

      Dialog = QtWidgets.QDialog()
      ui = Ui_Dialog()
      ui.setupUi(Dialog)
      Dialog.exec_()


      If anyone could help me out that'd be great! Also if it's a few lines of code instead of changing how the code works, that'd be better but either would do.







      python-3.x dialog pyqt5






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 9:14









      Matthew64Matthew64

      82 bronze badges




      82 bronze badges






















          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353425%2fhow-to-close-a-window-and-open-a-new-window-with-a-button-click%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353425%2fhow-to-close-a-window-and-open-a-new-window-with-a-button-click%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현