Gathering Wxpy widgets

Reply

Join Date: Jun 2007
Posts: 1,258
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 118
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Gathering Wxpy widgets

 
0
  #1
Nov 19th, 2008
I have code but when I want to gather my widgets under same wx.StaticBox I fail. I wonder what is wrong! Please someone to corrrect me!

  1.  
  2. #Add static box to hold related widgets--- it otherwise does nothing
  3. holder1 = wx.StaticBox(mpanel, -1, label="Transactions", pos = (10, 10), size = (300,300))
  4. #add box to sizer for widgets only --- This is not main sizer
  5. wsizer = wx.BoxSizer(wx.VERTICAL)
  6. wsizer.Add(holder1, 0, wx.EXPAND |wx.ALL, 5)
  7.  
  8. #Make widgets for transaction
  9. #First row of widets
  10. id_text = wx.StaticText(mpanel, -1, "Enter Product ID")
  11. id_text_area = wx.TextCtrl(mpanel, -1)
  12. find = wx.Button(mpanel, -1, "Find", size=(70, 30))
  13. #Add them to hor sizer
  14. hbox1 = wx.BoxSizer()
  15. hbox1.Add(id_text, 0, wx.ALL, 5)
  16. hbox1.Add(id_text_area, 0, wx.BOTTOM| wx.TOP| wx.RIGHT, 5)
  17. hbox1.Add(find, 0, wx.BOTTOM| wx.TOP| wx.RIGHT, 5)
  18. #add this sizer to widgets sizer
  19. wsizer.Add(hbox1,0, wx.EXPAND)
  20.  
  21. #add widgets sizer wsizer to main vertical sizer mains
  22. mains.Add(wsizer, 0, wx.EXPAND)
  23. #set sizers and Layouts
  24. mpanel.SetSizer(mains)
  25. mpanel.Layout()
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,862
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 870
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Gathering Wxpy widgets

 
0
  #2
Nov 19th, 2008
Of hand, I would say main vertical sizer mains is missing.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,258
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 118
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: Gathering Wxpy widgets

 
0
  #3
Nov 19th, 2008
I forgot to say that, that is a part of code; May be I have to post full code!
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,258
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 118
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: Gathering Wxpy widgets

 
0
  #4
Nov 19th, 2008
  1. import wx
  2. class MainWindow(wx.Frame):
  3. def __init__(self, parent, id, title):
  4. wx.Frame.__init__(self, parent, id, title)
  5. # make a panel
  6. mpanel = wx.Panel(self, -1)
  7. #Define main sizer
  8. mains = wx.BoxSizer(wx.VERTICAL)
  9. #make display window
  10. display = wx.TextCtrl(mpanel, -1, style = wx.TE_MULTILINE)
  11. #Add to a sizer
  12. mains.Add(display, 1, wx.EXPAND|wx.TOP| wx.BOTTOM, 30)
  13.  
  14. #Add static box to hold related widgets--- it otherwise does nothing
  15. holder1 = wx.StaticBox(mpanel, -1, label="Transactions", pos = (10, 10), size = (300,300))
  16. #add box to sizer for widgets only --- This is not main sizer
  17. wsizer = wx.BoxSizer(wx.VERTICAL)
  18. wsizer.Add(holder1, 0, wx.EXPAND |wx.ALL, 5)
  19.  
  20. #Make widgets for transaction
  21. #First row of widets
  22. id_text = wx.StaticText(mpanel, -1, "Enter Product ID")
  23. id_text_area = wx.TextCtrl(mpanel, -1)
  24. find = wx.Button(mpanel, -1, "Find", size=(70, 30))
  25. #Add them to hor sizer
  26. hbox1 = wx.BoxSizer()
  27. hbox1.Add(id_text, 0, wx.ALL, 5)
  28. hbox1.Add(id_text_area, 0, wx.BOTTOM| wx.TOP| wx.RIGHT, 5)
  29. hbox1.Add(find, 0, wx.BOTTOM| wx.TOP| wx.RIGHT, 5)
  30. #add this sizer to widgets sizer
  31. wsizer.Add(hbox1,0, wx.EXPAND)
  32.  
  33. #add widgets sizer wsizer to main vertical sizer mains
  34. mains.Add(wsizer, 0, wx.EXPAND)
  35. #set sizers and Layouts
  36. mpanel.SetSizer(mains)
  37. mpanel.Layout()
  38.  
  39.  
  40.  
  41.  
  42. app = wx.App(False)
  43. f = MainWindow(None, -1, "Cash Program")
  44. f.Center()
  45. f.Show()
  46. app.MainLoop()
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Reply

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



Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC