티스토리 뷰

PySide - Show Licence (File Open)


licence.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="showButton">
      <property name="text">
       <string>&amp;Show Lincence</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>507</width>
        <height>26</height>
       </size>
      </property>
     </spacer>
    </item>
    <item row="1" column="0" colspan="2">
     <widget class="QTextEdit" name="textEdit"/>
    </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 licence.ui > ui_licence.py


licence.py

#!/usr/bin/python
# -*- coding: utf-8 -*-
 
# licence.py - this small program reads and displays licence details.
 
import sys
from PySide.QtGui import QApplication, QMainWindow, QTextEdit, QPushButton
from ui_licence import Ui_MainWindow
 
__version__ = '1.0.0'
 
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        '''Mandatory initialisation of a class.'''
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.showButton.clicked.connect(self.fileRead)
        
    def fileRead(self):
        '''Read and display licence.'''
        with open('licence.txt') as nonamefile:
            self.textEdit.setText(nonamefile.read())
        #self.textEdit.setText(open('licence.txt').read())
        
if __name__ == '__main__':
    app = QApplication(sys.argv)
    frame = MainWindow()
    frame.show()
    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 - 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
댓글
«   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