Sorry if this is in the wrong thread, I haven't been here in a long time.

Hi, I'm having a hard time in trying to position my wx.StaticText and wx.TextCtrl so that it's not stuck at the very top and very left. Life so

Screenshot Here

Here is the code

import sqlite3
import sys
import os
import wx

class add (wx.Frame):
             def __init__(self, parent, id):
                 wx.Frame.__init__(self, parent, id, '', size=(660,450), style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN)
                 self.panel = wx.Panel(self)
                 self.Centre()

                 fnameLabel = wx.StaticText(self.panel, -1, 'First Name: ')
                 self.fname = wx.TextCtrl(self.panel, -1, "", size=(200, -1))
                 fnameLabel.SetFont(wx.Font (10, wx.SWISS, wx.NORMAL, wx.BOLD))
                 self.fname.SetInsertionPoint(0)

                 #Create sizer
                 sizer = wx.FlexGridSizer(cols = 2 , hgap = 4, vgap = 10)
                 sizer.AddGrowableCol(1)

                 sizer.Add(fnameLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
                 sizer.Add(self.fname, 0)

                 sizer.Add((50,50))

                 self.panel.SetSizer(sizer)
        

if __name__=='__main__':
    app = wx.App()
    frame = add(parent = None, id = -1)
    frame.Show()
    app.MainLoop()

Thanks in advance for any and all your help.

Your description was not very clear, not sure how you want to layout your control.
You can try this below, it adds some padding.

sizer.Add(fnameLabel, 0, wx.ALIGN_RIGHT|wx.TOP|wx.LEFT, 5)
                 sizer.Add(self.fname, 0, wx.RIGHT|wx.TOP|wx.LEFT, 5)
commented: short and efficient +4

Your description was not very clear, not sure how you want to layout your control.
You can try this below, it adds some padding.

sizer.Add(fnameLabel, 0, wx.ALIGN_RIGHT|wx.TOP|wx.LEFT, 5)
                 sizer.Add(self.fname, 0, wx.RIGHT|wx.TOP|wx.LEFT, 5)

Thank You very much cghtkh. You solution worked perfectly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.