2012-04-03 3 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

함께했다. pyside 예제 코드에서 qdialog 예제를 살펴보십시오. http://qt.gitorious.org/pyside/pyside-examples 예제/대화 상자의 코드를 확인하십시오. 찾고있는 것이 standarddialogs.py 파일에 있다고 생각합니다. . – James

답변

0

이 최선의 방법 인 경우 나도 몰라,하지만 난 이해할 수있는 하나 그러나, 나는 그 팝업 창을 생성하는 방법을 모른다 ... 여기

내 코드입니다 밤새도록 나가서 ... 나는 비슷한 문제가 붙어있는 누군가를 도울 수 있기를 바란다.

그래서, (간단하게) 그 두 번째 창에 대한 별도의 코드를 생성하고 난 당신이 4 월에 물었다에 이동했을 수 있습니다하지만 난 정확히 답을 찾고 있었다 알고

from subprocess import call 
call("./my_2nd_window_code.py") 
관련 문제