That seems fine.  It can be done a little easier with the new method  
find_widget_by_name():

from leo.core.leoQt import QtWidgets
QSplitter, QTextEdit = QtWidgets.QSplitter, QtWidgets.QTextEdit

gui = g.app.gui
w = gui.find_widget_by_name(c, '*main_splitte*r')
something_log = w.findChild(QTextEdit, "something_log")
if something_log == None:
    something_log = QtWidgets.QTextEdit()
    something_log.setObjectName('something_log')
    w.addWidget(something_log)

If you ever want to delete your added widget, remember to call 
deleteLater() on it as the last thing.  This will cause Qt to delete the 
underlying C++ widget.  Otherwise only the Python widget wrapper will get 
deleted.
On Sunday, May 26, 2024 at 5:17:22 AM UTC-4 [email protected] wrote:

> I haven't kept up with the latest progress. In my previous code, I created 
> a textedit panel to output something.
>
> ```python
>      w = c.frame.body.widget
>      while not isinstance(w, NestedSplitter):
>          w = w.parent()
>      something_log = w.find_child(QtWidgets.QTextEdit, "something_log")
>      if something_log == None:
>          self.something_log = QtWidgets.QTextEdit()
>          self.something_log.setObjectName('something_log')
>          w.insert(-1, self.something_log)
> ```
> Regarding the recent changes, I try to fix it.
>
> ```python
>     w = c.frame.body.widget
>     while not isinstance(w, QSplitter):
>         w = w.parent()
>     something_log = w.findChild(QtWidgets.QTextEdit, "something_log")
>     if something_log == None:
>         self.something_log = QtWidgets.QTextEdit()
>         self.something_log.setObjectName('something_log')
>         w.addWidget(self.something_log)
> ```
>
> It works. But I'm not sure, is there anything else I need to pay attention 
> to? The original code maybe copy from Thomas, I don't remember :D I don’t 
> have the guts to study layout yet
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/adb1a981-427b-4af1-814d-4358e6a86f8dn%40googlegroups.com.

Reply via email to