Class: Wx::FileDialog

Inherits:
Dialog show all
Defined in:
lib/wx/doc/gen/file_dialog.rb

Overview

This class represents the file chooser dialog.

The path and filename are distinct elements of a full file pathname. If path is EmptyString, the current directory will be used. If filename is EmptyString, no default filename will be supplied. The wildcard determines what files are displayed in the file selector, and file extension supplies a type extension for the required filename. The typical usage for the open file dialog is:

class MyFrame
  ...
  def on_open(event)
    if (...current content has not been saved...)
      if Wx.message_box('Current content has not been saved! Proceed?', 'Please confirm',
                        Wx::ICON_QUESTION | Wx::YES_NO, self) == Wx::NO
        return 
      #else: proceed asking to the user the new file to open
      end
    end
  
    Wx::FileDialog(self, "Open XYZ file", "", "",
                        "XYZ files (*.xyz)|*.xyz", Wx::FD_OPEN|Wx::FD_FILE_MUST_EXIST) do |dlg|
      return if dlg.show_modal == Wx::ID_CANCEL # the user changed idea...?

      # proceed loading the file chosen by the user
      file = File.open(dlg.path, 'r') rescue nil
      unless file
         Wx.log_error("Cannot open file '#{dlg.path}'.")
         return
      end
      ...
    end
  end

end

The typical usage for the save file dialog is instead somewhat simpler:

class MyFrame
  ...
  def on_save_as(event)
    Wx::FileDialog(self, "Save XYZ file", "", "",
                        "XYZ files (*.xyz)|*.xyz", Wx::FD_SAVE|Wx::FD_OVERWRITE_PROMPT) do |dlg|
      return if dlg.show_modal == Wx::ID_CANCEL # the user changed idea...?
  
      # save the current contents in the file
      begin
        File.open(dlg.path, 'w+') do |f|
          # save to file
        end
      rescue 
        Wx.log_error("Cannot save current contents in file '#{dlg.path}'.")
        return
      end
    end
    ...
  end

end

Wildcard Filters

All implementations of the FileDialog provide a wildcard filter. Typing a filename containing wildcards (*, ?) in the filename text item, and clicking on Ok, will result in only those files matching the pattern being displayed. The wildcard may be a specification for multiple types of file with a description for each, such as:

"BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png"

On Mac macOS in the open file dialog the filter choice box is not shown by default. Instead all given wildcards are applied at the same time: So in the above example all bmp, gif and png files are displayed. To enforce the display of the filter choice set the corresponding SystemOptions before calling the file open dialog:

Wx::SystemOptions.set_option(Wx::OSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1)

But in contrast to Windows and Unix, where the file type choice filters only the selected files, on Mac macOS even in this case the dialog shows all files matching all file types. The files which does not match the currently selected file type are greyed out and are not selectable.

Dialog Customization

Uniquely among the other standard dialogs, FileDialog can be customized by adding extra controls to it. Moreover, there are two ways to do it: the first one is to define a callback function and use set_extra_control_creator to tell the dialog to call it, while the second one requires defining a class inheriting from FileDialogCustomizeHook and implementing its virtual functions, notably Wx::FileDialogCustomizeHook#add_custom_controls where the extra controls have to be created, and finally calling #set_customize_hook with this custom hook object. The first approach is somewhat simpler and more flexible, as it allows to create any kind of custom controls, but is not supported by the “new style” (where “new” means used since Windows Vista, i.e. circa 2007) file dialogs under MSW. Because of this, calling set_extra_control_creator in WXMSW forces the use of old style (Windows XP) dialogs, that may look out of place. The second approach is implemented by the MSW dialogs natively and doesn’t suffer from this limitation, so its use is recommended, especially if the few simple control types supported by it (see FileDialogCustomize for more information about the supported controls) are sufficient for your needs. Both of the approaches to the dialog customization are demonstrated in the Dialogs Sample, please check it for more details.

Note:

New style file dialogs can only be used in WXMSW when the apartment, COM threading model is used. This is the case by default, but if the application initializes COM on its own using multi-threaded model, old style dialogs are used, at least when they must have a parent, as the new style dialog doesn't support this threading model.

Styles

