Help needed with Tree - Multitree ctl


New member
Is there anybody out there who have a functionating python example of the tree / multitree control?

It seems that no one of the callback functions get called by the Framework. So I don't know how to use this controls.
Is there maybe some secret function to call or any other trick?

And a question about Listboxes / Multilistboxes...
How can I programmatically select a bunch of rows? All my tries Ends up with only the last of the given range is selected.
I used the set_int() to select in a Loop... result: only the last gets selected (at least only the last Shows as selected)

And a question about raster functions.
Is it possible to Transfer the current pixels from a Panel to a raster? What I mean is the opposit of blitPanel which
transferes the raster to the Panel. I need the opposit, but it seems not to be possible.

What is the secret about the ctl.visible() method? Calling this with False works propper and the control vanishes,
but how to make it visible again? calling with True does not work.

And last my last question for now is... Is it possible to get the "human" readable python scripts? During develope process
this can be a great help.

All of These questions are coming up during the developement of a Panel designer. I am on the way to develope a
Panel designer in which you can create python code in a "WYSIWYG" art.
At the Moment I can save a Panel as a functionating stand alone script (you only have to fill the created functions and
callbacks with the code you want). The optic Looks like in the designer. Or you can save a snippet which can create the
designed controls in an existing script.
In the LScript Interface Designer you can not create all of the controls that are possible (66 at the Moment)
With my designer you can create all of them. The only ones who did not function are the tree and multitree controls.
They can be created, but without any function (they look like empty listboxes)

Last edited:


New member
I see, that my question about the "human" readable scripts isn't clear... I did not tell scripts of what...
Of the lwsdk. As so as the PRIS. I know that it is't beta anymore, but this would help enorm. In this way maybe the secrets
of the other questions can be lifted.



New member
I have found a Workaround for the Problem with control.visible(False)

You can hide a control with control.visible(False), but other than the Name implied, the control.visible(True) is not making the control visible again. To make a control visible again, you can use the
To make a control visible again, that should be not enabled, you must use

I hope this helps someone

Is there a possibility to get the actual column width of a multicolumn listbox?
The width of the columns at the start of the listbox is known (because you have to define if for your own) but the user is able to Change the columnwidth during his work. So my question is.... how to get the actual width?



New member
So after nobody has replied to this thread, I think that this are bugs (nobody seems to have a solution). And so I have "bug-reported" the issues. I will Keep you informed (if I for myself get informed from a developer)



New member
Here is code generated for the multi-tree with ODTools 2018 AutoGUI Generator. I've added some random data for testing. As of 2018 i think we can do other things with PySi QT. Which i know little about.

Screen Shot 2018-06-20 at 17.43.16.jpg

# ! /usr/bin/env python
# -*- Mode: Python -*-
# -*- coding: ascii -*-

__author__ = "the code master"
__date__ = "june 20, 2018"
__copyright__ = "the code master"
__version__ = "1.0"
__maintainer__ = "AI"
__email__ = "[email protected]"
__status__ = ""
__lwver__ = "2018"

import lwsdk

class MultitreeNode(object):
   # def tree_ctl(self, arg0, arg1, arg2, arg3, arg4, arg5, arg6=None):
   #      tree_ctl(self, char title, int width, int height, PyObject info_func,
   #      PyObject count_func, PyObject node_func,
   #      PyObject move_func = None) -> Control
   #      tree_ctl(self, char title, int width, int height, PyObject info_func,
   #      PyObject count_func, PyObject node_func) -> Control

  def __init__(self, name_list):
    self.name_list = name_list
    self.flags = 0
    self.children = []

