Aug-14-2018, 02:23 AM
I am fluent in tkinter, but i wanted to dip a little into wxpython.
I am trying common layout tasks and struggling. This one is just simply setting 2 buttons next to each other. However the buttons overlap i am guessing. I think my understanding of boxsizer is the issue, but i am not sure.
I am trying common layout tasks and struggling. This one is just simply setting 2 buttons next to each other. However the buttons overlap i am guessing. I think my understanding of boxsizer is the issue, but i am not sure.
import wx app = wx.App() root = wx.Frame(None) panel = wx.Panel(root) btn = wx.Button(panel, label='press me 1') btn.Bind(wx.EVT_BUTTON, lambda x:print('pressed 1')) btn2 = wx.Button(panel, 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, 0, wx.ALIGN_CENTER_HORIZONTAL) root.Show() app.MainLoop()While i am on the subject the App, Frame, and Panel i find even more confusing. Tkinter you just have root, and put the parent window in. I would of assumed the same for wxpython. Hwoever the window for a widget has to be a panel, not what i might assume would be a frame instead. But yet need the frame too. It seriously took me 20 minutes to find out why a seg fault was because frame required None as an argument.