[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

tkToplvel remove close,restore and minimize buttons

Jesus Jesus

3/28/2009 7:40:00 PM

i need to remove close,restore and minimize buttons from tk toplevel
--
Posted via http://www.ruby-....

6 Answers

Gregory Brown

3/28/2009 7:58:00 PM

0

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

--
Technical Blaag at: http://blog.majesticseacr...
Non-tech stuff at: http://metametta.bl...
"Ruby Best Practices" Book now in O'Reilly Roughcuts:
http://rubybestpra...

Jesus Jesus

3/28/2009 8:42:00 PM

0

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?


--
Posted via http://www.ruby-....

Gregory Brown

3/28/2009 8:57:00 PM

0

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

poison tooth

3/29/2009 1:55:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

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/tcl...

On Sat, Mar 28, 2009 at 1:39 PM, Jesus Jesus <jesussalas187@hotmail.com>wrote:

> i need to remove close,restore and minimize buttons from tk toplevel
> --
> Posted via http://www.ruby-....
>
>


--
There was a man, they called him mad.
The more he gave, the more he had.

Hidetoshi NAGAI

3/31/2009 10:23:00 PM

0

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) # ??????
# 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) # ??????
# 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
------------------------------------------------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Jesus Jesus

4/18/2009 10:52:00 PM

0

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

--
Posted via http://www.ruby-....