Hello, i'm a student from Argentina

I am developing an application that send and receive SMS messages.

This works fine in Python + Pybluez, but when i want to execute this code
from VBNET, i have problems. Ironpython can't resolve the bluetooth import

I am using NET 2008, python 2.6, Iron python 2.6 and
PyBluez-0.18.win32-py2.6.exe


Here i have a testing class "HelloWorl.py" to try to import package
bluetooth. The error result in NET is "global name 'discover_devices' is not
defined"

import clr
import sys
sys.path.append(r"C:\Python26\Lib")
sys.path.append(r"C:\Python26\Lib\site-packages")
import bluetooth
import select
clr.AddReference('prueba')
from prueba import HelloWorldVB
class HelloWorldIronPython(HelloWorldVB):
    def HelloWorld(self, name):
        return "Hello '" + name + "' from IronPython"
Bluetooth's package is installed in the following path:
C:\Python26\Lib\site-packages\bluetooth

I founded the function discover_devices and it is in bluez.py

If i try to import directly the bluez.py i have another error. Ironpython
not found the _bluetooth import.

import sys
import struct
import binascii
from btcommon import *
import _bluetooth as _bt
import array
import fcntl

Here my code for NET (solutions name is "prueba"):


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
AsSystem.EventArgs)
Handles Button1.Click

Dim helloWorld As New HelloWorldVB()

MsgBox(helloWorld.HelloWorld("Maurice"))

Dim runtime As ScriptRuntime =
IronPython.Hosting.Python.CreateEngine.Runtime

Dim scope As ScriptScope = runtime.ExecuteFile("HelloWorld.py")

Dim pythonType As PythonType = scope.GetVariable(Of PythonType)(
"HelloWorldIronPython")

helloWorld = CType(runtime.Operations.Invoke(pythonType), HelloWorldVB)

MsgBox(helloWorld.HelloWorld("Maurice"))

End Sub


Public Class HelloWorldVB

Public Overridable Function HelloWorld(ByVal name As String) As String

Return String.Format("Hello '{0}' from Visual Basic", name)

End Function

End Class


Any idea to import correctly the package bluetooth????


Thanks!!!


Sebastian
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to