It looks like you have a problem with seeing functions as variables.
Essentially, everything in Python is an object, including integers and functions for example. Some objects are "callable", like functions and classes. You can assign functions and classes to variables as you please. Defining a function with the "def func(a):" statement for example creates a function and assigns it to the "func" variable. You can then call that function by accessing the variable and adding parenthesis behind it to denote the parameters, which can be empty (e.g. "func(1)"). lambdas in Python are a kind of anonymous functions in that they can be created inline and their expression value can be used without assigning it to a variable, which the "def func():" syntax requires.
So, going back to the Sublime API, the "show_quick_panel" function has the following signature:
- Code: Select all
show_quick_panel(items, on_done, <flags>, <selected_index>, <on_highlighted>)
Which means you need to specify at least 2 and at most 5 parameters. "on_done" and "on_highlighted" are so-called "callbacks" in that they are called (using the way I outlined above) in certain situations, such as when the selection has changed or when the panel has been closed. This allows you to take action on these events in time without knowing when they occur beforehand. Anyway, you should pass an object/variable that is "callable", which is a function in most cases, so that the API can call it later. Python tracks the types of objects internally so it would know if your object is actually callable or not. If it's not, it will throw an error like 'TypeError: 'int' object is not callable' when trying to execute something like '1()'. You can test this before triggering the exception by using the built-in "callable" function which returns a boolean.
Regarding your example, I'm not exactly sure what you want to achieve with that. If I saw your whole code I could probably fix the issue but it's not clear with the 2 lines you pasted here. (Also I suspect you actually want to use "self.run" and not just "run".)