Popup Window with Controls not working
Walid Sakr <[email protected]>
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <[email protected]> |
I have created a simple implementation of a popup window with a
CheckListBox and a couple of buttons as below:
[image: Annotation 2019-10-03 193337.jpg]
and here is the code
class MyPopList(wx.PopupWindow):
def __init__(self, parent, lst):
wx.PopupWindow.__init__(self, parent, flags=wx.SIMPLE_BORDER |
wx.PU_CONTAINS_CONTROLS)
#self.parent = parent
#self.lst = lst
panel = wx.Panel(self)
panel.SetBackgroundColour("LIGHT GREY")
self.clb = wx.CheckListBox(panel, id=wx.ID_ANY, choices=lst,
style=wx.LB_MULTIPLE, validator=wx.DefaultValidator)
topsizer = wx.BoxSizer(wx.VERTICAL)
topsizer.Add(self.clb, wx.SizerFlags(0).Center().Border(wx.ALL,
2).Expand())
button_sizer = wx.BoxSizer(wx.HORIZONTAL)
button_sizer.Add(wx.Button(panel, wx.ID_OK, "Apply"),
wx.SizerFlags(0).Align(wx.ALIGN_CENTER).Border(wx.ALL, 5))
button_sizer.AddSpacer(15)
button_sizer.Add(wx.Button(panel, wx.ID_CANCEL, "Cancel"),
wx.SizerFlags(0).Align(wx.ALIGN_CENTER).Border(wx.ALL, 5))
topsizer.Add(button_sizer,
wx.SizerFlags(0).Center())
panel.SetSizer(topsizer)
#panel.SetFocus()
topsizer.Fit(panel)
topsizer.Fit(self)
self.Layout()
print(self.GetChildren())
self.clb.Bind(wx.EVT_CHECKLISTBOX, self.FilterChoice)
self.Bind(wx.EVT_BUTTON, self.GetChoices)
def ProcessLeftDown(self, evt):
print("Mouse button pressed")
return wx.PopupTransientWindow.ProcessLeftDown(self, evt)
def ShowList(self):
#self.clb.Set(lst)
self.Show()
def FilterChoice(self, event):
print("List Clicked")
event.Skip()
def GetChoices(self, event):
print("button Clicked")
self.Destroy()
#event.Skip()
The problem is I cannot get the list to respond to mouse clicks ....
buttons are working fine
moreover when I use the style wx.PU_CONTAINS_CONTROLS as stated in the
popup docs *HERE
<https://wxpython.org/Phoenix/docs/html/wx.PopupWindow.html#styles-window-styles>*
I receive this error msg
> wx.PopupWindow.__init__(self, parent, flags=wx.SIMPLE_BORDER |
>> wx.PU_CONTAINS_CONTROLS)
>
> AttributeError: module 'wx' has no attribute 'PU_CONTAINS_CONTROLS'
>
>
Any help is greatly appreciated
Python 3.7.3
Phoenix 4.0.4
windows 10
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/5ba96348-5dc6-4f05-a5a1-9d6f388bdf41%40googlegroups.com.
Annotation 2019-10-03 193337.jpg
(image/jpeg, 73.5 KB) - not displayed