`self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)` maked min/max buttons disappear

88 views
Skip to first unread message

cool-RR

unread,
May 21, 2011, 4:53:41 PM5/21/11
to wxpytho...@googlegroups.com
Hey,

When I do `self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)` on a frame, the minimize/maximize buttons disappear. Why? How can I have all buttons?

(Win XP.)


Thanks,
Ram.

Boštjan Mejak

unread,
May 22, 2011, 4:52:12 AM5/22/11
to wxpytho...@googlegroups.com
I think you'll find this StackOverflow thread useful: http://stackoverflow.com/questions/3243495/wxpython-context-help

cool-RR

unread,
May 22, 2011, 9:05:22 AM5/22/11
to wxpython-users
On Sun, May 22, 2011 at 4:52 AM, Boštjan Mejak <bostja...@gmail.com> wrote:
I think you'll find this StackOverflow thread useful: http://stackoverflow.com/questions/3243495/wxpython-context-help

I ran it and it has the same problem: It makes a frame with a question mark button but without minimize/maximize buttons.


Ram. 

Robin Dunn

unread,
May 22, 2011, 4:13:23 PM5/22/11
to wxpytho...@googlegroups.com

From the wxFrame docs:
"""
wxFRAME_EX_CONTEXTHELP Under Windows, puts a query button on the
caption. When pressed, Windows will go into a context-sensitive help
mode and wxWidgets will send a wxEVT_HELP event if the user clicked on
an application window. Note that this is an extended style and must be
set by calling SetExtraStyle before Create is called (two-step
construction). You cannot use this style together with wxMAXIMIZE_BOX or
wxMINIMIZE_BOX, so you should use wxDEFAULT_FRAME_STYLE & ~
(wxMINIMIZE_BOX | wxMAXIMIZE_BOX) for the frames having this style (the
dialogs don't have a minimize or a maximize box by default)
"""

Apparently the part about needing to remove the min/max styles and using
2-phase create is no longer true, but it is clear that the min/max boxes
can not be used at the same time as the built-in context help button.
My guess is that it is a limitation imposed by Microsoft.

If you need to keep the ability to minimize and maximize the frame then
use a wx.ContextHelpButton within the frame's contents instead.


--
Robin Dunn
Software Craftsman
http://wxPython.org

cool-RR

unread,
May 22, 2011, 6:08:01 PM5/22/11
to wxpytho...@googlegroups.com
On Sun, May 22, 2011 at 10:13 PM, Robin Dunn <ro...@alldunn.com> wrote:
On 5/22/11 6:05 AM, cool-RR wrote:
On Sun, May 22, 2011 at 4:52 AM, Boštjan Mejak <bostja...@gmail.com
<mailto:bostja...@gmail.com>> wrote:

   I think you'll find this StackOverflow thread useful:
   http://stackoverflow.com/questions/3243495/wxpython-context-help


I ran it and it has the same problem: It makes a frame with a question
mark button but without minimize/maximize buttons.

From the wxFrame docs:
"""
wxFRAME_EX_CONTEXTHELP   Under Windows, puts a query button on the caption. When pressed, Windows will go into a context-sensitive help mode and wxWidgets will send a wxEVT_HELP event if the user clicked on an application window. Note that this is an extended style and must be set by calling SetExtraStyle before Create is called (two-step construction). You cannot use this style together with wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so you should use wxDEFAULT_FRAME_STYLE & ~ (wxMINIMIZE_BOX | wxMAXIMIZE_BOX) for the frames having this style (the dialogs don't have a minimize or a maximize box by default)
"""

Apparently the part about needing to remove the min/max styles and using 2-phase create is no longer true, but it is clear that the min/max boxes can not be used at the same time as the built-in context help button. My guess is that it is a limitation imposed by Microsoft.

Unfortunately you're right, as described in this MSDN document:

 
Quote: "The window has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style."


If you need to keep the ability to minimize and maximize the frame then use a wx.ContextHelpButton within the frame's contents instead.


--
Robin Dunn


Thanks,
Ram.

Boštjan Mejak

unread,
May 22, 2011, 6:41:56 PM5/22/11
to wxpytho...@googlegroups.com
So how would you code such a frame then? Please give a code snippet example. For noobs like myself to learn.

cool-RR

unread,
May 22, 2011, 6:43:40 PM5/22/11
to wxpytho...@googlegroups.com
On Mon, May 23, 2011 at 12:41 AM, Boštjan Mejak <bostja...@gmail.com> wrote:
So how would you code such a frame then? Please give a code snippet example. For noobs like myself to learn.

I didn't understand (1) whether the question was directed at me and (2) what exactly you mean by "such a frame".


Ram.

Boštjan Mejak

unread,
May 22, 2011, 9:02:33 PM5/22/11
to wxpytho...@googlegroups.com
By "such a frame" I mean how would the subclass of wx.Frame be.

Robin Dunn

unread,
May 22, 2011, 9:16:07 PM5/22/11
to wxpytho...@googlegroups.com
On 5/22/11 6:02 PM, Bo�tjan Mejak wrote:
> By "such a frame" I mean how would the subclass of wx.Frame be.
>

