Problem with setting the textBrowser text using a variable
-
wrote on 16 Apr 2020, 12:06 last edited by
I am having a problem with setting the text of textBrowser on PYQT5.
It is ok when I assign a string.
"""self.textBrowser.setText("string")"""But it does nothing when I assign a variable.
"""self.textBrowser.setText(lst)"""sorting.bubble_sort(text) is function which return an array
def run(self): try: text = "534 23 654 43 21 2" text = Ui_MainWindow.str_list_to_int_list(text.split()) lst=simulator_cal.sorting.bubble_sort(text) self.textBrowser.setText(lst) self.textBrowser.repaint() except: None
-
Thanks for your response.
lst is a string like "2, 21, 23, 43, 534, 654", but that is not working.
It is working when the lst like "123".
textBrowser is a object of QTextBrowser.
setText() is the function from PYQT.wrote on 16 Apr 2020, 12:37 last edited by JonB@Davidhahaha
Sorry I was wrong aboutQTextBrowser
not havingsetText()
, I have corrected that.lst is a string like "2, 21, 23, 43, 534, 654"
So you have a function
str_list_to_int_list(text.split())
which accepts a list but returns a string? And/or,simulator_cal.sorting.bubble_sort(text)
takes a list/string depending, but returns its answer as a string, does it? You originally said:sorting.bubble_sort(text) is function which return an array
https://doc.qt.io/qt-5/qtextbrowser.html
The QTextBrowser class provides a rich text browser with hypertext navigation
I don't know what it does with a plain text input, nor why you would want to use it.
I'll have to leave someone else to help you further.
-
I am having a problem with setting the text of textBrowser on PYQT5.
It is ok when I assign a string.
"""self.textBrowser.setText("string")"""But it does nothing when I assign a variable.
"""self.textBrowser.setText(lst)"""sorting.bubble_sort(text) is function which return an array
def run(self): try: text = "534 23 654 43 21 2" text = Ui_MainWindow.str_list_to_int_list(text.split()) lst=simulator_cal.sorting.bubble_sort(text) self.textBrowser.setText(lst) self.textBrowser.repaint() except: None
wrote on 16 Apr 2020, 12:12 last edited by JonB@Davidhahaha
You don't say what typetextBrowser
is, which is going to be needed to answer this question. If I have to guess it'sQTextBrowser
,I don't see that has anyAnd if it did it would be intended to take rich (HTML) text....setText()
method.You do not show what is in
lst
aftersimulator_cal.sorting.bubble_sort(text)
.QTextBrowser
does not accept a list as an argument.If
lst
is a list ofint
s, it's not going to be suitable, in any case, and certainly not for passing to function namedsetText()
.Your
repaint()
is unlikely to do anything.Whatever your issues are, it will not be because you are using a variable. Rather it will be a question of the value & type of the variable.
-
wrote on 16 Apr 2020, 12:29 last edited by
Thanks for your response.
lst is a string like "2, 21, 23, 43, 534, 654", but that is not working.
It is working when the lst like "123".
textBrowser is a object of QTextBrowser.
setText() is the function from PYQT. -
Thanks for your response.
lst is a string like "2, 21, 23, 43, 534, 654", but that is not working.
It is working when the lst like "123".
textBrowser is a object of QTextBrowser.
setText() is the function from PYQT.wrote on 16 Apr 2020, 12:37 last edited by JonB@Davidhahaha
Sorry I was wrong aboutQTextBrowser
not havingsetText()
, I have corrected that.lst is a string like "2, 21, 23, 43, 534, 654"
So you have a function
str_list_to_int_list(text.split())
which accepts a list but returns a string? And/or,simulator_cal.sorting.bubble_sort(text)
takes a list/string depending, but returns its answer as a string, does it? You originally said:sorting.bubble_sort(text) is function which return an array
https://doc.qt.io/qt-5/qtextbrowser.html
The QTextBrowser class provides a rich text browser with hypertext navigation
I don't know what it does with a plain text input, nor why you would want to use it.
I'll have to leave someone else to help you further.
-
@Davidhahaha
Sorry I was wrong aboutQTextBrowser
not havingsetText()
, I have corrected that.lst is a string like "2, 21, 23, 43, 534, 654"
So you have a function
str_list_to_int_list(text.split())
which accepts a list but returns a string? And/or,simulator_cal.sorting.bubble_sort(text)
takes a list/string depending, but returns its answer as a string, does it? You originally said:sorting.bubble_sort(text) is function which return an array
https://doc.qt.io/qt-5/qtextbrowser.html
The QTextBrowser class provides a rich text browser with hypertext navigation
I don't know what it does with a plain text input, nor why you would want to use it.
I'll have to leave someone else to help you further.
wrote on 16 Apr 2020, 12:42 last edited by@JonB Thank you sir.
I have finished the problem
1/5