This class supports the following styles:

  • FD_DEFAULT_STYLE: Equivalent to FD_OPEN.

  • FD_OPEN: This is an open dialog; usually this means that the default button's label of the dialog is "Open". Cannot be combined with FD_SAVE.

  • FD_SAVE: This is a save dialog; usually this means that the default button's label of the dialog is "Save". Cannot be combined with FD_OPEN.

  • FD_OVERWRITE_PROMPT: For save dialog only: prompt for a confirmation if a file will be overwritten. This style is always enabled on WXOSX and cannot be disabled.

  • FD_NO_FOLLOW: Directs the dialog to return the path and file name of the selected shortcut file, not its target as it does by default. Currently this flag is only implemented in WXMSW and WXOSX (where it prevents aliases from being resolved). The non-dereferenced link path is always returned, even without this flag, under Unix and so using it there doesn't do anything. This flag was added in wxWidgets 3.1.0.

  • FD_FILE_MUST_EXIST: For open dialog only: the user may only select files that actually exist. Notice that under macOS the file dialog with FD_OPEN style always behaves as if this style was specified, because it is impossible to choose a file that doesn't exist from a standard macOS file dialog.

  • FD_MULTIPLE: For open dialog only: allows selecting multiple files.

  • FD_CHANGE_DIR: Change the current working directory (when the dialog is dismissed) to the directory where the file(s) chosen by the user are.

  • FD_PREVIEW: Show the preview of the selected files (currently only supported by WXGTK).

  • FD_SHOW_HIDDEN: Show hidden files. This flag was added in wxWidgets 3.1.3

Category: Common Dialogs

See Also:

Requires:

  • USE_FILEDLG

Instance Method Summary collapse

Methods inherited from Dialog

#add_main_button_id, #can_do_layout_adaptation, #centre, #create, #create_button_sizer, #create_separated_button_sizer, #create_separated_sizer, #create_std_dialog_button_sizer, #create_text_sizer, #do_layout_adaptation, enable_layout_adaptation, #end_modal, #get_affirmative_id, #get_escape_id, #get_layout_adaptation_done, #get_layout_adaptation_level, #get_layout_adaptation_mode, get_layout_adapter, #get_main_button_ids, #get_return_code, #iconize, #is_iconized, is_layout_adaptation_enabled, #is_main_button_id, #is_modal, #set_affirmative_id, #set_escape_id, #set_icon, #set_icons, #set_layout_adaptation_done, #set_layout_adaptation_level, #set_layout_adaptation_mode, set_layout_adapter, #set_return_code, #show, #show_window_modal

Methods inherited from TopLevelWindow

#can_set_transparent, #center_on_screen, #centre_on_screen, #create, #create_persistent_object, #enable_close_button, #enable_full_screen_view, #enable_maximize_button, #enable_minimize_button, #get_content_protection, #get_default_item, get_default_size, #get_icon, #get_icons, #get_title, #get_tmp_default_item, #iconize, #is_active, #is_always_maximized, #is_full_screen, #is_iconized, #is_maximized, #layout, #maximize, #msw_get_system_menu, #osx_is_modified, #osx_set_modified, #request_user_attention, #restore, #set_content_protection, #set_default_item, #set_icon, #set_icons, #set_max_size, #set_min_size, #set_represented_filename, #set_size_hints, #set_title, #set_tmp_default_item, #set_transparent, #should_prevent_app_exit, #show_full_screen, #show_without_activating

Methods inherited from NonOwnedWindow

#set_shape

Methods inherited from Window

