Python Forum
[WxPython] setting two buttons next to each other
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] setting two buttons next to each other
#2
Yep! Frame needs to know if there a parent or not.

have to add sizer to panel.
panel.SetSizer(box)

Also can be done without a panel.
import wx

app = wx.App()
root = wx.Frame(None)
btn = wx.Button(root, label='press me 1')
btn.Bind(wx.EVT_BUTTON, lambda x:print('pressed 1'))

btn2 = wx.Button(root, label='press me 2')
btn2.Bind(wx.EVT_BUTTON, lambda x:print('pressed 2'))

box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(btn, 0, wx.EXPAND)
box.Add(btn2, 2, wx.ALIGN_CENTER_HORIZONTAL)
root.SetSizer(box);

root.Show()
app.MainLoop()
99 percent of computer problems exists between chair and keyboard.
Reply


Messages In This Thread
RE: setting two buttons next to each other - by Windspar - Aug-14-2018, 03:17 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020