Notebook & PopMenus

Hi,

( No answers - just a reason why :] )

I have seen the "right mouse click" used to popup a menu
on Notebook (tab controls) in a couple of software packages I use.

As an example "EditPad" (a text editor) uses the right click on a
notebook
tab to popup a menu to close, save, save as etc.

It obviously doesn't have uses in all Notebook controls, but there are
cases
where it can be useful.

Regards,

Ray Smith

···

-----Original Message-----
From: Jeff Sasmor [mailto:jsasmor@gte.net]
Sent: Thursday, 12 December 2002 9:39 AM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Notebook & PopMenus

It's probably possible, you can detect the click or mouseover with an
EVT and
pop up a menu easily enough, but it would certainly confuse people -
no one would expect it. If you click on a notebook tab the notebook
page
changes. How would you distinguish between that click and the one to pop
up the menu? Hmm, I've managed to confuse mysmelf.
#--------------------------------
Jeff Sasmor
jeff@sasmor.com
----- Original Message -----
From: "Tiago Duarte Felix" <tdf@mega.ist.utl.pt>
To: <wxPython-users@lists.wxwindows.org>
Sent: Wednesday, December 11, 2002 3:02 AM
Subject: [wxPython-users] Notebook & PopMenus

I'd like to know if it is possible to put a popup menu on the tabs of
the
notebook!

If it is possible.. please reply with some ideas... thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

The "close" menu option will be hell to implement due to the fact that
you must try to close the tab in the event handler which brings up all
sort of rentrancy issues (not to mention just knowing what tab you're
currently on).

But here's what you asked for (popup menu on tab):

from wxPython.wx import *

···

On Wed, 2002-12-11 at 14:42, Smith, Ray wrote:

Hi,

( No answers - just a reason why :] )

I have seen the "right mouse click" used to popup a menu
on Notebook (tab controls) in a couple of software packages I use.

As an example "EditPad" (a text editor) uses the right click on a
notebook
tab to popup a menu to close, save, save as etc.

It obviously doesn't have uses in all Notebook controls, but there are
cases
where it can be useful.

#----------------------------------------------------------------------
class MyFrame(wxFrame):
    def __init__(self):
        wxFrame.__init__(self, None, -1, "Popup Menus Demo")
        self.nb = wxNotebook(self, -1, style=wxCLIP_CHILDREN)
        self.nextPage = 1
        self.newTab()

        EVT_RIGHT_DOWN(self.nb, self.OnRightDown)

    def OnRightDown(self, event):
        menu = wxMenu()

        mid = wxNewId()
        item = wxMenuItem(menu, mid, "New")
        menu.AppendItem(item)
        EVT_MENU(self, mid, lambda evt: self.newTab())

        mid = wxNewId()
        item = wxMenuItem(menu, mid, "Close")
        menu.AppendItem(item)
        EVT_MENU(self, mid, lambda evt: self.closeTab())
        
        self.PopupMenu(menu, wxPoint(event.GetX(), event.GetY()))
        menu.Destroy()

        event.Skip()

    def newTab(self):
        self.nb.AddPage(wxPanel(self.nb, -1), "Page %d" % self.nextPage)
        self.nextPage += 1

    def closeTab(self):
        # this would require a *lot* of work
        pass
    
    def OnExit(self, evt):
        self.Close(true)

#----------------------------------------------------------------------
if __name__ == '__main__':
    class MyApp(wxApp):
        def OnInit(self):
            frame = MyFrame()
            frame.Show(true)
            self.SetTopWindow(frame)
            return true

    app = MyApp()
    app.MainLoop()

--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308

Thank you very much Ray!!! That's why... i am building an editor.... i
started by doing it using
MDI windows but now.. i have seen tabs and Notebook.. and i really like
it....!!!

What i need is right clicking on a tab.. and show a menu.... with some stuff
relative to the file....

I o somehing like this in a tree... but the tree has a fantastic thing ..
called Hit...
tabs don't... so i need something like:

riht click down:
    selects tab under mouse pointer

right click up:
    pops menu

if anyone has done some something like this.. please tell me....

Thanks!!

···

----- Original Message -----
From: "Smith, Ray" <Ray.Smith@fujitsu.com.au>
To: <wxPython-users@lists.wxwindows.org>
Sent: Wednesday, December 11, 2002 10:42 PM
Subject: RE: [wxPython-users] Notebook & PopMenus

Hi,

( No answers - just a reason why :] )

I have seen the "right mouse click" used to popup a menu
on Notebook (tab controls) in a couple of software packages I use.

As an example "EditPad" (a text editor) uses the right click on a
notebook
tab to popup a menu to close, save, save as etc.

It obviously doesn't have uses in all Notebook controls, but there are
cases
where it can be useful.

Regards,

Ray Smith

-----Original Message-----
From: Jeff Sasmor [mailto:jsasmor@gte.net]
Sent: Thursday, 12 December 2002 9:39 AM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Notebook & PopMenus

It's probably possible, you can detect the click or mouseover with an
EVT and
pop up a menu easily enough, but it would certainly confuse people -
no one would expect it. If you click on a notebook tab the notebook
page
changes. How would you distinguish between that click and the one to pop
up the menu? Hmm, I've managed to confuse mysmelf.
#--------------------------------
Jeff Sasmor
jeff@sasmor.com
----- Original Message -----
From: "Tiago Duarte Felix" <tdf@mega.ist.utl.pt>
To: <wxPython-users@lists.wxwindows.org>
Sent: Wednesday, December 11, 2002 3:02 AM
Subject: [wxPython-users] Notebook & PopMenus

I'd like to know if it is possible to put a popup menu on the tabs of
the
notebook!

If it is possible.. please reply with some ideas... thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Can't you get around that problem with wxCallAfter or
setting up something to be handled by the idle event handler?

···

At 15:59 2002-12-11 -0800, Cliff Wells wrote:

The "close" menu option will be hell to implement due to the fact that
you must try to close the tab in the event handler which brings up all
sort of rentrancy issues (not to mention just knowing what tab you're
currently on).

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

wxCallAfter... where did you see that? An idle event is a possibility.
Anyway, like I said, it will be far from simple.

···

On Thu, 2002-12-12 at 01:38, Magnus Lycka wrote:

At 15:59 2002-12-11 -0800, Cliff Wells wrote:
>The "close" menu option will be hell to implement due to the fact that
>you must try to close the tab in the event handler which brings up all
>sort of rentrancy issues (not to mention just knowing what tab you're
>currently on).

Can't you get around that problem with wxCallAfter or
setting up something to be handled by the idle event handler?

--
Cliff Wells <clifford.wells@attbi.com>

wxCallAfter... where did you see that? An idle event is a possibility.
Anyway, like I said, it will be far from simple.

wxCallAfter has been introduced in 2.3.3 (anyway, it's pure python and works wonderfully well also with 2.3.2 - just cut & paste it), and it simplifies the task a lot. Anyway, closing the tab is difficult nevertheless because you have to find out which tab you clicked on, and I don't think this is so easy. Supposing that you want always to close the active one, though, it should be feasible.

Alberto

>
> wxCallAfter... where did you see that? An idle event is a possibility.
> Anyway, like I said, it will be far from simple.

wxCallAfter has been introduced in 2.3.3 (anyway, it's pure python and
works wonderfully well also with 2.3.2 - just cut & paste it), and it

Ah. So it won't be in the wxWindows docs...

simplifies the task a lot. Anyway, closing the tab is difficult
nevertheless because you have to find out which tab you clicked on,
and I don't think this is so easy. Supposing that you want always to
close the active one, though, it should be feasible.

Yes, closing the active tab seems the only doable approach, although
this still presents a problem (from a programming perspective) since
there doesn't appear to be any way to determine that the user has
right-clicked on the *active* tab. It is also confusing (from a
user-interface perspective) to right click on an inactive tab, select
close and see the active tab go away. I wasn't able to find an
acceptable work-around for this (although I admittedly only spent a
short time [less than an hour] on the problem).

Another option might be to use something like Mozilla does: a separate
close button (with an "X" in it) that closes the active tab.

···

On Thu, 2002-12-12 at 02:31, Alberto Griggio wrote:

--
Cliff Wells <clifford.wells@attbi.com>

OK, I can see that making sense, a right click on a tab popping
up a menu. I still think that it wouldn't be intuitive for a user
to try to do that but...

···

#--------------------------------
Jeff Sasmor
jeff@sasmor.com
----- Original Message -----
From: "Smith, Ray" <Ray.Smith@fujitsu.com.au>
To: <wxPython-users@lists.wxwindows.org>
Sent: Wednesday, December 11, 2002 5:42 PM
Subject: RE: [wxPython-users] Notebook & PopMenus

Hi,

( No answers - just a reason why :] )

I have seen the "right mouse click" used to popup a menu
on Notebook (tab controls) in a couple of software packages I use.

As an example "EditPad" (a text editor) uses the right click on a
notebook
tab to popup a menu to close, save, save as etc.

It obviously doesn't have uses in all Notebook controls, but there are
cases
where it can be useful.

Regards,

Ray Smith

-----Original Message-----
From: Jeff Sasmor [mailto:jsasmor@gte.net]
Sent: Thursday, 12 December 2002 9:39 AM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Notebook & PopMenus

It's probably possible, you can detect the click or mouseover with an
EVT and
pop up a menu easily enough, but it would certainly confuse people -
no one would expect it. If you click on a notebook tab the notebook
page
changes. How would you distinguish between that click and the one to pop
up the menu? Hmm, I've managed to confuse mysmelf.
#--------------------------------
Jeff Sasmor
jeff@sasmor.com
----- Original Message -----
From: "Tiago Duarte Felix" <tdf@mega.ist.utl.pt>
To: <wxPython-users@lists.wxwindows.org>
Sent: Wednesday, December 11, 2002 3:02 AM
Subject: [wxPython-users] Notebook & PopMenus

I'd like to know if it is possible to put a popup menu on the tabs of
the
notebook!

If it is possible.. please reply with some ideas... thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

I haven't used tabs, so I'm just speculating wildly.

Couldn't right-click -> select "close" do:

1. Make the tab we clicked on active.
2. wxCallAfter(myCloseActiveTab)

(I guess that might cause some flickering though. And worse,
we might end up with a different active tab than the one we
had before. :frowning: )

Or is activating a tab something hardwired to left-click that
we can't get to?

What window/control is handling the right-click event? Is there
no way to set an "I'm the tab to close later" attribute somewhere?

···

At 11:31 2002-12-12 +0100, Alberto wrote:

Anyway, closing the tab is difficult nevertheless because you have to find out which tab you clicked on, and I don't think this is so easy. Supposing that you want always to close the active one, though, it should be feasible.

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

Yes, closing the active tab seems the only doable approach, although
this still presents a problem (from a programming perspective) since
there doesn't appear to be any way to determine that the user has
right-clicked on the *active* tab.

I agree 100%.

It is also confusing (from a

user-interface perspective) to right click on an inactive tab, select
close and see the active tab go away. I wasn't able to find an
acceptable work-around for this (although I admittedly only spent a
short time [less than an hour] on the problem).

Yes, I wasn't saying that the solution is good, I just wanted to point out that wxCallAfter is useful in similar situations.

Another option might be to use something like Mozilla does: a separate
close button (with an "X" in it) that closes the active tab.

Since we're talking about web browsers, I would prefer something like Galeon, in which every tab has its own close button. Unfortunately, this seems not possible with wxWindows.

Alberto

Couldn't right-click -> select "close" do:

1. Make the tab we clicked on active.

