def setupUi(self, MainWindow):
"""Setting up UI for Main Window
"""
MainWindow.setObjectName("MainWindow")
MainWindow.resize(804, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.horizontalLayout = QtGui.QHBoxLayout(self.centralwidget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.txtInput = QtGui.QPlainTextEdit(self.centralwidget)
self.txtInput.setObjectName("MarkDtextEdit")
self.horizontalLayout.addWidget(self.txtInput)
self.txtOutput = QtGui.QTextEdit(self.centralwidget)
self.txtOutput.setObjectName("MarkDownView")
self.horizontalLayout.addWidget(self.txtOutput)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 804, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
python类QPlainTextEdit()的实例源码
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(680, 403)
self.gridLayout = QtGui.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.labelVersion = QtGui.QLabel(Dialog)
self.labelVersion.setObjectName("labelVersion")
self.gridLayout.addWidget(self.labelVersion, 0, 0, 1, 1)
self.labelSupport = QtGui.QLabel(Dialog)
self.labelSupport.setObjectName("labelSupport")
self.gridLayout.addWidget(self.labelSupport, 1, 0, 1, 1)
self.labelLicense = QtGui.QLabel(Dialog)
self.labelLicense.setObjectName("labelLicense")
self.gridLayout.addWidget(self.labelLicense, 2, 0, 1, 1)
self.pushButton = QtGui.QPushButton(Dialog)
self.pushButton.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icon/mpowertcx icon flat.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton.setIcon(icon)
self.pushButton.setIconSize(QtCore.QSize(256, 256))
self.pushButton.setFlat(True)
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 3, 1, 1, 1)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 4, 1, 1, 1)
self.licenseEdit = QtGui.QPlainTextEdit(Dialog)
self.licenseEdit.setFrameShape(QtGui.QFrame.Box)
self.licenseEdit.setReadOnly(True)
self.licenseEdit.setObjectName("licenseEdit")
self.gridLayout.addWidget(self.licenseEdit, 3, 0, 2, 1)
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.buttonBox.setCenterButtons(True)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 2)
self.retranslateUi(Dialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(756, 395)
self.gridLayout = QtGui.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.labelVersion = QtGui.QLabel(Dialog)
self.labelVersion.setObjectName("labelVersion")
self.gridLayout.addWidget(self.labelVersion, 0, 0, 1, 1)
self.labelSupport = QtGui.QLabel(Dialog)
self.labelSupport.setObjectName("labelSupport")
self.gridLayout.addWidget(self.labelSupport, 1, 0, 1, 1)
self.labelLicense = QtGui.QLabel(Dialog)
self.labelLicense.setObjectName("labelLicense")
self.gridLayout.addWidget(self.labelLicense, 2, 0, 1, 1)
self.pushButton = QtGui.QPushButton(Dialog)
self.pushButton.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icon/mpowertcx icon flat.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton.setIcon(icon)
self.pushButton.setIconSize(QtCore.QSize(256, 256))
self.pushButton.setFlat(True)
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 3, 1, 1, 1)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 4, 1, 1, 1)
self.licenseEdit = QtGui.QPlainTextEdit(Dialog)
self.licenseEdit.setFrameShape(QtGui.QFrame.NoFrame)
self.licenseEdit.setReadOnly(True)
self.licenseEdit.setObjectName("licenseEdit")
self.gridLayout.addWidget(self.licenseEdit, 3, 0, 2, 1)
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.buttonBox.setCenterButtons(True)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 2)
self.retranslateUi(Dialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def __init__(self, *args):
QtWidgets.QPlainTextEdit.__init__(self, *args)
self.setFrameStyle(QtWidgets.QFrame.NoFrame)
self.zoomWheelEnabled = 0
self.highlight()
#self.setLineWrapMode(QtWidgets.QPlainTextEdit.NoWrap)
self.cursorPositionChanged.connect(self.highlight)
def wheelEvent(self, event, forward=True):
if event.modifiers() == QtCore.Qt.ControlModifier:
if self.zoomWheelEnabled == 1:
if event.delta() == 120:
self.zoom_in()
elif event.delta() == -120:
self.zoom_out()
event.ignore()
QtWidgets.QPlainTextEdit.wheelEvent(self, event)
def setWrap(self, state):
if state == 0:
self.edit.setLineWrapMode(QtWidgets.QPlainTextEdit.NoWrap)
else:
self.edit.setLineWrapMode(QtWidgets.QPlainTextEdit.WidgetWidth)
def setReadOnlyStyle(self, state):
if state == 1:
mainWindowBgColor = QtWidgets.QPalette().color(QtWidgets.QPalette.Window)
self.setStyleSheet('QPlainTextEdit[readOnly="true"] { background-color: %s;} QFrame {border: 0px}' % mainWindowBgColor.name() )
self.setHighlight(0)
else:
self.setStyleSheet('')
self.setHighlight(1)
LNTextEdit_v3.2.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 33
收藏 0
点赞 0
评论 0
def __init__(self, *args):
QtGui.QPlainTextEdit.__init__(self, *args)
self.setFrameStyle(QtGui.QFrame.NoFrame)
self.zoomWheelEnabled = 0
self.highlight()
#self.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
self.cursorPositionChanged.connect(self.highlight)
LNTextEdit_v3.2.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def setWrap(self, state):
if state == 0:
self.edit.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
else:
self.edit.setLineWrapMode(QtGui.QPlainTextEdit.WidgetWidth)
LNTextEdit_v3.2.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def setReadOnlyStyle(self, state):
if state == 1:
mainWindowBgColor = QtGui.QPalette().color(QtGui.QPalette.Window)
self.setStyleSheet('QPlainTextEdit[readOnly="true"] { background-color: %s;} QFrame {border: 0px}' % mainWindowBgColor.name() )
self.setHighlight(0)
else:
self.setStyleSheet('')
self.setHighlight(1)
def setupUi(self):
"""Bruh"""
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setGeometry(50, 50, 850, 425)
self.setWindowTitle("ZeZe's TWTools - Coord Extractor")
self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))
"""Background color"""
self.backgroundPalette = QtGui.QPalette()
self.backgroundColor = QtGui.QColor(217, 204, 170)
self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor)
self.setPalette(self.backgroundPalette)
"""Main layout & return to main menu button"""
self.verticalLayout = QtGui.QVBoxLayout(self)
self.buttonLayout = QtGui.QHBoxLayout(self)
self.verticalLayout.addLayout(self.buttonLayout)
self.returnButton = QtGui.QPushButton(" Return to the Main Menu ", self)
self.returnButton.clicked.connect(self.return_function)
self.buttonLayout.addWidget(self.returnButton)
self.buttonSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.buttonLayout.addItem(self.buttonSpacer)
"""Line Spacer and line"""
self.lineSpacer = QtGui.QSpacerItem(40, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.verticalLayout.addItem(self.lineSpacer)
self.line = QtGui.QFrame(self)
self.line.setFrameShape(QtGui.QFrame.HLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.verticalLayout.addWidget(self.line)
"""Text input label and edit"""
self.Spacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout.addItem(self.Spacer)
self.inputLabel = QtGui.QLabel("Input text with coordinates here:")
self.verticalLayout.addWidget(self.inputLabel)
self.plainTextEdit = QtGui.QPlainTextEdit(self)
self.verticalLayout.addWidget(self.plainTextEdit)
"""Coordinates output label and edit"""
self.Spacer1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout.addItem(self.Spacer1)
self.outputLabel = QtGui.QLabel("Output coordinates magically appear here:")
self.verticalLayout.addWidget(self.outputLabel)
self.plainTextEdit_2 = QtGui.QPlainTextEdit(self)
self.verticalLayout.addWidget(self.plainTextEdit_2)
"""Extract coordinates button"""
self.horizontalLayout = QtGui.QHBoxLayout()
self.verticalLayout.addLayout(self.horizontalLayout)
self.Spacer2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout.addItem(self.Spacer2)
self.extractButton = QtGui.QPushButton(" Extract Coordinates ", self)
self.extractButton.clicked.connect(self.extract_function)
self.horizontalLayout.addWidget(self.extractButton)