2012-04-03 13 views
0

ボタンをクリックすると、QLabel、QLineEdit、QSpinBoxなどのいくつかのフィールドを持つ別のウィンドウが作成されます。ボタンクリック時のポップアップウィンドウ

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 

import sys      # Needed for PySide 
from PySide.QtCore import * 
from PySide.QtGui import * 

class Form(QDialog): 
    def __init__(self, parent=None): 
     super(Form, self).__init__(parent) 

     # Create widgets 
     self.label1 = QLabel("Label1") 
     self.button_open = QPushButton("Open popup") 

     self.button = QPushButton("Go!") 
     self.qbtn = QPushButton('Quit') 

     # Create layout and add widgets 
     layout = QVBoxLayout() 
     layout.addWidget(self.label1) 
     layout.addWidget(self.button_open) 

     # Buttons layout 
     hbox_buttons = QHBoxLayout() 
     hbox_buttons.addStretch(1) 
     hbox_buttons.addWidget(self.button) 
     hbox_buttons.addWidget(self.qbtn) 

     # Main layout 
     layout.addStretch(1) 
     layout.addWidget(self.button_open) 
     layout.addLayout(hbox_buttons) 

     self.setLayout(layout) 

     # Add buttons slots 
     self.button_open.clicked.connect(self.popup) 
     self.button.clicked.connect(self.function_runner) 
     self.qbtn.clicked.connect(QCoreApplication.instance().quit) 


    def popup (self, parent=__init__): 
     new_win = # I wonder what should be here 

if __name__ == '__main__': 
    # Create the Qt Application 
    app = QApplication(sys.argv) 

    # Create and show the form 
    form = Form() 
    form.show() 

    # Run the main Qt loop 
    sys.exit(app.exec_()) 
+1

でそれを呼びました。 pydideのサンプルコードのqdialogの例を見てください:http://qt.gitorious.org/pyside/pyside-examplesサンプル/ダイアログのコードを調べて、探しているものがstandarddialogs.pyファイルにあると思います。 – James

答えて

0

これが最善の方法である場合、私は知りませんが、私は理解でき1:しかし、私はそのポップアップウィンドウを作成する方法がわからない...ここで

は私のコードです私はそれが同じような問題に立ち往生した人を助けることを願っています。

だから、私は(単に)、第2のウィンドウのための別々のコードを作成し、私はあなたが4月に尋ねたし、上に移動しているかもしれないが、私は、まさにこの答えを探していた知っている

from subprocess import call 
call("./my_2nd_window_code.py")