Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

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

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();

In reply to SOLVED - TK: How to change color of readonly BrowseEntry by mrider

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: (11)
    As of 2014-07-31 15:39 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (249 votes), past polls