RapaGUI Treeview - Empty Leaf when inserting Leafs dynamically

Discuss GUI programming with the RapaGUI plugin here
Post Reply
Yvan_Amiga
Posts: 10
Joined: Mon Mar 14, 2022 5:05 pm

RapaGUI Treeview - Empty Leaf when inserting Leafs dynamically

Post by Yvan_Amiga »

RapaGUI Treeview - Empty Leaf when inserting Leafs dynamically

The following codes creates a Treeview and inserts for leaves dynamically.
See screenshot under the following URL to seee what it creates (odn't look at the Arrows for now)

https://drive.proton.me/urls/AJ39E0GEK4#779ZhwJGhBYQ

Code: Select all

/****************************************************************
**                                                             **
** Name:        Formular Taskmanager                           **
** Author:      Yvan Gutknecht                                 **
** Version:     1.0                                            **
** Date:        28.05.23                                       **
** Interpreter: Hollywood 9.0                                  **
** Function:    Task Manager                                   **
**                                                             **
****************************************************************/

/*
** Make sure we have at least Hollywood 9.0!
*/
@VERSION 9,0


/*
** Enable DPI-awareness so that our GUI looks sharp even on high DPI monitors
*/
@OPTIONS {DPIAware = True}


/*
** This script requires the RapaGUI plugin
*/
@REQUIRE "RapaGUI"
@REQUIRE "sqlite3"






/*
** Information about this app
*/
@APPTITLE "Task Manager"
@APPVERSION "$VER: Weight 1.0 (15.04.22)"
@APPCOPYRIGHT "(C) 2022 Yvan Gutknecht"
@APPAUTHOR "Yvan Gutknecht"


/*
** Our XML GUI definition
*/
@FILE 1, "configfiles/TaskManagerTest.xml"

; dynamically create GUI from an external *.xml file definition



moai.CreateApp(ReadString(1))


InstallEventHandler({RapaGUI = p_EventFunc})

moai.DoMethod("tv", "open", "root", True)
;Open Tasks
moai.DoMethod("tv", "insertleaf", 0 , "open", "taskopen", "Prio1", "Title1", "Date1", "Time1", "Cat1")
moai.DoMethod("tv", "insertleaf", 1 , "open", "taskopen", "Prio2", "Title2", "Date2", "Time2", "Cat2")

;Closed Tasks

moai.DoMethod("tv", "insertleaf", 2 , "closed", "taskclosed", "Prio3", "Title3", "Date3", "Time3", "Cat3")
moai.DoMethod("tv", "insertleaf", 3 , "closed", "taskclosed", "Prio4", "Title4", "Date4", "Time4", "Cat4")








; main loop!
Repeat
	WaitEvent
Forever
Here is the XML for the Treeview Definition

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
					
	<window id="win" title="Tasks" height="400">
		<vgroup>
			<treeview id="tv" height="250" notify="active">
				<column title="Priority"/>
				<column title="Title"/>
				<column title="Due Date"/>
				<column title="Due Time"/>
				<column title="Category"/>
				
				<node id="tasks" name="My Tasks">
					<node id="open" name="Open Tasks">
						<leaf id="taskopen">
						</leaf>
					
					</node>
					
					<node id="closed" name="Closed Tasks">
						<leaf id="taskclosed">
						</leaf>
											
					</node>		
				</node>
			</treeview>

	
		</vgroup>
	</window>
</application>

Now the problem is as you can see in the screenshot, look at the Arrows, it inserts an empty leaf before 'Prio2, Title2...' and also before 'Prio4, Title4 and so on'.


How can I get rid of the empty leaf?

It's not only a cosmetic problem, but this empty leaf is in some kind equal to the leaf with 'Prio1, Title1...'.

So if in the apllication the Users has the idea to delete the empty leaf he will in fact delete the leaf with 'Prio1, Title1 and so on'. Which is really bad.

How can I get rid of the empty leaf?
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: RapaGUI Treeview - Empty Leaf when inserting Leafs dynamically

Post by plouf »

you have the first leaf which is created inside xml empty

Code: Select all

<leaf id="taskopen"><item>Text that apears in so called empty leaf here</item>
</leaf>
Christos
Yvan_Amiga
Posts: 10
Joined: Mon Mar 14, 2022 5:05 pm

Re: RapaGUI Treeview - Empty Leaf when inserting Leafs dynamically

Post by Yvan_Amiga »

Oh sh..... :D
This looks quite obvious and easy. I think this is it. Thank you. I'll try it, probably only tieme next weekend and come back with the result.
Thank you
Yvan_Amiga
Posts: 10
Joined: Mon Mar 14, 2022 5:05 pm

Re: RapaGUI Treeview - Empty Leaf when inserting Leafs dynamically

Post by Yvan_Amiga »

Okay, I tested it but it doesn't work that way.

If I remove the empty leaf from the XML then Hollywood is not able to add a new leaf.

I changed the XML to

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
					
	<window id="win" title="Tasks" height="400">
		<vgroup>
			<treeview id="tv" height="250" notify="active">
				<column title="Priority"/>
				<column title="Title"/>
				<column title="Due Date"/>
				<column title="Due Time"/>
				<column title="Category"/>
				
				<node id="tasks" name="My Tasks">
					<node id="open" name="Open Tasks">

					
					</node>
					
					<node id="closed" name="Closed Tasks">

											
					</node>		
				</node>
			</treeview>

	
		</vgroup>
	</window>
</application>

Now when I try to start the script I get the following error message
Error in line 60 (TaskManager_Forum.hws): Cannot find MOAI object "taskopen"!
Of course it can't find it, I removed it. But when I let it in the XML it will prodcue an empty leaf which is bad.

What am I doing wrong?
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: RapaGUI Treeview - Empty Leaf when inserting Leafs dynamically

Post by plouf »

because there is NO "taskopen" object to your new xml !!
you are trying to insert AFTER a leaf that do not exist.

Special "Head" or "Tail" should be used to add to the top or bottom since there is no specific leaf to add it AFTER to

full working example

Code: Select all

xml$ = [[
<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
					
	<window id="win" title="Tasks" height="400" width="400">
		<vgroup>
			<treeview id="tv" height="250" notify="active">
				<column title="Priority"/>
				<column title="Title"/>
				<column title="Due Date"/>
				<column title="Due Time"/>
				<column title="Category"/>
				
				<node id="tasks" name="My Tasks">
					<node id="open" name="Open Tasks">

					
					</node>
					
					<node id="closed" name="Closed Tasks">

											
					</node>		
				</node>
			</treeview>
	
		</vgroup>
	</window>
</application>
]]

@REQUIRE "RapaGUI"

moai.CreateApp(xml$)


InstallEventHandler({RapaGUI = p_EventFunc})

moai.DoMethod("tv", "open", "root", True)
;Open Tasks
moai.DoMethod("tv", "insertleaf", 0 , "open", "Tail", "Prio1", "Title1", "Date1", "Time1", "Cat1")
moai.DoMethod("tv", "insertleaf", 1 , "open", "Tail", "Prio2", "Title2", "Date2", "Time2", "Cat2")

;Closed Tasks

moai.DoMethod("tv", "insertleaf", 2 , "closed", "Tail", "Prio3", "Title3", "Date3", "Time3", "Cat3")
moai.DoMethod("tv", "insertleaf", 3 , "closed", "Tail", "Prio4", "Title4", "Date4", "Time4", "Cat4")


; main loop!
Repeat
	WaitEvent
Forever
Last edited by plouf on Sat Jun 03, 2023 6:43 pm, edited 1 time in total.
Christos
Yvan_Amiga
Posts: 10
Joined: Mon Mar 14, 2022 5:05 pm

Re: RapaGUI Treeview - Empty Leaf when inserting Leafs dynamically

Post by Yvan_Amiga »

Thank you Cristos

'tail' was the key. It's working now without empty leaf.

Here a Screenshot of what I developed so far. But I'm not finished. At the end it should be a tool in which you can keep track of your tasks. The tasks are saved in a SQLite DB file and the interface is done with RapaGUI. It's my first try at develpoing something this large and I thought Hollywood is a good choice to start.

Image

Screenshot doesn't seem to work with the img tag, here the URL to it.
https://drive.proton.me/urls/8DSD9JBBW0#gbXg6KgyM4Z4
Post Reply