RSSThe TSW Blog

Making a mini webbrowser with WebCoder scripting

October 22, 2007

So, I thought I would do a little WebCoder scripting. We need some more demo scripts, showing off the potential off the scripting system. I created a small webbrowser, inside of WebCoder, and I'm now sharing the result with you. It could use a bit of polishing, but it works, and it has the basic webbrowser functionality, in only 61 lines of commented and nicely structured code - I think that's pretty cool! :)

So, here it is. If you wish to try it out, be sure to copy/paste it exactly like it is - the Python language is whitespace sensitive :). I know that this script is not terribly useful, but hopefully it will give you an idea of how easy it is to create something cool. I hope you can extend on this and make something even cooler! :)

# We need stuff from the .NET class library - add the 
# required assemblies and then import the classes we need
clr.AddReferenceByPartialName("System.Windows.Forms")
from System.Windows.Forms import WebBrowser, ToolStrip, ToolStripButton, ToolStripTextBox, Form, DockStyle

# Create our form (the dialog window)
browserForm = Form()
browserForm.Text = "Mini browser"
browserForm.Height = 400
browserForm.Width = 600

# Create an instance of the WebBrowser control and place it correctly
browser = WebBrowser()
browser.Dock = DockStyle.Fill
browserForm.Controls.Add(browser)

# Create an instance of a ToolStrip control (the .NET toolbar) and place it in the top
toolbar = ToolStrip()
toolbar.Dock = DockStyle.Top

# Events for the buttons we are about to create
def BackButtonClick(s, e):
	browser.GoBack()
	
def ForwardButtonClick(s, e):
	browser.GoForward()

def GoButtonClick(s, e):
	browser.Navigate(addressBox.Text)

# Create a couple of buttons on the toolbar
backButton = ToolStripButton()
backButton.Text = "Go back";
backButton.Click += BackButtonClick
toolbar.Items.Add(backButton)

forwardButton = ToolStripButton()
forwardButton.Text = "Go forward";
forwardButton.Click += ForwardButtonClick
toolbar.Items.Add(forwardButton)

# Create a text field for entering URL's
addressBox = ToolStripTextBox()
toolbar.Items.Add(addressBox)

# Create a Go button
goButton = ToolStripButton()
goButton.Text = "Go!"
goButton.Click += GoButtonClick
toolbar.Items.Add(goButton)

# Add the toolbar to the form
browserForm.Controls.Add(toolbar)

# Navigate to the TSW blog
browser.Navigate("http://www.tsware.net/blog/")

# Show the form
browserForm.ShowDialog()
# Dispose the form, freeing up it's resources
browserForm.Dispose()
Kasper (TSW) @ 9:44 pm in WebCoder

TSW WebCoder 2007, version 7.03 released

October 12, 2007

I'm happy to announce a new minor release of TSW WebCoder 2007. This release comes with a fair amount of small fixes, tweaks and a couple of additions. Here is the list:

  • Added a setting for controlling which type of linebreak used when saving files (Unix, Mac and Windows style)
  • Tweaked the HTML IntelliSense to work better when writing within PHP strings
  • The Alt key was not handled properly when used to access the main menu
  • When creating new files from a project, the file would be empty - the project template OR the default template will now be used
  • Removed visual appearance settings for bracket highlighting from the Editor settings tab. In WebCoder 2007, they should be set from the Syntax coloring tab
  • A few very minor issues were corrected

The update has been released to replace previous versions, so if you are bothered by any of these minor bugs, just re-download from the WebCoder product page and install on top of the previous version. There should be no conflicts with datafiles from the final version of WebCoder.

Note to registered users of WebCoder: This is of course a free upgrade for you :). If you are running WebCoder 2007, version 7.00, you should be aware of the following: The location of the product key has been moved, so that WebCoder can now be registered by users not having access to the HKEY_LOCAL_MACHINE part of the registry. Instead, it will be installed in HKEY_CURRENT_USER. This means that you have to re-register the application. Simply use the same key if you still have it, or get a new one from the serial key system, as described in the e-mail you received upon purchasing WebCoder. If you have any problems, be sure to contact us.

Kasper (TSW) @ 10:31 am in WebCoder