mrider has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks,

Background: I'm writing a simple tool that offers end users a number of pre-packaged ad-hoc reports. This tool is to be used in Windows. I started off with the idea of using Win32::GUI (because it has a better native LNF) - but after a considerable amount of wailing and thrashing, I'm starting to wonder if perhaps that isn't where I want to be (more explanation below).

So now I'm working on rewriting the GUI portion in Tk. It's taken me a while, but I'm starting to get a handle on how to layout my widgets and how to get them to behave. I do however have one problem: I'm simulating a Windows read-only combobox using a Tk::BrowseEntry that has the state option set to readonly. However, everyone that I've shown mockups to thinks the entire dropdown is disabled, not just the edit function. The edit portion is the same color as the window background, and the text is a lighter color.

I understand why the author did the LNF like that and I don't necessarily disagree. My concern is that my users will think the whole widget is disabled, rather than just the edit portion (based on my user testing). So for my specific window, I'd like for the edit portion to BE disabled, but not LOOK disabled. If you'll forgive the ASCII art, below is what I'm looking for.

------------------------------------- Chooser: | Foo (how to make this white?) |V| ------------------------------------- | Foo | | Bar | | Bas | ---------------------------------

I can figure out how to change everything except the part where it says "(how to make this white?)" to a different color. In the code sample below I've made everything red, since red jumps out at me. The color is not important - what is important is that the one section I want to change is the only section that doesn't change.

#!/usr/bin/perl use strict; use Tk; use Tk::BrowseEntry; my $mw = MainWindow->new(); $mw->geometry("300x300+100+100"); my @choices = ("Foo", "Bar", "Bas"); my $dd_value; my $dd = $mw->BrowseEntry( -label => 'Chooser', -variable => \$dd_value, -state => 'readonly' )->pack(); foreach my $choice (@choices) { $dd->insert('end', $choice); } $dd_value = $choices[0]; $dd->Subwidget('entry')->configure(-bg => "#FF0000"); $dd->Subwidget('arrow')->configure(-bg => "#FF0000"); $dd->Subwidget('choices')->configure(-bg => "#FF0000"); $dd->Subwidget('slistbox')->configure(-bg => "#FF0000"); #What else can I configure to a different color?? MainLoop;

So is there another exported widget that I can't find? Or maybe I should be using a different widget (e.g. something other than BrowseEntry)? I'm even willing to edit the original Perl module if necessary. I'll just add the edit to the instructions regarding how to install Perl onto a development machine.

[More explanation]
  1. Win32::GUI has some odd behavior. For example, all of my widgets start with a flat "XP" style, but one of them changes to the older indented style when I change values in a completely different widget.
  2. CPAN's Win32::GUI appears to be unmaintained. For example, if you download the code from CPAN you'll need to immediately edit line 101 and change it from "if($[ < 5.008000) {" to "if($] < 5.008000) {". How could they not notice that problem?
  3. General lack of documentation. Far too many entries are simply [TBD] for my taste.



I don't know if all the anonymous monks were the same monks or not. But the suggestion about trying JBrowseEntry helped. The page for JBrowseEntry doesn't mention this, but looking down through the source code for the module I found a place where the code looks at the -disabledforeground and -disabledbackground options. On a lark, I tried that in BrowseEntry as well, and it works there. In fact I'd say that JBrowseEntry is worth having around as much to see what all options are available as anything. Anyway the answer is:

my $dd = $mw->BrowseEntry( -label => 'Chooser', -variable => \$dd_value, -state => 'readonly' -disabledforeground => '#000000', -disabledbackground => '#FFFFFF', )->pack();