[wxPython-users] Recent file list
Saketh Bhamidipati
saketh.bhamidipati at gmail.com
Thu Jul 27 16:23:57 PDT 2006
On 7/27/06, Josiah Carlson <jcarlson at uci.edu> wrote:
>
>
> "Saketh Bhamidipati" <saketh.bhamidipati at gmail.com> wrote:
> > I've figured out the problem, but I can't find a solution.
> >
> > I used the following code to get the ID's of the menu items:
> > ...
> >
> > filerecentmenu =3D wx.Menu()
> > filemenu.AppendMenu(wx.NewId(), "&Recent Files", filerecentmenu)
> > self.hist.UseMenu(filerecentmenu)
> > self.hist.AddFilesToMenu()
> > ...
> > for item in filerecentmenu.GetMenuItems():
> > print item.GetId()
> [snip]
> > Is there any way I can get the recent file MenuItems to have wx.ID_FILE=
1and
> > wx.ID_FILE2 as their IDs. without explicitly defining the IDs? Now that
> I
> > have identified the exact nature of the problem, finding a solution
> should
> > be easier.
>
> The trick is that you let the history object handle all menu item
> creation, etc. Assuming you have a list of files in your history,
> called history...
>
> for h in history:
> self.hist.AddFileToHistory(h)
>
> Though be aware that the last file added to the history will be the one
> on top, so you may need to reverse the list prior to iterating through
> it.
>
> - Josiah
>
> I thought of that after writing this code:
for item in filerecentmenu.GetMenuItems():
wx.ID_FILE1 =3D item.GetId()
break
wx.ID_FILE9 =3D wx.ID_FILE1 + 8
I don't know if it will hold, but if the code breaks then I will come
begging for help again. So far, so good, though.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200607=
27/4239d055/attachment.htm
More information about the wxpython-users
mailing list