Solved Inserting a textbox in order to print information
-
Hello, I use this code:
https://github.com/kklmn/OrthoView/blob/master/OrthoView.py
I want to add a text box in order to print 4 lines of 30 characters (max) information each line. What method/function should I use for this? Where in the code should I focus?
Thanks -
Hi
You could use a QTextEdit since that can hold multiple text lines.You should create the QTextEdit in
class OrthoView(qt.QWidget): (line 456) as that seems to be the main window holding all the other widgets.
and maybe put it in around 464
It seems to be using layout so I would add it to that layout and see where it ends up.
layout = qt.QVBoxLayout(self)
so that might be ok to add there.
-
Thank you! In case I want only see text/information and not to be able to edit, what I use?
-
@john_hobbyist
you can set TextEdit to ReadOnly.
textedit.setReadOnly(true); -
I wrote:
QTextEdit.setReadOnly(True);
and I get this error:
TypeError: setReadOnly(self, bool): first argument of unbound method must have type 'QTextEdit'
I am trying to find the solution...Can you help?
-
@john_hobbyist said in Inserting a textbox in order to print information:
QTextEdit.setReadOnly(True);
This does not make sense as setReadOnly is not a static method!
You have to call it on your QTextEdit instance -
Sorry I do not understand...in which line should I insert it? Thanks
-
@john_hobbyist
Hi
You should set it to the new QTextEdit you created.name_of_your_variable.setReadOnly(True);
-
@john_hobbyist How is you QTextEdit instance called and where do you initialise it? I have no idea in which line you have to put that as I do not have your code. You just need to learn the absolute basics. And @mrjj even shows you how it should look like:
textedit.setReadOnly(true);
where textedit is your QTextEdit instance.
-
This post is deleted!