It depends on what else will be in the frame, you just add a
wx.ContextHelpButton inside the frame somewhere like any other button,
however it best fits within the UI.

Boštjan Mejak

unread,
May 23, 2011, 3:51:18 AM5/23/11
to wxpytho...@googlegroups.com
Do you think it would be done like this?


class MyFrame(wx.Frame):

    def __init__(self, *args, **kwargs):
        helpButtonOnFrame = wx.ContextHelpButton(self)


Would that suffice? Other code follows of course, but would you say that this would be enough? Assuming Windows OS.

Boštjan Mejak

unread,
May 23, 2011, 4:12:01 AM5/23/11
to wxpytho...@googlegroups.com
I thought in these lines...


import wx

class MyFrame(wx.Frame):

    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        # helpButton = wx.ContextHelpButton(self)

if __name__ == '__main__':
    app = wx.App(redirect=False)
    window = MyFrame(parent=None,
                     style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_EX_CONTEXTHELP)
    window.Center()
    window.Show()
    app.MainLoop()

But this does *not* work. There's just no context help button besides the minimize, maximize, and close button. (Windows user here.) What can we do to make it appear? Then how to make it respond to a user click and to generate some event?

Robin Dunn

unread,
May 23, 2011, 12:00:10 PM5/23/11
to wxpytho...@googlegroups.com

That creates the button. You still need to create a help provider, set
help text on items, etc. See the ContextHelp sample in the demo or even
the stackoverflow example you pointed to earlier.

Robin Dunn

unread,
May 23, 2011, 12:00:14 PM5/23/11
to wxpytho...@googlegroups.com
On 5/23/11 1:12 AM, Bo�tjan Mejak wrote:

> window = MyFrame(parent=None,
> style=wx.DEFAULT_FRAME_STYLE |
> wx.FRAME_EX_CONTEXTHELP)

>


> But this does *not* work. There's just no context help button besides
> the minimize, maximize, and close button. (Windows user here.) What can
> we do to make it appear?

As stated in the docs the wx.FRAME_EX_CONTEXTHELP style is an *extra*
style, so it has to be set with SetExtraStyle.


> Then how to make it respond to a user click and
> to generate some event?

Take a look at the sample in the demo.

Boštjan Mejak

unread,
May 23, 2011, 3:06:16 PM5/23/11
to wxpytho...@googlegroups.com
Ah yes, Robin, I see what you mean. What I wanna know is how to put that '?' button besides the minimize button, maximize button, and the X button in the top-right place of the frame.

Robin Dunn

unread,
May 23, 2011, 3:30:19 PM5/23/11
to wxpytho...@googlegroups.com

You can't. That is what the rest of this thread has been about.

Boštjan Mejak

unread,
May 23, 2011, 3:47:13 PM5/23/11
to wxpytho...@googlegroups.com
I see. How are other people implementing this button right there besides the X button then?

Tim Roberts

unread,
May 23, 2011, 3:53:44 PM5/23/11
to wxpytho...@googlegroups.com
Bo�tjan Mejak wrote:
I see. How are other people implementing this button right there besides the X button then?

Do you have an example?� In all the cases I've seen, that ? button is only displayed on dialogs, where you don't have or need Minimize and Maximize buttons.� An application is expected to have a "Help" menu item.

In a C++ application, you can take over all the drawing of the "non-client" areas yourself (that includes the title bar, buttons, and decorations) and do whatever you want, but users don't expect to see the ? button up there on application windows.
-- 
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Robin Dunn

unread,
May 23, 2011, 3:55:39 PM5/23/11
to wxpytho...@googlegroups.com
On 5/23/11 12:47 PM, Bo�tjan Mejak wrote:
> I see. How are other people implementing this button right there besides
> the X button then?

As has been mentioned a couple times already in this thread, you use the
extra style on the frame to get the context help button on the caption
bar, but because of a limitation imposed by microsoft you can not have
the minimize and maximize buttons at the same time as the help button.

Boštjan Mejak

unread,
May 23, 2011, 4:02:41 PM5/23/11
to wxpytho...@googlegroups.com
Aha! Now I get it! Thanks for clearing that up.

Boštjan Mejak

unread,
May 24, 2011, 4:01:14 AM5/24/11
to wxpytho...@googlegroups.com
But... Is there a workaround?

Tim Roberts

unread,
May 24, 2011, 1:09:14 PM5/24/11
to wxpytho...@googlegroups.com
Bo�tjan Mejak wrote:
But... Is there a workaround?

I don't know how many times we can say the same thing.� What you are asking is not supported by the operating system.� It isn't supported, in part, because Microsoft's user interface research showed it to be confusing for users.� It makes sense in a small dialog with a few controls, and such a dialog does not use minimize and maximize buttons.� In a window that is complicated enough to need minimize and maximize buttons, users don't expect or look for the context ? button.� They expect to find a "Help" button or "Help" menu item in the application.

Stop trying to find a workaround.� You will just confuse your users.
Reply all
Reply to author
Forward
0 new messages