473,322 Members | 1,405 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,322 software developers and data experts.

wx formating with grid sizers

What can I do to this code to keep the layout from looking line

button button button grid

or worse

button
button
button
grid

I need something like

grid
button button button

I was trying to use the splitter example but couldn't get it to work. I am using python 2.5 and the latest wxwindows. Thanks for the help in advance




Expand|Select|Wrap|Line Numbers
  1.  
  2. ):
  3.  
  4.         wx.Frame.__init__(self, parent, -1, "Dex Tracker Score Editor", size=(640,480))
  5.         p = wx.Panel(self, -1, style=0)
  6.         self.grid = WordGrid(p, log)
  7.         b = wx.Button(p, -1, "Save Grid")            #b gets numbered per button and then description set
  8.         b2 = wx.Button(p, 100, "Add Line")
  9.         b3 = wx.Button(p, -1, "Insert Line")
  10.         b4 = wx.Button(p, -1, "Delete Line")
  11.         b5 = wx.Button(p, -1, "Play from line to line")
  12.  
  13.         b.SetDefault()
  14.         self.Bind(wx.EVT_BUTTON, self.OnButton, b)    #bind to the button I am numbering them
  15.         self.Bind(wx.EVT_BUTTON, self.OnButton2, b2)
  16.         self.Bind(wx.EVT_BUTTON, self.OnButton3, b3)
  17.         self.Bind(wx.EVT_BUTTON, self.OnButton4, b4)
  18.         self.Bind(wx.EVT_BUTTON, self.OnButton5, b5)
  19.         b.Bind(wx.EVT_SET_FOCUS, self.OnButtonFocus)  #bind button focus if needed
  20.         #bs = wx.BoxSizer(wx.ALIGN_BOTTOM)
  21.         #bs = wx.StaticBoxSizer(wx.
  22.         bs = wx.BoxSizer(wx.HORIZONTAL)#(wx.VERTICAL)#|wx.ALIGN  _BOTTOM)   #(wx.HORIZONTAL_HATCH)   #(wx.VERTICAL)
  23.         #bs.Add(self.grid, 1, wx.GROW|wx.ALL, 5)
  24.         bs.Add(b)                                     #add the button here numbered in par
  25.         bs.Add(b2)
  26.         bs.Add(b3)
  27.         bs.Add(b4)
  28.         bs.Add(b5)
  29.         #p.placed
  30.         bs = wx.BoxSizer(wx.VERTICAL)
  31.         bs.Add(self.grid, 1, wx.GROW|wx.ALL, 5)
  32.         p.SetSizer(bs)
  33.  
  34.  
Dec 12 '06 #1
4 2578
bartonc
6,596 Expert 4TB
This thread will be renamed to include the word "grid sizers" for future reference.
I need something like

grid
button button button
One sizer holds the panel. The panel gets a GridBagSizer which lets you do things like span multiple columns.
Expand|Select|Wrap|Line Numbers
  1. Boa:Frame:Frame1
  2.  
  3. import wx
  4. import wx.grid
  5.  
  6. def create(parent):
  7.     return Frame1(parent)
  8.  
  9. [wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1BUTTON2, wxID_FRAME1BUTTON3, wxID_FRAME1GRID1, 
  10.  wxID_FRAME1PANEL1, 
  11. ] = [wx.NewId() for _init_ctrls in range(6)]
  12.  
  13. class Frame1(wx.Frame):
  14.     def _init_coll_gridBagSizer1_Items(self, parent):
  15.         # generated method, don't edit
  16.  
  17.         parent.AddWindow(self.button1, (1, 0), border=0, flag=wx.ALIGN_CENTER, span=(1, 1))
  18.         parent.AddWindow(self.button2, (1, 1), border=0, flag=wx.ALIGN_CENTER, span=(1, 1))
  19.         parent.AddWindow(self.button3, (1, 2), border=0, flag=wx.ALIGN_CENTER, span=(1, 1))
  20.         parent.AddWindow(self.grid1, (0, 0), border=0, flag=wx.GROW | wx.EXPAND, span=(1, 3))
  21.  
  22.     def _init_coll_boxSizer1_Items(self, parent):
  23.         # generated method, don't edit
  24.  
  25.         parent.AddWindow(self.panel1, 1, border=0, flag=wx.EXPAND)
  26.  
  27.     def _init_sizers(self):
  28.         # generated method, don't edit
  29.         self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)
  30.  
  31.         self.gridBagSizer1 = wx.GridBagSizer(hgap=0, vgap=0)
  32.  
  33.         self._init_coll_boxSizer1_Items(self.boxSizer1)
  34.         self._init_coll_gridBagSizer1_Items(self.gridBagSizer1)
  35.  
  36.         self.SetSizer(self.boxSizer1)
  37.         self.panel1.SetSizer(self.gridBagSizer1)
  38.  
  39.     def _init_ctrls(self, prnt):
  40.         # generated method, don't edit
  41.         wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(485, 430),
  42.               size=wx.Size(400, 250), style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
  43.         self.SetClientSize(wx.Size(392, 223))
  44.  
  45.         self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self, pos=wx.Point(0, 0),
  46.               size=wx.Size(392, 223), style=wx.TAB_TRAVERSAL)
  47.  
  48.         self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label='button1', name='button1',
  49.               parent=self.panel1, pos=wx.Point(27, 201), size=wx.Size(75, 23), style=0)
  50.  
  51.         self.button2 = wx.Button(id=wxID_FRAME1BUTTON2, label='button2', name='button2',
  52.               parent=self.panel1, pos=wx.Point(157, 201), size=wx.Size(75, 23), style=0)
  53.  
  54.         self.button3 = wx.Button(id=wxID_FRAME1BUTTON3, label='button3', name='button3',
  55.               parent=self.panel1, pos=wx.Point(287, 201), size=wx.Size(75, 23), style=0)
  56.  
  57.         self.grid1 = wx.grid.Grid(id=wxID_FRAME1GRID1, name='grid1', parent=self.panel1,
  58.               pos=wx.Point(0, 0), size=wx.Size(390, 201), style=0)
  59.  
  60.         self._init_sizers()
  61.  
  62.     def __init__(self, parent):
  63.         self._init_ctrls(parent)
Dec 12 '06 #2
bartonc
6,596 Expert 4TB
Actually, Eric, I've gotten fed up with trying to get sizers to work right. What I do is used fixed sized windows and absolute (x, y) positioning of the widgets. Of course, using a gui gernerator (like wxGlade, ect (see my post on IDE choices)) makes this much easier.
Dec 12 '06 #3
Actually, Eric, I've gotten fed up with trying to get sizers to work right. What I do is used fixed sized windows and absolute (x, y) positioning of the widgets. Of course, using a gui gernerator (like wxGlade, ect (see my post on IDE choices)) makes this much easier.
I saw the gui builder for sale (you know the stick figure with the big nose like mine) but I don't have the cash for such things. I was hopeing for a simple way to changing the generated code over to the format I want. What I would realy like is a way to change direction while the display is being built. I don't care if I use a sizer or another method. Using excel as an alternative method looks intresting but it isn't what I was after.

ie from bs = wx.BoxSizer(wx.HORIZONTAL) to bs = wx.BoxSizer(wx.VERTICAL) while I am building the display.
Dec 14 '06 #4
bartonc
6,596 Expert 4TB
I saw the gui builder for sale (you know the stick figure with the big nose like mine) but I don't have the cash for such things. I was hopeing for a simple way to changing the generated code over to the format I want. What I would realy like is a way to change direction while the display is being built. I don't care if I use a sizer or another method. Using excel as an alternative method looks intresting but it isn't what I was after.

ie from bs = wx.BoxSizer(wx.HORIZONTAL) to bs = wx.BoxSizer(wx.VERTICAL) while I am building the display.
wx.VERTICAL and wx.HORIZONTAL are flags in the Style "constructor" arguement. On all wx widgets that I've looked at so far, there are no commands that change the style on the fly (after it has been created). The proper technique is to put sizers inside sizers. It easy (I take back what I said earlier, after playing with this) to get good results this way. Make a vertical sizer with a horizontal box sizer in it which gets you buttons added to it. The only other item that the horizontal sizer is in charge of is your grid.

There are lots of free tools (I don't recall any commercial products in my list).
Dec 14 '06 #5

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

Similar topics

2
by: Deltones | last post by:
Hi, I'm trying to understand one of the wiki wxPython tutorial, and I must admit I`m a bit baffled by sizers. If I run the following relevant piece of code, I get the result I expect, i.e a...
0
by: Ashok | last post by:
hi, I am trying to build a small gui program in python using boa constructor. i have a few problems. i would be grateful if anyone can help me in this regard. 1. i have four static text controls...
1
by: JAPHET | last post by:
I am Trying to Format date in my Datagrid to SHORTDATE format with the following codes, Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As...
3
by: Tina | last post by:
I have a datagrid where I specified {0:###,###,###} at design time. However sometimes I am putting percentages in the grid instead of money and I want to change the formating to {##%}. I've...
4
by: Jack M | last post by:
I have a large data grid with several rows that contain dates. I want to display the date only(no time). Even when I use the trunc function in Oracle the rows show a time of 12:00:00 am. What I...
3
by: Jordan | last post by:
Hey Peoples, I'm wonderg if there is a way to make a subclass of wx.grid.Grid in which the coloumn labels for the grid appear on the bottom of the grid instead of the top. 1 2 3 4 5 a| | ...
0
by: shbrittan | last post by:
I need to have my users type in instructions in either plain text or with imbedded html tags at their choice. The typed data along with other columns are stored in a sql database, then displayed in...
4
by: BH | last post by:
Hi ! I have a small problem with wx.Grid and scrollbars. Scrollbars definitively dissapears after resizing the frame. Thx for help ...
1
by: Astan Chee | last post by:
Hi, I have a wxNoteBook with a bunch of wxPanels attached to it as pages. Every page has its own GUI items. What Im trying to do is on a certain page, a certain GUI (wxTextCtrl) to be resized...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.