BrowseEntry on multiple displays issue

[email protected] Tue, 6 Dec 2011 15:40:24 +0000 (UTC)
Newsgroups gmane.comp.lang.perl.tk
Message-ID <1316266701.751642.1323186024927.JavaMail.root@sz0059a.westchester.pa.mail.comcast.net>
Hello,

Google has failed me thus far or I haven't hit on the right keywords to search on.
Hopefully the ptk list will have some insight...

I have a perl/Tk script that is working pretty well.  The sole exception is the PopupChoices for a HistEntry I am using.  The script is run on a multiple monitor Windows box.  When it is run on display 2 or 3, the PopupChoices appear on display 1.

After some hacking in the BrowseEntry.pm file, I've narrowed it down to some logic that tries to keep the entire popup visible when toggled:

        # if listbox is too far right, pull it back to the left
	#
	if ($x2 > $w->vrootwidth) {
	    print "listbox is too far right... pulling back\n";
	    print "vrootwidth   = ", $w->vrootwidth, "\n";
	    print "screenwidth  = ", $w->screenwidth, "\n";
	    print "screenheight = ", $w->screenheight, "\n";
	    print "screen       = ", $w->screen, "\n";

            # offending line...
	    $x1 = $w->vrootwidth - $width;
	}

The output when it is hit is:

listbox is too far right... pulling back
vrootwidth   = 1680
screenwidth  = 1680
screenheight = 1050
screen       = :0.0

The 'screen' is 5040x1050 (3 x 1680) x 1050.

I get what it is trying to do and looked for a workaround.  There doesn't seem to be a Tk call to get the display number the app is running in.  It is always :0.0.  I haven't tested this on a UN*X box yet to see how it behaves there.

Simply commenting out the offending line from BrowseEntry.pm works for now but is not a viable solution for the long run...


I had a similar problem with displaying a Toplevel in the same screen as the main window.  In the end it required doing:

                my @geometry = split( /[x+]/, $widgets{'MW'}->geometry() );
                
                my $geometry;
                
                my $xpos = $geometry[2] + 100;
                my $ypos = $geometry[3] + 100;
                
                $geometry = "200x120+$xpos+$ypos";

Which causes the sub-window to be displayed 100 pixels right and down from the top left corner of the main window.

Is there a way to determine which display of a multi-monitor desktop the GUI is actually running in?  Should I hack up a patch which does something similar for BrowseEntry's PopupChoices.  I would prefer a more elegant solution, but I'm not sure one exists in the Tk toolkit right now.

If anyone has more insight into the inner workings of perl/Tk, I'd love to hear it.

Thanks for the assistance!

- Todd
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk