[IronPython] Ironpython 2 Alpha 4

Dino Viehland dinov at exchange.microsoft.com
Tue Sep 11 17:20:48 CEST 2007


Is line 28:

        HighlightingManager.Manager.AddSyntaxModeFileProvider(FileSyntaxModeProvider(sys.path[0]));

?

Can you provide the text of the exception (even better w/ the -X:ExceptionDetail command line option) ?

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of David.Lawler at franke.com
Sent: Tuesday, September 11, 2007 6:40 AM
To: users at lists.ironpython.com
Subject: [IronPython] Ironpython 2 Alpha 4

The following ugly hack works fine with IronPython 1.1 and with 2.0 alpha
3 but raises an exception on line 28 with IronPython 2.0 alpha 4.
To run this you need a copy of the ICSharpCode.TextEditor.dll from
SharpDevelop (http://www.icsharpcode.net/OpenSource/SD).
Is this a bug or a new 'feature'?  Is there a work-around?  Thanks.   DJL

import clr
import sys

clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
clr.AddReference('ICSharpCode.TextEditor')

from System.IO import (Path, Directory, FileInfo)
from System.Windows.Forms import *
from System.Drawing import (Color, Font, FontStyle, GraphicsUnit, Point,
Size)
from ICSharpCode.TextEditor import *
from ICSharpCode.TextEditor.Document import *

class ExecuteForm(Form):

    def __init__(self):

        self.Size = Size(1024, 768)
        self.Text = "IronPythonDev"

        self.editor = TextEditorControl()
        self.editor.Location = Point(0,20)
        self.editor.Enabled = True
        self.editor.Size = Size(1000, 700)
        self.editor.Anchor = AnchorStyles.Top | AnchorStyles.Left |
AnchorStyles.Right | AnchorStyles.Bottom


HighlightingManager.Manager.AddSyntaxModeFileProvider(FileSyntaxModeProvider(sys.path[0]));

        self.editor.Document.HighlightingStrategy =
HighlightingManager.Manager.FindHighlighter("Python");
        self.editor.ShowEOLMarkers = False
        self.editor.ConvertTabsToSpaces = True
        self.Controls.Add(self.editor)

        # Create the menu
        mainMenu1 = MainMenu()

        fileMenu = MenuItem()
        fileMenu.Text = "File"
        menuItemOpen = MenuItem()
        menuItemOpen.Text = "Open..."
        menuItemOpen.Click += self.OpenMenuHandler
        menuItemSave = MenuItem()
        menuItemSave.Text = "Save..."
        menuItemSave.Click += self.SaveMenuHandler
        menuItemExit = MenuItem()
        menuItemExit.Text = "Exit"
        menuItemExit.Click += self.ExitMenuHandler
        fileMenu.MenuItems.Add(menuItemOpen)
        fileMenu.MenuItems.Add(menuItemSave)
        fileMenu.MenuItems.Add(menuItemExit)

        mainMenu1.MenuItems.Add(fileMenu)
        self.Menu = mainMenu1

        self.OpenDialog = OpenFileDialog()
        self.OpenDialog.Filter = "*.py|*.*"
        self.FileName = None
        self.InitCurrDir = Directory.GetCurrentDirectory()

    def OpenMenuHandler(self, source, ev):

        if self.OpenDialog.ShowDialog() == DialogResult.OK:

            self.FileName = self.OpenDialog.FileName
            self.editor.LoadFile(self.FileName)
            ext = self.FileName.lower().split(".")[-1]

    def SaveMenuHandler(self, source, ev):

        self.editor.SaveFile(self.FileName)

    def ExitMenuHandler(self, source, ev):
        self.Close()

Application.EnableVisualStyles()
form = ExecuteForm()
Application.Run(form)

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



More information about the Ironpython-users mailing list