Show files in a lister from poppath

Discuss GUI programming with the RapaGUI plugin here
Post Reply
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Show files in a lister from poppath

Post by papiosaur »

Hello,

i would like to show file names from a poppath in a simple lister but I can't do it after several attempts.

Any help please? I don't find example into RapaGui doc.

Thanks!
User avatar
Redlion
Posts: 125
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: Show files in a lister from poppath

Post by Redlion »

@ papiosaur

Not sure but is this what you are after.

Code: Select all

/*** 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"

/*** setup GUI ************************************************************************************/
moai.CreateApp([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application>
    <window title="File Path Lister." id="window" width="600" height="400" notify="closerequest">
        <vgroup color="#607B99">
            <vgroup>
                <poppath title="Please select a drawer..." notify="path"/>
                <listview id="list" >
                    <column></column>                    
                </listview>
            </vgroup>
        </vgroup>
    </window>
</application>
]])

Function PopulateList(Dir$)
    OpenDirectory(1, Dir$)
    e = NextDirectoryEntry(1)
    While e <> Nil
        If e.type = #DOSTYPE_FILE
           moai.DoMethod("list", "Insert", "Bottom", e.name)
       EndIf
       e = NextDirectoryEntry(1)
    Wend
    CloseDirectory(1)

EndFunction

/*** Handles all incoming events ******************************************************************/
Function E_EventFunc(msg)
    Switch msg.action
        Case "RapaGUI":
            Switch msg.attribute
                Case "Path":
                    PopulateList(msg.triggervalue) 

                Case "CloseRequest"
                    End

        EndSwitch
    EndSwitch
EndFunction

/*** listen to these events **********************************************************************/
InstallEventHandler({RapaGUI = E_EventFunc})

/*** main loop **********************************************************************************/
Repeat
     WaitEvent
Forever
Edit; Opps pasted the wrong one fixed now.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Re: Show files in a lister from poppath

Post by papiosaur »

Thanks a lot Leo!!!

Work fine!!!

[EDIT] if i change text string i have an error... Error locking...
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Re: Show files in a lister from poppath

Post by papiosaur »

"Path" case is for "Poppath", no problem with that but how do if i have 2 poppath and 2 listers... (1 poppath for one lister of course)
User avatar
Redlion
Posts: 125
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: Show files in a lister from poppath

Post by Redlion »

Try this, it should be what you are after.

Code: Select all

/*** 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"

/*** setup GUI ************************************************************************************/
moai.CreateApp([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application>
    <window title="File Path Lister." id="window" width="600" height="400" notify="closerequest">
        <hgroup color="#607B99">
            <vgroup>
                <poppath id="pop1" title="Please select a drawer..." notify="path"/>
                <listview id="list1" >
                    <column></column>                    
                </listview>
            </vgroup>
            <vgroup>
                <poppath id="pop2" title="Please select a drawer..." notify="path"/>
                <listview id="list2" >
                    <column></column>                    
                </listview>
            </vgroup>
        </hgroup>
    </window>
</application>
]])

Function PopulateList(Dir$, List)
    OpenDirectory(1, Dir$)
    e = NextDirectoryEntry(1)
    While e <> Nil
        If e.type = #DOSTYPE_FILE
           moai.DoMethod("list" .. List, "Insert", "Bottom", e.name)
        EndIf
        e = NextDirectoryEntry(1)
    Wend
    CloseDirectory(1)
    moai.DoMethod("list" .. List, "jump", "bottom")
EndFunction

/*** Handles all incoming events ******************************************************************/
Function E_EventFunc(msg)
    Switch msg.action
        Case "RapaGUI":
            Switch msg.attribute
                Case "Path":
                    Switch msg.id
                        Case "pop1"
                            List = 1
                            PopulateList(msg.triggervalue, List) 

                        Case "pop2"
                            List = 2
                            PopulateList(msg.triggervalue, List)

                    EndSwitch

                Case "CloseRequest"
                    End

        EndSwitch

    EndSwitch
EndFunction

/*** listen to these events **********************************************************************/
InstallEventHandler({RapaGUI = E_EventFunc})

/*** main loop **********************************************************************************/
Repeat
     WaitEvent
Forever
Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Re: Show files in a lister from poppath

Post by papiosaur »

Thanks a lot leo!!! Work fine!!!

i understand better the "Case" now :-D

I have always Error locking... but i will try to that.
Post Reply