This is the problematic point. On GTK, any click on a tab selects it, but on MSW, only left-click works (apparently), and it seems that there's no way to know over which tab the mouse is from inside a mouse event handler.

Or is activating a tab something hardwired to left-click that
we can't get to?

Yes, I think this is the point.

Alberto

Why is everyone saying that it isn't user friendly???

Has eever worked with Komodo?
That is what i want to build.... the problem is that when i right click the
menu should only appear on
a selected tab... and i have no idea how this is done...
but from what i have seen it isn't possible....

that's ok.. i will do it with MDI....

Thanks everyone!

PS: I really think that tabs are user friendly......

Why is everyone saying that it isn't user friendly???

Has eever worked with Komodo?
That is what i want to build.... the problem is that when i right click the
menu should only appear on
a selected tab... and i have no idea how this is done...
but from what i have seen it isn't possible....

that's ok.. i will do it with MDI....

MDI on GTK is done with tabs anyway.

Thanks everyone!

PS: I really think that tabs are user friendly......

That's not what is being said. I think tabs are the best (far
preferable to either opening a bunch of windows or the MDI child window
monster). The problems that have been brought up have more to do with
circumventing limitations in wxWindows so that the experience isn't
confusing for the user.

The problems so far:

1. The tab isn't an obvious place for a menu (this is overcome by
learning, of course).

2. When you capture the right click, you have no way of determining
which tab the click occurred in, so if the menu item takes action on a
tab (e.g. to close it) other than the currently selected tab you'll
have a difficult time knowing which tab to take the action on. Also,
since clicking on the tab *selects* it, the current tab is going to
change as soon as your event handler exits.

3. Probably some other stuff when you get 2) figured out :wink:

···

On Thu, 2002-12-12 at 09:52, Tiago Duarte Felix wrote:

--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308

Tabs are user friendly. I guess that's not the point - the point is that
having a menu as right click on a tab might not be so obvious. It's simply
uncommon. Most users don't even know that there are right click menus in
Internet explorer :slight_smile: I'm doing consulting and UI design for 19 years now -
what I learned from that is that the average user is more stupid than you
anticipate - where "stupid" has nothing to do with the IQ. Users will only
click what they can SEE. If you want or have to use unobvious elements make
sure the user knows about it (i.e. a Tip popup that tells him to click right
on the tab). As a little anekdote: years back we designed a webpage with a
single big button saying "Don't click here or your computer will hang". The
button invoked a small script that would create new browser windows in an
endless loop. Old versions of IE had a error which would cause internal
overflows and therefor most likely create a "blue screen" when too many
windows where open.
You can imagine - we had over 1000 "stupid clicks" a day :-))

There is one rule for GUI design: Never do anything that isn't obvious.
The "average" user will not try right clicking on the tab without a hint. Thus
he might never find your menu - what will result in customer service calls.
IMHO that's why a lot of people on this list think its not user friendly ( and
I have to concur, even if the solution is elegant in its way)

  UC

···

On Thursday 12 December 2002 09:52 am, Tiago Duarte Felix wrote:

Why is everyone saying that it isn't user friendly???

Has eever worked with Komodo?
That is what i want to build.... the problem is that when i right click the
menu should only appear on
a selected tab... and i have no idea how this is done...
but from what i have seen it isn't possible....

that's ok.. i will do it with MDI....

Thanks everyone!

PS: I really think that tabs are user friendly......

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

Tiago Duarte Felix wrote:

from what i have seen it isn't possible....

That's because wxNoteBook uses the native control, which doesn't support
what you want.

that's ok.. i will do it with MDI....

PS: I really think that tabs are user friendly......

I think tabs are user friendly as well, and I hate MDI (which is only
supported properly on Windows anyway). If it makes sense to see ore than
one window at a time, use separate frames. If it makes sense to only see
one window at a time, use a Notebook. Couldn't you come up with another
way? perhaps you could create a custom panel that would go on al your
notebook pages, that had some sort of control at the top that could do
what you want (menubar, toolbar, wxchoice, whatever)

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov