self.textBrowser = QtGui.QTextBrowser(self.tab_4) self.textBrowser.setGeometry(QtCore.QRect(0, 10, 781, 301)) self.textBrowser.setOpenExternalLinks(True) fsock = os.popen('cat /home/opt/healthcheck/about.txt').read() self.textBrowser.setHtml(fsock) # self.textBrowser.setText (fsock) # Make the font small!!! font = QtGui.QFont() font.setPointSize(20)
def mouseMoveEvent(self, event): self.mousePressPos = QtCore.QPoint(event.pos()) if self.mousePressPos.isNull(): event.ignore() return self.x = self.mousePressPos.x() self.y = self.mousePressPos.y() event.accept() self.update()
import sys from PyQt4.QtCore import Qt from PyQt4.QtGui import * class TableWidget(QTableWidget): def __init__(self, parent = None): QTableWidget.__init__(self, parent) def contextMenuEvent(self, event): menu = QMenu(self) quitAction = menu.addAction("Quit") action = menu.exec_(self.mapToGlobal(event.pos())) if action == quitAction: qApp.quit() app = QApplication([]) tableWidget = TableWidget() tableWidget.show() sys.exit(app.exec_())