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()
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())
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:
print(12)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())