Issue
I want to display multiple lists in QTextEdit, however all functions that insert text only take strings. When reading the documentation of QTextEdit it says that QTextCursor can handle lists, however I can't get its insertList()
to work either.
The following function generates six lists, which I want to display:
def gen_reading_frames(self):
frames = []
frames.append(self.translate_seq(0))
frames.append(self.translate_seq(1))
frames.append(self.translate_seq(2))
tmp_seq = bio_seq(self.reverse_complement(), self.seq_type)
frames.append(tmp_seq.translate_seq(0))
frames.append(tmp_seq.translate_seq(1))
frames.append(tmp_seq.translate_seq(2))
del tmp_seq
return frames
These are my approaches:
# 1.:
tmp_rf = qtg.QTextListFormat(seq.gen_reading_frames())
self.textEditReadingFrames.insertList(tmp_orf)
# 2.:
tmp_rf = self.textEditReadingFrames.textCursor()
tmp_rf.insertList(seq.gen_reading_frames())
Both throw type errors, the first one because QTextListFormat does not accept lists, and the second because insertList only accepts QTextListFormat.
So if both of these do not accept lists, how to display the lists in QTextEdit? Or do I have to convert them to strings, because there is just no other way?
I hope that the question was not asked before, but when searching the forum and Qt documentation I could not find an answer.
Solution
In case anyone needs an answer to this, I inserted the strings one by one:
rfs = seq.gen_reading_frames()
for rf in rfs:
self.textEditReadingFrames.append(f'{rf}\n')
del rfs
Answered By - JägerMT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.