Re: Getting this to Work

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

Jason Gade wrote:
> 
> I've still got a demo of this if you want it... I don't know if you've added
> it to your wxEuphoria example programs or not.
> 

Cool.  Here's an update for v0.10.0 (you'll probably need the latest from
svn for this to work well at all).

without warning
include wxeud.e
global constant
main = create( wxFrame, {0, -1, "Download Demo", 0, 0, 419, 200,
wxDEFAULT_FRAME_STYLE }),
panel = create( wxPanel, main ),
file_label = create( wxStaticText, {panel, -1, "File name:", 13, 34, 116, 22 }),
file_name = create( wxTextCtrl, {panel, -1, "http://wxeuphoria.sourceforge.net",
135, 34, 300,  23 }),
download_button = create( wxButton, {panel, -1, "Download Now", 13, 126, 96, 30
}),
html_win = create( wxHtmlWindow, {panel, -1}),
status_bar = create( wxStatusBar, {main}),
vsizer = create( wxBoxSizer, wxVERTICAL ),
hsizer = create( wxBoxSizer, wxHORIZONTAL)

add_window_to_sizer( hsizer, file_label, 0, 0, 0 )
add_window_to_sizer( hsizer, file_name, 1, 0, 0 )
add_sizer_to_sizer ( vsizer, hsizer, 0, wxGROW + wxTOP + wxLEFT, 10 )
add_window_to_sizer( vsizer, download_button, 0, 0, 0 )
add_window_to_sizer( vsizer, html_win, 1, wxGROW, 0 )
set_sizer( panel, vsizer )

set_related_frame( html_win, main, "%s", 0 )

procedure on_click( atom this, atom event_type, atom id, atom event )
    atom wxurl, stream
    integer fn, ix
    sequence url, current, path
    url = get_text_value( file_name )
    path = reverse( url )
    ix = find( '/', path )
    if ix then
        path = reverse( path[1..ix-1] )
    
    else
        path = reverse( path )      
    end if
    
    wxurl = create( wxURL, {url} )
    stream = get_url_input( wxurl )
    if stream then
    	set_html_page( html_win, stream_read( stream ) )
    else
        puts(2, "Stream failed!\n")
    end if
    delete_instance( wxurl )
     
    
end procedure
set_event_handler( download_button, -1, wxEVT_COMMAND_BUTTON_CLICKED,
routine_id("on_click"))

wxMain( main )


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

Search



Quick Links

User menu

Not signed in.

Misc Menu