1. Tree using wxEuphoria
- Posted by EUWX Mar 20, 2012
- 2148 views
I changed my focus to working with the tree control in wxEuphoria (instead of Menu control).
Actually it gives me the change in fonts (at each menu or tree item) and also a vertical rather than horizontal access to the "menu". However, I am at a loss as to the use of events in a tree.
There is only one demo regarding trees. In that demo (tree_list_demo.exw), I was not able to understand the use of
void = add_tree_item( tree, items[i][2][j][1], nums[k], rand_image(), rand_image())
at the third level and got lost trying to keep tabs on the multi dimentional sequence "items". There is also no demo of event handling.
If someone can post a couple of examples of event handling in a tree, I will be able to get further along. I am going to four levels of "menu" as a tree structure. Also some explanation of the sequence "items" as it gets built and expanded..... please.
Thanks in advance.
2. Re: Tree using wxEuphoria
- Posted by EUWX Mar 23, 2012
- 2068 views
I thought it was simple request, but after 74 views there is no answer. Perhaps I ought to change to Linux as there seems to be more support for it here.
Could anybody please direct me to which version of linux I should install to get going fast with Euphoria and wxEuphoria and cross the hurdle?
I just want to get going further with using Tree control in wxEuphoria.
3. Re: Tree using wxEuphoria
- Posted by mattlewis (admin) Mar 24, 2012
- 1996 views
I thought it was simple request, but after 74 views there is no answer. Perhaps I ought to change to Linux as there seems to be more support for it here.
Could anybody please direct me to which version of linux I should install to get going fast with Euphoria and wxEuphoria and cross the hurdle?
I just want to get going further with using Tree control in wxEuphoria.
Sorry, I'd been meaning to reply to you...
Try putting the following event handler into the tree_list_demo.exw demo:
procedure on_right_click(atom this, atom event_type, atom id, atom event ) atom item = get_tree_event_item( event ) message_box( get_tree_text( tree, item ), "right click", wxOK ) end procedure set_event_handler( tree, -1, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, routine_id("on_right_click") )
It pops up a message box when you right click on one of the tree items.
Matt
4. Re: Tree using wxEuphoria
- Posted by EUWX Mar 24, 2012
- 1992 views
Thanks a lot.
Will try and get back.
5. Re: Tree using wxEuphoria
- Posted by EUWX Mar 24, 2012
- 1971 views
The event handler you suggested works well as described.
I have still not understood
1. The sequence "items"
2. The "void" in the following line, although I have copied and modified it:
void = add_tree_item( tree, items[i][2][j][1], nums3[i][j][k], qimg2,qimg2)
3. I have failed to decipher exact structure of the sequence "items", to make it more meaningful in my modified demo as follows:-
-- #!/home/matt/euphoria/bin/exu -- tree-demo-modified.exw -- wxEuphoria tree control demo modified -- To demonstrate, open out the tree to any extent, and right click on any of the items. -- We start with the required includes include std/text.e include wxeu/wxeud.e include tbar_xpm.e without warning object void -- Create the main window global constant main = create( wxFrame, {0, -1, "wxTreeCtrl and wxListCtrl Demo" }), win = create( wxPanel, main ), tree = create( wxTreeCtrl, win), list = create( wxListCtrl, win), $ -- Create the image list global constant ilist = create( wxImageList, {24, 24, 1, 0}), Bitmap1 = create( wxBitmap, {BM_XPM, copy_xpm}), Bitmap2 = create( wxBitmap, {BM_XPM, paste_xpm}), Bitmap3 = create( wxBitmap, {BM_XPM, ok_xpm}), Bitmap4 = create( wxBitmap, {BM_XPM, left_arrow_xpm}), Bitmap5 = create( wxBitmap, {BM_XPM, right_arrow_xpm}), i1 = add_image( ilist, Bitmap1, 0 ), i2 = add_image( ilist, Bitmap2, 0 ), i3 = add_image( ilist, Bitmap3, 0 ), i4 = add_image( ilist, Bitmap4, 0 ), i5 = add_image( ilist, Bitmap5, 0 ), images = {i1, i2, i3, i4, i5}, $ -- Execute the procedure setup setup() -- The functions and procedures used above function rand_image() integer i i = rand(4) + 1 return images[i] end function procedure setup() atom root, parent, hsizer, qimg1, qimg2, qimg3 sequence nums,nums2, items, nums3A,nums3B, nums3C,nums3 -- assign an imagelist to the tree tree_imagelist( tree, ilist ) -- The variables nums, nums2, and nums3 can be changed to suit your needs nums = { "one", "two", "three" } nums2 = { { "One-Sub", "Two-Sub", "Three-Sub" }, { "Four-Sub", "Five-Sub", "Six-Sub" }, { "Seven-Sub", "Eight-Sub", "Nine-Sub" } } nums3A = { { "ABC1", "BCD1", "DEF1" }, { "EFG1", "FGH1", "GHI1" }, { "HIJ1", "IJK1", "JKL1" } } nums3B = { { "ABC2", "BCD2", "DEF2" }, { "EFG2", "FGH2", "GHI2" }, { "HIJ2", "IJK2", "JKL2" } } nums3C = { { "ABC3", "BCD3", "DEF3" }, { "EFG3", "FGH3", "GHI3" }, { "HIJ3", "IJK3", "JKL3" } } nums3 = {nums3A,nums3B,nums3C} -- add the root item qimg1 = images[5] qimg2 = images[4] root = add_tree_root( tree, "Demo", qimg1, qimg1) -- add three layers of children to the tree items = repeat({0, repeat( {0, { 0, repeat( 0, 3 ) }}, 3 )}, 3) for i = 1 to 3 do items[i][1] = add_tree_item( tree, root, nums[i], qimg1,qimg1) for j = 1 to 3 do items[i][2][j][1] = add_tree_item( tree, items[i][1], nums2[i][j] , qimg1,qimg1) for k = 1 to 3 do void = add_tree_item( tree, items[i][2][j][1], nums3[i][j][k], qimg2,qimg2) end for end for end for -- add two columns to the list void = insert_list_column( list, 0, "Numbers", 0, -1 ) void = insert_list_column( list, 1, "#", 0, -1 ) -- assign the image list to the list list_imagelist( list, ilist, wxIMAGE_LIST_SMALL ) -- add three items to the list with text in each column for i = 1 to 3 do void = insert_listctrl_item( list, i-1, {nums[i], sprint(i)}, rand_image()) end for void = insert_listctrl_item( list, 3, {"Four", sprint(4)}, -1) -- put the controls into sizers hsizer = create( wxBoxSizer, wxHORIZONTAL ) add_window_to_sizer( hsizer, tree, 1, wxGROW, 0 ) add_window_to_sizer( hsizer, list, 1, wxGROW, 0 ) set_sizer( win, hsizer ) end procedure -- procedures for all event handlers here. -- keep the procedure and event handler together. procedure on_right_click(atom this, atom event_type, atom id, atom event ) atom item = get_tree_event_item( event ) -- Show the right clicked item message_box( get_tree_text( tree, item ), "right click", wxOK ) end procedure set_event_handler( tree, -1, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, routine_id("on_right_click") ) -- draw and show the window wxMain( main )
Thanks again. I am using Win XP Pro with SP2
and Euphoria 4.0.3 wxEuphoria ver 16
6. Re: Tree using wxEuphoria
- Posted by mattlewis (admin) Mar 24, 2012
- 2004 views
The event handler you suggested works well as described.
I have still not understood
1. The sequence "items"
2. The "void" in the following line, although I have copied and modified it:
void = add_tree_item( tree, items[i][2][j][1], nums3[i][j][k], qimg2,qimg2)
If you look at the tree, you'll see it's structured (partially opened) like:
- Demo + one | + One-Sub | | + ABC1 | | + BCD1 | | + DEF1 | + Two-sub | | + EFG1 | | + FGH1 | | + GHI1 | + Three-Sub + two + three
The structure of the sequences mirrors the structure of the tree. It stores the ids of the tree items, which were returned from add_tree_item(). So it would look something like:
{ DEMO, { one, { One-Sub, Two-Sub, Three-Sub } }, { two, { ... } }, { three, { ... } } }
Matt
7. Re: Tree using wxEuphoria
- Posted by EUWX Mar 24, 2012
- 2005 views
Thanks again.
I will ask later if I have more questions.
8. Re: Tree using wxEuphoria
- Posted by gbonvehi Mar 24, 2012
- 2056 views
The void is a global variable used to store results which are not needed, that's why it doesn't use it later.
Basically when you build a tree, you need a reference to each node on the tree to work on it later.
If you see in the code, the first added node is stored as root.
Then each subitem of root, is saved inside items so they can later be referenced to add more subnodes to them.
Some pseudocode:
root = add_tree_root() -- This will act as the holder of all my items subitem1 = add_tree_item(root) -- Add an item to root, and save this id as subitem1 subitem2 = add_tree_item(root) -- Add an item to root, and save this id as subitem2 subitem1_1 = add_tree_item(subitem1) -- Add an item to subitem1
This is done on the example using the sequence called items instead of individual variables.
Cheers,
Guillermo
PS: I downloaded wxEuphoria and added a handler to test and works great, I got the info from here: http://wxeuphoria.sourceforge.net/sfdocs/EVENT.html
It will popup after selecting an item from the treeview
procedure on_sel_changed(atom this, atom event_type, atom id, atom event ) atom item = get_tree_event_item( event ) message_box( get_tree_text( tree, item ), "on_sel_changed", wxOK ) end procedure set_event_handler( tree, -1, wxEVT_COMMAND_TREE_SEL_CHANGED, routine_id("on_sel_changed") )
9. Re: Tree using wxEuphoria
- Posted by EUWX Mar 26, 2012
- 1870 views
The void is a global variable used to store results which are not needed, that's why it doesn't use it later.
.........
This is done on the example using the sequence called items instead of individual variables.
I appreciate your and Matt Lewis' response and explanation.
I understand the need for storing the node items in the variable "item".
I don't understand why the last level of items are not stored and are in fact, "voided".
If I wanted to store them, I presume I would have to make another empty variable, otherwise the sequence might become unwieldy.
Referring still to the demo program, I was also initially confused about the use of value 0 in the sequence "item". I am used to (in other languages) creating an appropriate literal or numeric variable for storage, but I presume although the demo is using 0, it is actually storing the text items and not their 32 bit pointers - Am I right in this presumption?
Going back to my earlier request re Linux, I would still like to work simultaneously in Linux. I noticed that the latest Ubuntu, Edubuntu, Versions 11 and 12 can be used off a CD/DVD, and I have installed on my computer a freeware program (by Gizmo) that allows a portion of hard drive to be seen as a CD/DVD with a separate drive letter. In fact I can have 4 or more virtual CD/DVDs to speed up the CD/DVD access. I would like to know which Linux version would be easiest to use with wxEuphoria and a URL to instructions for Euphoria and wxEuphoria on your favourite Linux distro.
10. Re: Tree using wxEuphoria
- Posted by mattlewis (admin) Mar 26, 2012
- 1872 views
The void is a global variable used to store results which are not needed, that's why it doesn't use it later.
.........
This is done on the example using the sequence called items instead of individual variables.
I appreciate your and Matt Lewis' response and explanation.
I understand the need for storing the node items in the variable "item".
I don't understand why the last level of items are not stored and are in fact, "voided".
I don't really recall, but knowing me, I got lazy or something and didn't bother storing them. Or maybe I added that extra layer later on, and didn't bother.
If I wanted to store them, I presume I would have to make another empty variable, otherwise the sequence might become unwieldy.
Yep, up to you.
Referring still to the demo program, I was also initially confused about the use of value 0 in the sequence "item". I am used to (in other languages) creating an appropriate literal or numeric variable for storage, but I presume although the demo is using 0, it is actually storing the text items and not their 32 bit pointers - Am I right in this presumption?
You mean the way that item is initialized? 0 was used just as a placeholder to create the sequence. That gets replaced with the wxTreeItem ids. IIRC, they're not really pointers.
Going back to my earlier request re Linux, I would still like to work simultaneously in Linux. I noticed that the latest Ubuntu, Edubuntu, Versions 11 and 12 can be used off a CD/DVD, and I have installed on my computer a freeware program (by Gizmo) that allows a portion of hard drive to be seen as a CD/DVD with a separate drive letter. In fact I can have 4 or more virtual CD/DVDs to speed up the CD/DVD access. I would like to know which Linux version would be easiest to use with wxEuphoria and a URL to instructions for Euphoria and wxEuphoria on your favourite Linux distro.
I tend to use Kubuntu. So, really, any Ubuntu variant should allow you to use the binaries that I've built and posted, though it's generally pretty easy to build them on Linux.
Matt
11. Re: Tree using wxEuphoria
- Posted by EUWX Mar 26, 2012
- 1845 views
I don't really recall, but knowing me, I got lazy or something and didn't bother storing them. Or maybe I added that extra layer later on, and didn't bother.
OMG.... Matt and Lazy .... Two words that cannot co-exist.
BTW, I have read many posts in many threads, and somehow the "lazy" Matt is often there.
Yep, up to you. (re creating a separate sequence)
I probably will.
You mean the way that item is initialized? 0 was used just as a placeholder to create the sequence. That gets replaced with the wxTreeItem ids. IIRC, they're not really pointers.
They must be integer values of ids. From the values, would there be a way of idetifying and relating them with the corresponding text item?
I tend to use Kubuntu. So, really, any Ubuntu variant should allow you to use the binaries that I've built and posted, though it's generally pretty easy to build them on Linux.
Matt
Considering Kubuntu uses KDE and Ubuntu uses Gnome and something called Unity, also considering that wxEuphoria is essentially graphical in nature, I will be inclined to use Kubuntu. What is working NOW is what counts.
It also can be downloaded as disk image and hopefully be used under Windows XP as a virtual CD/DVD.
Thanks for your continuing help.
12. Re: Tree using wxEuphoria
- Posted by mattlewis (admin) Mar 26, 2012
- 1859 views
You mean the way that item is initialized? 0 was used just as a placeholder to create the sequence. That gets replaced with the wxTreeItem ids. IIRC, they're not really pointers.
They must be integer values of ids. From the values, would there be a way of idetifying and relating them with the corresponding text item?
Yes, take a look at the event handler I posted before:
procedure on_right_click(atom this, atom event_type, atom id, atom event ) atom item = get_tree_event_item( event ) message_box( get_tree_text( tree, item ), "right click", wxOK ) end procedure
The call to get_tree_text() fetches the text of the item.
Considering Kubuntu uses KDE and Ubuntu uses Gnome and something called Unity, also considering that wxEuphoria is essentially graphical in nature, I will be inclined to use Kubuntu. What is working NOW is what counts.
It also can be downloaded as disk image and hopefully be used under Windows XP as a virtual CD/DVD.
In fact, wxWidgets is slightly more at home on Ubuntu, since Gnome and wxWidgets both use GTK. It still works fine on KDE, though. I just personally prefer KDE.
Matt
13. Re: Tree using wxEuphoria
- Posted by EUWX Mar 26, 2012
- 1799 views
Your comments noted and appreciated.
Now I have to go and wrestle with a monster called Linux flanked by
ubuntu, kubuntu, lubuntu, xubuntu, edubuntu, debian, opensuse, and many more.
Wish me luck.
14. Re: Tree using wxEuphoria
- Posted by gbonvehi Mar 27, 2012
- 1806 views
Considering Kubuntu uses KDE and Ubuntu uses Gnome and something called Unity, also considering that wxEuphoria is essentially graphical in nature, I will be inclined to use Kubuntu. What is working NOW is what counts.
It also can be downloaded as disk image and hopefully be used under Windows XP as a virtual CD/DVD.
Thanks for your continuing help.
If your machine has enough RAM you could create a virtual machine and install Kubuntu there. VirtualBox is a great software that allows you to do this and it's free: http://www.virtualbox.org
Cheers, Guillermo
15. Re: Tree using wxEuphoria
- Posted by EUWX Mar 27, 2012
- 1777 views
If your machine has enough RAM you could create a virtual machine and install Kubuntu there. VirtualBox is a great software that allows you to do this and it's free: http://www.virtualbox.org
I have AMD Anthalon 64bit CPU with 4GB memory with a XP Pro 32bit on a part of HD and XP Pro 64bit on another partition. I am told that if I install Linux in yet another partition, Linux partition manager will take over, and I would hate to give control of my partitions to a foreigner.
4GB memory should be plenty for running VirtualBox. However, I am not so sure about complexity and speed under VirtualBox as opposed to running a Ubuntu version directly in a virtual RAM CD, at least initially. My intention is to develop under wxEuphoria and Windows which I am comfortable with, but off and on test under Linux to maintain compatibility all along. My escapade into Linux is strictly for one purpose only.
16. Re: Tree using wxEuphoria
- Posted by mattlewis (admin) Mar 27, 2012
- 1786 views
I have AMD Anthalon 64bit CPU with 4GB memory with a XP Pro 32bit on a part of HD and XP Pro 64bit on another partition. I am told that if I install Linux in yet another partition, Linux partition manager will take over, and I would hate to give control of my partitions to a foreigner.
I'm not sure what that person meant, unless he thought that you were a foreigner, at which point, they already are!
Possibly, he meant that when you boot up, you'd probably see GRUB (Grand Unified Boot Loader) which would offer you the choice of which partition / OS to boot. Basically, whatever Windows does to handle this situation, it will not work with Linux (or anything else). GRUB allows you to boot into any. My current machine has Win7 64-bit on one partition and Kubuntu 11.10 64-bit on another.
4GB memory should be plenty for running VirtualBox. However, I am not so sure about complexity and speed under VirtualBox as opposed to running a Ubuntu version directly in a virtual RAM CD, at least initially. My intention is to develop under wxEuphoria and Windows which I am comfortable with, but off and on test under Linux to maintain compatibility all along. My escapade into Linux is strictly for one purpose only.
For most things, it would likely be faster than running a live CD, since loading stuff from the CD will be a lot slower than from hard disk, even using whatever sort of virtual filesystem VirtualBox uses.
I use VMWare for virtualization, which is also free, and works very well. In fact, you can download VMWare appliances that are all set up for you to use under VMWare (the free Player is what I generally use).
I suspect that virtualization is probably the way to go for you here, whichever virtualization app you pick.
Matt
17. Re: Tree using wxEuphoria
- Posted by gbonvehi Mar 27, 2012
- 1772 views
I have AMD Anthalon 64bit CPU with 4GB memory with a XP Pro 32bit on a part of HD and XP Pro 64bit on another partition. I am told that if I install Linux in yet another partition, Linux partition manager will take over, and I would hate to give control of my partitions to a foreigner.
4GB memory should be plenty for running VirtualBox. However, I am not so sure about complexity and speed under VirtualBox as opposed to running a Ubuntu version directly in a virtual RAM CD, at least initially. My intention is to develop under wxEuphoria and Windows which I am comfortable with, but off and on test under Linux to maintain compatibility all along. My escapade into Linux is strictly for one purpose only.
Yes, Windows's boot manager doesn't allow other systems while with GRUB or Lilo (the ones most Linux distro uses) you can choose any OS.
4GB is really fine, you could easily give 2GB to the VM. It won't, of course, be as fast as running it from a Virtual RAM CD as I think your processor does not have emulation extensions. The advantage of the VM is that you really have all inside an emulated machine, all the things you do are "contained" there, you can take a snapshot of the VM, make a mess, and rollback to it.
Here are some Kubuntu VM images you can directly download and start using them: http://virtualboxes.org/images/kubuntu/
Both alternatives should work fine for you.
18. Re: Tree using wxEuphoria
- Posted by EUWX Mar 27, 2012
- 1775 views
Yes, Windows's boot manager doesn't allow other systems while with GRUB or Lilo (the ones most Linux distro uses) you can choose any OS.
I do play around (and like it) with boot.ini in XP Pro. So I will leave the current Boot options (of Win Pro 32 and Win Pro 64) as is and use Gizmo to give me 3-4 Virtual DVD drives with all the flavours of Ubuntus. Grub might be too grubby for me and my wife may not like to see me dancing with Lilo, because she only knows Windows and has never heard of Linux and Lilo.
4GB is really fine, you could easily give 2GB to the VM. It won't, of course, be as fast as running it from a Virtual RAM CD as I think your processor does not have emulation extensions. The advantage of the VM is that you really have all inside an emulated machine, all the things you do are "contained" there, you can take a snapshot of the VM, make a mess, and rollback to it.
Here are some Kubuntu VM images you can directly download and start using them:
http://virtualboxes.org/images/kubuntu/
Both alternatives should work fine for you.
I have a 1.5TB drive currently as the 2nd hard drive, with three partitions. I am using it for storage of downloads and backups and emails in last 2 partitions, and the first partition has a reasonably current Windows 7 installed, which I rarely use. I will put VirtualBox on this drive and use the Kubuntu there under VM. I can (during initial boot) change drive priorities to boot into Windows 7 and thence to Virtual box and Kubuntu for testing under cirucmstances similar to yours. Even if I mess up there, I don't mind reformatting the Windows 7 partition of the large drive and installing Win 7 again.
My main drive (250GB) has a simultaneous backup into the large drive and selective backup into the cloud. My large drive has a backup in the form of multiple DVDs and also some in the cloud.
I downloaded the several 4.0.3 versions for Linux at Sourceforge and I presume the .deb are the ones for use under Kubuntu.
I am totally new to the Linux world, and if there exist instructions on loading Euphoria etc under Kubuntu, I would like to have that URL before I start.
Thanks for all your responses including Matt Lewis' repsonses.