PyQt 설치
- PyQt-5.5.1 downlaod :
- 현재(2016-02-28) python 2.7 버전은 없다.
- PyQt - Browse /PyQt5/PyQt-5.5.1 at SourceForge.net
- PyQt-4.11.4 download: PyQt - Browse /PyQt4/PyQt-4.11.4 at SourceForge.net
python 아래의 경로에 설치된다.
- <python_path>\Lib\site-packages\PyQt4
pip 로 설치
아래 경로에서 whl 을 download 한다.그리고 아래처럼 실행하면 된다.
pip install PyQt4-4.11.4-cp35-none-win_amd64.whl
Tutorial
예제
- http://zetcode.com/gui/pyqt4/widgets/
- QtGui.QCheckBox
- ToggleButton
- QtGui.QSlider
- QtGui.QProgressBar
- QtGui.QCalendarWidget
- http://zetcode.com/gui/pyqt4/widgets2/
- QtGui.QPixmap
- QtGui.QLineEdit
- QtGui.QSplitter
- QtGui.QComboBox
- http://stackoverflow.com/a/7771743
- QtGui.QTextEdit
PyQt vs PySlide
- Why is PyQt even a thing anymore when PySide is extremely similar, mature, and completely free for any use? : Python : PySlide 는 MS 가 nokia 를 인수하면서 개발이 더디다고 하는 듯 하다. 그래서 PyQt 를 추천하는 분위기다.
PyQt Designer
qt 에서 기본적으로 gui 로 windows 등을 그릴 수 있는 tool 을 제공한다. windows 에서는 아래 경로에서 designer 를 찾을 수 있다.- <python_lib>\site-packages\PyQt4\designer.exe
- Qt Designer Manual | Qt 4.8
- .ui 사용법 : user interface - Linking a qtDesigner .ui file to python/pyqt? - Stack Overflow
QListView + QStandardItemModel
나의 예제
아래 code 는 실행되는 것은 아니다. 그냥 qt gui 를 어떻게 그리는지 참고하자.class BloggerUpdateWidget(QtGui.QWidget):
def __init__(self, service):
super(BloggerUpdateWidget, self).__init__()
self.service = service
self.blogInfo = None
self.initUI()
def initUI(self):
grid = QtGui.QGridLayout()
self.setLayout(grid)
hbox = QtGui.QHBoxLayout()
self.editUrl = QtGui.QTextEdit()
self.edit = QtGui.QTextEdit('Edit')
# PostPath - VBoxLayout
vboxPostPath = QtGui.QVBoxLayout()
vboxPostPath.addWidget(QtGui.QLabel('Post Path'))
vboxPostPath.addWidget(self.editUrl)
# New Content - VBoxLayout
vboxNewContent = QtGui.QVBoxLayout()
vboxNewContent.addWidget(QtGui.QLabel('Content'))
vboxNewContent.addWidget(self.edit)
# HBoxLayout
self.button = QtGui.QPushButton("button")
hbox.addWidget(self.button)
self.button.clicked.connect(self._OnClickOfRetrieve)
# GridLayout
grid.addLayout(vboxPostPath, 0, 0)
grid.addLayout(vboxNewContent, 0, 1)
grid.addLayout(hbox, 0, 2)
self.move(300, 150)
self.setWindowTitle('Blogger Updater')
self.show()
def showDialog(self):
text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog',
'Enter your name:')
if ok:
self.le.setText(str(text))
def _OnClickOfRetrieve(self):
try:
postPath = str(self.editUrl.toPlainText()) # ex : "/2016/01/4.html"
newContent = str(self.edit.toPlainText())
pupdater = blogger.PostUpdater(self.service, self._getBlogId())
pupdater.update(path=postPath, newbody={
"content": newContent
}, append=True)
except client.AccessTokenRefreshError:
print('The credentials have been revoked or expired, please re-run'
'the application to re-authorize')
def _getBlogId(self):
blogUrl = 'http://myblog.blogspot.com/'
if self.blogInfo is None:
self.blogInfo = blogger.BlogInfo(self.service, blogUrl)
return self.blogInfo.blogId
def main():
app = QtGui.QApplication(sys.argv)
service, flags = blogger.getService(sys.argv)
ex = BloggerUpdateWidget(service)
sys.exit(app.exec_())
if __name__ == '__main__':
main()
댓글 없음:
댓글 쓰기