Re: wxEuphoria: Progress Dialog for Non-Timer-Related Activity

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu