Python Forum
[PyQt] Add a function in QtextBrowser
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Add a function in QtextBrowser
#4
qwert
(Sep-23-2021, 06:31 PM)deanhystad Wrote: That kind of thing does not belong in the class (plus it is really annoying). If you want to scroll to the bottom whenever you append text, use an intermediary function that does the append and the scrolling.

You can do what you want (modify method behavior in existing class) in Python. It is called "monkey patching". Now that you know what it's called you can find lots of examples and tutorials.

Thank you that worked:
def AddnRefresh(self,content):
    self.append(content)
    self.verticalScrollBar().setValue(self.verticalScrollBar().maximum())
QTextBrowser.AddnRefresh=AddnRefresh

(Sep-23-2021, 07:03 PM)Axel_Erfurt Wrote: You can convert your ui file to a py file , then you can work without the ui file

Example:

pyuic5 mainwindow.ui -o mainwindow.py -x

Yeah I know i just skipped that part but thanks anyways
Reply


Messages In This Thread
Add a function in QtextBrowser - by catlessness - Sep-23-2021, 05:17 PM
RE: Add a function in QtextBrowser - by deanhystad - Sep-23-2021, 06:31 PM
RE: Add a function in QtextBrowser - by Axel_Erfurt - Sep-23-2021, 07:03 PM
RE: Add a function in QtextBrowser - by catlessness - Sep-25-2021, 01:55 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020