#accepts_focus, #accepts_focus_from_keyboard, #accepts_focus_recursively, #add_child, #adjust_for_layout_direction, #always_show_scrollbars, #begin_repositioning_children, #cache_best_size, #can_accept_focus, #can_accept_focus_from_keyboard, #can_scroll, #can_set_transparent, #capture_mouse, #center, #center_on_parent, #centre, #centre_on_parent, #clear_background, #client_to_screen, #client_to_window_size, #close, #convert_dialog_to_pixels, #convert_pixels_to_dialog, #create, #destroy, #destroy_children, #disable, #disable_focus_from_keyboard, #do_update_window_ui, #drag_accept_files, #each_child, #enable, #enable_touch_events, #enable_visible_focus, #end_repositioning_children, find_focus, #find_window_by_id, find_window_by_id, #find_window_by_label, find_window_by_label, #find_window_by_name, find_window_by_name, #fit, #fit_inside, #freeze, #from_dip, from_dip, #from_phys, from_phys, #get_accelerator_table, #get_auto_layout, #get_background_colour, #get_background_style, #get_best_height, #get_best_size, #get_best_virtual_size, #get_best_width, #get_border, get_capture, #get_caret, #get_char_height, #get_char_width, #get_children, get_class_default_attributes, #get_client_area_origin, #get_client_rect, #get_client_size, #get_containing_sizer, #get_content_scale_factor, #get_cursor, #get_default_attributes, #get_dpi, #get_dpi_scale_factor, #get_drop_target, #get_effective_min_size, #get_event_handler, #get_extra_style, #get_font, #get_foreground_colour, #get_grand_parent, #get_help_text, #get_help_text_at_point, #get_id, #get_label, #get_layout_direction, #get_max_client_size, #get_max_height, #get_max_size, #get_max_width, #get_min_client_size, #get_min_height, #get_min_size, #get_min_width, #get_name, #get_next_sibling, #get_parent, #get_popup_menu_selection_from_user, #get_position, #get_prev_sibling, #get_rect, #get_screen_position, #get_screen_rect, #get_scroll_pos, #get_scroll_range, #get_scroll_thumb, #get_size, #get_sizer, #get_text_extent, #get_theme_enabled, #get_tool_tip, #get_tool_tip_text, #get_update_client_rect, #get_update_region, #get_validator, #get_virtual_size, #get_window_border_size, #get_window_style, #get_window_style_flag, #get_window_variant, #handle_as_navigation_key, #handle_window_event, #has_capture, #has_extra_style, #has_flag, #has_focus, #has_multiple_pages, #has_scrollbar, #has_transparent_background, #hide, #hide_with_effect, #hit_test, #inform_first_direction, #inherit_attributes, #inherits_background_colour, #inherits_foreground_colour, #init_dialog, #invalidate_best_size, #is_being_deleted, #is_descendant, #is_double_buffered, #is_enabled, #is_exposed, #is_focusable, #is_frozen, #is_retained, #is_scrollbar_always_shown, #is_shown, #is_shown_on_screen, #is_this_enabled, #is_top_level, #is_transparent_background_supported, #layout, #line_down, #line_up, #locked, #lower_window, #move, #move_after_in_tab_order, #move_before_in_tab_order, #navigate, #navigate_in, new_control_id, #on_internal_idle, #page_down, #page_up, #paint, #paint_buffered, #popup_menu, #post_size_event, #post_size_event_to_parent, #process_window_event, #process_window_event_locally, #push_event_handler, #raise_window, #refresh, #refresh_rect, #register_hot_key, #release_mouse, #remove_child, #remove_event_handler, #reparent, #screen_to_client, #scroll_lines, #scroll_pages, #scroll_window, #send_size_event, #send_size_event_to_parent, #set_accelerator_table, #set_auto_layout, #set_background_colour, #set_background_style, #set_can_focus, #set_caret, #set_client_size, #set_containing_sizer, #set_cursor, #set_double_buffered, #set_drop_target, #set_event_handler, #set_extra_style, #set_focus, #set_focus_from_kbd, #set_font, #set_foreground_colour, #set_help_text, #set_id, #set_initial_size, #set_label, #set_layout_direction, #set_max_client_size, #set_max_size, #set_min_client_size, #set_min_size, #set_name, #set_next_handler, #set_own_background_colour, #set_own_font, #set_own_foreground_colour, #set_position, #set_previous_handler, #set_scroll_pos, #set_scrollbar, #set_size, #set_size_hints, #set_sizer, #set_sizer_and_fit, #set_theme_enabled, #set_tool_tip, #set_transparent, #set_validator, #set_virtual_size, #set_window_style, #set_window_style_flag, #set_window_variant, #should_inherit_colours, #show, #show_with_effect, #switch_sizer, #thaw, #to_dip, to_dip, #to_phys, to_phys, #toggle_window_style, #transfer_data_from_window, #transfer_data_to_window, #unregister_hot_key, unreserve_control_id, #unset_tool_tip, #update, #update_window_ui, #use_background_colour, #use_bg_col, #use_foreground_colour, #validate, #warp_pointer, #window_to_client_size

Methods inherited from EvtHandler