class Gui(lwsdk.IGeneric):
  def __init__(self, context):
    super(Gui, self).__init__()

  def my_tree_info_func(self, control, user_data, node, column, flags):
    if node == None: node = self.my_tree_root
    if flags != 0: node.flags = flags
    if column == -1: return (None, node.flags)
    assert (column < len(node.name_list))
    return (node.name_list[column], node.flags)

  def my_tree_count_func(self, control, user_data, node):
    if node == None: node = self.my_tree_root
    return len(node.children)

  def my_tree_node_func(self, control, user_data, node, index):
    if node == None:
      node = self.my_tree_root
      child = node.children[index]
      child = None
    return child

  def my_tree_width_func(self, control, user_data, column):
    if column == 0: return 100  # width of column
    if column < 3:  return 100  # width of column
    return 0

  def my_tree_event_func(self, control, user_data, selected_node):
    print selected_node.name_list[0]

  def process(self, ga):
    def callback(id, data):
      pass  # Remove this line if there are other callbacks

    self.ui = lwsdk.LWPanels()
    self.panel = self.ui.create("Multi-Tree display")

    data = {"automotive":{"color":"red", "object":"car"},
            "visualisation":{"color":"blue", "object":"house"},
            "fiber_fx":{"color":"brown", "object":"furry bear"},
            "materials":{"color":"green", "object":"bottle"},}

    column1 = []
    column2 = []
    column3 = []

    for key in data:

    print 'keys: {}'.format(repr(column1))
    print ' - color: {}'.format(repr(column2))
    print ' - object: {}'.format(repr(column3))

    # In order to add items to the list, this is how you do it, and then refresh the control:
    # self.my_tree_root.children.append(MultitreeNode([column1[i],column2[i],column3[i]]))

    self.my_tree_root = MultitreeNode(["Category", "Spectrum", "Object"])
    for i in range(len(column1)):
      description = "a " + str(column2[i]) + " " + str(column3[i])
      code = "color code for " + str(column2[i])
      id = "ID " + str(i)
      self.my_tree_root.children[-1].children.append(MultitreeNode([description, code, id]))

    self.my_tree = self.panel.multitree_ctl("my_tree", 550, 160, self.my_tree_info_func, self.my_tree_count_func,
                                            self.my_tree_node_func, self.my_tree_width_func)

    self.panel.size_to_layout(5, 5)

    if | lwsdk.PANF_CANCEL) == 0:
      print "Aborted..."
      return lwsdk.AFUNC_OK  # when cancel was clicked

    lwsdk.LWMessageFuncs().info("Gui created.", "")
    return lwsdk.AFUNC_OK

ServerTagInfo = [("MultiTree", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH),
                 ("MultiTree", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH)]
ServerRecord = {lwsdk.GenericFactory("MultiTree", Gui): ServerTagInfo}


New member
Thank you Diepgroen for answering and showing a Piece of code which is working.

I don't know why, but in my own code there was no one of the funcs from the parameterlist called back. So I used your example and it works, all callbacks are called. And now the strange Thing... trying my old code and.... it works also... I don't know why this is happen.

The only difference between the old calls and the calls now is the Change from 2018.0.3 to 2018.0.4. But I don't think this is the reason.

Maybe I was blind during my first tests and wrote something that can not work. And after seeing your example i did not make the same error. How ever... I don't know.

A big thank you for your answer. If you had not answered, I would hang in this in an infinite Loop....

Thank you 1000 times.



New member
heheh The times i've been confused! Too many. Glad this helps! LWPython demo scripts are in the support folder of you app. Great source for checking how things are done. Not everything, but enough demos to look at.


New member
I did not rest in finding out why sometimes id did not function with the tree control.
As Long as I do not add a "tree.set_event(eventfunc)", the control did not come to life, no one of the callbacks are called
If I add a eventfunc for the tree, it comes to life and all callbacks are called...
Strange, but you can reproduce this...

I hope this helps someone out, who came into the same Situation, that no callback is called.



New member
I looked deeper into the dead trees...
The tree will be dead only if no event function is set nor select function is set.
So to get a working tree, you must set an Event func, or a select func or both. Even if you don't need any of this functions.
You can simply "pass" this functions, it does not care what the function is doing, it must simply be set.

There is an other problem with the move-function of a tree. If you set the move-function (this allowes the User to move items around) and the user is trying to move an item to the root or an other 1st rank item of higher Level in the tree,
lwsdk crashes before the move-function will be called.

I will bug-report this 2 issues.

Top Bottom