Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Perl/TK borderwidth question

by perltux (Monk)
on Oct 26, 2012 at 11:55 UTC ( #1001052=perlquestion: print w/replies, xml ) Need Help??
perltux has asked for the wisdom of the Perl Monks concerning the following question:

I'm using the Perl/TK 'BrowseEntry' widget and have set the '-borderwidth' parameter to '1'. Despite that the border of the pop-up pane, the scrollbar and the buttom all still have a 2 pixel border width.

See screenshot of my app here (the 'BrowseEntry' widget is on the upper right):

The '-borderwidth' parameter setting seems to only affect the Entry box, no other element of the 'BrowseEntry' widget.

How can I set the border width of all elements of the 'BrowseEntry' widget to '1'?

In fact is there a way to universally set the default border width to '1' for all widgets of the whole program?

Replies are listed 'Best First'.
Re: Perl/TK borderwidth question
by kcott (Chancellor) on Oct 26, 2012 at 12:43 UTC
      Good day to you too! Thanks, for the pointers with regards to the Subwidget() method, I will look into that.

      I'm aware of your reply from two days ago, I used the hash method and that worked fine for the purposes of that question, but that's not the same as I was asking here (unless I'm missing something which is quite possible due to my still limited Perl/TK skills?).

      Edit: ok I think I get it:

      $mw->optionAdd('*borderWidth', '1');

      seems to work for (almost) everything!

        There's probably a few things you should take into consideration before making universal changes.

        As well as borderWidth, some widgets also have activeBorderWidth, insertBorderWidth and selectBorderWidth - Tk::options has details of these. If, for instance, you had borderWidth and activeBorderWidth with different sizes, you'll get unwanted visual effects when you interact with these widgets.

        Other widgets, such as Tk::Frame, have a default borderWidth of zero which you'll generally not want to change.

        In short, while $mw->optionAdd('*borderWidth', '1'); might look like a quick fix, it will probably lead to all sorts of unwanted problems - some of which may not be immediately obvious.

        My advice would be to just change what you need on a widget-by-widget basis.

        Here's a few more examples, taken from the same script as the earlier examples, that demonstrate some of the points I've just made:

        $mw->optionAdd(q{*Entry*borderWidth}, 1, $priority); $mw->optionAdd(q{*Entry*insertBorderWidth}, 0, $priority); $mw->optionAdd(q{*Entry*selectBorderWidth}, 0, $priority); $mw->optionAdd(q{*NoteBook.borderWidth}, 1, $priority); $mw->optionAdd(q{*NoteBook.activeBorderWidth}, 1, $priority); $mw->optionAdd(q{*NoteBook.Frame.borderWidth}, 0, $priority); $mw->optionAdd(q{*NoteBook.Frame.activeBorderWidth}, 0, $priority) +;

        -- Ken

        In this thread, I've just provided a link to the thread from two days ago. Here it is again: Re: Perl/TK: how to set defaults for the whole script?. If you follow this link, you'll see that in addition to the hash solution, I discussed an option database solution. I gave a very brief overview, a link to documentation on the subject, some example code and an indication of how you should integrate it into your script.

        -- Ken

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1001052]
Approved by kcott
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2018-04-21 04:55 GMT
Find Nodes?
    Voting Booth?