wxWidgets platforms
Win32
–
Mac OS X
–
GTK+
–
X11
–
Motif
–
WinCE
–
and more
–
Windows
Linux
Mac
Why Desktop Apps?
local machine resources
●
large files
–
soundcard
–
cpu
–
private data
●
encryption
●
airplanes
●
Why Perl?
freedom from
●
static code
–
compilers
–
\"cross-platform reinvention of string
–
libraries\"
easier reuse
●
common (e.g. company-wide) modular
–
code
web apps
–
command-line apps
–
The “Wx” distribution (aka
wxPerl)
wraps wxWidgets in XS and some Perl
●
332K tarball
●
breakdown:
●
xs: ~21680 (57.42%)
perl: 8685 (23.00%)
cpp: 7395 (19.58%)
xsp: ~1662
note: SLOCCOUNT doesn't really speak XS
but very little documentation
●
Compare to WxGTK
(i.e. core+gtk port)
6.9M of C++ !
●
20x21k
cpp: 416710 (77.09%)
ansic: 112754 (20.86%)
sh: 10026 (1.85%)
python: 645 (0.12%)
lex: 194 (0.04%)
yacc: 128 (0.02%)
pascal: 74 (0.01%)
lisp: 6 (0.00%)
generated using David A. Wheeler's 'SLOCCount'
dotReader
open-source e-book reader in Perl
read, annotate, and search books
●
browse the web, send mail, etc
●
shared annotations
●
online/offline network fun
–
DRM (makes publishers happy)
●
flexible, environment-agnostic architecture
●
open source
●
plugins, plugins, plugins
●
dotReader details
today's raw numbers (Jun. 25th, 2007)
●
13K SLOC
98 modules + ~1200 line Build subclass
drop-in distributions
●
linux/qdos - PAR
–
mac - PerlWrapper + ExtUtils::MacMaker
–
embedded html widgets
●
IE (activeX)
–
Webkit
–
Mozilla
–
Getting Started with wxPerl
Finding Documentation
wxPerl specific
●
a slow wiki (somebody please make a US
–
mirror)
not much pod
–
some perlmonks stuff
–
demo directory
–
C++ documentation
●
C++ examples
●
wxGlade
●
Cross-platform Development
(aka fun with vnc)
svk and working copy on linux workstation
●
more and better tools
–
80% or more development is command-line
–
tests
●
● small utilities
● good discipline
● good for architecture
rsync+fam
●
rdesktop/vnc to windows+cygwin
●
vnc to mac
●
Installation
(aka fun with make/nmake/bake/shake/quake)
Linux
●
debian (sarge, etch)
–
Windows
●
camelpack + sourceforge PPMs
–
ExtUtils::FakeConfig
●
Strawberry
–
Mac
●
xcode
–
cpan
–
wxGlade
BAD
code generation and why it is (maybe) a good idea
XRC (speed?)
●
segregate generated code
●
have a consistent environment
●
windows vs linux, glade versions
–
use version control!
●
use subversion
–
have to make it be valid (strict) Perl
●
stupid regular expressions do the trick
–
Getting Past Getting Started
copy and paste is evil
●
strive for deep clarity, not superficial
●
don't ape glade
●
don't ape C++
●
don't even ape the examples
●
Leaving “Getting Started”
Way Behind
modularity
●
subclassing
●
traits
●
CMT / POE for responsiveness
●
subprocesses
●
discipline
●
as always, but particularly because we don't
–
have “best practices” in this realm yet
Eliminating Tabular Code
EVT_MENU( $self, 5007, sub {$_[0]>activate_sidebar($_[1])});
EVT_MENU( $self, 5011, sub {$_[0]>activate_reader($_[1])});
...
my $acc_table = Wx::AcceleratorTable>new(
[0, WXK_F2, 5007, ], # activate sidebar
[0, WXK_F3, 5011, ], # activate widget
...
);
$self>SetAcceleratorTable($acc_table);
my $acc_table = Wx::AcceleratorTable>new(
map({$self>_accel(@$_)}
['F2', sub {$_[0]>activate_sidebar($_[1]);}],
['F3', sub {$_[0]>activate_reader($_[1]); }],
...
),
);
$self>SetAcceleratorTable($acc_table);
needs Perlin'
...
if($stroke =~ s/^(.*)\\+//) {
my $mk = 'wxACCEL_' . $1;
Wx>can($mk) or croak(\"cannot find modifier key $mk\");
$mod = Wx>$mk;
}
...
if($kl > 1) {
my $key_const = 'WXK_' . $key;
Wx>can($key_const) or croak(\"cannot find key\");
$key = Wx>$key_const;
}
else {
# it's a letter
$key = ord(uc($key));
}
my $id = Wx::NewId;
Wx::Event::EVT_MENU($self, $id, $subref);
return([$mod, $key, $id]);
More Perlification
can() doesn't work right
●
wxPerl::Constructors
●
wxPerl::Styles
●
wxPerl::Lay_er_outer ???
●
What we really want is a
better wxGlade?
stealing ideas from smalltalk
●
(without losing unixness)
–
named objects and accessors
●
DSL / YAML
●
read + write and in-process dynamicism
●
procedural / config-integration
●
and/or code-snippet insertion?
●
Other Thoughts
menu introspection
● (WxPerl::MenuMaker)
event driven OOP
●
break into small pieces (e.g.
–
backend_file_open)
callbacks
●
closures
–
method calls
–
NOT \\&subname, please
–
accessors
●
Needs more Perlin' -- WxPerl/foo.pm
●
Browser Widgets
wxMozilla / Wx::Mozilla
●
my eyes are bleeding!
–
Wx::WebKit
●
Wx::ActiveX
●
move along, nothing to see here
–
wxWebCore / Wx::WebCore
●
Apple's Objective-C experiment (take 2)
–
cross-platform
–
“The Future”
–
Logger
Log::Log4perl
●
dynamically configurable
–
init_and_watch
–
SIGHUP
–
insanely configurable
●
5 levels
–
any depth of 'class' hierarchy
–
levels are even implicit classes
–
don't get carried away here
–
wrap it
not
●
$logger = Log::Log4perl>get_logger('blahblahblah');
$logger>debug('foo');
just returns a singleton, so:
●
use dtRdr::Logger;
L - logging in caller() package
–
L>debug('foo');
RL - arbitrary logging
–
trapping
●
$SIG{__WARN__}, logging to file
–
trapping $SIG{__DIE__} (popup)
–
Testing
./Build test
●
standard tests
●
300 lines of custom test-support code
–
3200 5400 lines of regular tests
–
only 400 600 of that is gui
–
t/location 1
t 5
t/logger 2
t/_gui 9
t/multitask 3
t/annotation 8
t/plugins 3
t/book 34
t/range 1
t/config 4
t/search 3
t/_sync 5
t/toc 5
t/history 3
t/user 1
t/library 3
Building
make a custom Module::Build class
●
(not with a HEREdoc)
–
Custom targets
●
./Build par
–
./Build starter_data
–
./Build books
–
./Build binpush
–
./Build bindistribute
–
Testing
./Build testall
●
'test', 'testsync', and 'testgui'
–
./Build testgui
●
is t/_gui/*.gt + Module::Build hack
–
Packaging and Deployment
Windows and Linux
●
PAR
–
(Wx::ActiveX hack)
●
bundle the dlls, etc -- no dependencies for
●
user
a bit slow to rebuild
●
startup speed needs work here
●
Mac
●
needs an AppBundle
–
PerlWrapper (Mac)
wxPerl (appbundle)
●
required to even get a working GUI
–
compiled with xcode, resource file, etc
–
automated tests work fine, but no focus
–
before click
PerlWrapper
●
a perl interpreter embedded in a compiled C
–
app
allows \"open myApp\" from command-line
–
ExtUtils::MacMaker
●
uh, no I don't run xcode on dos and linux
–
Manual Testing
just hacks:
●
Ctrl+Shift+F5 does Module::Refresh
–
F7 quick window resize (to see console)
–
production stuff
●
Ctrl+L activate library pane
–
F2/F3 focus switch
–
command-line options or parameters
●
./run test_packages/foo/book.xml
–
dual-purpose tests
●
perl -Ilib t/_gui/note_editor.gt foo
–
Acceptance Tests
ala data-driven testing
●
scripted manual verifications
●
automate actions as much as possible
●
still need better GUI test frameworks
●
0 comments
Post a comment