foo2.htm 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <HTML>
  2. <BODY>
  3. <SCRIPT>
  4. b="Hello"
  5. </SCRIPT>
  6. <SCRIPT LANGUAGE="Python">
  7. import win32traceutil
  8. import sys
  9. print "Hello"
  10. a="Hi there"
  11. print "Location is", document.location
  12. document.write("Hello", " from version ", 2, " of the Python AXScript Engine","<P>")
  13. document.writeln("This is Python", sys.version)
  14. </SCRIPT>
  15. <P>The caption on the first button is set by the Window Load code. Clicking
  16. that button changes the text in the first edit box.
  17. <P>The second button changes its own text when clicked.
  18. <P>The fourth button calls a global function, defined in the global 'script' scope,
  19. rather than the 'MyForm' scope.
  20. <FORM NAME="MyForm" METHOD="GET">
  21. <SCRIPT LANGUAGE="Python">
  22. print "Hello from in the form"
  23. </SCRIPT>
  24. <INPUT NAME="Button1" TYPE="Button" OnClick="MyForm.Text1.value='Hi'" LANGUAGE="Python">
  25. <INPUT TYPE="TEXT" SIZE=25 NAME="Text1">
  26. <INPUT NAME="Button2" TYPE="Button" VALUE="Click for 'Hi'" OnClick="a='Howdy'; MyForm.Button2.value='Hi'" LANGUAGE="Python">
  27. <INPUT NAME="Button3" TYPE="Button" VALUE="Click for URL" OnClick="MyForm.Text2.value=document.location" LANGUAGE="Python">
  28. <INPUT TYPE="TEXT" SIZE=25 NAME="Text2">
  29. <INPUT NAME="Button4" TYPE="Button" VALUE="Call global fn" OnClick="foo1()" LANGUAGE="Python">
  30. <INPUT NAME="Button5" TYPE="Button" VALUE="Script for... Test">
  31. <script for="Button5" event="onClick" language="Python">
  32. print "HelloThere";
  33. window.alert("Hello")
  34. def ATest():
  35. print "Hello from ATEst"
  36. ATest()
  37. </script>
  38. <INPUT NAME="Button6" TYPE="Button" VALUE="Set Other" OnClick="Form2.Text1.Value='Hi from other'" LANGUAGE="Python">
  39. </FORM><BR>
  40. <P>
  41. And here is a second form
  42. <P>
  43. <FORM NAME="Form2" METHOD="GET">
  44. <INPUT NAME="Button1" TYPE="Button" OnClick="Form2.Text1.Value='Hi'" LANGUAGE="Python">
  45. <INPUT NAME="Button2" TYPE="Button" VALUE="Set Other" OnClick="MyForm.Text1.Value='Hi from other'" LANGUAGE="Python">
  46. <INPUT TYPE="TEXT" SIZE=25 NAME="Text1">
  47. <INPUT NAME="ButRExec" TYPE="Button" VALUE="RExec fail" OnClick="import win32api;win32api.MessageBox(0,'Oops')" LANGUAGE="Python">
  48. <INPUT NAME="ButRExec2" TYPE="Button" VALUE="RExec fail 2" OnClick="import sys,win32traceutil;print sys.modules;from win32com.client import dynamic;import win32com.client.dynamic, pythoncom, win32com.client;o=win32com.client.Dispatch('Word.Application')" LANGUAGE="Python">
  49. <INPUT NAME="ButVB" TYPE="Button" VALUE="VBScript Button" OnClick='alert("Hi from VBScript")'>
  50. <INPUT NAME="ButCallChain" TYPE="Button" VALUE="Multi-Language call" OnClick='CallPython()'>
  51. </FORM><BR>
  52. <SCRIPT LANGUAGE="VBScript">
  53. function CallPython()
  54. alert("Hello from VB - Im about to call Python!")
  55. PythonGlobalFunction()
  56. end function
  57. </SCRIPT>
  58. <SCRIPT LANGUAGE="JScript">
  59. function JScriptFunction()
  60. {
  61. alert("Hello from JScript");
  62. }
  63. </SCRIPT>
  64. <SCRIPT LANGUAGE="Python">
  65. x=13
  66. def foo1():
  67. y = 14
  68. for name, item in globals().items():
  69. print name, `item`
  70. alert ("Hello from AXCode")
  71. print "Y is ",y
  72. def PythonGlobalFunction():
  73. window.alert("Hello from Python - Im about to call JScript!")
  74. window.JScriptFunction()
  75. def Window_OnLoad():
  76. print "X is", x
  77. print "a is", a
  78. # print "------ GLOBALS ----------"
  79. # for n,v in globals().items():
  80. # print n,'=',v
  81. print "MyForm is", MyForm
  82. print "MyForm is repr", `MyForm`
  83. print "MyForm.Button1 is", `MyForm.Button1`
  84. MyForm.Button1.Value = "Python Rules!"
  85. Form2.Button1.value = "Form2!"
  86. MyForm.Text1.value = document.location
  87. </SCRIPT>
  88. </BODY>
  89. </HTML>