add_filter, #add_pending_event, #call_after, clear_filters, #connect, #delete_pending_events, #disconnect, #evt_activate, #evt_activate_app, #evt_aui_pane_activated, #evt_aui_pane_button, #evt_aui_pane_close, #evt_aui_pane_maximize, #evt_aui_pane_restore, #evt_aui_render, #evt_auinotebook_allow_dnd, #evt_auinotebook_begin_drag, #evt_auinotebook_bg_dclick, #evt_auinotebook_button, #evt_auinotebook_drag_done, #evt_auinotebook_drag_motion, #evt_auinotebook_end_drag, #evt_auinotebook_page_changed, #evt_auinotebook_page_changing, #evt_auinotebook_page_close, #evt_auinotebook_page_closed, #evt_auinotebook_tab_middle_down, #evt_auinotebook_tab_middle_up, #evt_auinotebook_tab_right_down, #evt_auinotebook_tab_right_up, #evt_auitoolbar_begin_drag, #evt_auitoolbar_middle_click, #evt_auitoolbar_overflow_click, #evt_auitoolbar_right_click, #evt_auitoolbar_tool_dropdown, #evt_button, #evt_calculate_layout, #evt_calendar, #evt_calendar_page_changed, #evt_calendar_sel_changed, #evt_calendar_week_clicked, #evt_calendar_weekday_clicked, #evt_char, #evt_char_hook, #evt_checkbox, #evt_checklistbox, #evt_child_focus, #evt_choice, #evt_choicebook_page_changed, #evt_choicebook_page_changing, #evt_close, #evt_collapsiblepane_changed, #evt_colourpicker_changed, #evt_colourpicker_current_changed, #evt_colourpicker_dialog_cancelled, #evt_combobox, #evt_combobox_closeup, #evt_combobox_dropdown, #evt_command, #evt_command_enter, #evt_command_kill_focus, #evt_command_left_click, #evt_command_left_dclick, #evt_command_range, #evt_command_right_click, #evt_command_scroll, #evt_command_scroll_bottom, #evt_command_scroll_changed, #evt_command_scroll_linedown, #evt_command_scroll_lineup, #evt_command_scroll_pagedown, #evt_command_scroll_pageup, #evt_command_scroll_thumbrelease, #evt_command_scroll_thumbtrack, #evt_command_scroll_top, #evt_command_set_focus, #evt_context_menu, #evt_date_changed, #evt_dialup_connected, #evt_dialup_disconnected, #evt_dirctrl_fileactivated, #evt_dirctrl_selectionchanged, #evt_dirpicker_changed, #evt_display_changed, #evt_dpi_changed, #evt_drop_files, #evt_end_session, #evt_enter_window, #evt_erase_background, #evt_filectrl_fileactivated, #evt_filectrl_filterchanged, #evt_filectrl_folderchanged, #evt_filectrl_selectionchanged, #evt_filepicker_changed, #evt_find, #evt_find_close, #evt_find_next, #evt_find_replace, #evt_find_replace_all, #evt_fontpicker_changed, #evt_fullscreen, #evt_gesture_pan, #evt_gesture_rotate, #evt_gesture_zoom, #evt_grid_cell_changed, #evt_grid_cell_changing, #evt_grid_cell_left_click, #evt_grid_cell_left_dclick, #evt_grid_cell_right_click, #evt_grid_cell_right_dclick, #evt_grid_cmd_col_size, #evt_grid_cmd_editor_created, #evt_grid_cmd_range_selected, #evt_grid_cmd_range_selecting, #evt_grid_cmd_row_size, #evt_grid_col_auto_size, #evt_grid_col_move, #evt_grid_col_size, #evt_grid_col_sort, #evt_grid_editor_created, #evt_grid_editor_hidden, #evt_grid_editor_shown, #evt_grid_label_left_click, #evt_grid_label_left_dclick, #evt_grid_label_right_click, #evt_grid_label_right_dclick, #evt_grid_range_selected, #evt_grid_range_selecting, #evt_grid_row_auto_size, #evt_grid_row_move, #evt_grid_row_size, #evt_grid_select_cell, #evt_grid_tabbing, #evt_header_begin_reorder, #evt_header_begin_resize, #evt_header_click, #evt_header_dclick, #evt_header_dragging_cancelled, #evt_header_end_reorder, #evt_header_end_resize, #evt_header_middle_click, #evt_header_middle_dclick, #evt_header_resizing, #evt_header_right_click, #evt_header_right_dclick, #evt_header_separator_dclick, #evt_help, #evt_help_range, #evt_hibernate, #evt_hotkey, #evt_html_cell_clicked, #evt_html_cell_hover, #evt_html_link_clicked, #evt_hyperlink, #evt_iconize, #evt_idle, #evt_init_dialog, #evt_joy_button_down, #evt_joy_button_up, #evt_joy_move, #evt_joy_zmove, #evt_joystick_events, #evt_key_down, #evt_key_up, #evt_kill_focus, #evt_leave_window, #evt_left_dclick, #evt_left_down, #evt_left_up, #evt_list_begin_drag, #evt_list_begin_label_edit, #evt_list_begin_rdrag, #evt_list_cache_hint, #evt_list_col_begin_drag, #evt_list_col_click, #evt_list_col_dragging, #evt_list_col_end_drag, #evt_list_col_right_click, #evt_list_delete_all_items, #evt_list_delete_item, #evt_list_end_label_edit, #evt_list_insert_item, #evt_list_item_activated, #evt_list_item_checked, #evt_list_item_deselected, #evt_list_item_focused, #evt_list_item_middle_click, #evt_list_item_right_click, #evt_list_item_selected, #evt_list_item_unchecked, #evt_list_key_down, #evt_listbook_page_changed, #evt_listbook_page_changing, #evt_listbox, #evt_listbox_dclick, #evt_long_press, #evt_magnify, #evt_maximize, #evt_media_finished, #evt_media_loaded, #evt_media_pause, #evt_media_play, #evt_media_statechanged, #evt_media_stop, #evt_menu, #evt_menu_close, #evt_menu_highlight, #evt_menu_highlight_all, #evt_menu_open, #evt_menu_range, #evt_middle_dclick, #evt_middle_down, #evt_middle_up, #evt_motion, #evt_mouse_aux1_dclick, #evt_mouse_aux1_down, #evt_mouse_aux1_up, #evt_mouse_aux2_dclick, #evt_mouse_aux2_down, #evt_mouse_aux2_up, #evt_mouse_capture_changed, #evt_mouse_capture_lost, #evt_mouse_events, #evt_mousewheel, #evt_move, #evt_move_end, #evt_move_start, #evt_moving, #evt_navigation_key, #evt_notebook_page_changed, #evt_notebook_page_changing, #evt_paint, #evt_pg_changed, #evt_pg_changing, #evt_pg_col_begin_drag, #evt_pg_col_dragging, #evt_pg_col_end_drag, #evt_pg_double_click, #evt_pg_highlighted, #evt_pg_item_collapsed, #evt_pg_item_expanded, #evt_pg_label_edit_begin, #evt_pg_label_edit_ending, #evt_pg_page_changed, #evt_pg_right_click, #evt_pg_selected, #evt_press_and_tap, #evt_query_end_session, #evt_query_layout_info, #evt_radiobox, #evt_radiobutton, #evt_ribbonbar_help_click, #evt_ribbonbar_page_changed, #evt_ribbonbar_page_changing, #evt_ribbonbar_tab_left_dclick, #evt_ribbonbar_tab_middle_down, #evt_ribbonbar_tab_middle_up, #evt_ribbonbar_tab_right_down, #evt_ribbonbar_tab_right_up, #evt_ribbonbar_toggled, #evt_ribbonbuttonbar_clicked, #evt_ribbonbuttonbar_dropdown_clicked, #evt_ribbongallery_clicked, #evt_ribbongallery_hover_changed, #evt_ribbongallery_selected, #evt_ribbonpanel_extbutton_activated, #evt_ribbontoolbar_clicked, #evt_ribbontoolbar_dropdown_clicked, #evt_richtext_buffer_reset, #evt_richtext_character, #evt_richtext_consuming_character, #evt_richtext_content_deleted, #evt_richtext_content_inserted, #evt_richtext_delete, #evt_richtext_focus_object_changed, #evt_richtext_left_click, #evt_richtext_left_dclick, #evt_richtext_middle_click, #evt_richtext_properties_changed, #evt_richtext_return, #evt_richtext_right_click, #evt_richtext_selection_changed, #evt_richtext_style_changed, #evt_richtext_stylesheet_changed, #evt_richtext_stylesheet_replaced, #evt_richtext_stylesheet_replacing, #evt_right_dclick, #evt_right_down, #evt_right_up, #evt_sash_dragged, #evt_sash_dragged_range, #evt_scroll, #evt_scroll_bottom, #evt_scroll_changed, #evt_scroll_command, #evt_scroll_linedown, #evt_scroll_lineup, #evt_scroll_pagedown, #evt_scroll_pageup, #evt_scroll_thumbrelease, #evt_scroll_thumbtrack, #evt_scroll_top, #evt_scrollbar, #evt_scrollwin, #evt_scrollwin_bottom, #evt_scrollwin_linedown, #evt_scrollwin_lineup, #evt_scrollwin_pagedown, #evt_scrollwin_pageup, #evt_scrollwin_thumbrelease, #evt_scrollwin_thumbtrack, #evt_scrollwin_top, #evt_search, #evt_search_cancel, #evt_set_cursor, #evt_set_focus, #evt_show, #evt_size, #evt_slider, #evt_spin, #evt_spin_down, #evt_spin_up, #evt_spinctrl, #evt_spinctrldouble, #evt_splitter_dclick, #evt_splitter_sash_pos_changed, #evt_splitter_sash_pos_changing, #evt_splitter_sash_pos_resize, #evt_splitter_unsplit, #evt_stc_autocomp_cancelled, #evt_stc_autocomp_char_deleted, #evt_stc_autocomp_completed, #evt_stc_autocomp_selection, #evt_stc_autocomp_selection_change, #evt_stc_calltip_click, #evt_stc_change, #evt_stc_charadded, #evt_stc_clipboard_copy, #evt_stc_clipboard_paste, #evt_stc_do_drop, #evt_stc_doubleclick, #evt_stc_drag_over, #evt_stc_dwellend, #evt_stc_dwellstart, #evt_stc_hotspot_click, #evt_stc_hotspot_dclick, #evt_stc_hotspot_release_click, #evt_stc_indicator_click, #evt_stc_indicator_release, #evt_stc_macrorecord, #evt_stc_margin_right_click, #evt_stc_marginclick, #evt_stc_modified, #evt_stc_needshown, #evt_stc_painted, #evt_stc_romodifyattempt, #evt_stc_savepointleft, #evt_stc_savepointreached, #evt_stc_start_drag, #evt_stc_styleneeded, #evt_stc_updateui, #evt_stc_userlistselection, #evt_stc_zoom, #evt_sys_colour_changed, #evt_taskbar_click, #evt_taskbar_left_dclick, #evt_taskbar_left_down, #evt_taskbar_left_up, #evt_taskbar_move, #evt_taskbar_right_dclick, #evt_taskbar_right_down, #evt_taskbar_right_up, #evt_text, #evt_text_copy, #evt_text_cut, #evt_text_enter, #evt_text_maxlen, #evt_text_paste, #evt_text_url, #evt_time_changed, #evt_timer, #evt_togglebutton, #evt_tool, #evt_tool_dropdown, #evt_tool_enter, #evt_tool_range, #evt_tool_rclicked, #evt_tool_rclicked_range, #evt_toolbook_page_changed, #evt_toolbook_page_changing, #evt_tree_begin_drag, #evt_tree_begin_label_edit, #evt_tree_begin_rdrag, #evt_tree_delete_item, #evt_tree_end_drag, #evt_tree_end_label_edit, #evt_tree_get_info, #evt_tree_item_activated, #evt_tree_item_collapsed, #evt_tree_item_collapsing, #evt_tree_item_expanded, #evt_tree_item_expanding, #evt_tree_item_gettooltip, #evt_tree_item_menu, #evt_tree_item_middle_click, #evt_tree_item_right_click, #evt_tree_key_down, #evt_tree_sel_changed, #evt_tree_sel_changing, #evt_tree_set_info, #evt_tree_state_image_click, #evt_treebook_node_collapsed, #evt_treebook_node_expanded, #evt_treebook_page_changed, #evt_treebook_page_changing, #evt_two_finger_tap, #evt_update_ui, #evt_update_ui_range, #evt_window_create, #evt_window_destroy, #evt_wizard_before_page_changed, #evt_wizard_cancel, #evt_wizard_finished, #evt_wizard_help, #evt_wizard_page_changed, #evt_wizard_page_changing, #evt_wizard_page_shown, #get_client_object, #get_evt_handler_enabled, #get_next_handler, #get_previous_handler, #is_unlinked, #process_event, #process_event_locally, #process_pending_events, #queue_event, register_class, remove_filter, #safely_process_event, #set_client_object, #set_evt_handler_enabled, #set_next_handler, #set_previous_handler, #try_after, #try_before, #unlink

