Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Here a small piece of code showing how to create a Notebook with icons at the side (think MSN). In this example you need two icons called "users.png" and "schedule.png" 16 x 16 pixels in directory "C:\Documents and Settings\Steve\My Documents\Projects\wx" and set the $loc_windows_linux flag to "l" or "w"

#!/usr/bin/perl -w -- # generated by wxGlade 0.6.3 on Wed Nov 18 13:50:09 2009 from "C:\Docu +ments and Settings\Steve\My Documents\Projects\wx\deletemeNotebook.wx +g" # To get wxPerl visit http://wxPerl.sourceforge.net/ use Wx 0.15 qw[:allclasses]; use strict; package MyFrame; use Wx qw[:everything]; use base qw(Wx::Frame); use strict; sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_ +; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; # begin wxGlade: MyFrame::new # my $loc_windows_linux = "l"; #Set to Linux my $loc_windows_linux = "w"; #Set to Windows my $loc_installation_path ; if ($loc_windows_linux eq "l") { $loc_installation_path = "/home/steve/Documents/wx/"; } if ($loc_windows_linux eq "w") { $loc_installation_path = "C:\\Documents and Settings\\Steve\\M +y Documents\\Projects\\wx\\"; } $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $sty +le, $name ); $self->{notebook_1} = Wx::Notebook->new($self, -1, wxDefaultPositi +on, Wx::Size->new(300, 300), wxNB_LEFT ); $self->{notebook_1_pane_1} = Wx::Panel->new($self->{notebook_1}, - +1, wxDefaultPosition, wxDefaultSize, ); $self->{notebook_1_pane_2} = Wx::Panel->new($self->{notebook_1}, - +1, wxDefaultPosition, wxDefaultSize, ); $self->{notebook_1_pane_3} = Wx::Panel->new($self->{notebook_1}, - +1, wxDefaultPosition, wxDefaultSize, ); $self->{notebook_1_pane_4} = Wx::Panel->new($self->{notebook_1}, - +1, wxDefaultPosition, wxDefaultSize, ); $self->{notebook_1_pane_5} = Wx::Panel->new($self->{notebook_1}, - +1, wxDefaultPosition, wxDefaultSize, ); $self->{Loc_Image_List} = Wx::ImageList->new(16,16,1, 1); my $loc_bitmap = Wx::Bitmap->new($loc_installation_path."schedule. +png", wxBITMAP_TYPE_PNG); my $a=$self->{Loc_Image_List} -> Add($loc_bitmap); $loc_bitmap = Wx::Bitmap->new($loc_installation_path."users.png", +wxBITMAP_TYPE_PNG); my $b=$self->{Loc_Image_List} -> Add($loc_bitmap); $self->{notebook_1}->AssignImageList($self->{Loc_Image_List}); $self->{notebook_1}->AddPage($self->{notebook_1_pane_1}, "", 0, $a +); $self->{notebook_1}->AddPage($self->{notebook_1_pane_2}, "", 1, $b +); $self->{notebook_1}->AddPage($self->{notebook_1_pane_3}, "tab3", 0 +, -1); $self->{notebook_1}->AddPage($self->{notebook_1_pane_4}, "tab4", 0 +, -1); $self->{notebook_1}->AddPage($self->{notebook_1_pane_5}, "tab5", 0 +, -1); $self->__set_properties(); $self->__do_layout(); # end wxGlade return $self; } sub __set_properties { my $self = shift; # begin wxGlade: MyFrame::__set_properties $self->SetTitle("frame_1"); # end wxGlade } sub __do_layout { my $self = shift; # begin wxGlade: MyFrame::__do_layout $self->{sizer_1} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_1}->Add($self->{notebook_1}, 1, wxEXPAND, 0); $self->SetSizer($self->{sizer_1}); $self->{sizer_1}->Fit($self); $self->Layout(); # end wxGlade } # end of class MyFrame 1; 1; package main; unless(caller){ local *Wx::App::OnInit = sub{1}; my $app = Wx::App->new(); Wx::InitAllImageHandlers(); my $frame_1 = MyFrame->new(); $app->SetTopWindow($frame_1); $frame_1->Show(1); $app->MainLoop(); }


In reply to Using Icons on Wx::Notebook by Steve_BZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (7)
    As of 2014-10-21 03:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (95 votes), past polls