Os Wilhelm

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite & 1 Group

    Os Wilhelm - Presentation Transcript

    1. wxPerl Agile Cross-Platform GUI Development (What I had to Learn the Hard Way) Eric Wilhelm Scratch Computing http://scratchcomputing.com
    2. wxPerl bindings for wxWidgets GUI toolkit ● multi-platform ● native widgets ● object-oriented ● event driven ●
    3. wxWidgets platforms Win32 – Mac OS X – GTK+ – X11 – Motif – WinCE – and more –
    4. Windows
    5. Linux
    6. Mac
    7. Why Desktop Apps? local machine resources ● large files – soundcard – cpu – private data ● encryption ● airplanes ●
    8. 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 –
    9. 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 ●
    10. 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'
    11. 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 ●
    12. 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 –
    13. 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 ●
    14. 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 ●
    15. Cross-platform Builds automate ● automate ● automate ● Module::Build ● CPDK + remote ssh automation ● nightly builds ● cross-platform repackaging from linux ●
    16. Installation (aka fun with make/nmake/bake/shake/quake) Linux ● debian (sarge, etch) – Windows ● camelpack + sourceforge PPMs – ExtUtils::FakeConfig ● Strawberry – Mac ● xcode – cpan –
    17. wxGlade
    18. 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 –
    19. 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 ●
    20. 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
    21. 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);
    22. 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]);
    23. More Perlification can() doesn't work right ● wxPerl::Constructors ● wxPerl::Styles ● wxPerl::Lay_er_outer ??? ●
    24. 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? ●
    25. 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 ●
    26. Wx::Perl/wxPerl Modules on CPAN wxPerl::Constructors ● wxPerl::Styles ● Wx::Perl::Throbber ● Wx::Perl::ProcessStream ● Wx::Perl::Imagick ● Wx::TreeListCtrl ●
    27. 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” –
    28. 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 –
    29. 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) –
    30. 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
    31. Building make a custom Module::Build class ● (not with a HEREdoc) – Custom targets ● ./Build par – ./Build starter_data – ./Build books – ./Build binpush – ./Build bindistribute –
    32. Testing ./Build testall ● 'test', 'testsync', and 'testgui' – ./Build testgui ● is t/_gui/*.gt + Module::Build hack –
    33. 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 –
    34. 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 –
    35. No really! Testing ./Build testgui ● outside-in ● X11::GUITest – Win32::GuiTest – inside-out ● EVT_IDLE – Wx::Timer – DISPLAY=localhost:3 ./Build testall –
    36. 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 –
    37. Acceptance Tests ala data-driven testing ● scripted manual verifications ● automate actions as much as possible ● still need better GUI test frameworks ●
    38. Questions?
    39. Thanks scratchcomputing.com ● wxperl.sourceforge.net ● dotreader.com ●

    + oscon2007oscon2007, 2 years ago

    custom

    1250 views, 1 favs, 1 embeds more stats

    More Info

    © All Rights Reserved

    Go to text version
    • Total Views 1250
      • 1246 on SlideShare
      • 4 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 0
    Most viewed embeds
    • 4 views on http://blazar.tumblr.com

    more

    All embeds
    • 4 views on http://blazar.tumblr.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as innappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel

    Categories

    Tags

    Groups / Events