tkToplvel remove close,restore and minimize buttons

i need to remove close,restore and minimize buttons from tk toplevel

On Sat, Mar 28, 2009 at 3:39 PM, Jesus J. [email protected]
wrote:

i need to remove close,restore and minimize buttons from tk toplevel

So what is your question?

-greg

Gregory B. wrote:

On Sat, Mar 28, 2009 at 3:39 PM, Jesus J. [email protected]
wrote:

i need to remove close,restore and minimize buttons from tk toplevel

So what is your question?

-greg

what is the way to do that?

On Sat, Mar 28, 2009 at 4:41 PM, Jesus J. [email protected]
wrote:

Gregory B. wrote:

On Sat, Mar 28, 2009 at 3:39 PM, Jesus J. [email protected]
wrote:

i need to remove close,restore and minimize buttons from tk toplevel

So what is your question?

-greg

what is the way to do that?

What have you tried so far? What websites / documentation have you
looked at? What errors have you run into?
Without these things, it seems more like you are asking folks to do
your work for you than it is that you are trying to get past a problem
you’ve run into.

-greg

I don’t know if it is possible to remove the x, -, or + but i know it is
possible to make the x button not work…

require ‘tk’
root = TkRoot.new()
root.protocol(‘WM_DELETE_WINDOW’, proc{p “This does not work anymore!”})
Tk.mainloop

I can not find anything describing how to change the - or the + button.
Also might this be of any use?
http://ad.informatik.uni-freiburg.de/bibliothek/tutorials/tcltk/wm.html

From: Jesus J. [email protected]
Subject: tkToplvel remove close,restore and minimize buttons
Date: Sun, 29 Mar 2009 04:39:31 +0900
Message-ID: [email protected]

i need to remove close,restore and minimize buttons from tk toplevel

For example,

require ‘tk’
top = TkToplevel.new{
overrideredirect true
geometry ‘200x150+200+200’
}

#top.withdraw.deiconify
#^^^^^^^^^^^^^^^^^^^^^^

Sometimes, this line is required to remove the frame

decorated by the window manager.

TkButton.new(top, :text=>‘close’,
:command=>proc{top.destroy}).pack(:pady=>20)
TkButton.new(top, :text=>‘exit’, :command=>proc{exit}).pack(:pady=>20)
Tk.mainloop

or

require ‘tk’
TkToplevel.new(:overrideredirect=>true,
:geometry=>‘200x150+200+200’){|top|
TkButton.new(top, :text=>‘close’,
:command=>proc{top.destroy}).pack(:pady=>20)
TkButton.new(top, :text=>‘exit’, :command=>proc{exit}).pack(:pady=>20)
}
Tk.mainloop

However, when remove the window manager’s frame,
you cannot move the toplevel window by mouse.
If you need to do that, you have to make bindings to control the
toplevel.

The following is a sample of “Non-rectangle window” (Windows only).

require ‘tk’

TRANS_COLOR = ‘#020202’ # Transparent color.
# Of course, any color is available which is
# not used at non-transparent part.

root = Tk.root.title(‘Non-rectangle and half-transparent window demo’)

root.overrideredirect = true
root.attributes(:transparentcolor=>TRANS_COLOR) # set transparent color

x = 300
y = 200

color = ‘#66bb88

color = ‘DarkSeaGreen’

root.attributes(:alpha=>0.75) # alpha setting (half-transparent
setting)
# 0.0 (full trans) e$B!Ae(B 1.0 (non
trans)

In this script, use a canvas widget as a base frame.

One of the other ways is a label widget with a photo-image.

c = TkCanvas.new(root, :width=>x, :height=>y,
:highlightthickness=>0,
:background=>TRANS_COLOR).pack

draw a figure which is a frame of non-rectangle window.

ov = TkcOval.new(c, [0,0], [x,y], :outline=>color, :fill=>color)

place buttons (Only demo use. Those have no callback function.)

TkcWindow.new(c, [200, 50], :window=>TkButton.new(:text=>‘button1’))
TkcWindow.new(c, [150, 100], :window=>TkButton.new(:text=>‘button2’))
TkcWindow.new(c, [100, 150], :window=>TkButton.new(:text=>‘button3’))

binding to toggle the window frame of the window manager.

It may looks complex.

The reason of the complexity is to control the window position

to avoid sliding of the window when toggle the window frame.

c.bind(‘Double-1’){
if root.overrideredirect
# with no window frame
rx = c.winfo_rootx; ry = c.winfo_rooty
root.overrideredirect = false
root.attributes(:transparentcolor=>nil) # e$BF)2a?‘$N2r=|e(B
# root.withdraw; root.deiconify # if X Window System
/^(\d+)x(\d+)+(-?\d+)+(-?\d+)$/ =~ root.geometry
xpos = $3.to_i; ypos = $4.to_i
dx = c.winfo_rootx - rx; dy = c.winfo_rooty - ry
root.geometry(“+#{xpos - dx}+#{ypos - dy}”)
else
# with a window frame
/^(\d+)x(\d+)+(-?\d+)+(-?\d+)$/ =~ root.geometry
xpos = $3.to_i; ypos = $4.to_i
rx = c.winfo_rootx; ry = c.winfo_rooty
root.overrideredirect = true
root.attributes(:transparentcolor=>TRANS_COLOR) # e$BF)2a?’$N@_Dje(B
# root.withdraw; root.deiconify # if X Window System
root.geometry(“+#{rx}+#{ry}”)
end
}

bindings to drag the window

mark_px = mark_py = 0
mark_geom_x = mark_geom_y = 0
c.bind(‘1’){
/^(\d+)x(\d+)+(-?\d+)+(-?\d+)$/ =~ root.geometry
mark_geom_x = $3.to_i; mark_geom_y = $4.to_i
mark_px, mark_py = c.winfo_pointerxy
}
c.bind(‘B1-Motion’){
x, y = c.winfo_pointerxy
root.geometry(“+#{mark_geom_x + x - mark_px}+#{mark_geom_y + y -
mark_py}”)
}

start eventloop

Tk.mainloop

Jesus J. wrote:

i need to remove close,restore and minimize buttons from tk toplevel

require ‘tk’
$root=TkRoot.new{}
$toplevel=TkToplevel.new($root)
$toplevel.transient($root)
$toplevel.protocol(‘WM_DELETE_WINDOW’, proc{Tk::messageBox :message
=>"$root says ‘$toplevel belongs to me’"})
Tk.mainloop