Skip to content
Permalink
Browse files

Repl and Python demo

  • Loading branch information...
jschementi committed Nov 16, 2008
1 parent 08b3919 commit f7e4b6a22974209600b6b95a8126bf63db0cdcf6
@@ -0,0 +1,109 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Silverlight Template</title>

<!-- Basic stylesheet for applicaiton -->
<link type="text/css" rel="stylesheet" href="stylesheets/screen.css" />
<!-- Formatting for Dynamic Language error window -->
<link type="text/css" rel="stylesheet" href="stylesheets/error.css" />
<!-- Defines "onSilverlightError" function for Silverlight plugin -->
<script type="text/javascript" src="javascripts/error.js"></script>
</head>

<body>
<!--
Runtime errors from Silverlight will be displayed here.
This will contain debugging information and should be
removed or hidden when debugging is completed
-->
<div id='errorLocation'></div>

<div id="silverlightControlHost">

<!--
Silverlight 2 Beta 2 plug-in control
http://msdn.microsoft.com/en-us/library/cc189089(VS.95).aspx#silverlight_plug_in_configuring
-->
<object data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%">

<!--
"source" points to the actual Silverlight application
If using "Chiron /w", value should be the "<your app folder>.xap"
-->
<param name="source" value="python.xap"/>

<!--
"initParams" is a comma-seperated way to pass key=value pair arguments
into your Silverlight application. Dynamic Languages use special
arguments to configure the application:
* start = app.(rb|py|js)
- this is the entry-point file to the application.
- By default, it will look for any file named "app", regardless of
the extension. The extension will be used to figure out the language.
- This option can be set to anything you want, but it must include
the extension.
* debug = [true]|false
- Runs your code as debug-able; stack traces will be shown if an error
occurs.
- This lets you attach the browser to the Visual Studio
debugger and step through the running program (only when the
Silverlight tools are installed).
- When omitted/set to false, all errors will be silent
(for deployment purposes)
* reportErrors = [HTML-element-ID]
- In the event of an error, the error window will be written into the
innerHTML property of the HTML element with an ID attribute matching
the value of this field.
- If there is no matching ID, a HTML element is created with that ID,
and the error window inserted.
- If this field is omitted, no errors will be shown.
+ You can define the "onerror" param, which will let you handle any
error with JavaScript (the index.html templates do this, if you
want sample code).
- This just causes HTML to be generated in the HTML element; the styling
of the error window is defined in a separate error.css file that must
be included in the page.
* exceptionDetail = true|false
- If set to true, this will also show the entire managed stack trace
in the error window rather than just the dynamic stack trace.
This is useful when debugging C#/Visual Basic when called from a
dynamic language.
-->
<param name="initParams" value="debug=true, reportErrors=errorLocation" />

<!-- Handle all Silverlight errors with function defined in javascripts/error.js -->
<param name="onerror" value="onSilverlightError" />

<!--
Other properties of the Silverlight plug-in. For documentation on this, see:
http://msdn.microsoft.com/en-us/library/cc189089(VS.95).aspx#silverlight_plug_in_configuring
-->
<param name="background" value="white" />
<param name="windowless" value="true" />

<!--
Shows a "Install Microsoft Silverlight" link if Silverlight is
not installed
-->
<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
</a>

</object>

<!--
<iframe> needed to prevent Safari from caching the page and reloading
the plugin when the user navigates back to a previously-visted
Silverlight page.
-->
<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>

</div>

