[nvda-addons] Re: Developing Addons - The best way to get started?

  • From: "Damien Sykes-Pendleton" <damien@xxxxxxxxxxxxxxxxxxxx>
  • To: <nvda-addons@xxxxxxxxxxxxx>
  • Date: Fri, 15 Apr 2016 19:11:36 +0100

Hi James,

1. When you say "accessing various objects in code," which objects do you mean?

I mean accessing the object tree hierarchically programatically, the same way object navigation allows you to do in NVDA itself. To be honest I thought there may have been some helper functions that allow you to find controls based on certain information, rather than having to try and find the object manually. Especially given that it could be in different places depending on the information that the summary shows.

2. Do you understand how event handlers work, and the fact that they receive the object on which the event was fired as an argument?

I wasn't sure about that, but now you mention it, it makes sense. I'm guessing that's why you have to check various things about the object, because it could be anything that has triggered the event. Is that why it beeped pretty much on every control change when I did the example gain focus event in the dev guide?

3. Do you understand that, from within an event handler function, you can find other objects using the object delivered to your function as a starting point?

You wrote that as part of the same question, but to me that is something totally different. I didn't know that at all. How can one object let you access all others?

4. Do you understand what methods and attributes objects have to help you
find other objects around them, e.g. simpleNext, simplePrevious,
children, etc?

I'm guessing that's what my biggest problem is. I know nothing about these.

5. Have you tried using the NVDA Python console to navigate around an application you're familiar with to get a feel for how all of this works?

No, because again I wouldn't know what to put in there. What I did do is try to get the focus information in the console, but it didn't show me any of the variables it had created for me. Even if it had, I'd have no idea how to make something actually happen as I know nothing of the NVDA source code, all I know how to do is make it beep.

6. Have you ran the Python built-in function dir on an object to see what properties and methods it exposes? Object introspection at runtime is one of Python's biggest bonuses, and you're probably going to need it.

No, because again I knew nothing of the existence of this function.

7. Have you downloaded the code of some other app modules contributed by the community to see if you can figure out how they work?

I wouldn't even know what to start looking at, as most of them are a lot more complex than what I am trying to do. I do use several addons (GoldWave, NVDA Remote, System Tray list etc) but to me they just sound way, way too advanced for me to start looking at their code at the moment.

8. Some of the app modules that ship with NVDA itself, if you check out the source code, are not overly complicated.

A lot of the apps NVDA supports (such as Microsoft Office) I don't actually have, so I can't compare the code to what it might be trying to do with the object.

9. Earlier, you were completely stumped by the snippet of code that I posted. You need to understand how that works.

When you explained the workings, I understood a lot more than I did beforehand.

Kind regards,
Damien.
-----Original Message----- From: James Scholes
Sent: Friday, April 15, 2016 2:41 PM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: Developing Addons - The best way to get started?

Damien Sykes-Pendleton wrote:

This is seeming to be a much more complicated job than I originally
thought - I've still no idea how to access various objects in code, let
alone try and apply logic about object positioning, ordering and/or
hierarchies.

Then you need to write some code and use the NVDA Python console to
figure out how it all fits together.  If there is something specific
that you don't understand, tell us so we can give you some pointers.
For instance:

- When you say "accessing various objects in code," which objects do you
mean?
- Do you understand how event handlers work, and the fact that they
receive the object on which the event was fired as an argument?  In
other words, do you understand that, from within an event handler
function, you can find other objects using the object delivered to your
function as a starting point?
- Do you understand what methods and attributes objects have to help you
find other objects around them, e.g. simpleNext, simplePrevious,
children, etc?
- Have you tried using the NVDA Python console to navigate around an
application you're familiar with to get a feel for how all of this works?
- Have you ran the Python built-in function dir on an object to see what
properties and methods it exposes?  Object introspection at runtime is
one of Python's biggest bonuses, and you're probably going to need it.
- Have you downloaded the code of some other app modules contributed by
the community to see if you can figure out how they work?  Some of the
app modules that ship with NVDA itself, if you check out the source
code, are not overly complicated.  Earlier, you were completely stumped
by the snippet of code that I posted.  You need to understand how that
works.

That gives you a number of things to investigate.  If you don't have a
clue what I'm talking about, take them step by step, and ask us about
any particular issues you're having.  Then try to write a simple,
useless app module.  A good exercise would be to implement an event
handler for the list box in your family tree application which simply
makes NVDA play a tone whenever you move to a new item.  Once you have
that working, perhaps add some logging which will write to the NVDA log
the newly-selected value in the list box, which will help you get a feel
for how it all fits together.  After that, you can start to implement
code to make NVDA find and speak the information you're looking for.

What you're not going to be able to do at this point is sit down and
write this app module from scratch, and have it finished in one sitting.
You need to build your understanding, and only then can you start to
make your code do what you want.
--
James Scholes
http://twitter.com/JamesScholes
----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting bugs.

Community addons are available from: http://addons.nvda-project.org
To send a message to the list: nvda-addons@xxxxxxxxxxxxx
To change your list settings/unsubscribe: //www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx
----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting bugs.
Community addons are available from: http://addons.nvda-project.org
To send a message to the list: nvda-addons@xxxxxxxxxxxxx
To change your list settings/unsubscribe: 
//www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx

Other related posts: