LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   wxTextCtrl.LoadFile error (https://www.linuxquestions.org/questions/programming-9/wxtextctrl-loadfile-error-190006/)

jalal 06-05-2004 09:51 AM

wxTextCtrl.LoadFile error
 
Hello,

I am trying to load a text file into a wxTextCtrl, and I keep getting this message:

Quote:

(test.py:4676): Gtk-CRITICAL **: file gtktextbuffer.c: line 557 (gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len, NULL)' failed
Here is the code I am using:

Code:

from wxPython.wx import *
class MainWindow(wxFrame):
    """ We simply derive a new class of Frame. """
    def __init__(self,parent,id,title):
        wxFrame.__init__(self,parent,wxID_ANY, title, size = ( 400,300),
                                    style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
        control = wxTextCtrl(self, 1, style=wxTE_MULTILINE)
        control.LoadFile("/etc/hosts")
        self.control = control
        self.Show(true)
app = wxPySimpleApp()
frame = MainWindow(None, -1, "Test")
app.MainLoop()


Any help will be appreciated.

leonora 02-01-2005 11:30 AM

I have the same problem ¿Have you solved the problem?

Many thanks in advance

leonora 02-02-2005 12:46 PM

Somebody can help me?

leonora 02-04-2005 03:37 AM

Somebody can help me?

MicahCarrick 09-12-2005 08:53 PM

I too am having trouble loading text files that were creating on other OS's due to the UTF-8 validation check. You can call the function g_utf8_validate() to handle the error in your program before it crashes, however, I have yet found out how to convert the files to utf-8. I'm using C and not python, but I believe we have similar issues here.

If I figure it out I will let you know.

- Micah


All times are GMT -5. The time now is 10:34 PM.