WideStudio Programming Guide

| WideStudio Programming Guide | WideStudio Index Table of contents

> ## The list

> ### Setting of the items by the method

> Use addItem method to add items to the list with an string and position. If the position is omitted,add it to the last of the list. The following program is a sample adding item to the list.

>     #----------------------------------------------------------
>     #Function for the event procedure
>     #----------------------------------------------------------
>     import mpfc
>     import newwin000

>     def btnep1(object):
>       # Delete all the items of the list.
>       newwin000.newlist_001.delAll();
>       # Add an item to the last of the list.
>       newwin000.newlist_001.addItem("item1");
>       newwin000.newlist_001.addItem("item2");
>       newwin000.newlist_001.addItem("item3");
>       newwin000.newlist_001.addItem("item4");
>       # Add an item to the specified position of the list.
>       newwin000.newlist_001.addItem("item0",0);  # 0 :top
>       newwin000.newlist_001.addItem("item5",-1); # -1 :last

>       # Update the modified list.
>       newwin000.newlist_001.updateList();
>       return
>     mpfc.WSGFfunctionRegister("btnep1",btnep1)

> ### Setting of the items by the property

> the property WSNdata can be used for setting the items of the list, if it is a comparatively little number of the items. In such case, set the property "dataSource" to WS_DATA_SOURCE_NONE, and set the items which is punctuated with comma every one item to the property "data".

> ###

> ###

>     #----------------------------------------------------------
>     #Function for the event procedure
>     #----------------------------------------------------------
>     import mpfc
>     import newwin000

>     def btnep1(object):
>       # Delete all the items of the list.
>       newwin000.newlist_001.delAll();

>       # Set the items of the list by the property
>       newwin000.newlist_001.setProperty("dataSource",mpfc.WS_DATA_SOURCE_NONE);
>       newwin000.newlist_001.setProperty("data","item0\nitem1\nitem2\nitem3\nitem4");
>       return
>     mpfc.WSGFfunctionRegister("btnep1",btnep1)

>     It is possible to indicate the specified ICON by icon file name as following program.
>     Set True to the property "useIcon" and
>     Set the items as following format.
>     If it is omitted,the value of "iconPixmap" is used for default icon.

>       format:
>       ICON1filename,string1ofTheItem\n ICON2filename,string2ofTheItem\n...

>     #----------------------------------------------------------
>     #Function for the event procedure
>     #----------------------------------------------------------
>     import mpfc
>     import newwin000

>     def btnep1(object):
>       # Delete all the list of the listĄŁ
>       newwin000.newlist_001.delAll();

>       # Set the items of the list by the property
>       newwin000.newlist_001.setProperty("dataSource",mpfc.WS_DATA_SOURCE_NONE);
>       newwin000.newlist_001.setProperty("data",
>          "$(WSDIR)/sys/pixmaps/bi16.xpm,item1\nitem2\nitem3");
>       return
>     mpfc.WSGFfunctionRegister("btnep1",btnep1)

>        Setting of the items from the file directly
>     It is possible to set the items from the file directly.
>     In such case at first,set WS_DATA_SOURCE_FILE to the property WSNdataSource,
>     and set the file name to the property WSNdataSourceName as following program.

>     #----------------------------------------------------------
>     #Function for the event procedure
>     #----------------------------------------------------------
>     import mpfc
>     import newwin000

>     def btnep1(object):
>       # Delete all the items of the list
>       newwin000.newlist_001.delAll();

>       # Set the items from file directly
>       newwin000.newlist_001.setProperty("dataSource",mpfc.WS_DATA_SOURCE_FILE);
>       newwin000.newlist_001.setProperty("dataSourceName","data.txt");
>       return
>     mpfc.WSGFfunctionRegister("btnep1",btnep1)

>     # data.txt contains...
>     $(WSDIR)/sys/pixmaps/bi16.xpm,item1
>     item2
>     item3
>     item4
>     $(WSDIR)/sys/pixmaps/bi16.xpm,item5
>     item6
>     item7
>     item8

>        Setting of the items from the other instance

>     It is possible to set the items from the data source target property
>     of the other instances.
>     In such case, set WS_DATA_SOURCE_INSTANCE to the property "dataSource",
>     and set the instance name to the property "dataSourceName".
>     In the following example,
>     a WSCtextField instance are specified to the property "dataSourceName" and
>     then it sets the string data of it to the list.

>     #----------------------------------------------------------
>     #Function for the event procedure
>     #----------------------------------------------------------
>     import mpfc
>     import newwin000

>     def btnep1(object):
>       # Delete all the items of the list
>       newwin000.newlist_001.delAll();

>       # Set the items from the other instances
>       newwin000.newlist_001.setProperty("dataSource",mpfc.WS_DATA_SOURCE_INSTANCE);
>       newwin000.newlist_001.setProperty("dataSourceName","newtext_000");
>       return
>     mpfc.WSGFfunctionRegister("btnep1",btnep1)

>     The following picture indicates the list(lower side) from the other instance
>     of WSCtextField class( upper side).

>     [The list data from the other instance]

Document Release 3.70 for WideStudio ver 3.70, Feb 2004

WideStudio documents index | Table of contents

Copyright(C) T. Hirabayashi, 2000-2004 | Last modified: Feb 25, 2004