Bwidget Source Code
View Ticket
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.
Ticket UUID: 5919a0ec2d31ae284f6de8b6c9c8b332ee02190c
Title: BWidget::place fails in a dual screen environment on windows
Type: Bug Version: 1.9.10
Submitter: anonymous Created on: 2016-07-20 20:42:55
Subsystem: bwidget Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2016-07-21 16:24:01
Resolution: Fixed Closed By: oehhar
    Closed on: 2016-07-21 16:24:01
I am using a laptop with the following screens:
- main screen: 2880x1800 (max. resolution), but currently running on 1920x1200
- 2nd screen: 1920x1200, operating system is windows 7.

When starting the BWidgets demo the process is running, but the window is initially placed outside the screen and therefore completely invisible.
As the  BWidget::place procedure is also used in the Dialog widget, a BWidget dialog comes along with the same problem.

The folowing code change fixes the problem on my machine - pls. see changes down below the "center to screen comment":

proc BWidget::place { path w h args } {


            set sw [winfo screenwidth  $path]
            set sh [winfo screenheight $path]
            if { $idx == 1 } {
                if { $arglen == 2 } {
                    # center to widget
                    set x0 [expr {[winfo rootx $widget] + ([winfo width  $widget] - $w)/2}]
                    set y0 [expr {[winfo rooty $widget] + ([winfo height $widget] - $h)/2}]
                } else {

                    # center to screen
                    # set x0 [expr {($sw - $w)/2 - [winfo vrootx $path]}]
                    # set y0 [expr {($sh - $h)/2 - [winfo vrooty $path]}]
		    set x0 [expr {[winfo rootx $path] + ([winfo width $path] / 2 -  [winfo reqwidth $widget] / 2)}]
		    set y0 [expr {[winfo rooty $path] + ([winfo height $path] / 2 - [winfo reqheight $widget] / 2)}]

		    # If $main is not realized we get funny sizes back
		    # This will make the dialog box visible at least.
		    if {$x0 < 0} {set x0 150}
		    if {$y0 < 0} {set y0 150}

I would also be glad to forward the changed util.tcl file if required.

Thanks a lot,
  Johann Oberdorfer
User Comments: oehhar added on 2016-07-21 16:24:01:

Johann confirmed the effectiveness of the patch.

Close bug

oehhar added on 2016-07-21 13:39:29:

Thank you for the bug report. Effectively an issue.

Please check, if [85ca650f34] solves the issue for you.