How to create menu in python?

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2008
Posts: 12
Reputation: Feenix45 is an unknown quantity at this point 
Solved Threads: 0
Feenix45 Feenix45 is offline Offline
Newbie Poster

How to create menu in python?

 
0
  #1
Sep 26th, 2008
Can someone guide me how to make menu in python please?

http://www.daniweb.com/forums/post69...tml#post693793

This is a previous post of what sort of menu i need.

Can someone just give me a start please.

Cheers
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 269
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: How to create menu in python?

 
0
  #2
Sep 26th, 2008
Here's a start: Google It
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 950
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 147
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: How to create menu in python?

 
0
  #3
Sep 26th, 2008
It really depends. Are you using wxPython Tkinter or some other kind of GUI becuase they all differ.
I can give you an example in wxPython
  1. import wx
  2.  
  3. class MainFrame(wx.Frame):
  4. def __init__(self):
  5. wx.Frame.__init__(self,None)
  6. self.menubar = wx.MenuBar()
  7. self.file = wx.Menu()
  8. self.file.Append(wx.ID_ANY,'&Test')
  9. self.menubar.Append(self.file,'File')
  10. self.SetMenuBar(self.menubar)
  11. self.Show()
  12.  
  13. app = wx.App(False)
  14. frame = MainFrame()
  15. app.MainLoop()
Hope that helps!
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,492
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 128
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: How to create menu in python?

 
0
  #4
Sep 27th, 2008
  1. Start with this!
  2.  
  3.  
  4. import wx
  5. class TextEditor(wx.Frame):
  6. def __init__(self, parent, id, title):
  7. wx.Frame.__init__(self, parent, id, title, size=(350, 600))
  8. # self/Text editor is now a Window with all attribute of a frame
  9. # create status bar
  10. self.CreateStatusBar()
  11. # set default status bar string
  12. self.SetStatusText("For help press F1")
  13. # define sizers
  14. vbox = wx.BoxSizer(wx.VERTICAL)
  15. hbox = wx.BoxSizer(wx.HORIZONTAL)
  16.  
  17. #Add menu
  18. #define menubar and menu
  19. menubar = wx.MenuBar()
  20. # attach menubar to the frame
  21. self.SetMenuBar(menubar)
  22. #define menus
  23. filemenu = wx.Menu()
  24. # Append items
  25. filemenu.Append(-1, "&New", "New Blank file")
  26. #-----------------------------------------------
  27. # Append a separator
  28. filemenu.AppendSeparator()
  29. #Print menu
  30. filemenu.Append(-1, "&Print", "Print file")
  31. #-------------------------------------------------------
  32. #Append print menu to menubar
  33. menubar.Append(filemenu, "&File")
  34.  
  35.  
  36. #------------------------------------
  37.  
  38. #center the window
  39. self.Center()
  40. #show the window(without this the windows will not show up)
  41. self.Show(True)
  42.  
  43.  
  44. #our main application
  45. app = wx.App(False)
  46. TextEditor(None, -1, "Text Editor")
  47. app.MainLoop()
Last edited by evstevemd; Sep 27th, 2008 at 6:48 am. Reason: code blocking! Some code tags arranging
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
---- Python, C++ PHP and Java ----
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 12
Reputation: Feenix45 is an unknown quantity at this point 
Solved Threads: 0
Feenix45 Feenix45 is offline Offline
Newbie Poster

Re: How to create menu in python?

 
0
  #5
Sep 28th, 2008
thnx and to jlm699 im sory fot the pm but i've google it already and im not getting any help because im using Dr python which has wxPython integrated.

Can i know how to modify the above codes so that i can add something to it plz.

Thnx again
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 950
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 147
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: How to create menu in python?

 
0
  #6
Sep 28th, 2008
what do you need to add?
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 12
Reputation: Feenix45 is an unknown quantity at this point 
Solved Threads: 0
Feenix45 Feenix45 is offline Offline
Newbie Poster

Re: How to create menu in python?

 
0
  #7
Sep 28th, 2008
I need to add
"Your program should display a menu which will allow the user to choose whether he wants to (1)
coefficients (2) check whether the linear system can be solved using iteration (3) calculate and display the
required results using Gauss-Seidel (4) calculate and display the required results using Gauss-Jacobi"

I need from the above question 4 menu that the user can click from.

Also i would be grateful if someone could tell me how i modify the codes for any particular menu(i worked in Visual Basic 6.0 where interfaces are much easier than python)
Thnx again.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,492
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 128
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: How to create menu in python?

 
0
  #8
Sep 28th, 2008
  1.  
  2. I have done some modification to show you how to add it:
  3. For more info you can consider www.zetcode.com. BTW any Python IDE can do it if only wxpython is installed
  4.  
  5.  
  6. import wx
  7. class TextEditor(wx.Frame):
  8. def __init__(self, parent, id, title):
  9. wx.Frame.__init__(self, parent, id, title, size=(350, 600))
  10. # self/Text editor is now a Window with all attribute of a frame
  11. # create status bar
  12. self.CreateStatusBar()
  13. # set default status bar string
  14. self.SetStatusText("For help press F1")
  15. # define sizers
  16. vbox = wx.BoxSizer(wx.VERTICAL)
  17. hbox = wx.BoxSizer(wx.HORIZONTAL)
  18.  
  19. #Add menu
  20. #define menubar and menu
  21. menubar = wx.MenuBar()
  22. # attach menubar to the frame
  23. self.SetMenuBar(menubar)
  24. #define menus
  25. filemenu = wx.Menu()
  26. #Add any other menu using same trick eg. help = wx.Menu() or print = wx.Menu()
  27. # Append items to menu predefined (For now file menu)
  28. filemenu.Append(-1, "&New", "New Blank file")
  29. # same for help menu i.e help.Append(menu id, menu caption, status bar text )
  30. #-----------------------------------------------
  31. # Append a separator -- line to separate menus
  32. filemenu.AppendSeparator()
  33. #Print menu
  34. filemenu.Append(-1, "&Print", "Print file")
  35. #-------------------------------------------------------
  36. #Append print menu to menubar
  37. menubar.Append(filemenu, "&File")
  38. # also menubar.Append(menu name, caption)
  39. # Note: as in VB, & is for ALT+F
  40.  
  41.  
  42. #------------------------------------
  43.  
  44. #center the window
  45. self.Center()
  46. #show the window(without this the windows will not show up)
  47. self.Show(True)
  48.  
  49.  
  50. #our main application
  51. app = wx.App(False)
  52. TextEditor(None, -1, "Text Editor")
  53. app.MainLoop()

Have that helped you??
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
---- Python, C++ PHP and Java ----
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 12
Reputation: Feenix45 is an unknown quantity at this point 
Solved Threads: 0
Feenix45 Feenix45 is offline Offline
Newbie Poster

Re: How to create menu in python?

 
0
  #9
Oct 5th, 2008
Can u give me the codes for the above menu i mean with the questions i gave?

Also i want to know who to modify menu that i add?
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: How to create menu in python?

 
0
  #10
Oct 5th, 2008
Your asking for a full code solution to your assignment? I think you may be going wrong there

Chris
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4332 | Replies: 9
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC