티스토리 뷰

Programming/Python

PySide - About Box

do9dark 2015.04.07 02:37

PySide - About Box


about.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>654</width>
    <height>467</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">
     <widget class="QPushButton" name="aboutButton">
      <property name="text">
       <string>&amp;About</string>
      </property>
     </widget>
    </item>
    <item row="0" column="1">
     <spacer name="horizontalSpacer">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>548</width>
        <height>26</height>
       </size>
      </property>
     </spacer>
    </item>
    <item row="1" column="0">
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>355</height>
       </size>
      </property>
     </spacer>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>654</width>
     <height>29</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

cs

$ pyside-uic about.ui > ui_about.py


about.py

#!/usr/bin/python
# -*- coding: utf-8 -*-
 
# about.py - display about box with info on platform etc.
 
import sys
import platform
import PySide
from PySide.QtGui import (QApplication, QMainWindow, QMessageBox)
from ui_about import Ui_MainWindow
 
__version__ = '1.0.0'
 
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.resize(600250)
        self.aboutButton.clicked.connect(self.about)
               
    def about(self):
        '''Popup a box with about message.'''
        QMessageBox.about(self, "About PySide, Platform and version.",
                """<b> about.py version %s </b> 
                <p>Copyright &copy; 2015 by do9dark. 
                <p>This application is useful for displaying  
                Qt version and other details.
                <p>Python %s -  PySide version %s - Qt version %s on %s""" %
                (__version__, platform.python_version(), PySide.__version__,
                 PySide.QtCore.__version__, platform.system()))
                                                                              
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 - Close Button  (0) 2015.04.05
PySide - QMessageBox  (0) 2015.04.05
OS X에서 PySide 설치하기  (0) 2015.04.05
쉘 스크립트(shell script)의 시작 #!(shebang)  (0) 2014.11.14
댓글
댓글쓰기 폼
«   2019/06   »
            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
76,647
Today
22
Yesterday
27