Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to do when WxPerl class doesn't have some method?

I'm programming an application that uses WxPerl, but the Wx::Grid class is missing the method UseNativeColHeader. What can I do to call this method anyway?

What about event? The event EVT_GRID_COL_SORT is not implemented either in WxPerl. Is there a way to bypass the restriction in pure Perl?

like image 675
user4373782 Avatar asked Dec 22 '14 13:12

user4373782


1 Answers

If you know the expected arguments for the missing method, you can rig you own method with that name and inject it into the BEGIN block, then it will be available to the module in question.

In order for this to work you will need to make sure you load that module first (in the BEGIN block) and then define the (empty, unless you know what's supposed to be there) subroutine, making sure it returns the proper value so that Wx::Grid does not error out on you.

If possible, you could just find the source somewhere and drop it into the BEGIN block instead, unless you are just looking to get by without it. However, if you are after the actual "identical" behavior you may be looking at re-inventing the wheel a bit.

I might be able to elaborate a bit more if I had more information on what you really need to have (do you need to call those methods and generate those events, are you able to update modules where you are, etc).

like image 152
osirisgothra Avatar answered Nov 14 '22 19:11

osirisgothra