Methods inherited from Object

#clone, #dup, #is_same_as, #un_share

Constructor Details

#initialize(parent, message = Wx::FILE_SELECTOR_PROMPT_STR, defaultDir = (''), defaultFile = (''), wildcard = Wx::FILE_SELECTOR_DEFAULT_WILDCARD_STR, style = Wx::FD_DEFAULT_STYLE, pos = Wx::DEFAULT_POSITION, size = Wx::DEFAULT_SIZE, name = Wx::FILE_DIALOG_NAME_STR) ⇒ Wx::FileDialog

Constructor.

Use #show_modal to show the dialog.

Parameters:

  • parent (Wx::Window)

    Parent window.

  • message (String) (defaults to: Wx::FILE_SELECTOR_PROMPT_STR)

    Message to show on the dialog.

  • defaultDir (String) (defaults to: (''))

    The default directory, or the empty string.

  • defaultFile (String) (defaults to: (''))

    The default filename, or the empty string.

  • wildcard (String) (defaults to: Wx::FILE_SELECTOR_DEFAULT_WILDCARD_STR)

    A wildcard, such as “.” or “BMP files (.bmp)|.bmp|GIF files (.gif)|.gif”. Note that the native Motif dialog has some limitations with respect to wildcards; see the Remarks section above.

  • style (Integer) (defaults to: Wx::FD_DEFAULT_STYLE)

    A dialog style. See wxFD_* styles for more info.

  • pos (Array(Integer, Integer), Wx::Point) (defaults to: Wx::DEFAULT_POSITION)

    Dialog position. Not implemented.

  • size (Array(Integer, Integer), Wx::Size) (defaults to: Wx::DEFAULT_SIZE)

    Dialog size. Not implemented.

  • name (String) (defaults to: Wx::FILE_DIALOG_NAME_STR)

    Dialog name. Not implemented.



