<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to create a menu with mitil-pages by Pyside2]]></title><description><![CDATA[<p dir="auto">I would like to create a meun with several pages, just like the menu of many PC game.</p>
<p dir="auto">For example, here is my trial. In first page, there are two button, "Start game" and "Exit". If Start game button is clicked, it would go to next page, with a button "back".  So when it be clicked, I deleted all two buttons in first page, and create a new button "back" that belong to 2nd page.</p>
<p dir="auto">However, it doesn't work as my expect. two buttons of first page were deleted, while "back" button not appeared.</p>
<p dir="auto">here is my code:</p>
<pre><code>import sys
from PySide2 import QtCore, QtGui, QtWidgets

class Main_meun(object):
    def __init__(self):
        
        self.start_button = QtWidgets.QPushButton(MainWindow)
        self.start_button.setGeometry(QtCore.QRect(90, 150, 221, 80))
        self.start_button.setIconSize(QtCore.QSize(250, 80))
        self.start_button.setText("Start a game")
        self.start_button.clicked.connect(self.start)
        
        self.ex_button = QtWidgets.QPushButton(MainWindow)
        self.ex_button.setGeometry(QtCore.QRect(90, 250, 221, 80))
        self.ex_button.setIconSize(QtCore.QSize(250, 80))
        self.ex_button.setText("Exit")
        self.ex_button.clicked.connect(app.quit)

    def start(self):
        print("Game Start")
        global ui
        ui = Game()      
        for widget in [self.start_button, self.ex_button]:
            widget.deleteLater()

class Game(object):
    def __init__(self):

        self.back_button = QtWidgets.QPushButton(MainWindow)
        self.back_button.setGeometry(QtCore.QRect(90, 150, 221, 80))
        self.back_button.setIconSize(QtCore.QSize(250, 80))
        self.back_button.clicked.connect(self.back)

    def back(self):
        print("back")

app = QtWidgets.QApplication(sys.argv)

MainWindow = QtWidgets.QMainWindow()
MainWindow.resize(640, 480)

ui = Main_meun()
 
MainWindow.show()
sys.exit(app.exec_())
</code></pre>
<p dir="auto">I hope experts can help me in this problem, thank you:)</p>
]]></description><link>https://forum.qt.io/topic/93781/how-to-create-a-menu-with-mitil-pages-by-pyside2</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 14:35:57 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/93781.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 17 Aug 2018 09:11:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to create a menu with mitil-pages by Pyside2 on Fri, 17 Aug 2018 09:28:01 GMT]]></title><description><![CDATA[<p dir="auto">My god... I thought I have a answer...</p>
<p dir="auto">just use this for each widgets I want to create...</p>
<pre><code>new_widget.show()
</code></pre>
]]></description><link>https://forum.qt.io/post/476707</link><guid isPermaLink="true">https://forum.qt.io/post/476707</guid><dc:creator><![CDATA[York Wu]]></dc:creator><pubDate>Fri, 17 Aug 2018 09:28:01 GMT</pubDate></item></channel></rss>