Re: EuGTK - Q: how to show a picture before main()
- Posted by jimcbrown (admin) Aug 07, 2010
- 1375 views
jimcbrown said...
Jerry_Story said...
jimcbrown said...
Without your full code, it's hard for me to say, but I'd guess where and how you call gtk_main() is an issue here.
The full relevant code is
include GtkEngine.e -- some code here global constant Win = create(GtkWindow) -- some code here constant splash = create(GtkWindow) -- some code here show_all(splash) -- This is supposed to show -before- the data is loaded. getUSDAdata() hide(splash) -- some code here show_all(Win) main() -- But this is where both splash and Win show, if I comment out hide.
Yep, after you call show_all(splash) (and before you call getUSDAdata() or hide(splash) ) you need to call the EuGTK version of this:
while (gtk_events_pending()) { gtk_main_iteration(); }
The GTK code in http://faq.pygtk.org/index.py?req=show&file=faq20.005.htp should show you exactly what you need to do.
I just tested the following code with EuGTK 4.1.5 and it seems to work. There's probably a more "correct" way of calling gtk_main_iteration() and gtk_events_pending() from EuGTK but I'll let Irv comment on that.
procedure getUSDAdata() integer k k = -1 while k = -1 do k = get_key() end while end procedure include GtkEngine.e include std/dll.e -- some code here global constant Win = create(GtkWindow) -- some code here constant splash = create(GtkWindow) -- some code here constant gtk_events_pending_ = define_c_func(GTK, "gtk_events_pending", {}, C_INT) constant gtk_main_iteration_ = define_c_proc(GTK, "gtk_main_iteration", {}) show_all(splash) -- This shows -before- the data is loaded. while c_func(gtk_events_pending_, {}) do c_proc(gtk_main_iteration_, {}) end while getUSDAdata() hide(splash) -- some code here show_all(Win) main()