I would recommend reading the official Extension Package Development Guide:
However, the best way to start making a new widget is to take an existing widget that does something like you want, and modify it. Built in widgets exist at
TomcatRoot\webapps\Thingworx\Common\thingworx\widgets
Here's a very brief guide to getting started with that. If you were to want to copy Textbox:
- Open the metadata.xml and change the "TextBox" to "MyWidget".
- There are two sections in this file. The "ExtensionPackage" section holds metadata for the pacakge (version, vendor, etc.)
- The second section , "Widgets" defines the widget files. Change the name of all these files to use your name e.g. MyWidget.ide.js Don’t forget to change name in the “Widget” xml tag too.
- Rename all necessary folder and files, replacing "TextBox" with "MyWidget"
- Open the both .js files and change the definition in each to reflect "MyWidget"
- In the ide file, change the icon path "widgetIconUrl" and the "name" property.
- Select the "ui" folder and the metadata.xml file and package them both into a new zip file. This file should import into Thingworx.
I would suggest searching for or asking this question in the PTC IoT Community, which is much more active for Thingworx developers than StackExchange.
UPDATE: The latest documentation for ThingWorx 9 Extension Package Development Guide can be found here