1. EuGTK - List: View - click event
- Posted by Jerry_Story Sep 25, 2010
- 1447 views
lstDiet = List:View(lvDiet,{"food","amount","kitchen measure","nutrient"}) -- lstDiet has a list of foods in it: -- bananas ...... -- beets .... -- Romaine lettuce ...... -- tomato .... -- etc. .... -- etc. ..... -- Clicking on one of them causes this event to happen. -- This is how it is done in wxEuphoria. procedure onClick_lstDiet(atom this, atom event_type, atom id, atom event) -- bunch of code end procedure set_event_handler(lstDiet, get_id(lstDiet),wxEVT_COMMAND_LIST_ITEM_SELECTED,routine_id("onCLick_lstDiet" ))
How is it done in EuGTK?
2. Re: EuGTK - List: View - click event
- Posted by irv Sep 25, 2010
- 1480 views
Just connect the "row-activated" signal to your eu routine. This works on double-click - obviously, since a single click only selects a row. See demo below. But first: DOWNLOAD THE LATEST EuGTK 4.2.4! There are many improvements, including fixing one severe memory leak! Get it from wikispaces or my home page or SourceForge
include GtkEngine.e include std/machine.e include ListView.e as LV enum VEG, MG, SERV constant veg = { {"Asparagus, raw",23,8}, {"Beet greens, boiled",164,12}, {"Broccoli, raw",43,14}, {"Cabbage, boiled",36,6}, {"Chard, swiss, boiled",102,5}, {"Collards, boiled",266,4}, {"Onions, raw",37,10} } function Foo(atom view) sequence selected_food = get(view,"text",VEG) integer selected_serv = get(view,"value",SERV) printf(1,"The recommended serving for %s is %d oz.\n",{selected_food,selected_serv}) return 1 end function constant foo = call_back(routine_id("Foo")) object lv = LV:Iter(4) constant tv = LV:View(lv,{"Name","mg/oz","Serving (oz)"}) -- {column headings} set(tv,"reorderable",TRUE) set(tv,"rules hint",TRUE) -- shade alternate lines set(tv,"grid lines",GTK_TREE_VIEW_GRID_LINES_BOTH) set(tv,"enable search",TRUE) -- < optional, but real handy. try it, you'll like it > connect(tv,"row-activated",foo) -- < here > constant img = create(GtkImage,"/home/irv/demos/tiphat.gif") constant win = create(GtkWindow) connect(win,"destroy",quit) set(win,"modify bg",0,"lightgray") set(win,"border width",5) constant panel = create(GtkVBox) add(win,panel) add(panel,tv) object store = LV:Store({gSTR,gINT,gINT}) -- {column data types} set(tv,"model",store) for i = 1 to length(veg) do -- load the list store with data LV:Row(lv,store,veg[i]) end for setRow(2,1,store,"Arthritic Aardvaarks") -- row #, col #, store, value) show_all(win) main()
Note: You seldom want to trigger a list or tree view event from a single click. 1. It doesn't work the way people expect it to if you do that 2. It prevents you from setting up lists which allow multiple selections 3. It prevents the user from being able to drag & drop items within the list
3. Re: EuGTK - List: View - click event
- Posted by Jerry_Story Sep 25, 2010
- 1467 views
What happened to CreateLV in ListView.e?
4. Re: EuGTK - List: View - click event
- Posted by irv Sep 26, 2010
- 1464 views
What happened to CreateLV in ListView.e?
I changed it to Iter, since it didn't create a ListView at all, just an Iter and corresponding renderers. LV:View creates the view, LV:Store creates a store, etc.
I still want to find a way to encapsulate all of these calls into sort of a pseudo 'listview object', which will be able to keep track of all these things itself, without the programmer having to do it.
5. Re: EuGTK - List: View - click event
- Posted by irv Sep 26, 2010
- 1306 views
Jerry:
I have prepared a sample program which should give you a good start on DMAK with EuGTK. Download it from http://etcwebspace.com/users/irvm/irvstest.tar.gz
It's compiled and also has the source. Plus an updated set of Gtk*.e files.
6. Re: EuGTK - List: View - click event
- Posted by Jerry_Story Sep 27, 2010
- 1304 views
- Last edited Sep 26, 2010
Jerry:
I have prepared a sample program which should give you a good start on DMAK with EuGTK. Download it from http://etcwebspace.com/users/irvm/irvstest.tar.gz
It's compiled and also has the source. Plus an updated set of Gtk*.e files.
Thanks. I think I made enough progress that it looks like I might eventually get it done. If I counted right, I have 12 files nominally done (need more testing), 1 file in progress, 2 files that are not important and might be skipped because they use grid, and 2 files not yet worked on. I'm doing a line by line translation from wxEuphoria to EuGTK. Every once in a while I get snagged on something.
7. Re: EuGTK - List: View - click event
- Posted by irv Sep 27, 2010
- 1288 views
I'm doing a line by line translation from wxEuphoria to EuGTK.
I was afraid you were doing something like that. It will mean writing lots of extra code to try and emulate the way wxWindows works, when there are perhaps easier and more user-friendly ways directly available. Plus, you'll end up with a less than optimum result.
For instance 1: Colors - don't use 'em. A bad idea for more than one reason. for instance 2: Putting everything in one window. That's the Windows way, but that doesn't mean it's the best way. It's more polite to let the user decide how he wants to lay out, size, and view the information.
8. Re: EuGTK - List: View - click event
- Posted by Jerry_Story Sep 27, 2010
- 1223 views
I'm doing a line by line translation from wxEuphoria to EuGTK.
I was afraid you were doing something like that. It will mean writing lots of extra code to try and emulate the way wxWindows works, when there are perhaps easier and more user-friendly ways directly available. Plus, you'll end up with a less than optimum result.
For instance 1: Colors - don't use 'em. A bad idea for more than one reason. for instance 2: Putting everything in one window. That's the Windows way, but that doesn't mean it's the best way. It's more polite to let the user decide how he wants to lay out, size, and view the information.
I will drop color coding in the nutrients list and use prefixes instead, like I used "* " and "# " for foods. That's one less thing for me to figure out.
About multiple windows instead of all in one window. That will come under consideration after I get the program to work. Re-designing the program and learning EuGTK both at the same time is more than I can handle.
9. Re: EuGTK - List: View - click event
- Posted by irv Sep 27, 2010
- 1243 views
Well, when you're ready, load Glade and design the whole thing graphically. It's very easy, and you'll need only a handful of 'glue' code to make it all work.
The best part about doing things this way is you can run the program, then go back to glade and make changes or additions to the program, sometimes without even adding or changing a single line of Euphoria code!
Things like redesigning windows and dialogs, changing titles, adding tool tips, changing sizes of things, etc. etc. -- you can see and set all of the most common properties right there in the Glade Interface Designer. It's a lot like Judith's IDE, except you don't have to write code in it. You do that separately, and there's a lot less code to write!
10. Re: EuGTK - List: View - click event
- Posted by euphoric (admin) Sep 27, 2010
- 1252 views
lolz
irv, fyi, the double dash (--) causes strikethrough unless you put brackets around it {{{--}}}.