python console menu level looping
Daiyue Weng
daiyueweng at gmail.com
Sun Sep 24 17:11:49 EDT 2017
well, in my case, there is no GUI, and we do not intend to use it since
this script is only for internal testing purposes. So I am just wondering
how to loop menu in this context.
On 24 September 2017 at 22:03, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> Daiyue Weng <daiyueweng at gmail.com> writes:
> >I am wondering how to loop back to the 1st level menu
>
> You are writing a historical kind of menu system.
>
> One way to proceed might be a more contemporary menu
> system like tkinter's:
>
> from tkinter import *
>
> class Main(Frame):
>
> def __init__(self, parent):
> Frame.__init__(self, parent)
> self.parent = parent
> self.initUI()
>
> def initUI(self):
> self.parent.title( "menu example" )
> self.pack( fill=BOTH, expand=1 )
> menubar = Menu( self.parent )
> self.parent.config( menu=menubar )
> mainMenu = Menu( self )
> subMenu = Menu( self )
> mainMenu.add_cascade( label='new collection', menu=subMenu )
> subMenu.add_command\
> ( label='manual setup', command = self.manual_setup )
> mainMenu.add_command\
> ( label='existing collection',
> command = self.existing_collection )
> menubar.add_cascade( label="File", menu=mainMenu )
> self.txt = Text( self )
> self.txt.pack( fill=BOTH, expand=1 )
>
> def onOpen( self ):
> pass
>
> def manual_setup( self ):
> pass
>
> def existing_collection( self ):
> pass
>
> def manual_setup( self ):
> pass
>
> root = Tk()
>
> ex = Main( root )
> ex.pack( side="bottom" )
>
> root.geometry( "300x250+300+300" )
> root.mainloop()
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list