180
# File 'lib/wx/doc/gen/file_dialog.rb', line 180

def initialize(parent, message=Wx::FILE_SELECTOR_PROMPT_STR, defaultDir=(''), defaultFile=(''), wildcard=Wx::FILE_SELECTOR_DEFAULT_WILDCARD_STR, style=Wx::FD_DEFAULT_STYLE, pos=Wx::DEFAULT_POSITION, size=Wx::DEFAULT_SIZE, name=Wx::FILE_DIALOG_NAME_STR) end

Instance Method Details

#get_currently_selected_filenameString Also known as: currently_selected_filename

Returns the path of the file currently selected in dialog.

Notice that this file is not necessarily going to be accepted by the user, so calling this function mostly makes sense from an update UI event handler of a custom file dialog extra control to update its state depending on the currently selected file. Currently this function is fully implemented under GTK and MSW and always returns an empty string elsewhere.

The path of the currently selected file or an empty string if nothing is selected.

Returns:

  • (String)

See Also:

  • set_extra_control_creator


190
# File 'lib/wx/doc/gen/file_dialog.rb', line 190

def get_currently_selected_filename; end

#get_currently_selected_filter_indexInteger Also known as: currently_selected_filter_index

Returns the file type filter index currently selected in dialog.

Notice that this file type filter is not necessarily going to be the one finally accepted by the user, so calling this function mostly makes sense from an update UI event handler of a custom file dialog extra control to update its state depending on the currently selected file type filter. Currently this function is fully implemented under macOS and MSW and always returns NOT_FOUND elsewhere.

