티스토리 뷰

Programming/Python

PySide - Close Button

do9dark 2015. 4. 5. 16:04

PySide - Close Button


quitter.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>348</width>
    <height>255</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QGridLayout" name="gridLayout">
    <item row="0" column="0">
     <spacer name="horizontalSpacer">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>282</width>
        <height>20</height>
       </size>
      </property>
     </spacer>
    </item>
    <item row="0" column="1">
     <widget class="QPushButton" name="pushButton">
      <property name="text">
       <string>Quit</string>
      </property>
     </widget>
    </item>
    <item row="1" column="1">
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>175</height>
       </size>
      </property>
     </spacer>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>348</width>
     <height>21</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections>
  <connection>
   <sender>pushButton</sender>
   <signal>clicked()</signal>
   <receiver>MainWindow</receiver>
   <slot>close()</slot>
   <hints>
    <hint type="sourcelabel">
     <x>318</x>
     <y>36</y>
    </hint>
    <hint type="destinationlabel">
     <x>173</x>
     <y>127</y>
    </hint>
   </hints>
  </connection>
 </connections>
</ui>

cs


$ pyside-uic quitter.ui -o ui_quitter.py 


quitter.py

#!/usr/bin/python
# -*- coding: utf-8 -*-
 
# quitter.py- provide a button to quit this "program"
 
import sys
from PySide.QtGui import QMainWindow, QPushButton, QApplication
from ui_quitter import Ui_MainWindow
 
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
 
if __name__ == '__main__':
    app = QApplication(sys.argv)
    frame = MainWindow()
    frame.show()
    sys.exit( app.exec_() )

cs




'Programming > Python' 카테고리의 다른 글

(PEP 8) Style Guide for Python Code  (0) 2016.08.15
Python Modules  (0) 2016.01.16
Scapy 사용하기  (0) 2015.04.11
Scapy 설치하기  (0) 2015.04.11
PySide - Combine (Show, About, Close)  (0) 2015.04.07
PySide - Show Licence (File Open)  (0) 2015.04.07
PySide - About Box  (0) 2015.04.07
PySide - QMessageBox  (0) 2015.04.05
OS X에서 PySide 설치하기  (0) 2015.04.05
쉘 스크립트(shell script)의 시작 #!(shebang)  (0) 2014.11.14
댓글
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
링크
공지사항
Total
Today
Yesterday