Problem: Help! How can I pass parameters in my Bindings?
Solution: By using lambda functions in python(Check your PL’s manual for anything similar), you would be able to create on-the-fly functions that returns your bindings with the extra parameters/arguments you want to pass.
Example 1: Passing an argument to a wx Button Event
btn = wx.Button(self, 10, “Button”, (10, 10))
self.Bind(wx.EVT_BUTTON, lambda event: self.OnClick(event, ‘passthis’))def OnClick(self, event, somearg):
print somearg
Example 2: Passing an argument to Pyhook’s HookManager.KeyUp Event
hook = pyHook.HookManager()
hook.KeyUp = lambda event: OnKeyboardEvent(event, ‘Pass Me.’)
hm.HookKeyboard()def OnKeyboardEvent(event, myarg)
print myarg
That’s It!
Related posts:
- Unix Super Tip: How to CHMOD all your files recursively
- Super Tip! How to Create that floating Facebook toolbar at the bottom of the page!
- Jquery Super Tip! Automatically highlight the links/menu of the current page with 1 line of code
- Super Tool: (Probably) the best SQLite Editor/IDE for web development and production use
- Unix Super Tip: Easy Access to your files and directories by creating symbolic links(shortcuts)
Still can't see what you're looking for?









