-
-
03 Dec 2011 20:17:34 UTC
- Distribution: Tie-Wx-Widget
- Module version: 1.0
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Clone repository
- Issues
- Testers (73 / 0 / 0)
- Kwalitee
Bus factor: 1- 21.28% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity
24 month- Tools
- Download (6.12KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
++ed by:2 non-PAUSE users- Dependencies
- Tie::Scalar
- Wx
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- NAME
- SYNOPSIS
- CALLBACKS
- WARNINGS
- INTERNALS
- BUGS
- SUPPORT
- ACKNOWLEDGEMENTS
- AUTHOR
- LICENSE AND COPYRIGHT
NAME
Tie::Wx::Widget - get and set main value of a Wx widget with less syntax and more magic
SYNOPSIS
use Tie::Wx::Widget; tie $tiedwidget, Tie::Wx::Widget, $widget; $tiedwidget = 7; # instead of $widgetref->SetValue(7); say $tiedwidget; # instead of say $widgetref->GetValue; untie $tiedwidget; # now $tiedwidget is a normal scalar again (not required)
CALLBACKS
Often are the widget values coupled with each other. For instance in App::Spirograph is a slider, which max value is the value of another slider. Once you know this, why keep track of it and change the range by hand any given time?
tie $tslider, Tie::Wx::Widget, $slider, sub { $[0]->SetValue($[1]); $subslider->SetRange(1, $[1]) };
The first parameter to the callback is always the Wx object reference, the assign-callback gets also a second with the assigned value. Own callbacks replace the the ones, generated by default.
The complete parameter list is is:
tie $tw, Tie::Wx::Widget, $widget, [&$do_when_assign, &$do_when_retrieve];
Yes, its also doable with events, but thats also more syntax than this. Plus, its a different event for many widgets, why remember this? Plus, a tied widget still gives you the freedom to change the value under the radar. See section "INTERNALS" for more.
WARNINGS
Your program will
die
, if you don't provide a proper Wx widget, that has a GetValue and SetValue method, or the callbacks are no coderef. Unless you init with:use Tie::Wx::Widget 'warn_mode';
or do later:
Tie::Wx::Widget::warn_mode();
Then will be called
warn
instead ofdie
. But you can switch anytime back with:Tie::Wx::Widget::die_mode();
Wich has only effect for all variables tied afterwards. Because if the Wx ref is not good, there will be no tying anyway.
INTERNALS
# how to get a reference to the Tie::Wx::Widget object ? $tieobject = tie $tiedwidget, Tie::Wx::Widget, $widget; $tieobject = tied $tiedwidget; # now you even can: $tieobject->FETCH() # aka: $tieobject->{'widget'}->GetValue; # or do any other method on the wx object $tieobject->{'w'}->Show(0); # works too (hides the widget) $tieobject->STORE(7); # doesn't do anything $tieobject->DESTROY()
BUGS
Please report any bugs or feature requests to
bug-tie-wx-widget at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tie-Wx-Widget. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Tie::Wx::Widget
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
Source Repository: (in case you fant to fork :))
ACKNOWLEDGEMENTS
This was solely my idea before Linuxtag 2011. Started as a slide for it.
AUTHOR
Herbert Breunung,
<lichtkind at cpan.org>
LICENSE AND COPYRIGHT
Copyright 2011 Herbert Breunung.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
Module Install Instructions
To install Tie::Wx::Widget, copy and paste the appropriate command in to your terminal.
cpanm Tie::Wx::Widget
perl -MCPAN -e shell install Tie::Wx::Widget
For more information on module installation, please visit the detailed CPAN module installation guide.