ChrisOfBristol
1st April 2015, 11:20
I want to load and display a text file when help is clicked. It needs to be a fair-sized panel with a vertical scrollbar, the text should preferably but not necessarily be HTML and loaded from a disk file. The best I can do so far is this:
with open(filename, 'r') as infile:
result = infile.read()
self.helptext = QtGui.QTextEdit()
self.helptext.setHtml(result)
self.helptext.setReadOnly(-1)
self.helptext.resize(800, 500)
self.helptext.show()
However, it floats on the main window and does not close if I close the main window. (Not modal?) I can make it attach to the main window and close when the main window is closed (modal?) by using QtGui.QTextEdit(self). This is not satisfactory though, as there is no 'X' on the window title bar (window decoration?) so no way of closing it. I have looked here http://pyqt.sourceforge.net/Docs/PyQt4/qtextedit.htmls for a way of adding it without success. Is there a way of doing so, or should I be using a different sort of widget? I have looked at all the widgets I can find but can't find what I want, a messagebox is not suitable for several reasons.
with open(filename, 'r') as infile:
result = infile.read()
self.helptext = QtGui.QTextEdit()
self.helptext.setHtml(result)
self.helptext.setReadOnly(-1)
self.helptext.resize(800, 500)
self.helptext.show()
However, it floats on the main window and does not close if I close the main window. (Not modal?) I can make it attach to the main window and close when the main window is closed (modal?) by using QtGui.QTextEdit(self). This is not satisfactory though, as there is no 'X' on the window title bar (window decoration?) so no way of closing it. I have looked here http://pyqt.sourceforge.net/Docs/PyQt4/qtextedit.htmls for a way of adding it without success. Is there a way of doing so, or should I be using a different sort of widget? I have looked at all the widgets I can find but can't find what I want, a messagebox is not suitable for several reasons.