ディレクトリ
記事のこのシリーズは、レビューを先行詞:
PyQt4学習--- 1のメニューバー(addMenu)、ツールバー(addToolBar)、テキストエディットツールボックス
設計されたボタン、LINEEDITツールなどは、これらのクレンジング上に配置する必要があります、私たちは、グリッドのグリッドレイアウトボックスレイアウトに必要
1.BoxLayout垂直/水平レイアウト
http://www.mamicode.com/info-detail-1251502.html
__author__ = "lingjun"
# 公众号:小白CV
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtCore
from PyQt4 import QtGui
QtCore.QTextCodec.setCodecForTr(QtCore.QTextCodec.codecForName("utf8"))
class BoxLayout(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self)
self.setWindowTitle(u'Box布局')
# 设定按钮
ok=QtGui.QPushButton(u'确定')
cancel = QtGui.QPushButton(u'取消')
# 水平布局
hbox = QtGui.QHBoxLayout()
hbox.addStretch(1) # 添加伸缩间隔元素,创建必须的空白空间
hbox.addWidget(ok)
hbox.addWidget(cancel)
# 垂直布局
vbox = QtGui.QVBoxLayout()
vbox.addStretch(1)
vbox.addLayout(hbox) # 把水平布局放在垂直布局里面
self.setLayout(vbox) # 设置窗口的主布局
self.resize(400, 250)
if __name__ == "__main__":
app=QtGui.QApplication(sys.argv)
b=BoxLayout()
b.show()
app.exec_()
2.GridLayoutグリッドレイアウト、デザイン電卓
class GridLayout(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self)
self.setWindowTitle(u'Grid计算器网格布局')
names=[u'清除', u'后退',"", u'关闭',
'7', '8', '9', '/',
'4', '5', '6', '*',
'1', '2', '3', '-',
'0', '.', '=', '+']
grid = QtGui.QGridLayout()
j = 0
pos = [(0,0), (0,1), (0,2), (0,3),
(1,0), (1,1), (1,2), (1,3),
(2,0), (2,1), (2,2), (2,3),
(3,0), (3,1), (3,2), (3,3),
(4,0), (4,1), (4,2), (4,3)]
for i in names:
button = QtGui.QPushButton(i)
if j == 2:
grid.addWidget(QtGui.QLabel(''), 0, 2)
else:
grid.addWidget(button, pos[j][0], pos[j][1])
j += 1
self.setLayout(grid) # 设置窗口的主布局
if __name__ == "__main__":
app=QtGui.QApplication(sys.argv)
b=GridLayout()
b.show()
app.exec_()
あなたは私のような少し不注意であれば、それは次のような結果が表示されることがあり、それは「」である宇宙責め
最後に、注意深く観察した後、私はそうであることが判明しました
ホワイトCV:いいえ公共のCV(コンピュータビジョン)、AI(人工知能)技術関連分野、C ++の周りの記事の主な内容、Pythonはプログラミング技術、機械学習(ML)を集中するように設計、など(DL)、OpenCVの画像処理を、学習の深さ技術、技術的なポイント、勉強や仕事レコードの一般的な操作の深さを探る、問題は仕事のアシスタントにあなたを学びます。唯一の技術、専門的な知識の共有プラットフォームのCVフィールドに関わります。