Dear Monks,

I was wondering if anyone may be able to help on this minor problem that's starting to bug me.

I'm writing a perl/Tk application that uses a BrowseEntry widget. I've recently noticed that on windows, the listbox drops down perfectly aligned with the entry space every time, but on osx and linux, the listbox always aligns to the left-most edge of the widget. This is fine when the BrowseEntry widget does not have a label, but when it does have a label, the listbox is no longer aligned with the entry space.

As a minimal example, this perl/Tk window has a BrowseEntry widget with a label ('Options:'), and the drop-down list box is misaligned on osx/linux:

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::BrowseEntry; my $mw = MainWindow -> new; $mw->geometry("350x50"); my $browseEntry = $mw ->BrowseEntry( -label => 'Options:', -state => 'readonly', -autolistwidth => '1', -justify => 'right', -buttontakefocus => 1) -> pack( -ipadx => 35, -side => 'right', -fill => 'x', -anchor => 'e', -expand => 0); $browseEntry -> insert('end', qw(Option_A Option_B Option_C)); MainLoop;

At the moment, the only way I can find to align the listbox and entry space on osx/linux is to use a separate label widget, something like this:

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::BrowseEntry; my $mw = MainWindow -> new; $mw->geometry("350x50"); my $labelSeparate = $mw ->Label( -text => 'Options:', -width => 15) -> pack( -side => 'left', -fill => 'x', -expand => 1); my $browseEntry = $mw ->BrowseEntry( #-label => 'Options:', -state => 'readonly', -listwidth => '220', -justify => 'right', -buttontakefocus => 1) -> pack( -ipadx => 35, -side => 'left', -fill => 'x', -anchor => 'e', -expand => 1); $browseEntry -> insert('end', qw(Option_A Option_B Option_C)); MainLoop;

But does anybody know if it's possible to adjust the listbox alignment without adding a separate label widget? Windows seems to do this automatically...

Thanks in advance!


In reply to Perl/Tk: BrowseEntry Listbox alignment on osx/linux by mtmcc

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.