Python Forum
Show second window using classes
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Show second window using classes
#3
Thank you once again Yoriz, this now works, I have stripped it down to the basics of what the question was addressing and I have also formatted the code in what appears to me to be a more standard pythonic format, please correct me if I have that wrong. This is what I have that now does exactly what I was after, I have set geometry the same as in my project and as the sub_windows will all be the same size and location, geometry is defined in init definition of the Form class.

#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
Qt4 example to embed
dialog box within window
"""

from PyQt4 import QtGui, QtCore

class Form(QtGui.QWidget):
    """Menu window"""
    def __init__(self, parent=None):
        super(Form, self).__init__()
        self.setGeometry(1000, 200, 400, 500)


class Window(QtGui.QMainWindow):
    """Main Window"""
    def __init__(self, parent=None):
        super(Window, self).__init__()
        self.setGeometry(50, 50, 1600, 900)
        self.new_window = Form(self)
        self.show() 
        self.dialog = Form(self)
        self.dialog.show()


         
def main():
    app = QtGui.QApplication(sys.argv)
    main_window = Window()
    sys.exit(app.exec_())    
 
if __name__ == "__main__":
    main()
Kind regards
iFunk
Reply


Messages In This Thread
Show second window using classes - by iFunKtion - Feb-09-2017, 10:31 AM
RE: Show second window using classes - by Yoriz - Feb-09-2017, 10:09 PM
SOLVED RE: Show second window using classes - by iFunKtion - Feb-10-2017, 12:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 608 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  [Tkinter] How to show text in window? wxnerd 4 3,800 Jun-20-2020, 04:16 PM
Last Post: wxnerd
  tkinter window and turtle window error 1885 3 6,792 Nov-02-2019, 12:18 PM
Last Post: 1885
  [PyQt] Can't show PyQt5 mediaPlayer in window DecaK 1 5,427 Sep-15-2018, 09:54 AM
Last Post: Axel_Erfurt
  update a variable in parent window after closing its toplevel window gray 5 9,172 Mar-20-2017, 10:35 PM
Last Post: Larz60+
  using qt with classes basic window iFunKtion 0 2,923 Feb-06-2017, 09:50 AM
Last Post: iFunKtion
  Show GPG keys in pyqt5 window Fred Barclay 1 4,654 Oct-24-2016, 07:09 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020