Is it posible to create a borderless floating menu?

Hi,

I’m attempting to create a UI component consisting of a wx.MenuBar housed in a borderless wx.Frame. In my sample code it works well as long as I specify the style for the frame window to have a caption. Since I intend to use this UI element as a child window elsewhere I would like to omit the caption style flag. But when doing so the second wx.Menu element, menu2, is never shown.

Does anybody have an idea of what’s wrong with my code or a suitable workaround? I’m testing it on Windows7 currently.

Many thanks,

Robert

CaptionlessMenuDemo.py (994 Bytes)

Tried it on Win7 with wxPython 3.0.0-classic. I get the same behavior, so I added a print w after you try getting all the menu widths, and in both cases I see 101 pixels. However if I change setting the width to self.SetClientSize((2*w, 0)) (twice w) then I can see Waffle… so something is weird there. I recommend adding in the widget inspector tool and then seeing what the difference is between both frame styles.

http://wiki.wxpython.org/Widget%20Inspection%20Tool

···

On Monday, November 24, 2014 10:55:26 AM UTC-8, Robert Oeffner wrote:

Hi,

I’m attempting to create a UI component consisting of a wx.MenuBar housed in a borderless wx.Frame. In my sample code it works well as long as I specify the style for the frame window to have a caption. Since I intend to use this UI element as a child window elsewhere I would like to omit the caption style flag. But when doing so the second wx.Menu element, menu2, is never shown.

Does anybody have an idea of what’s wrong with my code or a suitable workaround? I’m testing it on Windows7 currently.

even just changing it to:

self.SetClientSize((w + 10, 0))

allows the second menu to show up, so I think your method for determining the full width is not correct/appropriate… or you’re forgetting something (the small amount of space between menus maybe?).

···

On Monday, November 24, 2014 11:28:32 AM UTC-8, Nathan McCorkle wrote:

Tried it on Win7 with wxPython 3.0.0-classic. I get the same behavior, so I added a print w after you try getting all the menu widths, and in both cases I see 101 pixels. However if I change setting the width to self.SetClientSize((2*w, 0))

Thanks Nathan for figuring this out. Looking at the example code I realise that the value

w += ext[0] + ext[1]

makes little sense since ext[1] is the height of the supplied text. A better value would simply have been

w += ext[0] + margin

Still investigating what margin should be.

Rob

···

On Monday, 24 November 2014 19:36:08 UTC, Nathan McCorkle wrote:

On Monday, November 24, 2014 11:28:32 AM UTC-8, Nathan McCorkle wrote:

Tried it on Win7 with wxPython 3.0.0-classic. I get the same behavior, so I added a print w after you try getting all the menu widths, and in both cases I see 101 pixels. However if I change setting the width to self.SetClientSize((2*w, 0))

even just changing it to:

self.SetClientSize((w + 10, 0))

allows the second menu to show up, so I think your method for determining the full width is not correct/appropriate… or you’re forgetting something (the small amount of space between menus maybe?).

So it seems that with an carefully selected margin I can get both menu elements to show. But this is all in vain as the code doesn’t run on Linux but emits the error:

Gtk-WARNING **: Can’t set a parent on a toplevel widget

···

On Monday, 24 November 2014 18:55:26 UTC, Robert Oeffner wrote:

Hi,

I’m attempting to create a UI component consisting of a wx.MenuBar housed in a borderless wx.Frame. In my sample code it works well as long as I specify the style for the frame window to have a caption. Since I intend to use this UI element as a child window elsewhere I would like to omit the caption style flag. But when doing so the second wx.Menu element, menu2, is never shown.

Does anybody have an idea of what’s wrong with my code or a suitable workaround? I’m testing it on Windows7 currently.

Many thanks,

Robert

Just tried the code here on Ubuntu 14.04 with wxPython 3.0.1.1-classic gtk2 and I’m not getting that error, but on the other hand, I don’t see the menus!

Correction: Since I am on Ubuntu which uses the Unity display/window manager (maybe that is the wrong term to call it) the menu is actually at the top of the screen, so they’re totally disconnected from the Frame altogether.

Looking through the wxPython demos, there is one called FloatBar.py which allows you to pull a toolbar out into it’s own floating window/frame kind of thing.

···

On Tuesday, November 25, 2014 10:25:43 AM UTC-8, Robert Oeffner wrote:

So it seems that with an carefully selected margin I can get both menu elements to show. But this is all in vain as the code doesn’t run on Linux but emits the error:

Gtk-WARNING **: Can’t set a parent on a toplevel widget