1. wxEuphoria: Progress Dialog for Non-Timer-Related Activity
- Posted by euphoric (admin) Aug 02, 2018
- 1033 views
There's a demo showing how to use a progress dialog with a timer, but I want to show a progress bar for processing files. I'm not sure how to go about doing that. Do I put the file processing code in the timer code?! That doesn't seem right.
How can I use it like this?
-- turn on progress dialog for t=1 to length(filesList) do -- update progress bar -- process the file end for -- dismiss progress dialog
2. Re: wxEuphoria: Progress Dialog for Non-Timer-Related Activity
- Posted by ghaberek (admin) Aug 02, 2018
- 1038 views
How can I use it like this?
Here you go:
include wxeu/wxeud.e constant NULL = 0, wxID_ANY = -1 constant Frame = create( wxFrame, {NULL,wxID_ANY,"Progress"} ), Panel = create( wxPanel, {Frame} ), Button = create( wxButton, {Panel,wxID_ANY,"Start"} ), $ procedure delay( atom duration ) atom target = time() + duration while time() < target do app_yield( wxTrue ) end while end procedure procedure Button_OnClick( atom this, atom event_type, atom id, atom event ) atom max_steps = 100 atom dialog = create( wxProgressDialog, {"Please wait...","Running (0%%)", max_steps,Frame,wxPD_AUTO_HIDE+wxPD_APP_MODAL+wxPD_CAN_ABORT} ) for i = 1 to max_steps do atom can_continue = progress_update( dialog, i, sprintf("Running (%d%%)",i) ) if not can_continue then atom response = message_box( "Are you sure you want to stop?", "Progress", wxICON_QUESTION+wxYES_NO ) if response = wxYES then exit end if progress_resume( dialog ) end if delay( 0.05 ) end for destroy( dialog ) end procedure procedure main() atom sizer = create( wxBoxSizer, {wxHORIZONTAL} ) space_sizer( sizer, 0, 0, 1, wxGROW, 0 ) add_window_to_sizer( sizer, Button, 0, wxALIGN_CENTER_VERTICAL, 0 ) space_sizer( sizer, 0, 0, 1, wxGROW, 0 ) set_sizer( Panel, sizer ) set_event_handler( Button, wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, routine_id("Button_OnClick") ) wxMain( Frame ) end procedure main()
-Greg
3. Re: wxEuphoria: Progress Dialog for Non-Timer-Related Activity
- Posted by euphoric (admin) Aug 02, 2018
- 1019 views
Looks like you didn't use show_modal(). Is that because of wxPD_AUTO_HIDE?
4. Re: wxEuphoria: Progress Dialog for Non-Timer-Related Activity
- Posted by euphoric (admin) Aug 02, 2018
- 1009 views
I guess I was doing some things right, but ultimately, setting an auto-close dialog of 100 to 100 makes it close, and it doesn't reopen...
I was doing several things that I wanted progress for, using the same dialog, but setting it to 100 for the first one (with a "Complete!" message), was closing it permanently... apparently.
Now, I only go to 99. Looks dumb, but it works.
I'm guessing I could remove the AUTO_HIDE and use end_modal() myself when I'm done with the dialog. I'm going to try it!
Not confident that will work. Waiting...
5. Re: wxEuphoria: Progress Dialog for Non-Timer-Related Activity
- Posted by ghaberek (admin) Aug 02, 2018
- 1010 views
I guess I was doing some things right, but ultimately, setting an auto-close dialog of 100 to 100 makes it close, and it doesn't reopen...
I was doing several things that I wanted progress for, using the same dialog, but setting it to 100 for the first one (with a "Complete!" message), was closing it permanently... apparently.
Now, I only go to 99. Looks dumb, but it works.
I'm guessing I could remove the AUTO_HIDE and use end_modal() myself when I'm done with the dialog. I'm going to try it!
Not confident that will work. Waiting...
You don't use wxProgressDialog like a normal control. I guess you could call it ephemeral. Make it, use it, destroy it. Rinse and repeat.
I guess what I should have done was wrap this in a series of functions instead of using the create() function...
atom dialog = progress_dialog( title, message, max_value, parent, ... ) for value = 1 to max_value do progress_update( dialog, value, message ) end for progress_destroy( dialog )
-Greg