The 0-based index of the currently selected file type filter or NOT_FOUND if nothing is selected.

Returns:

  • (Integer)

See Also:



205
# File 'lib/wx/doc/gen/file_dialog.rb', line 205

def get_currently_selected_filter_index; end

#get_directoryString Also known as: directory

Returns the default directory.

Returns:

  • (String)


210
# File 'lib/wx/doc/gen/file_dialog.rb', line 210

def get_directory; end

#get_extra_controlWx::Window Also known as: extra_control

If functions set_extra_control_creator and #show_modal were called, returns the extra window.

Otherwise returns NULL.

Returns:



217
# File 'lib/wx/doc/gen/file_dialog.rb', line 217

def get_extra_control; end

#get_filenameString Also known as: filename

Returns the default filename.

Note:

This function can't be used with dialogs which have the Wx::FD_MULTIPLE style, use #get_filenames instead.

Returns:

  • (String)


228
# File 'lib/wx/doc/gen/file_dialog.rb', line 228

def get_filename; end

#get_filenamesArray<String> Also known as: filenames

Fills the array filenames with the names of the files chosen.

This function should only be used with the dialogs which have Wx::FD_MULTIPLE style, use #get_filename for the others. Note that under Windows, if the user selects shortcuts, the filenames include paths, since the application cannot determine the full path of each referenced file by appending the directory containing the shortcuts to the filename.

Returns:

  • (Array<String>)


