no display name and no $DISPLAY environment variable
while executing
"load /enadisk/commun/linux/local/ActiveTcl-8.6.11/lib/libtk8.6.so Tk"
("package ifneeded Tk 8.6.11" script)
invoked from within
"package require Tk 8"
(in namespace eval "::request" script line 12)
invoked from within
"namespace eval ::request $script"
("::try" body line 12)
OUTPUT BUFFER:
#==============================================================================
# Contains scaling-related utility procedures.
#
# Structure of the module:
# - Namespace initialization
# - Public utility procedures
# - Private helper procedures
#
# Copyright (c) 2020 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================
package require Tk 8
#
# Namespace initialization
# ========================
#
namespace eval scaleutil {
#
# Public variables:
#
variable version 1.0
variable library
if {$::tcl_version >= 8.4} {
set library [file dirname [file normalize [info script]]]
} else {
set library [file dirname [info script]] ;# no "file normalize" yet
}
#
# Public procedures:
#
namespace export scalingPercentage \
scaleBWidgetSpinBox scaleBWidgetComboBox \
scaleIncrDateentry scaleIncrTimeentry \
scaleIncrCombobox scaleOakleyComboboxArrow
}
#
# Public utility procedures
# =========================
#
#------------------------------------------------------------------------------
# scaleutil::scalingPercentage
#
# Returns the display's current scaling percentage (100, 125, 150, 175, or 200).
#------------------------------------------------------------------------------
proc scaleutil::scalingPercentage winSys {
variable onX11 [expr {[string compare $winSys "x11"] == 0}]
set pct [expr {[tk scaling] * 75}]
if {$onX11} {
set factor 1
if {[catch {exec ps -e | grep xfce}] == 0} { ;# Xfce
if {[catch {exec xfconf-query -c xsettings \
-p /Gdk/WindowScalingFactor} result] == 0} {
set factor $result
set pct [expr {100 * $factor}]
}
} elseif {[catch {exec ps -e | grep mate}] == 0} { ;# MATE
if {[catch {exec gsettings get org.mate.interface \
window-scaling-factor} result] == 0} {
if {$result == 0} { ;# means: "Auto-detect"
#
# Try to get the scaling factor from the cursor size
#
if {[catch {exec xrdb -query | grep Xcursor.size} \
result] == 0 &&
[catch {exec gsettings get org.mate.peripherals-mouse \
cursor-size} defCursorSize] == 0} {
scan $result "%*s %d" cursorSize
set factor [expr {($cursorSize + $defCursorSize - 1) /
$defCursorSize}]
set pct [expr {100 * $factor}]
}
} else {
set factor $result
set pct [expr {100 * $factor}]
}
}
} elseif {[catch {exec gsettings get \
org.gnome.settings-daemon.plugins.xsettings overrides} \
result] == 0 &&
[set idx \
[string first "'Gdk/WindowScalingFactor'" $result]] >= 0} {
scan [string range $result $idx end] "%*s <%d>" factor
set pct [expr {100 * $factor}]
} elseif {[catch {exec xrdb -query | grep Xft.dpi} result] == 0} {
scan $result "%*s %f" dpi
set pct [expr {100 * $dpi / 96}]
} elseif {$::tk_version >= 8.3 &&
[catch {exec ps -e | grep gnome}] == 0 &&
![info exists ::env(WAYLAND_DISPLAY)] &&
[catch {exec xrandr | grep " connected"} result] == 0 &&
[catch {open $::env(HOME)/.config/monitors.xml} chan] == 0} {
#
# Update pct by scanning the file ~/.config/monitors.xml
#
scanMonitorsFile $chan pct
}
#
# Conditionally correct and then scale the sizes of the standard fonts
#
if {$::tk_version >= 8.5} {
scaleX11Fonts $factor
}
}
if {$pct < 100 + 12.5} {
set pct 100
} elseif {$pct < 125 + 12.5} {
set pct 125
} elseif {$pct < 150 + 12.5} {
set pct 150
} elseif {$pct < 175 + 12.5} {
set pct 175
} else {
set pct 200
}
if {$onX11} {
tk scaling [expr {$pct / 75.0}]
if {$pct > 100} {
#
# Scale the default scrollbar width
#
set helpScrlbar .__helpScrlbar
for {set n 2} {[winfo exists $helpScrlbar]} {incr n} {
set helpScrlbar .__helpScrlbar$n
}
scrollbar $helpScrlbar
set defScrlbarWidth [lindex [$helpScrlbar configure -width] 3]
destroy $helpScrlbar
set scrlbarWidth [expr {$defScrlbarWidth * $pct / 100}]
option add *Scrollbar.width $scrlbarWidth userDefault
}
}
if {$::tk_version >= 8.5} {
#
# Scale a few styles for the built-in themes
# "alt", "clam", "classic", and "default"
#
scaleStyles $pct
#
# For the "xpnative" and "vista" themes work around a bug
# related to the scaling of ttk::checkbutton and ttk::radiobutton
# widgets in Tk releases no later than 8.6.10 and 8.7a3
#
if {$pct > 100 &&
([package vcompare $::tk_patchLevel "8.6.10"] <= 0 ||
($::tk_version == 8.7 &&
[package vcompare $::tk_patchLevel "8.7a3"] <= 0))} {
foreach theme {xpnative vista} {
if {[lsearch -exact [ttk::style theme names] $theme] >= 0} {
patchWinTheme $theme $pct
}
}
}
}
return $pct
}
#------------------------------------------------------------------------------
# scaleutil::scaleBWidgetSpinBox
#
# Scales a BWidget SpinBox widget of the given path name.
#------------------------------------------------------------------------------
proc scaleutil::scaleBWidgetSpinBox {w pct} {
#
# Scale the width of the two arrows, which is set to 11
#
set arrWidth [expr {11 * $pct / 100}]
$w.arrup configure -width $arrWidth
$w.arrdn configure -width $arrWidth
}
#------------------------------------------------------------------------------
# scaleutil::scaleBWidgetComboBox
#
# Scales a BWidget ComboBox widget of the given path name.
#------------------------------------------------------------------------------
proc scaleutil::scaleBWidgetComboBox {w pct} {
#
# Scale the width of the arrow, which is set to 11 or 15
#
variable onX11
set defaultWidth [expr {$onX11 ? 11 : 15}]
set width [expr {$defaultWidth * $pct / 100}]
$w.a configure -width $width
#
# Scale the width of the two scrollbars, which is set to 11 or 15
#
ComboBox::_create_popup $w
if {![Widget::theme]} {
bind $w.shell