NAME
Wx::Perl::Dialog - Abstract dialog class for simple dialog creation
SYNOPSIS
my $layout = [
[
[ 'Wx::StaticText', undef, 'Some text entry'],
[ 'Wx::TextCtrl', 'name_of', 'Default value' ],
],
[
[ 'Wx::Button', 'ok', Wx::wxID_OK ],
[ 'Wx::Button', 'cancel', Wx::wxID_CANCEL ],
],
];
my $dialog = Wx::Perl::Dialog->new(
parent => $win,
title => 'Widgetry dialog',
layout => $layout,
width => [150, 200],
);
return if not $dialog->show_modal;
my $data = $dialog->get_data;
#### You may also create a tabbed dialog for more complex tasks:
my $tabbed_dialog = Wx::Perl::Dialog->new(
parent => $win,
title => 'Widgetry dialog',
layout => [ $layout_a, $layout_b, ]
multipage => {
auto_ok_cancel => 1,
ok_widgetid => '_ok_',
cancel_widgetid => '_cancel_',
pagenames => [ 'Basic', 'Advanced' ]
},
);
Where $win is the Wx::Frame of your application.
WARNING
This is still an alpha version of the code. It is used mainly by Padre and its plug-ins. The API can change without any warning.
Actually as of version 0.28 we have move this code back to the Padre distribution in order to make it easier for the Padre developers to improve it.
DESCRIPTION
Layout
The layout is reference to a two dimensional array. Every element (an array) represents one line in the dialog.
Every element in the internal array is an array that describes a widget.
The first value in each widget description is the type of the widget.
The second value is an identifier (or undef
if we don't need any access to the widget).
The widget will be accessible form the dialog object using $dialog-
{_widgets_}{identifier}>
The rest of the values in the array depend on the widget.
Supported widgets and their parameters
Wx::StaticText
-
3.: "the text",
Wx::Button
-
3.: button type (stock item such as Wx::wxID_OK or string "&do this")
Wx::DirPickerCtrl
-
3. default directory (must be '') ??? 4. title to show on the directory browser
Wx::TextCtrl
-
3. default value, if any
Wx::Treebook
-
3. array ref for list of values
Wx::FontPickerCtrl
-
3. A string describing the font
Wx::ColourPickerCtrl
-
3. A HTML-compatible colour description string: '#' plus 6 hex digits; i.e. #FF0000
Wx::SpinCtrl
-
3. Current value (as text value in wxWidgets; an Integer) 4. Minimum value allowed (Integer) 5. Maximum value allowed (Integer)
Multi-page Layout (with a Wx::Notebook)
If you pass in a parameter multipage
, a tabbed dialog will be created using a Wx::Notebook
. The value of the layout
parameter will be interpreted as an array reference where each value represents the contents of one page (see "Layout").
The value of the multipage
parameter should be a hash containing extra options.
auto_ok_cancel
-
If set to a true value, an OK and a CANCEL button will be displayed automatically below the tabbed pages.
ok_widgetid
-
An identifier for the automatically generated OK button. Useful if you want to have access to the button via
$dialog->{_widgets_}{<ok_widgetid>}
cancel_widgetid
-
Same as above but for the CANCEL button
pagenames
-
An array reference of strings which represent the tab titles.
METHODS
new
get_data
my $data = $dialog->get_data;
Returns a hash with the keys being the names you gave for each widgets and the value being the value of that widget in the dialog.
show_modal
Helper function that will probably change soon...
return if not $dialog->show_modal;
BUGS
Please submit bugs you find on http://padre.perlide.org/
COPYRIGHT
Copyright 2008 Gábor Szabó. http://www.szabgab.com/
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 484:
Non-ASCII character seen before =encoding in 'Gábor'. Assuming UTF-8