|Think about Loose Coupling|
SOLVED - TK: How to change color of readonly BrowseEntryby mrider (Beadle)
|on Oct 04, 2012 at 19:29 UTC||Need Help??|
mrider has asked for the
wisdom of the Perl Monks concerning the following question:
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.
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.
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]
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: