Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Dear esteemed PerlMonks

Continuing my odyssey, I need to develop an application for traversing/roaming in databases, letting the user inspect/view tables and joins in an efficient and friendly way. (On Windowz only).

Quite a while ago I decided to do it in Perl (over friendly attempts of colleagues and friends to have me use ASP .Net and C#).
I had to choose a GUI development environment. Initially I've chosen Win32::GUI. It was pretty neat, but eventually I had to drop it, since:
a. it doesn't support Unicode/UTF-8,
and b. it doesn't seem to be supported any longer.
So after considering various pieces of advice, I decided to use wxPerl.

But, I am getting more and more frustrated. Here is a concrete question, and then some more general ones:
1. It seems to me that the widget I should be using for the main purpose I listed above (namely, a user-friendly way of browsing database tables and joins) is wxListCtrl (and mainly the virtual list control). (Gurus: I'd love to get you opinion on this).
For a neat look, I need to be able:
a. to set size and font of the list control column headings;
b. to set size and font of the item lines.

The wxPerl documentation is scant. I couldn't find an example for doing that. I did find a wxPython example: at: http://wxpython-users.1045709.n5.nabble.com/ListCtrl-SetItemTextColor-SetItemFont-td2348263.html (attached to Robert Tomlin's post, Oct 15, 2006 4:55 (8th from top)):

# taken from: http://wxpython-users.1045709.n5.nabble.com/ListCtrl-Set +ItemTextColor-SetItemFont-td2348263.html (main.py) import wx class MyFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, pos=(150, 150), siz +e=(350, 400)) # Now create the Panel to put the other controls on. panel = wx.Panel(self) btnBold = wx.Button(panel, -1, "Bold") btnRed = wx.Button(panel, -1, "Red") self.Bind(wx.EVT_BUTTON, self.OnBold, btnBold) self.Bind(wx.EVT_BUTTON, self.OnRed, btnRed) # create a list control self.listControl = wx.ListCtrl(panel, style=wx.LC_REPORT, size +=(200,100)) self.listControl.InsertColumn(0, "Col1") self.listControl.InsertColumn(1, "Col2") self.listControl.InsertStringItem(0, "Data 1") self.listControl.SetStringItem(0,1, "Data 2") sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.listControl, 0, wx.ALL, 10) sizer.Add(btnBold, 0, wx.ALL, 10) sizer.Add(btnRed, 0, wx.ALL, 10) panel.SetSizer(sizer) panel.Layout() def OnBold(self, evt): f = self.listControl.GetItemFont(0) f.SetWeight(wx.BOLD) self.listControl.SetItemFont(0, f) def OnRed(self, evt): self.listControl.SetItemTextColour(0, wx.RED) class MyApp(wx.App): def OnInit(self): frame = MyFrame(None, "Demonstrate listctrl") self.SetTopWindow(frame) frame.Show(True) return True app = MyApp(redirect=True) app.MainLoop()

Porting this example into wxPerl:

# taken from: http://wxpython-users.1045709.n5.nabble.com/ListCtrl-Set +ItemTextColor-SetItemFont-td2348263.html (main.py) # ported 23 3 2013 v 0-1 use strict; use warnings; use Wx; use 5.014; use autodie; use Carp; use Carp qw {cluck}; use Carp::Always; use Win32::Console; package MyFrame; use Wx ':everything'; use Wx ':listctrl'; use Wx::Event 'EVT_BUTTON'; use parent -norequire, 'Wx::Frame'; sub new { #1 MyFrame:: my ($class, $parent, $title) = @_; my $self = $class->SUPER::new( $parent, -1, # parent window; ID -1 means any $title, # title [150, 150 ], # position [ 350, 400 ], # size ); # wx.Frame.__init__(self, parent, -1, title, pos=(150, 150), size +=(350, 400)) (Python) my $panel = Wx::Panel->new($self); my $btnBold = Wx::Button->new($panel, -1, 'Bold', wxDefaultPos +ition, wxDefaultSize); my $btnRed = Wx::Button->new($panel, -1, 'Red', wxDefaultPosit +ion, wxDefaultSize); EVT_BUTTON ($self, $btnBold, sub { $self->{listControl}->MyFr +ame::OnBold }); # self.Bind(wx.EVT_BUTTON, self.OnBold, btnBold) (Python) EVT_BUTTON ($self, $btnRed, sub { $self->{listControl}->MyFram +e::OnRed }); # self.Bind(wx.EVT_BUTTON, self.OnRed, btnRed) (Python) # create a list control $self->{listControl} = Wx::ListCtrl->new($panel, -1, wxDefault +Position, [300,100], wxLC_REPORT); $self->{listControl}->InsertColumn(0, 'Col1', wxLIST_FORMAT_LE +FT, 150); $self->{listControl}->InsertColumn(1, 'Col2', wxLIST_FORMAT_LE +FT, 150); $self->{listControl}->InsertStringItem( 0, 'dummy' ); $self->{listControl}->SetItemText( 0, 'Data 1'); $self->{listControl}->SetItem( 0, 1, 'Data 3'); $self->{listControl}->InsertStringItem( 1, 'dummy' ); $self->{listControl}->SetItemText(1, 'Data 2'); $self->{listControl}->SetItem( 0, 1, 'Data 3'); my $sizer = Wx::BoxSizer->new(wxVERTICAL); $sizer->Add($self->{listControl}, 0, wxALL, 10); $sizer->Add($btnBold, 0, wxALL, 10); $sizer->Add($btnRed, 0, wxALL, 10); $panel->SetSizer($sizer); $panel->Layout(); return $self; } #1 end sub new MyFrame:: sub OnBold { # def OnBold(self, evt) +: (Python) my $this = shift; my $f = $this->GetItemFont(0); my $f = Wx::Font->new(12, -1, wxNORMAL, wxBOLD, 0, 'arial' +); $f->SetWeight(wxBOLD); $this->Wx::ListCtrl->SetItemFont(0, $f); } #1 end sub OnBold sub OnRed { # def OnRed(self, evt): + (Python) my $this = shift; $this->SetItemTextColour(0, wxRED); } #1 end sub OnRed # end class MyFrame:: # class MyApp(Wx::App): (Python) # def OnInit(self): (Python) my $frame = MyFrame->new(undef, 'Demonstrate listctrl'); # Wx::SetTopWindow($frame); $frame->Show(1); # return True (Python) my $app = Wx::SimpleApp->new; $app->MainLoop; 1;

you note that the "Red" button works ok (makes the items red), but the "Bold" button fails, with the error message: (the program is called: "Set item font post.pl"):

Error while autoloading 'Wx::ListCtrl' at F:/Win7programs/Dwimperl/per +l/site/lib/Wx.pm line 48 Wx::AUTOLOAD('Wx::ListCtrl=HASH(0x26f6454)') called at Set ite +m font post.pl line 60 MyFrame::OnBold('Wx::ListCtrl=HASH(0x26f6454)') called at Set +item font post.pl line 31 MyFrame::__ANON__('MyFrame=HASH(0x2712734)', 'Wx::CommandEvent +=SCALAR(0x2b9f3bc)') called at Set item font post.pl line 76 eval {...} called at F:/Win7programs/Dwimperl/perl/site/lib/Wx +.pm line 48

So here are my case-specific questions, and some more general questions:

1. Is GetItemFont/SetItemFont implemented for Wx::ListCtrl in wxPerl? If not, how come it's not implemented; if yes, what am I doing wrong?
2. Are all methods (see here: http://docs.wxwidgets.org/2.8/wx_wxlistctrl.html#wxlistctrlgetitemfont) of the wxListCtrl widget implemented in wxPerl? wxPerl documentation led me to think so?
3. Should I stick with wxPerl and Wx::ListCtrl for this project, or should I choose some other tools?
4. This "ObjectListView" wxPython widget looks neat: http://objectlistview.sourceforge.net/python/features.html. Is there something like it in Perl?
Should I try to port it into wxPerl?
5. I had chosen using Perl (and investing time and energy in it) since I was impressed with the power and expressiveness of the language, and its internal logic; you can feel it was designed by a linguist. But, considering the dearth of support and examples (for displaying database tables in a neat GUI), should I abandon Perl and do the project in Python?

Esteemed gurus - your help and advice will be appreciated

Many TIA - Helen


In reply to wxPerl: is wxListCtrl Get/SetItemFont implemented? and further important questions by HelenCr

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-20 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found