</body>
</html>
@@ -0,0 +1,32 @@
function onSilverlightError(sender, args) {
var appSource = "";
if (sender != null && sender != 0) {
appSource = sender.getHost().Source;
}
var errorType = args.ErrorType;
var iErrorCode = args.ErrorCode;

var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n" ;

errMsg += "Code: "+ iErrorCode + " \n";
errMsg += "Category: " + errorType + " \n";
errMsg += "Message: " + args.ErrorMessage + " \n";

if (errorType == "ParserError")
{
errMsg += "File: " + args.xamlFile + " \n";
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
else if (errorType == "RuntimeError")
{
if (args.lineNumber != 0)
{
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
errMsg += "MethodName: " + args.methodName + " \n";
}

throw new Error(errMsg);
}
@@ -0,0 +1,18 @@
from System.Windows import Application
from System.Windows.Controls import UserControl
from System.Windows.Media import SolidColorBrush, Colors

class App:
def __init__(self):
root = Application.Current.LoadRootVisual(UserControl(), "app.xaml")
root.Message.Text = "Welcome to Python!"
root.Message.MouseLeftButtonDown += self.Message_MLBD
root.Message.MouseLeftButtonUp += self.Message_MLBU

def Message_MLBD(self, s, e):
s.Foreground = SolidColorBrush(Colors.Red)

def Message_MLBU(self, s, e):
s.Foreground = SolidColorBrush(Colors.Black)

App()
@@ -0,0 +1,9 @@
<UserControl x:Class="System.Windows.Controls.UserControl"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Grid x:Name="layout_root" Background="White">
<TextBlock x:Name="Message" FontSize="30" />
</Grid>

</UserControl>
@@ -0,0 +1,110 @@
div.silverlightDlrErrorReport {
font-size: 12px;
font-weight: normal;
font-family: Consolas, "Courier New", serif;
color: black;
background-color: white;
text-align: left;
}

div.silverlightDlrErrorReport a,
div.silverlightDlrErrorReport a:link,
div.silverlightDlrErrorReport a:visited {
padding: 2px;
background-color: none;
color: black;
}
div.silverlightDlrErrorReport a:hover {
background-color: black;
color: white;
}

div.silverlightDlrErrorWrapper {
background-color: white;

position: absolute;
bottom: 10px;
left: 10px;
right: 10px;

border-top: 2px solid black;
border-right: 2px solid black;
border-left: 2px solid black;
margin-bottom: 15px;
padding-bottom: 5px;
}

h2.silverlightDlrErrorMessage {
margin: 0px;
background-color: black;
color: white;
padding: 5px;
font-size: 18px;
overflow: auto;
}

div.silverlightDlrErrorSource {
margin: 10px;
}

div.silverlightDlrErrorSourceFile,
div.silverlightDlrErrorType {
font-weight: bold;
font-size: 14px;
padding-left: 5px;
}

code.silverlightDlrErrorSourceCode {
color: #ccc;
background-color: #222;
display: block;
padding: 10px;
}

span.silverlightDlrErrorLine {
color: red;
}

div.silverlightDlrErrorType {
border-bottom: 1px solid gray;
}

code.silverlightDlrErrorStackTrace {
display: block;
padding: 5px 10px;
max-height: 100px;
overflow: auto;
}
div.silverlightDlrErrorStackTraceLine {
border-bottom: 1px solid #bbb;
}

div.silverlightDlrErrorMenu {
background-color: #440000;
color: white;
font-size: 12px;
padding: 5px;

position: absolute;
height: 15px;
bottom: 0px;
left: 0px;
right: 0px;
margin-top: 15px;
}
div.silverlightDlrErrorMenu a,
div.silverlightDlrErrorMenu a:link,
div.silverlightDlrErrorMenu a:visited {
padding: 2px;
background-color: none;
color: white;
}
div.silverlightDlrErrorMenu a:hover {
background-color: white;
color: #440000;
}

div.silverlightDlrErrorMenu,
div.silverlightDlrErrorWrapper {
position: fixed;
}
@@ -0,0 +1,15 @@
html, body {
height: 100%;
overflow: auto;
}
body {
padding: 0;
margin: 0;
}
#silverlightControlHost {
height: 100%;
}
#errorLocation {
font-size: small;
color: Gray;
}
@@ -18,7 +18,7 @@
#silverlightDlrConsole {
padding: 15px;
background-color: black;
height: 250px;
height: 300px;
overflow: auto;
}

0 comments on commit f7e4b6a

Please sign in to comment.
You can’t perform that action at this time.