hi,

I would like a alert message to pop up on a EVENT of Mouse click in the Custom tree control and CHECKLISTBOX.

Please assist me capturing the MOUSE CLICK event and pop up the alert message or FRAME with message.

Your response will be highly appreciated.

Regards
Dinil

Are you using wxPython?
In that case the event you are looking for is: wx.EVT_LEFT_DOWN

Hi,

I tried all events including the one you suggested. But they dont work when the Checklist box is disabled.... How do I do it?

Regards,
Dinil

If the event works to disable ListCtrl, then it fails to disable, I guess that might be due to no special reference. I mean that when you disable it you need reference to that item so as using that reference, you can enable it again.
BTW are you calling the method in the same class or from another class?

I am calling the method in the same class.. some thing like this:

def __init__(self, parent,show_images=1):

self.Bind(wx.EVT_CHECKLISTBOX, self.Clicked, id=self.chkLstBox.GetId())

def Clicked(self,event):
print "Hello"

Bothe the above functions are present inside the same class. But I have disabled the Checklist box also. If I enable it, the event is fired.

Regards,
Dinil

import wx
class CListBox(wx.Frame):
    def __init__ (self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(350, 450))
        
        #Add a panel as parent to widget
        panel = wx.Panel(self, -1)
        self.lst = ["Jesus", "Loves", "You!"]
        self.clbox = wx.CheckListBox(panel, -1,(0, 0), wx.DefaultSize, self.lst )
        self.mess = wx.StaticText(panel, -1, "Love of God")
        
        #Add to sizers
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.mess, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 20)
        vbox.Add(self.clbox, 0, wx.ALL, 10)        
        panel.SetSizer(vbox)
        panel.Layout()
        
        #Set up event handlers - set from widgets on special section for clarity
        #bind event to checklistbox
        self.Bind(wx.EVT_CHECKLISTBOX, self.OnChecked, id = self.clbox.GetId())
        
        
        
        
        self.Centre()
        self.Show(True)
        
        #Start event handlers
    def OnChecked(self, event):
        # Get Index of the checked item from List
        index = event.GetSelection() 
        # Get string corresponding to that item
        label = self.clbox.GetString(index) 
        
        #Use if to check whether the item is checked or not
        if self.clbox.IsChecked(index) : 
            status = "Checked"
        else:
            status = "Unchecked"     
        #Set message for dialog box
        message = "%s Option is %s" %(label, status)  
        # Dialog box for Alert
        dia = wx.MessageDialog(self,message , "Alert", style = wx.OK |wx.ICON_INFORMATION )
        ret = dia.ShowModal()
        if ret == wx.ID_YES :
            dia.Destroy()
    
        
app = wx.App(False)
#Instantiate class CListBox
CListBox(None, -1, "Simple List Box")
app.MainLoop()

Just have a look at example and tell me what is you exact question.

Hi,

Thanks for ur suggestions....
I am using:
dlg = wx.MessageDialog(None, "U dont have priliges!", 'Error',
wx.OK|wx.ICON_EXCLAMATION)
res = dlg.ShowModal()
dlg.Destroy()

This is working fine for me.....
Thanks again...

Regards,
Dinil

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.