Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8253373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:51:24+00:00 2026-06-08T00:51:24+00:00

I want to make a grid like this: Not the wx.Grid. Does anyone know

  • 0

I want to make a grid like this:

enter image description here

Not the wx.Grid. Does anyone know how to do this, and could provide an example?

This would be for a GridSizer or GridBagSizer to separate the widgets.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:51:26+00:00Added an answer on June 8, 2026 at 12:51 am

    use the drawing context of the frame wxWindow subclass(frame/panel/etc…really any wxObject almost).

    one way of doing it is this

    import wx
    class MyCustomFrame(wx.Frame):
        def __init__(self,parent,id):
            wx.Frame.__init__(self,parent,id)
            self.Bind(wx.EVT_PAINT,self.OnPaint)
        def OnPaint(self,evt):
            self.dc = dc = wx.PaintDC(self)
            p1 = [0,0]
            p2 = [500,0]
            for i in range(100):
                dc.DrawLine(p1[0],p1[1],p2[0],p2[1])
                p1 = [p1[0],p1[1]+5]
                p2 = [p2[0],p2[1]+5]
            p1=[0,0]
            p2 = [0,500]
            for i in range(100):
                dc.DrawLine(p1[0],p1[1],p2[0],p2[1])
                p1 = [p1[0]+5,p1[1]]
                p2 = [p2[0]+5,p2[1]]
    if __name__ == "__main__":
        a = wx.App(redirect=False)
        f = MyCustomFrame(None,-1)
        #f.OnPaint(None) --- dont do this!!!
        f.Show()
        a.MainLDop()
    

    you could speed it up by using drawlines instead

        def OnPaint(self,evt):
            self.dc = dc = wx.PaintDC(self)
            verticle_lines = [(i*5,0,i*5,500) for i in range(100)]
            horizontal_lines = [(0,i*5,500,i*5) for i in range(100)]
            dc.DrawLineList(horizontal_lines+verticle_lines)
    

    In Order to do what you want with the grid sizer you could do this

    import  wx
    class   MyCustomPanel(wx.Panel):
        def __init__(self,parent,id):
            wx.Panel.__init__(self,parent,id)
            self.sz =   wx.GridSizer(5,5,0,0)
            for i   in  range(25):
                self.sz.Add(wx.StaticText(self,-1,str(i)))
            self.SetSizer(self.sz)
            self.Bind(wx.EVT_PAINT,self.OnPaint)
        def OnPaint(self,evt):
            self.dc =   dc  =   wx.PaintDC(self)
            w,h = self.sz.GetSize()
            nr = self.sz.GetRows()
            nc = self.sz.GetCols()
            cell_w = float(w)/nc
            cell_h = float(h)/nr
            hlines = [(0,i*cell_h,w,i*cell_h)for i in range(nr+1)]
            vlines = [(i*cell_w,0,i*cell_w,h)for i in range(nc+1)]
            self.dc.DrawLineList(hlines+vlines)
    
    if  __name__    ==  "__main__":
        a   =   wx.App(redirect=False)
        f1 = wx.Frame(None,-1)
        f   =   MyCustomPanel(f1,-1)
        #f.OnPaint(None)
        f1.Show()
        a.MainLoop()
    

    you could also accomplish this with styles like this

    import  wx
    class SimplePanel(wx.Panel):
        def __init__(self,parent,id,str_val):
            wx.Panel.__init__(self,parent,id,style=wx.SIMPLE_BORDER)
            self.sz = wx.BoxSizer()
            self.sz.Add(wx.StaticText(self,-1,str_val),0,wx.ALIGN_CENTER)
            self.SetSizer(self.sz)
    class   MyCustomPanel(wx.Panel):
        def __init__(self,parent,id):
    
            wx.Panel.__init__(self,parent,id)
            self.sz =   wx.GridSizer(5,5,0,0)
            for i   in  range(25):
                self.sz.Add(SimplePanel(self,-1,str(i)),0,wx.GROW)
            self.SetSizer(self.sz)
    
    if  __name__    ==  "__main__":
        a   =   wx.App(redirect=False)
        f1 = wx.Frame(None,-1)
        f   =   MyCustomPanel(f1,-1)
        #f.OnPaint(None)
        f1.Show()
        a.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now I've seen some questions like this, but it's not exactly what I want
I want to make a custom design for my magento store like this :
I want to make sure 'grid' can't return 2 same values, but I'm not
I want to make a page like this in 960 gs 12 col I
I want to iterate through store and make grid columns dynamically. When I use
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
This crashes: var grdMakes = Ext.extend(Ext.grid.Panel, { constructor: function(paConfig) { } } This does
READ FIRST I re-wrote this to make it more readable. If you want to
Sorry if this has already been asked, but I just want to make sure
How do you make Mathematica export a Row of graphics. I do not like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.