• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Os Wilhelm
 

Os Wilhelm

on

  • 3,546 views

 

Statistics

Views

Total Views
3,546
Views on SlideShare
3,534
Embed Views
12

Actions

Likes
1
Downloads
0
Comments
0

3 Embeds 12

http://www.slideshare.net 6
http://blazar.tumblr.com 5
http://www.techgig.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Os Wilhelm Os Wilhelm Presentation Transcript

    • wxPerl Agile Cross-Platform GUI Development (What I had to Learn the Hard Way) Eric Wilhelm Scratch Computing http://scratchcomputing.com
    • wxPerl bindings for wxWidgets GUI toolkit ● multi-platform ● native widgets ● object-oriented ● event driven ●
    • 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 – quot;cross-platform reinvention of string – librariesquot; 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 ●
    • Cross-platform Builds automate ● automate ● automate ● Module::Build ● CPDK + remote ssh automation ● nightly builds ● cross-platform repackaging from linux ●
    • 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(quot;cannot find modifier key $mkquot;);   $mod = Wx­>$mk; } ... if($kl > 1) {   my $key_const = 'WXK_' . $key;   Wx­>can($key_const) or croak(quot;cannot find keyquot;);   $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 ●
    • Wx::Perl/wxPerl Modules on CPAN wxPerl::Constructors ● wxPerl::Styles ● Wx::Perl::Throbber ● Wx::Perl::ProcessStream ● Wx::Perl::Imagick ● Wx::TreeListCtrl ●
    • 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 quot;open myAppquot; from command-line – ExtUtils::MacMaker ● uh, no I don't run xcode on dos and linux –
    • No really! Testing ./Build testgui ● outside-in ● X11::GUITest – Win32::GuiTest – inside-out ● EVT_IDLE – Wx::Timer – DISPLAY=localhost:3 ./Build testall –
    • 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 ●
    • Questions?
    • Thanks scratchcomputing.com ● wxperl.sourceforge.net ● dotreader.com ●