PyQt4_SplitterWindow
'''
FuncName: PyQt4_SplitterWindow.py.py
Desc: Splitter Windows with PyQt4
Date: 2017-02-10 10:30
Author: johnny
Home: http://blog.csdn.net/z_johnny
'''
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))
class JzmainWindow(QMainWindow):
"""
主窗口布局,包括“菜单栏、工具栏、状态栏、内容等”
QMainWindow 类提供一个有菜单条、锚接窗口(例如工具条)和一个状态条的主应用程序窗口。
主窗口通常用在提供一个大的中央窗口部件(例如文本编辑或者绘制画布)以及周 围菜单、工具条和一个状态条。
QMainWindow常常被继承,因为这使得封装中央部件、菜单和工具条以及窗口状态变得更容易。
"""
def __init__(self, parent=None):
super(JzmainWindow, self).__init__(parent)
mainSplitter = QSplitter(Qt.Horizontal)
mainSplitter.setOpaqueResize(True)
listWidget = QListWidget(mainSplitter)
listWidget.insertItem(0, self.tr("设置"))
listWidget.insertItem(1, self.tr("结果"))
listWidget.insertItem(2, self.tr("计算器"))
frame = QFrame(mainSplitter)
stack = QStackedWidget()
stack.setFrameStyle(QFrame.Panel | QFrame.Raised)
stack.addWidget(JzleftWidget())
stack.addWidget(JzrightWidget())
stack.addWidget(JzCalc())
amendPushButton = QPushButton(self.tr("修改"))
closePushButton = QPushButton(self.tr("关闭"))
buttonLayout = QHBoxLayout()
buttonLayout.addStretch(1)
buttonLayout.addWidget(amendPushButton)
buttonLayout.addWidget(closePushButton)
mainLayout = QVBoxLayout(frame)
mainLayout.setMargin(10)
mainLayout.setSpacing(6)
mainLayout.addWidget(stack)
mainLayout.addLayout(buttonLayout)
self.connect(listWidget, SIGNAL("currentRowChanged(int)"), stack, SLOT("setCurrentIndex(int)"))
self.connect(closePushButton, SIGNAL("clicked()"), self, SLOT("close()"))
layout = QHBoxLayout(self)
layout.addWidget(mainSplitter)
widget = QWidget()
widget.setLayout(layout)
self.setCentralWidget(widget)
self.setWindowTitle('JzmainWindow')
self.setWindowIcon(QIcon("/conf/head.ico"))
self.MenuBar()
self.ToolBar()
self.StatusBar()
self.Center()
def MenuBar(self):
open_config = QAction(u'打开配置文件', self)
open_config.setShortcut('Ctrl+E')
open_config.setStatusTip('Open config.ini')
start_test = QAction(u'开始测试', self)
start_test.setShortcut('Ctrl+T')
start_test.setStatusTip('Start application')
exit = QAction(u'退出', self)
exit.setShortcut('Ctrl+Q')
exit.setStatusTip('Start application')
shortcutkey = self.menuBar().addMenu(u'&功能')
shortcutkey.addAction(open_config)
shortcutkey.addAction(start_test)
shortcutkey = self.menuBar().addMenu(u'&工具')
shortcutkey.addAction(exit)
def ToolBar(self):
saveEvent = QAction(u"保存", self)
copyEvent = QAction(u"复制", self)
pasteEvent = QAction(u"粘贴", self)
toolbar = self.addToolBar(u"工具栏")
toolbar.addAction(saveEvent)
toolbar.addAction(copyEvent)
toolbar.addAction(pasteEvent)
def StatusBar(self):
self.statusBar().showMessage(self.tr("作者:johnny 博客地址: http://blog.csdn.net/z_johnny"))
def Center(self):
screen = QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
def closeEvent(self, event):
reply = QMessageBox.question(self, u'来自 Johnny 的消息',
"Are you sure to quit?", QMessageBox.Yes, QMessageBox.No)
if reply == QMessageBox.Yes:
event.accept()
else:
event.ignore()
def CalendarWidget(self):
self.calendarWidget = QCalendarWidget(self)
self.calendarWidget.setGridVisible(True)
self.connect(self.calendarWidget, SIGNAL('selectionChanged()'),
self.showDate)
self.date_label = QLabel()
date = self.calendarWidget.selectedDate()
self.date_label.setText(str(date.toPyDate()))
return self.calendarWidget
def showDate(self):
date = self.calendarWidget.selectedDate()
self.date_label.setText(self.tr(' 已选择日期: ')+str(date.toPyDate()))
return self.date_label
class JzCalc(QDialog):
"""
计算器,使用方法:输入后按回车,如 ' 1+1 '
QDialog类是对话框窗口的基类。对话框窗口是主要 用于短期任务以及和用户进行简要通讯的顶级窗口。
QDialog可以是模式的也可以是非模式的。QDialog支持扩展性并且可以提供返回值。它们可以有 默认按钮。
QDialog也可以有一个QSizeGrip在它的右下角,使用setSizeGripEnabled()。
QDialog 是最普通的顶级窗口。不被嵌入到一个父窗口部件的窗口部件被叫做顶级窗口部件。
"""
def __init__(self, parent=None):
super(JzCalc, self).__init__(parent)
self.browser = QTextBrowser()
self.lineEdit = QLineEdit(self.tr("使用方法:输入后按回车,如 ' 1+1 '"))
self.lineEdit.selectAll()
self.lineEdit.setFocus()
layout = QVBoxLayout()
layout.addWidget(self.browser)
layout.addWidget(self.lineEdit)
self.setLayout(layout)
self.connect(self.lineEdit, SIGNAL("returnPressed()"),
self.result)
def result(self):
try:
text = unicode(self.lineEdit.text())
self.browser.append("%s = %s" % (text, eval(text)))
except:
self.browser.append(
"%s is invalid!" % text)
class JzleftWidget(QWidget):
"""
一套整体布局,点击'内存区选择'出现新窗口(复选框)
QWidget类是所有用户界面对象的基类。
窗口部件是用户界面的一个原子:它从窗口系统接收鼠标、键盘和其它事件,并且在屏幕上绘制自己的表现。
每一个窗口部件都是矩形,并且它们按Z轴顺序排列的。
一个窗口部件可以被它的父窗口部件或者它前面的窗口部件盖住一部分。
"""
def __init__(self, parent=None):
super(JzleftWidget, self).__init__(parent)
leftBoxLayout = QVBoxLayout()
leftBoxLayout.addWidget(self.ServiceURL(),)
leftBoxLayout.addWidget(self.InventoryModule())
leftBoxLayout.addWidget(self.Protocol())
leftBoxLayout.addWidget(self.Business())
self.setLayout(leftBoxLayout)
def ServiceURL(self):
url_Label = QLabel(self.tr("地址:"))
url_Label_lineEdit = QLineEdit("http://192.168.*.*:8181/ttk")
url_groupbox = QGroupBox(self.tr("TTK服务地址"))
url_varLayout = QVBoxLayout(url_groupbox)
url_varLayout.addWidget(url_Label)
url_varLayout.addWidget(url_Label_lineEdit)
return url_groupbox
def InventoryModule(self):
module_singleRadioButton = QRadioButton(self.tr("单次"))
module_setnumRadioButton = QRadioButton(self.tr("按次"))
module_loopRadioButton = QRadioButton(self.tr("无限循环"))
module_mustsucceedRadioButton = QRadioButton(self.tr("至少成功一次"))
module_settimeRadioButton = QRadioButton(self.tr("定时(单位ms)"))
module_setnumRadioButton_lineEdit = QLineEdit()
module_settimeRadioButton_LineEdit = QLineEdit("5000")
module_groupbox = QGroupBox(self.tr("清点模式"))
module_varLayout = QVBoxLayout(module_groupbox)
module_varLayout.addStretch(1)
module_varLayout.addWidget(module_singleRadioButton)
module_varLayout.addWidget(module_setnumRadioButton)
module_varLayout.addWidget(module_setnumRadioButton_lineEdit)
module_varLayout.addWidget(module_loopRadioButton)
module_varLayout.addWidget(module_mustsucceedRadioButton)
module_varLayout.addWidget(module_settimeRadioButton)
module_varLayout.addWidget(module_settimeRadioButton_LineEdit)
return module_groupbox
def Protocol(self):
protocol_sLabel = QLabel(self.tr("协议标准"))
protocol_iLabel = QLabel(self.tr("清点周期(单位ms)"))
protocol_ComboBox = QComboBox()
protocol_ComboBox.insertItem(0, self.tr("GB"))
protocol_ComboBox.insertItem(1, self.tr("6C"))
protocol_iLabel_lineEdit = QLineEdit("1")
protocol_groupbox = QGroupBox(self.tr("协议和清点周期"))
protocol_varLayout = QVBoxLayout(protocol_groupbox)
protocol_varLayout.addWidget(protocol_sLabel)
protocol_varLayout.addWidget(protocol_ComboBox)
protocol_varLayout.addWidget(protocol_iLabel)
protocol_varLayout.addWidget(protocol_iLabel_lineEdit)
return protocol_groupbox
def Business(self):
business_Label = QLabel(self.tr("业务测试"))
business_combobox = QComboBox(self)
business_combobox.insertItem(0, self.tr("清点"))
business_combobox.insertItem(1, self.tr("读取"))
business_combobox.insertItem(2, self.tr("写入"))
business_combobox.insertItem(3, self.tr("写回读"))
business_PushButton = QPushButton(self.tr("内存区选择"))
business_groupbox = QGroupBox(self.tr("业务选择"))
business_varLayout = QHBoxLayout(business_groupbox)
business_varLayout.addWidget(business_Label)
business_varLayout.addWidget(business_combobox)
business_varLayout.addWidget(business_PushButton)
self.connect(business_PushButton, SIGNAL('clicked()'), self.memory_show)
return business_groupbox
def memory_show(self):
business_checkboxs = []
business_memoryCheckBox1 = QCheckBox("user01-1-word")
business_checkboxs.append(business_memoryCheckBox1)
business_memoryCheckBox2 = QCheckBox("user01-2-word")
business_checkboxs.append(business_memoryCheckBox2)
business_memoryCheckBox3 = QCheckBox("user01-4-word")
business_checkboxs.append(business_memoryCheckBox3)
business_memoryCheckBox4 = QCheckBox("user01-6-word")
business_checkboxs.append(business_memoryCheckBox4)
business_memoryCheckBox5 = QCheckBox("user01-8-word")
business_checkboxs.append(business_memoryCheckBox5)
business_memoryCheckBox6 = QCheckBox("user01-16-word")
business_checkboxs.append(business_memoryCheckBox6)
business_memoryCheckBox7 = QCheckBox("user01-28-word")
business_checkboxs.append(business_memoryCheckBox7)
business_memoryCheckBox8 = QCheckBox("user01-32-word")
business_checkboxs.append(business_memoryCheckBox8)
business_memoryData_lable = QLabel(self.tr("写数据"))
business_memoryData_lable_lineEdit = QLineEdit("5A5A")
self.business_memoryWidge = QWidget()
self.business_memoryWidge.setWindowTitle(self.tr("内存区选择"))
business_memoryLayout = QGridLayout(self.business_memoryWidge)
business_memoryLayout.addWidget(business_memoryCheckBox1, 0, 0)
business_memoryLayout.addWidget(business_memoryCheckBox2, 0, 1)
business_memoryLayout.addWidget(business_memoryCheckBox3, 0, 2)
business_memoryLayout.addWidget(business_memoryCheckBox4, 0, 3)
business_memoryLayout.addWidget(business_memoryCheckBox5, 1, 0)
business_memoryLayout.addWidget(business_memoryCheckBox6, 1, 1)
business_memoryLayout.addWidget(business_memoryCheckBox7, 1, 2)
business_memoryLayout.addWidget(business_memoryCheckBox8, 1, 3)
business_memoryLayout.addWidget(business_memoryData_lable, 2, 0)
business_memoryLayout.addWidget(business_memoryData_lable_lineEdit, 2, 1)
self.business_memoryWidge.hide()
if self.business_memoryWidge.isHidden():
self.business_memoryWidge.show()
else:
self.business_memoryWidge.hide()
class JzrightWidget(QWidget):
def __init__(self, parent=None):
super(JzrightWidget, self).__init__(parent)
rightBoxLayout = QVBoxLayout()
rightBoxLayout.addWidget(self.Fileset() )
rightBoxLayout.addLayout(self.TagDistance())
rightBoxLayout.addLayout(self.DataShow())
rightBoxLayout.addLayout(self.Button())
rightBoxLayout.addWidget(self.Table())
rightBoxLayout.addWidget(self.FrameLable())
self.setLayout(rightBoxLayout)
def Fileset(self):
file_Label = QLabel(self.tr("文件保存路径"))
file_PushButton = QPushButton(self.tr("选择路径"))
file_lineEdit = QLineEdit()
file_groupbox = QGroupBox(self.tr("文件设置"))
file_varLayout = QVBoxLayout(file_groupbox)
file_varLayout.addWidget(file_Label)
file_varLayout.addWidget(file_lineEdit)
file_varLayout.addWidget(file_PushButton)
return file_groupbox
def TagDistance(self):
tagDistance_lable = QLabel(self.tr("标签距离(单位m)"))
tagDistance_lineEdit = QLineEdit()
tagDistance_varLayout = QVBoxLayout()
tagDistance_varLayout.addWidget(tagDistance_lable)
tagDistance_varLayout.addWidget(tagDistance_lineEdit)
return tagDistance_varLayout
def DataShow(self):
data_Label = QLabel(self.tr("测试数据"))
data_TextBrowser = QTextBrowser()
data_varLayout = QVBoxLayout()
data_varLayout.addWidget(data_Label)
data_varLayout.addWidget(data_TextBrowser)
return data_varLayout
def Button(self):
button_start = QPushButton(self.tr("开始测试"))
button_goon = QPushButton(self.tr("继续测试"))
bottonLayout = QHBoxLayout()
bottonLayout.addStretch(1)
bottonLayout.addWidget(button_start)
bottonLayout.addWidget(button_goon)
return bottonLayout
def Table(self):
treewidget = QTreeWidget()
treewidget.setHeaderLabels(['Johnny', 'very', u'帅'])
return treewidget
def FrameLable(self):
otherLabel = QLabel(self.tr("备注:"))
otherLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
return otherLabel
if __name__ == '__main__':
app = QApplication(sys.argv)
windows = JzmainWindow()
windows.show()
app.exec_()
PyQt4_LayoutWindow
'''
FuncName: PyQt4_LayoutWindow.py
Desc: Layout Windows with PyQt4
Date: 2017-02-10 10:30
Author: johnny
Home: http://blog.csdn.net/z_johnny
'''
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))
class JzmainWindow(QMainWindow):
def __init__(self, parent=None):
super(JzmainWindow, self).__init__(parent)
self.setWindowTitle('JzmainWindow')
self.setWindowIcon(QIcon("/conf/head.ico"))
self.MenuBar()
self.ToolBar()
self.StatusBar()
self.Center()
self.CentralWidget()
def CentralWidget(self):
mainLayout = QGridLayout(self)
mainLayout.setMargin(20)
mainLayout.setSpacing(15)
mainLayout.addWidget(JzleftWidget(), 0, 0)
mainLayout.addWidget(JzQWidget(), 1, 1)
mainLayout.addWidget(JzrightWidget(), 0, 1)
mainLayout.addWidget(self.CalendarWidget(), 1, 0)
mainLayout.addWidget(self.showDate(), 2, 0)
widget = QWidget()
widget.setLayout(mainLayout)
self.setCentralWidget(widget)
def MenuBar(self):
open_config = QAction(u'打开配置文件', self)
open_config.setShortcut('Ctrl+E')
open_config.setStatusTip('Open config.ini')
start_test = QAction(u'开始测试', self)
start_test.setShortcut('Ctrl+T')
start_test.setStatusTip('Start application')
exit = QAction(u'退出', self)
exit.setShortcut('Ctrl+Q')
exit.setStatusTip('Start application')
shortcutkey = self.menuBar().addMenu(u'&功能')
shortcutkey.addAction(open_config)
shortcutkey.addAction(start_test)
shortcutkey = self.menuBar().addMenu(u'&工具')
shortcutkey.addAction(exit)
def ToolBar(self):
saveEvent = QAction(u"保存", self)
copyEvent = QAction(u"复制", self)
pasteEvent = QAction(u"粘贴", self)
toolbar = self.addToolBar(u"工具栏")
toolbar.addAction(saveEvent)
toolbar.addAction(copyEvent)
toolbar.addAction(pasteEvent)
def StatusBar(self):
self.statusBar().showMessage(self.tr("作者:johnny 博客地址: http://blog.csdn.net/z_johnny"))
def Center(self):
screen = QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
def closeEvent(self, event):
reply = QMessageBox.question(self, u'来自Johnny的消息',
"Are you sure to quit?", QMessageBox.Yes, QMessageBox.No)
if reply == QMessageBox.Yes:
event.accept()
else:
event.ignore()
def CalendarWidget(self):
self.calendarWidget = QCalendarWidget(self)
self.calendarWidget.setGridVisible(True)
self.connect(self.calendarWidget, SIGNAL('selectionChanged()'),
self.showDate)
self.date_label = QLabel()
date = self.calendarWidget.selectedDate()
self.date_label.setText(str(date.toPyDate()))
return self.calendarWidget
def showDate(self):
date = self.calendarWidget.selectedDate()
self.date_label.setText(self.tr(' 已选择日期: ')+str(date.toPyDate()))
return self.date_label
class JzQWidget(QWidget):
def __init__(self, parent=None):
super(JzQWidget, self).__init__(parent)
self.initUI()
def initUI(self):
names = ['Cls', 'Bck', '', 'Close', '7', '8', '9', '/',
'4', '5', '6', '*', '1', '2', '3', '-',
'0', '.', '=', '+']
grid = 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 = QPushButton(i)
if j == 2:
grid.addWidget(QLabel(''), 0, 2)
else:
grid.addWidget(button, pos[j][0], pos[j][1])
j = j + 1
self.setLayout(grid)
class JzCalc(QDialog):
def __init__(self, parent=None):
super(JzCalc, self).__init__(parent)
self.browser = QTextBrowser()
self.lineEdit = QLineEdit(self.tr("使用方法:输入后按回车,如 ' 1+1 '"))
self.lineEdit.selectAll()
self.lineEdit.setFocus()
layout = QVBoxLayout()
layout.addWidget(self.browser)
layout.addWidget(self.lineEdit)
self.setLayout(layout)
self.connect(self.lineEdit, SIGNAL("returnPressed()"),
self.result)
def result(self):
try:
text = unicode(self.lineEdit.text())
self.browser.append("%s = %s" % (text, eval(text)))
except:
self.browser.append(
"%s is invalid!" % text)
class JzleftWidget(QDialog):
def __init__(self, parent=None):
super(JzleftWidget, self).__init__(parent)
leftBoxLayout = QVBoxLayout()
leftBoxLayout.addWidget(self.ServiceURL(),)
leftBoxLayout.addWidget(self.InventoryModule())
leftBoxLayout.addWidget(self.Protocol())
leftBoxLayout.addWidget(self.Business())
self.setLayout(leftBoxLayout)
def ServiceURL(self):
url_Label = QLabel(self.tr("地址:"))
url_Label_lineEdit = QLineEdit("http://192.168.*.*:8181/ttk")
url_groupbox = QGroupBox(self.tr("TTK服务地址"))
url_varLayout = QVBoxLayout(url_groupbox)
url_varLayout.addWidget(url_Label)
url_varLayout.addWidget(url_Label_lineEdit)
return url_groupbox
def InventoryModule(self):
module_singleRadioButton = QRadioButton(self.tr("单次"))
module_setnumRadioButton = QRadioButton(self.tr("按次"))
module_loopRadioButton = QRadioButton(self.tr("无限循环"))
module_mustsucceedRadioButton = QRadioButton(self.tr("至少成功一次"))
module_settimeRadioButton = QRadioButton(self.tr("定时(单位ms)"))
module_setnumRadioButton_lineEdit = QLineEdit()
module_settimeRadioButton_LineEdit = QLineEdit("5000")
module_groupbox = QGroupBox(self.tr("清点模式"))
module_varLayout = QVBoxLayout(module_groupbox)
module_varLayout.addStretch(1)
module_varLayout.addWidget(module_singleRadioButton)
module_varLayout.addWidget(module_setnumRadioButton)
module_varLayout.addWidget(module_setnumRadioButton_lineEdit)
module_varLayout.addWidget(module_loopRadioButton)
module_varLayout.addWidget(module_mustsucceedRadioButton)
module_varLayout.addWidget(module_settimeRadioButton)
module_varLayout.addWidget(module_settimeRadioButton_LineEdit)
return module_groupbox
def Protocol(self):
protocol_sLabel = QLabel(self.tr("协议标准"))
protocol_iLabel = QLabel(self.tr("清点周期(单位ms)"))
protocol_ComboBox = QComboBox()
protocol_ComboBox.insertItem(0, self.tr("GB"))
protocol_ComboBox.insertItem(1, self.tr("6C"))
protocol_iLabel_lineEdit = QLineEdit("1")
protocol_groupbox = QGroupBox(self.tr("协议和清点周期"))
protocol_varLayout = QVBoxLayout(protocol_groupbox)
protocol_varLayout.addWidget(protocol_sLabel)
protocol_varLayout.addWidget(protocol_ComboBox)
protocol_varLayout.addWidget(protocol_iLabel)
protocol_varLayout.addWidget(protocol_iLabel_lineEdit)
return protocol_groupbox
def Business(self):
business_Label = QLabel(self.tr("业务测试"))
business_combobox = QComboBox(self)
business_combobox.insertItem(0, self.tr("清点"))
business_combobox.insertItem(1, self.tr("读取"))
business_combobox.insertItem(2, self.tr("写入"))
business_combobox.insertItem(3, self.tr("写回读"))
business_PushButton = QPushButton(self.tr("内存区选择"))
business_groupbox = QGroupBox(self.tr("业务选择"))
business_varLayout = QHBoxLayout(business_groupbox)
business_varLayout.addWidget(business_Label)
business_varLayout.addWidget(business_combobox)
business_varLayout.addWidget(business_PushButton)
self.connect(business_PushButton, SIGNAL('clicked()'), self.memory_show)
return business_groupbox
def memory_show(self):
business_checkboxs = []
business_memoryCheckBox1 = QCheckBox("user01-1-word")
business_checkboxs.append(business_memoryCheckBox1)
business_memoryCheckBox2 = QCheckBox("user01-2-word")
business_checkboxs.append(business_memoryCheckBox2)
business_memoryCheckBox3 = QCheckBox("user01-4-word")
business_checkboxs.append(business_memoryCheckBox3)
business_memoryCheckBox4 = QCheckBox("user01-6-word")
business_checkboxs.append(business_memoryCheckBox4)
business_memoryCheckBox5 = QCheckBox("user01-8-word")
business_checkboxs.append(business_memoryCheckBox5)
business_memoryCheckBox6 = QCheckBox("user01-16-word")
business_checkboxs.append(business_memoryCheckBox6)
business_memoryCheckBox7 = QCheckBox("user01-28-word")
business_checkboxs.append(business_memoryCheckBox7)
business_memoryCheckBox8 = QCheckBox("user01-32-word")
business_checkboxs.append(business_memoryCheckBox8)
business_memoryData_lable = QLabel(self.tr("写数据"))
business_memoryData_lable_lineEdit = QLineEdit("5A5A")
self.business_memoryWidge = QWidget()
self.business_memoryWidge.setWindowTitle(self.tr("内存区选择"))
business_memoryLayout = QGridLayout(self.business_memoryWidge)
business_memoryLayout.addWidget(business_memoryCheckBox1, 0, 0)
business_memoryLayout.addWidget(business_memoryCheckBox2, 0, 1)
business_memoryLayout.addWidget(business_memoryCheckBox3, 0, 2)
business_memoryLayout.addWidget(business_memoryCheckBox4, 0, 3)
business_memoryLayout.addWidget(business_memoryCheckBox5, 1, 0)
business_memoryLayout.addWidget(business_memoryCheckBox6, 1, 1)
business_memoryLayout.addWidget(business_memoryCheckBox7, 1, 2)
business_memoryLayout.addWidget(business_memoryCheckBox8, 1, 3)
business_memoryLayout.addWidget(business_memoryData_lable, 2, 0)
business_memoryLayout.addWidget(business_memoryData_lable_lineEdit, 2, 1)
self.business_memoryWidge.hide()
if self.business_memoryWidge.isHidden():
self.business_memoryWidge.show()
else:
self.business_memoryWidge.hide()
class JzrightWidget(QWidget):
def __init__(self, parent=None):
super(JzrightWidget, self).__init__(parent)
rightBoxLayout = QVBoxLayout()
rightBoxLayout.addWidget(self.Fileset() )
rightBoxLayout.addLayout(self.TagDistance())
rightBoxLayout.addLayout(self.DataShow())
rightBoxLayout.addLayout(self.Button())
rightBoxLayout.addWidget(self.Table())
rightBoxLayout.addWidget(self.FrameLable())
self.setLayout(rightBoxLayout)
def Fileset(self):
file_Label = QLabel(self.tr("文件保存路径"))
file_PushButton = QPushButton(self.tr("选择路径"))
file_lineEdit = QLineEdit()
file_groupbox = QGroupBox(self.tr("文件设置"))
file_varLayout = QVBoxLayout(file_groupbox)
file_varLayout.addWidget(file_Label)
file_varLayout.addWidget(file_lineEdit)
file_varLayout.addWidget(file_PushButton)
return file_groupbox
def TagDistance(self):
tagDistance_lable = QLabel(self.tr("标签距离(单位m)"))
tagDistance_lineEdit = QLineEdit()
tagDistance_varLayout = QVBoxLayout()
tagDistance_varLayout.addWidget(tagDistance_lable)
tagDistance_varLayout.addWidget(tagDistance_lineEdit)
return tagDistance_varLayout
def DataShow(self):
data_Label = QLabel(self.tr("测试数据"))
data_TextBrowser = QTextBrowser()
data_varLayout = QVBoxLayout()
data_varLayout.addWidget(data_Label)
data_varLayout.addWidget(data_TextBrowser)
return data_varLayout
def Button(self):
button_start = QPushButton(self.tr("开始测试"))
button_goon = QPushButton(self.tr("继续测试"))
bottonLayout = QHBoxLayout()
bottonLayout.addStretch(1)
bottonLayout.addWidget(button_start)
bottonLayout.addWidget(button_goon)
return bottonLayout
def Table(self):
treewidget = QTreeWidget()
treewidget.setHeaderLabels(['Johnny', 'is', u'帅'])
return treewidget
def FrameLable(self):
otherLabel = QLabel(self.tr("备注:"))
otherLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
return otherLabel
if __name__ == '__main__':
app = QApplication(sys.argv)
windows = JzmainWindow()
windows.show()
app.exec_()