FLTK logo

[fltk.general] Re: Use worker thread to call Fl_Window and Fl_run

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Use worker thread to call Fl_Window and Fl_run "anmol.... Sep 30, 2020  
 
Alternatively is there a non-blocking Fl::run() - basically I do not want my main thread to block.
So perhaps I can start the window() and run() and return immediately so the GUI does not block
till the window is closed.

On Wednesday, September 30, 2020 at 10:19:43 PM UTC+5:30 anmol....@gmail.com wrote:
Hi. I want to create a simple progress bar, and do not need any user input. I cannot block my main app as it already has its own GUI.
What will happen if I use the following from a worker thread ?

Fl_Window win(220,90);
win.begin(); // add progress bar to it..
Fl_Progress *progress = new Fl_Progress(10,50,200,30);
progress->minimum(0); // set progress range to be 0.0 ~ 1.0
progress->maximum(1);
progress->color(0x88888800); // background color
progress->selection_color(0x4444ff00); // progress bar color
progress->labelcolor(FL_WHITE); // percent text color 50 
win.end();
win.show();
Fl::run();

And I update it from main thread.
progress->value(t/500.0); 
progress->label(percent); // update progress bar's label
Fl::check();

I read the docs, and its clear that the main thread owns the window, but if I dont care about user input, is there any harm in this ?

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/8af1263f-13a7-4b7c-b5e1-9ce526a9f711n%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.