Forum: Ruby tkToplvel remove close,restore and minimize buttons

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3759a90eac7bca9706dc1367b619f70e?d=identicon&s=25 Jesus Jesus (omaha)
on 2009-03-28 20:39
i need to remove close,restore and minimize buttons from tk toplevel
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2009-03-28 20:58
(Received via mailing list)
On Sat, Mar 28, 2009 at 3:39 PM, Jesus Jesus <jesussalas187@hotmail.com>
wrote:
> i need to remove close,restore and minimize buttons from tk toplevel

So what is your question?

-greg
3759a90eac7bca9706dc1367b619f70e?d=identicon&s=25 Jesus Jesus (omaha)
on 2009-03-28 21:41
Gregory Brown wrote:
> On Sat, Mar 28, 2009 at 3:39 PM, Jesus Jesus <jesussalas187@hotmail.com>
> 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?
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2009-03-28 21:57
(Received via mailing list)
On Sat, Mar 28, 2009 at 4:41 PM, Jesus Jesus <jesussalas187@hotmail.com>
wrote:
> Gregory Brown wrote:
>> On Sat, Mar 28, 2009 at 3:39 PM, Jesus Jesus <jesussalas187@hotmail.com>
>> 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
5247e7cd27b3d17e949a4008624c1059?d=identicon&s=25 Stefan Codrescu (Guest)
on 2009-03-29 03:56
(Received via mailing list)
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/tu...
E4f967492dbd03c526cc9b397e68021d?d=identicon&s=25 Hidetoshi NAGAI (Guest)
on 2009-04-01 00:24
(Received via mailing list)
From: Jesus Jesus <jesussalas187@hotmail.com>
Subject: tkToplvel remove close,restore and minimize buttons
Date: Sun, 29 Mar 2009 04:39:31 +0900
Message-ID: <7212f8602e9c8ec2fc49434282afcba6@ruby-forum.com>
> 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) 〜 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) # 透過職3校の解除
    # 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) # 透過職3校の設定
    # 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
3759a90eac7bca9706dc1367b619f70e?d=identicon&s=25 Jesus Jesus (omaha)
on 2009-04-19 00:51
Jesus Jesus 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
This topic is locked and can not be replied to.