236
# File 'lib/wx/doc/gen/file_dialog.rb', line 236

def get_filenames; end

#get_filter_indexInteger Also known as: filter_index

Returns the index into the list of filters supplied, optionally, in the wildcard parameter.

Before the dialog is shown, this is the index which will be used when the dialog is first displayed. After the dialog is shown, this is the index selected by the user.

Returns:

  • (Integer)


244
# File 'lib/wx/doc/gen/file_dialog.rb', line 244

def get_filter_index; end

#get_messageString Also known as: message

Returns the message that will be displayed on the dialog.

Returns:

  • (String)


249
# File 'lib/wx/doc/gen/file_dialog.rb', line 249

def get_message; end

#get_pathString Also known as: path

Returns the full path (directory and filename) of the selected file.

Note:

This function can't be used with dialogs which have the Wx::FD_MULTIPLE style, use #get_paths instead.

Returns:

  • (String)


260
# File 'lib/wx/doc/gen/file_dialog.rb', line 260

def get_path; end

#get_pathsArray<String> Also known as: paths

Fills the array paths with the full paths of the files chosen.

This function should only be used with the dialogs which have Wx::FD_MULTIPLE style, use #get_path for the others.

Returns:

  • (Array<String>)


267
# File 'lib/wx/doc/gen/file_dialog.rb', line 267

def get_paths; end

#get_wildcardString Also known as: wildcard

Returns the file dialog wildcard.

Returns:

  • (String)


272
# File 'lib/wx/doc/gen/file_dialog.rb', line 272

def get_wildcard; end

#set_customize_hook(customizeHook) ⇒ Boolean Also known as: customize_hook=

Set the hook to be used for customizing the dialog contents.

This function can be called before calling #show_modal to specify that the dialog contents should be customized using the provided hook. See Wx::FileDialogCustomizeHook documentation and Dialogs Sample for the examples of using it.

Note:

In order to define a custom hook object, Wx::/filedlgcustomize.h must be included in addition to the usual Wx::/filedlg.h header.

true if the hook was successfully set or false if customizing the file dialog is not supported by the current platform.

Parameters:

Returns:

  • (Boolean)


288
# File 'lib/wx/doc/gen/file_dialog.rb', line 288

def set_customize_hook(customizeHook) end

#set_directory(directory) ⇒ void Also known as: directory=

This method returns an undefined value.

Sets the default directory.

Parameters:

  • directory (String)


294
# File 'lib/wx/doc/gen/file_dialog.rb', line 294

def set_directory(directory) end

#set_filename(setfilename) ⇒ void Also known as: filename=

This method returns an undefined value.

Sets the default filename.

In WXGTK this will have little effect unless a default directory has previously been set.

Parameters:

  • setfilename (String)


302
# File 'lib/wx/doc/gen/file_dialog.rb', line 302

def set_filename(setfilename) end

#set_filter_index(filterIndex) ⇒ void Also known as: filter_index=

This method returns an undefined value.

Sets the default filter index, starting from zero.

Parameters:

  • filterIndex (Integer)


308
# File 'lib/wx/doc/gen/file_dialog.rb', line 308

def set_filter_index(filterIndex) end

#set_message(message) ⇒ void Also known as: message=

This method returns an undefined value.

Sets the message that will be displayed on the dialog.

Parameters:

  • message (String)


314
# File 'lib/wx/doc/gen/file_dialog.rb', line 314

def set_message(message) end

#set_path(path) ⇒ void Also known as: path=

This method returns an undefined value.

Sets the path (the combined directory and filename that will be returned when the dialog is dismissed).

Parameters:

  • path (String)


320
# File 'lib/wx/doc/gen/file_dialog.rb', line 320

def set_path(path) end

#set_wildcard(wildCard) ⇒ void Also known as: wildcard=

This method returns an undefined value.

Sets the wildcard, which can contain multiple file types, for example: “BMP files (.bmp)|.bmp|GIF files (.gif)|.gif”.

Note that the native Motif dialog has some limitations with respect to wildcards; see the Remarks section above.

Parameters:

  • wildCard (String)


328
# File 'lib/wx/doc/gen/file_dialog.rb', line 328

def set_wildcard(wildCard) end

#show_modalInteger

Shows the dialog, returning StandardID::ID_OK if the user pressed OK, and StandardID::ID_CANCEL otherwise.

Returns:

  • (Integer)


333
# File 'lib/wx/doc/gen/file_dialog.rb', line 333

def show_modal; end