Re: trying to build submenu

phmau <[email protected]> Sun, 29 Mar 2009 12:58:30 -0700 (PDT)
Newsgroups gmane.comp.ide.boa-constructor.user
Message-ID <[email protected]>
Thank you.
I will try.


Werner F. Bruhin wrote:
> 
> phmau wrote:
>> OK, I have seen this example in section 2.4
>> 
>> But it does not explain how to creat action from a sub or a sub sub menu.
>> 
>> Thanks if you can help me, with such an example.
> See attached is a modified version of the frame1.py from the guide 
> example folder.
> 
> What you probably miss and I did not mention in the post is that you 
> need to use the second icon in the menu collection editor to add your 
> sub-menu to a menu.  I added it to the file menu as the last item, then 
> creating the action/event on the items on the sub-menu is done exactly 
> in the same way as an event for a "normal" menu item.
> 
> Hope this helps
> Werner
>> 
>> regards,
>> 
>> 
>> 
>> Werner F. Bruhin wrote:
>>> Philippe,
>>>
>>> phmau wrote:
>>>> No it is not enough.
>>>> An example or documentation could be very helpfull.
>>>> My problem is to create the sub menu and to have an action associated
>>>> with
>>>> it, or annother subsubmenu with an action associated, under boa
>>>> cosntructor.
>>>> With boa constructor, I have created the name of the submenu, but I do
>>>> not
>>>> knon how to associate an axion.
>>> Check out the "Getting Started Guide for Boa Constructor" section 2.4 
>>> adding a "Menu bar" shows how to create a menu bar and menu item and how 
>>> to handle/create the menu event (action).
>>>
>>> The working example for the above is also in the folder
>>> boa/examples/guide.
>>>
>>> Hope this helps
>>>
>>> Werner
>>>> Thank you.
>>>>
>>>>
>>>> Werner F. Bruhin wrote:
>>>>> Philippe,
>>>>>
>>>>> philippe wrote:
>>>>>> Can anyone help me to build submenu with boa constructore.
>>>>>> I am  trying to build an application with python.
>>>>>>
>>>>>> Do you have an example ? And a documentation.
>>>>> A sub-menu is just a wx.Menu in a wx.Menu.
>>>>>
>>>>> Let me know if this is enough of a hint, otherwise I will do you a 
>>>>> little sample in the next few days.
>>>>>
>>>>> Werner
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM)
>>>>> are
>>>>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly
>>>>> and
>>>>> easily build your RIAs with Flex Builder, the Eclipse(TM)based
>>>>> development
>>>>> software that enables intelligent coding and step-through debugging.
>>>>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>>>>> _______________________________________________
>>>>> Boa-constructor-users mailing list
>>>>> Boa-constructor-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
>>>>> https://lists.sourceforge.net/lists/listinfo/boa-constructor-users
>>>>>
>>>>>
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Boa-constructor-users mailing list
>>> Boa-constructor-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
>>> https://lists.sourceforge.net/lists/listinfo/boa-constructor-users
>>>
>>>
>> 
> 
> 
> #Boa:Frame:Frame1
> 
> import wx
> import Dialog2
> 
> def create(parent):
>     return Frame1(parent)
> 
> [wxID_FRAME1, wxID_FRAME1STATUSBAR1, wxID_FRAME1TEXTEDITOR, 
> ] = [wx.NewId() for _init_ctrls in range(3)]
> 
> [wxID_FRAME1MENUFILECLOSE, wxID_FRAME1MENUFILEEXIT,
> wxID_FRAME1MENUFILEITEMS5, 
>  wxID_FRAME1MENUFILEOPEN, wxID_FRAME1MENUFILESAVE,
> wxID_FRAME1MENUFILESAVEAS, 
> ] = [wx.NewId() for _init_coll_menuFile_Items in range(6)]
> 
> [wxID_FRAME1SUBMENUSUBMENU0] = [wx.NewId() for _init_coll_subMenu_Items in
> range(1)]
> 
> [wxID_FRAME1MENUHELPABOUT] = [wx.NewId() for _init_coll_menuHelp_Items in
> range(1)]
> 
> class Frame1(wx.Frame):
>     def _init_coll_menuBar1_Menus(self, parent):
>         # generated method, don't edit
> 
>         parent.Append(menu=self.menuFile, title='File')
>         parent.Append(menu=self.menuHelp, title='Help')
> 
>     def _init_coll_menuHelp_Items(self, parent):
>         # generated method, don't edit
> 
>         parent.Append(help='Display general information about Notebook',
>               id=wxID_FRAME1MENUHELPABOUT, kind=wx.ITEM_NORMAL,
> text='About')
>         self.Bind(wx.EVT_MENU, self.OnMenuHelpAboutMenu,
>               id=wxID_FRAME1MENUHELPABOUT)
> 
>     def _init_coll_menuFile_Items(self, parent):
>         # generated method, don't edit
> 
>         parent.Append(help='Open a file', id=wxID_FRAME1MENUFILEOPEN,
>               kind=wx.ITEM_NORMAL, text='Open')
>         parent.Append(help='Save file', id=wxID_FRAME1MENUFILESAVE,
>               kind=wx.ITEM_NORMAL, text='Save')
>         parent.Append(help='Save file as', id=wxID_FRAME1MENUFILESAVEAS,
>               kind=wx.ITEM_NORMAL, text='Save as')
>         parent.Append(help='Close file', id=wxID_FRAME1MENUFILECLOSE,
>               kind=wx.ITEM_NORMAL, text='Close')
>         parent.Append(help='Close program', id=wxID_FRAME1MENUFILEEXIT,
>               kind=wx.ITEM_NORMAL, text='Exit')
>         parent.AppendMenu(help='', id=wxID_FRAME1MENUFILEITEMS5,
>               submenu=self.subMenu, text=u'the sub menu')
>         self.Bind(wx.EVT_MENU, self.OnMenuFileOpenMenu,
>               id=wxID_FRAME1MENUFILEOPEN)
>         self.Bind(wx.EVT_MENU, self.OnMenuFileSaveMenu,
>               id=wxID_FRAME1MENUFILESAVE)
>         self.Bind(wx.EVT_MENU, self.OnMenuFileSaveasMenu,
>               id=wxID_FRAME1MENUFILESAVEAS)
>         self.Bind(wx.EVT_MENU, self.OnMenuFileExitMenu,
>               id=wxID_FRAME1MENUFILEEXIT)
>         self.Bind(wx.EVT_MENU, self.OnMenuFileCloseMenu,
>               id=wxID_FRAME1MENUFILECLOSE)
> 
>     def _init_coll_subMenu_Items(self, parent):
>         # generated method, don't edit
> 
>         parent.Append(help='', id=wxID_FRAME1SUBMENUSUBMENU0,
>               kind=wx.ITEM_NORMAL, text=u'The submenu item 0')
>         self.Bind(wx.EVT_MENU, self.OnSubMenuSubmenu0Menu,
>               id=wxID_FRAME1SUBMENUSUBMENU0)
> 
>     def _init_coll_statusBar1_Fields(self, parent):
>         # generated method, don't edit
>         parent.SetFieldsCount(1)
> 
>         parent.SetStatusText(number=0, text='status')
> 
>         parent.SetStatusWidths([-1])
> 
>     def _init_utils(self):
>         # generated method, don't edit
>         self.menuFile = wx.Menu(title='')
> 
>         self.menuHelp = wx.Menu(title='')
> 
>         self.menuBar1 = wx.MenuBar()
> 
>         self.subMenu = wx.Menu(title=u'')
> 
>         self._init_coll_menuFile_Items(self.menuFile)
>         self._init_coll_menuHelp_Items(self.menuHelp)
>         self._init_coll_menuBar1_Menus(self.menuBar1)
>         self._init_coll_subMenu_Items(self.subMenu)
> 
>     def _init_ctrls(self, prnt):
>         # generated method, don't edit
>         wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
>               pos=wx.Point(669, 347), size=wx.Size(621, 438),
>               style=wx.DEFAULT_FRAME_STYLE, title='Notebook')
>         self._init_utils()
>         self.SetClientSize(wx.Size(605, 402))
>         self.SetMenuBar(self.menuBar1)
> 
>         self.statusBar1 = wx.StatusBar(id=wxID_FRAME1STATUSBAR1,
>               name='statusBar1', parent=self, style=0)
>         self._init_coll_statusBar1_Fields(self.statusBar1)
>         self.SetStatusBar(self.statusBar1)
> 
>         self.textEditor = wx.TextCtrl(id=wxID_FRAME1TEXTEDITOR,
>               name='textEditor', parent=self, pos=wx.Point(0, 0),
>               size=wx.Size(605, 359), style=wx.TE_MULTILINE, value='')
> 
>     def __init__(self, parent):
>         self._init_ctrls(parent)
>         self.FileName=None
> 
>     def OnMenuFileOpenMenu(self, event):
>         dlg = wx.FileDialog(self, "Choose a file", ".", "", "*.*",
> wx.OPEN)
>         try:
>             if dlg.ShowModal() == wx.ID_OK:
>                 filename = dlg.GetPath()
>                 # Your code
>                 self.textEditor.LoadFile(filename) 
>                 self.FileName=filename
>                 self.SetTitle(('Notebook - %s') % filename)
>         finally:
>             dlg.Destroy()
> 
>     def OnMenuFileSaveMenu(self, event):
>         if self.FileName == None:
>             return self.OnFileSaveasMenu(event)
>         else:
>             self.textEditor.SaveFile(self.FileName)
> 
>     def OnMenuFileSaveasMenu(self, event):
>         dlg = wx.FileDialog(self, "Save file as", ".", "", "*.*", wx.SAVE)
>         try:
>             if dlg.ShowModal() == wx.ID_OK:
>                 filename = dlg.GetPath()
>                 # Your code
>                 self.textEditor.SaveFile(filename) 
>                 self.FileName=filename
>                 self.SetTitle(('Notebook - %s') % filename)
>         finally:
>             dlg.Destroy()
> 
>     def OnMenuFileExitMenu(self, event):
>         self.Close()
> 
>     def OnMenuFileCloseMenu(self, event):
>         self.FileName = None
>         self.txtEditor.Clear()
>         self.SetTitle('Notebook')
> 
>     def OnMenuHelpAboutMenu(self, event):
>         dlg = Dialog2.Dialog2(self)
>         try:
>             dlg.ShowModal()
>         finally:
>             dlg.Destroy()  
> 
>     def OnSubMenuSubmenu0Menu(self, event):
>         print 'from sub menu event'
>         event.Skip()
> 
> 
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Boa-constructor-users mailing list
> Boa-constructor-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/boa-constructor-users
> 
> 

-- 
View this message in context: http://www.nabble.com/trying-to-build-submenu-tp22650190p22771896.html
Sent from the BoA Constructor - User mailing list archive at Nabble.com.


------------------------------------------------------------------------------