Hello David,

To create a popup window with a complex layout, you should create a custom Python class which inherits from QWidget and has the QLayout and widgets that you want. You cannot use a plain unmodified QInputDialog because it is too simple, you need to create a custom class to represent the popup window. In the code below, class MainWindow is the main window and class PopupWindow is the popup, and both inherit from QDialog.

This is a full working example:

# Example of how to make a popup window (second window) with complex layout.
#
# By Zak Fallows
# 2012-12-21

import sys
import os
from PySide.QtCore import *
from PySide.QtGui import *

class MainWindow(QDialog):

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setWindowTitle("Main Window")

        self.top_label = QLabel("Middle of main window")

        self.bottom_button = QPushButton("Add Name")

        layout = QVBoxLayout()
        layout.addWidget(self.top_label)
        layout.addWidget(self.bottom_button)
        self.setLayout(layout)

        self.connect(self.bottom_button, SIGNAL("clicked()"),
                     self.button_clicked)

    def button_clicked(self):
        self.popup_window = PopupWindow(self)
        self.popup_window.show()

class PopupWindow(QDialog):

    def __init__(self, parent=None):
        super(PopupWindow, self).__init__(parent)

        self.setWindowTitle("Popup Window")
        layout = QGridLayout()

        line1 = QLabel("What is your first name?")
        layout.addWidget(line1, 0, 0)
        self.line1_edit = QLineEdit()
        layout.addWidget(self.line1_edit, 0, 1)

        line2 = QLabel("What is your occupation?")
        layout.addWidget(line2, 1, 0)
        self.line2_edit = QLineEdit()
        layout.addWidget(self.line2_edit, 1, 1)

        line3 = QLabel("How many years have you had this job?")
        layout.addWidget(line3, 2, 0)
        self.line3_edit = QLineEdit()
        layout.addWidget(self.line3_edit, 2, 1)

        line4 = QLabel("Do you want email?")
        layout.addWidget(line4, 3, 0)
        self.line4_checkbox = QCheckBox()
        layout.addWidget(self.line4_checkbox, 3, 1)

        self.setLayout(layout)

app = QApplication(sys.argv)

main_window = MainWindow()
main_window.resize(400, 400)
main_window.show()
# The .raise_() brings the window to the foreground, in front of other windows
main_window.raise_()

app.exec_()
sys.exit()

Good luck,

Zak F.

On 12/21/12 3:00 PM, [email protected] wrote:
Sorry in advance, this is all very new to me.

I'm working with Windows 7, Python 2.6, PySide 1.1.0 and QT Creator 2.4.1.

I acquired a project where the GUI was written in QT Creator, it is a glorified NotePad/Editor.
It has a text menu and an icon menu.

So here is the question:
How do I click on an icon and get a window to pop up with multiple questions, asked of the user?

I have been able to click an icon and use QInputDialog to get a popup and give a single question or multiple popup's one after the other with a single question, but I can't figure out how to get a single window to popup with multiple questions.

i.e.  Click Add Name
    What is you first name: *input text*
    What is you occupation?: *input text*
    How many years have you been at this job?: *input text*
    Check box if you want email: *check box*


David


_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside

_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to