how can I get the "usable" screensize in Ruby/TK?
I mean, the total screensize minus taskbar (on Windows).
I tried:
require 'tk'
root = TkRoot.new
root.state('zoomed')
Tk.update
p TkWinfo.x(root)
p TkWinfo.y(root)
p TkWinfo.width(root)
p TkWinfo.height(root)
p TkWinfo.geometry(root)
but this gives me only
total_screensize - (taskbar + window_decoration)
window_decoration is titlebar and borders of a window, maybe
even something else.
I found http://wiki.tcl.tk/11291 which points into the
same direction, but I cannot use it with success (it's TCL).
I'm using:
* Windows XP
* ruby 1.8.7 (2009-06-12 patchlevel 174) [i386-mingw32]
* TCL/TK 8.5
how can I get the "usable" screensize in Ruby/TK?
I mean, the total screensize minus taskbar (on Windows).
I tried:
require 'tk'
root = TkRoot.new
root.state('zoomed')
Tk.update
p TkWinfo.x(root)
p TkWinfo.y(root)
p TkWinfo.width(root)
p TkWinfo.height(root)
p TkWinfo.geometry(root)
but this gives me only
total_screensize - (taskbar + window_decoration)
Hmmm.... Well, does this work?
···
From: Axel <a99.googlegroups.a99@dfgh.net>
Subject: TK: Get the "usable" screensize"?
Date: Tue, 2 Feb 2010 03:55:24 +0900
-------------------------------------------------------------------------
root = Tk.root
root.state(:zoomed)
Tk.update
root.geometry =~ /(\d+)x(\d+)\+([+-]?\d+)\+([+-]?\d)/
w = $1.to_i
h = $2.to_i
x = $3.to_i
y = $4.to_i
sw = root.winfo_screenwidth
sh = root.winfo_screenheight
rx = root.winfo_rootx
ry = root.winfo_rooty # maybe, taskbar height
usable_screenwidth = w + rx * 2 # maybe, x_border * 2
usable_screenheight = h + ry
taskbar_height = sh - usable_screenheight
-------------------------------------------------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
I found Total Window Geometry which points into the
same direction, but I cannot use it with success (it's TCL).
FYI, Ruby/Tk can use Tcl scripts.
For example,
···
From: Axel <a99.googlegroups.a99@dfgh.net>
Subject: TK: Get the "usable" screensize"?
Date: Tue, 2 Feb 2010 03:55:24 +0900
-------------------------------------------------------------------------
Tk.ip_eval <<EOS
proc totalGeometry {{w .}} {
set geom [wm geometry $w]
regexp -- {([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+)} $geom -> \
width height decorationLeft decorationTop
set contentsTop [winfo rooty $w]
set contentsLeft [winfo rootx $w]
# Measure left edge, and assume all edges except top are the
# same thickness
set decorationThickness [expr {$contentsLeft -
$decorationLeft}]
Tk.ip_eval <<EOS
proc taskbar {{w .taskBarSize}} {
catch {destroy $w}
toplevel $w
wm state $w zoomed
update
set val [expr {[winfo screenheight $w]-[winfo height $w]}]
destroy $w
return $val;
}
EOS
Tk.tk_call("totalGeometry") #=> e.g. "220 72 0 0"
TkComm.simplelist(Tk.tk_call("totalGeometry")) #=> e.g. ["220", "72", "0", "0"]
TkComm.list(Tk.tk_call("totalGeometry")) #=> e.g. [220, 72, 0, 0]
TkComm.tk_tcl2ruby(Tk.tk_call("totalGeometry")) #=> e.g. [220, 72, 0, 0]
Tk.tk_call_to_simplelist("totalGeometry")) #=> e.g. ["220", "72", "0", "0"]
Tk.tk_call_to_list("totalGeometry")) #=> e.g. [220, 72, 0, 0]
top = TkToplevel.new
Tk.tk_call("totalGeometry", top) #=> e.g. "230 104 0 0"
Tk.tk_call("taskbar") #=> e.g. "47"
TkComm.number(Tk.tk_call("taskbar")) #=> e.g. 47
TkComm.tk_tcl2ruby(Tk.tk_call("taskbar")) #=> e.g. 47
-------------------------------------------------------------------------
Also, please see an example ext/tk/sample/tktree.rb and tktree.tcl on
Ruby's source tree.
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
how can I get the "usable" screensize in Ruby/TK?
I mean, the total screensize minus taskbar (on Windows).
I tried:
require 'tk'
root = TkRoot.new
root.state('zoomed')
Tk.update
p TkWinfo.x(root)
p TkWinfo.y(root)
p TkWinfo.width(root)
p TkWinfo.height(root)
p TkWinfo.geometry(root)
but this gives me only
total_screensize - (taskbar + window_decoration)
window_decoration is titlebar and borders of a window, maybe
even something else.
I found Total Window Geometry which points into the
same direction, but I cannot use it with success (it's TCL).
I'm using:
* Windows XP
* ruby 1.8.7 (2009-06-12 patchlevel 174) [i386-mingw32]
* TCL/TK 8.5
Thank you,
Axel
MessageID:<4af30c88$0$83250$e4fe514c@news.xs4all.nl>
in comp.lang.tcl 11/06/2009