A (kind of desperate) question to VPython and menubar

34 views
Skip to first unread message

stefan....@web.de

unread,
Apr 5, 2017, 2:34:50 AM4/5/17
to VPython-users
Hi,

frist I need to say that I have very little experience with VPython. I only started using it two days ago. What I tried to make is a simple program with VPython. Unfortunately, I wasn't able to add any menu items to the default 'File' menu or to delete it to add my own. So in the end I got two 'File' menus. Could you please help me out?

#!/usr/bin/python
# -*- coding: utf-8 -*-

from visual import *
import wx


class Example(object):
 
   
def __init__(self, *args, **kwargs):
       
self.InitUI()
   
   
   
def InitUI(self):
        L
= 320
        mainWindow
= window( width  = 2* (L + window.dwidth),
                             height
= L + window.dheight + window.menuheight,
                             menus
=True,
                             title
='Example',
                             style
=wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)

       
# Create a menubar
        menubar
= mainWindow.menubar

       
# File menu
        fileMenu
= wx.Menu()
        newMenuItem
= wx.MenuItem(fileMenu, -1, '&New\tCtrl+N')
        fileMenu
.AppendItem(newMenuItem)

        openMenuItem
= wx.MenuItem(fileMenu, -1, '&Open\tCtrl+O')
        fileMenu
.AppendItem(openMenuItem)
       
        saveMenuItem
= wx.MenuItem(fileMenu, -1, '&Save\tCtrl+S')
        fileMenu
.AppendItem(saveMenuItem)

        fileMenu
.AppendSeparator()

        quitMenuItem
= wx.MenuItem(fileMenu, -1, '&Quit\tCtrl+Q')
        fileMenu
.AppendItem(quitMenuItem)

        menubar
.Append(fileMenu, '&File')
       
       
while True:
            rate
(50)
           
   
def OnQuit(self, e):
       
exit()

   
def main():
    app
= wx.App()
   
Example(None)
    app
.MainLoop()

if __name__ == '__main__':
    main
()


With kind regards
Stefan Fuchs

stefan....@web.de

unread,
Apr 5, 2017, 3:18:13 AM4/5/17
to VPython-users
I'm sorry. I solved the problem myself.

4ctest...@gmail.com

unread,
Apr 5, 2017, 11:41:53 AM4/5/17
to VPython-users
Whats the answer?
Reply all
Reply to author
Forward
0 new messages