import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QDesktopWidget, QVBoxLayout, QHBoxLayout, QApplication, QButtonGroup
from utils.tableUtils import MYWIDGET
class MainWindow(QWidget):
def __init__(self):
super().__init__()
# 窗体标题和尺寸
self.setWindowTitle("Python QT5 Demo")
# 窗体的尺寸
self.resize(365, 200)
# 窗体的位置
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
# 垂直方向的布局
layout = QVBoxLayout()
# 1.创建主要内容
# 纸宽 纸高 间距
layout.addLayout(self.content_layout(['纸宽', '纸高', '间距']))
# 宽度 高度 页数
layout.addLayout(self.content_layout(['宽度', '高度', '页数']))
# 列数 行数 编号
layout.addLayout(self.content_layout(['列数', '行数', '编号']))
# 输出路径 切 刀 转
layout.addLayout(self.filed_layout())
# 导入路径 拼版尺寸 拼版按钮
layout.addLayout(self.filed2_layout())
# 2.创建底部菜单
layout.addLayout(self.footer_layout())
# 给窗体设置元素的排列方式
self.setLayout(layout)
def footer_layout(self):
layout = QHBoxLayout()
btngroup_left = QButtonGroup(self)
btngroup_right = QButtonGroup(self)
MYWIDGET.addRadioButton(layout,btngroup_left, '单')
MYWIDGET.addRadioButton(layout,btngroup_left, '自')
MYWIDGET.addRadioButton(layout,btngroup_left, '双')
MYWIDGET.addRadioButton(layout,btngroup_right, '横奇')
MYWIDGET.addRadioButton(layout,btngroup_right, '横偶')
MYWIDGET.addRadioButton(layout,btngroup_right, '竖奇')
MYWIDGET.addRadioButton(layout,btngroup_right, '竖偶')
return layout
def filed2_layout(self):
layout = QHBoxLayout()
pdf_edit = MYWIDGET.addLineEditD(self,layout, '双击或拖入PDF文件')
pdf_edit.mouseDoubleClickEvent= self.mouse_click
pdf_edit.setDragEnabled(True)
MYWIDGET.addComboBox(layout, ['','597x444 0','597x444 3','444x398 0','444x398 3'])
MYWIDGET.addButton(layout, '拼版')
return layout
def filed_layout(self):
layout = QHBoxLayout()
MYWIDGET.addLineEdit(layout, '请写入PDF输出名称')
MYWIDGET.addCheckBox(layout, '切')
MYWIDGET.addCheckBox(layout, '刀')
MYWIDGET.addCheckBox(layout, '转')
return layout
def content_layout(self, _list):
layout = QHBoxLayout()
for item in _list:
MYWIDGET.addLabel(layout, '{}:'.format(item))
MYWIDGET.addLineEdit(layout, '')
return layout
def mouse_click(self, event):
if event.button() == 1:
# 双击
# handle left mouse button here
print(12)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())