473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Nested wx.StaticBox

jlm699
314 100+
Greetings developers!

I'm in a pickle and can't figure out how to get around this problem...

Here is a complete test case of code

Expand|Select|Wrap|Line Numbers
  1. import os, sys, wx
  2.  
  3. class MainPanel(wx.Panel):
  4.     def __init__(self,parent):
  5.         wx.Panel.__init__(self, parent, -1)
  6.         #self.SetBackgroundColour(wx.Color(185,185,185))
  7.  
  8.         box = wx.StaticBox(self, -1, "Digital Dashboard")
  9.         bxsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  10.         trsizer = wx.BoxSizer(wx.HORIZONTAL)
  11.         brsizer = wx.BoxSizer(wx.HORIZONTAL)
  12.  
  13.         # This will be the top row of information
  14.         # Operator Information Box
  15.         op_box = wx.StaticBox(self, -1, "Operator")
  16.         trsizer.Add(op_box, 1, wx.EXPAND | wx.ALL, 5)
  17.         op_box_szr = wx.StaticBoxSizer(op_box, wx.VERTICAL)
  18. ##########################################################
  19.         # This text box will not get placed in the staticboxsizer... I've even
  20.         #  tried putting a panel on the op_box_szr and giving that a sizer
  21.         #  and then placing the text in THAT sizer with no luck.
  22.         self.dir = wx.StaticText(self, -1, 'Speed')
  23.         op_box_szr.Add(self.dir, 1, wx.EXPAND|wx.ALL, 2)
  24. ##########################################################
  25.         # Traction Information Box
  26.         trac_box = wx.StaticBox(self, -1, "Traction")
  27.         trsizer.Add(trac_box, 1, wx.EXPAND | wx.ALL, 5)
  28.         trac_box_szr = wx.StaticBoxSizer(trac_box, wx.VERTICAL)
  29.         # Motor Information Box
  30.         tm_box = wx.StaticBox(self, -1, "Motors")
  31.         trsizer.Add(tm_box, 1, wx.EXPAND | wx.ALL, 5)
  32.         tm_box_szr = wx.StaticBoxSizer(tm_box, wx.VERTICAL)
  33.  
  34.         # This will be the bottom row of information
  35.         # Trip Stats Information Box
  36.         stats_box = wx.StaticBox(self, -1, "Trip Stats")
  37.         brsizer.Add(stats_box, 1, wx.EXPAND | wx.ALL, 5)
  38.         stats_box_szr = wx.StaticBoxSizer(stats_box, wx.VERTICAL)
  39.         # Auxilary Information Box
  40.         aux_box = wx.StaticBox(self, -1, "Auxilary Info")
  41.         brsizer.Add(aux_box, 1, wx.EXPAND | wx.ALL, 5)
  42.         aux_box_szr = wx.StaticBoxSizer(aux_box, wx.VERTICAL)
  43.  
  44.         bxsizer.Add(trsizer, 1, wx.EXPAND | wx.ALL, 5)
  45.         bxsizer.Add(brsizer, 1, wx.EXPAND | wx.ALL, 5)
  46.  
  47.         border = wx.BoxSizer()
  48.         border.Add(bxsizer, 1, wx.EXPAND|wx.ALL, 5)
  49.         self.SetSizer(border)
  50.  
  51.  
  52. class MainWindow(wx.Frame):
  53.     def __init__(self, *args, **kwargs):
  54.         wx.Frame.__init__(self, *args, **kwargs)
  55.  
  56.         self.sb = self.CreateStatusBar(2)
  57.         self.sb.SetStatusWidths([-2, -1])
  58.  
  59.         # Set up the window layout controller
  60.         self.sizer = wx.BoxSizer(wx.VERTICAL)
  61.         self.SetSizer(self.sizer)
  62.  
  63.         self.main_panel = MainPanel(self)
  64.         self.sizer.Add(self.main_panel, 5, wx.EXPAND | wx.ALL)
  65.  
  66.         # Set up a log on the main window
  67.         self.userLog = wx.TextCtrl(self, -1,
  68.             style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
  69.         self.sizer.Add(self.userLog, 1, wx.LEFT | wx.TOP | wx.GROW)
  70.  
  71.         # Set up a connection status tool bar on the bottom of the window
  72.         self.cs = wx.Panel(self, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE)
  73.         self.conn_stat = wx.StaticText(self.cs, -1, " Disconnected")
  74.         self.sizer.Add(self.cs, 0, wx.LEFT | wx.GROW)
  75.  
  76.         self.Bind(wx.EVT_CLOSE, self.exitApp)
  77.  
  78.  
  79.     def exitApp(self,event=None):
  80.         self.Destroy()
  81.  
  82.  
  83. if __name__ == '__main__':
  84.     myapp = wx.App(redirect=False)
  85.  
  86.     myframe = MainWindow(None, title = 'Digital Dashboard', size=(1000, 800))
  87.     myframe.Show()
  88.     myapp.MainLoop()
  89.  
So all I'm tring to do is put a couple of stats in each of these "sub" boxes but I seem to be unable to do that since box's children are really their siblings (can you tell it's my first time working with wx.StaticBox)... I don't know, I'm confused and would appreciate any help.

Regards,

James
Jan 17 '08 #1
2 3691
jlm699
314 100+
Note: I don't know if I made it clear or not, but the static text within that 'sub' box displays in the upper left hand corner of the main window object :(
Jan 17 '08 #2
jlm699
314 100+
Woops! I just needed to add the StaticBoxSizers of each static box to my trsizer and brsizer accordingly (instead of the static box itself).

That was a good learning experience of how to do layouts with multiple static boxes!
Jan 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Glen | last post by:
I have a Struts action form which contains a bean. I am trying to display a bean retrieved from the database in this form using the nested tag. Can anyone help me? I continue to get an error...
6
by: Andy Baker | last post by:
Hi there, I'm learning Python at the moment and trying to grok the thinking behind it's scoping and nesting rules. I was googling for nested functions and found this Guido quote:...
3
by: Erik Bongers | last post by:
Hi, Nested classes only seem to be able to access static members of the surrounding class : class SurroundingClass { public: class InnerClass { public:
6
by: B0nj | last post by:
I've got a class in which I want to implement a property that operates like an indexer, for the various colors associated with the class. For instance, I want to be able to do 'set' operations...
8
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
1
by: Tomas Sieger | last post by:
Hi all, I'm in doubt with the following code: class Base { public: class Nested {}; }; class Derived:public Base { public: class Nested {
77
by: Peter Olcott | last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html The above link shows that C# is 450% slower on something as simple as a nested loop....
3
by: jdurancomas | last post by:
Dear all, I'm trying to declare the operator++ to a nested class. The nested class is not template but the container it is. The code used in teh sample program is included bellow: ...
4
by: sarabhjeet | last post by:
I need to put a StaticBox,how to put it in existing design.Just write the whole example syntax with real world values.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.