Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
Tim, I tried using "monospace" and it looks like it works fine. If it works as well in Linux that's what I'll use. Thanks! James Simmons On Sun, Dec 12, 2010 at 7:06 PM, Tim Evans wrote: > On 2010-12-13 13:31, James Simmons wrote: >> >> Dieter, >> >> Good catch! It seems to be an issue with the Courier font in Windows. >> If I replace the line that specifies the font with one saying "Sans >> 12" everything is fine and I'm guessing that the mysterious >> disappearing cursor problem might be improved too. >> >> I had reasons for wanting to use a Courier font, but for Windows users >> of my program this is a useful workaround. > > On Windows you should use "Courier New" rather than "Courier" anyway. > Courier is an old bitmap font which is probably why it doesn't work > properly, Courier New is the truetype version. > > You could also use the font name "monospace" which will default to a useful > monospaced font. I'm not sure what the standard GTK+ install uses but it > should be Consolas where available (Vista and 7 for sure) falling back to > Courier New otherwise. > > -- > Tim Evans > Senior Software Engineer > ARANZ Geo Limited > p: +64 3 374 6120 | e: t.ev...@aranz.com > Level 6, 227 Cambridge Terrace, PO Box 3894, Christchurch, New Zealand > www.aranzgeo.com > ___ > pygtk mailing list pygtk@daa.com.au > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://faq.pygtk.org/ > ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
On 2010-12-13 13:31, James Simmons wrote: Dieter, Good catch! It seems to be an issue with the Courier font in Windows. If I replace the line that specifies the font with one saying "Sans 12" everything is fine and I'm guessing that the mysterious disappearing cursor problem might be improved too. I had reasons for wanting to use a Courier font, but for Windows users of my program this is a useful workaround. On Windows you should use "Courier New" rather than "Courier" anyway. Courier is an old bitmap font which is probably why it doesn't work properly, Courier New is the truetype version. You could also use the font name "monospace" which will default to a useful monospaced font. I'm not sure what the standard GTK+ install uses but it should be Consolas where available (Vista and 7 for sure) falling back to Courier New otherwise. -- Tim Evans Senior Software Engineer ARANZ Geo Limited p: +64 3 374 6120 | e: t.ev...@aranz.com Level 6, 227 Cambridge Terrace, PO Box 3894, Christchurch, New Zealand www.aranzgeo.com ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
Dieter, Good catch! It seems to be an issue with the Courier font in Windows. If I replace the line that specifies the font with one saying "Sans 12" everything is fine and I'm guessing that the mysterious disappearing cursor problem might be improved too. I had reasons for wanting to use a Courier font, but for Windows users of my program this is a useful workaround. Thanks much! James Simmons On Sun, Dec 12, 2010 at 3:35 AM, Dieter Verfaillie wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 11/12/2010 16:24, James Simmons wrote: >> Dieter, >> >> I tried replacing all my Python and PyGTK files with older versions >> and that didn't help. What's odd is that I CAN split a line into two >> lines with the Enter key; I just can't create a blank line. > > Oh! But I misunderstood your problem then :S > >> It is a great help to know that my program seems to work on Windows >> for other people, so I thank everyone who tried it. > > Well, it does not... I see the same problem here, I cannot create blank > lines. Or said in another way, multiple newline characters render as a > single newline character. The strange thing is that the saved textfile > *does* contain the exact amount of newline characters you would > expect... > > So, I did some further debugging and found that the modify_font call > is the culprit. Put line 151 [self.textview.modify_font(self.font_desc)] > in a comment and try again. All of the sudden, multiple newline > characters are actually rendered as blank lines :) > > mvg, > Dieter ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/12/2010 16:24, James Simmons wrote: > Dieter, > > I tried replacing all my Python and PyGTK files with older versions > and that didn't help. What's odd is that I CAN split a line into two > lines with the Enter key; I just can't create a blank line. Oh! But I misunderstood your problem then :S > It is a great help to know that my program seems to work on Windows > for other people, so I thank everyone who tried it. Well, it does not... I see the same problem here, I cannot create blank lines. Or said in another way, multiple newline characters render as a single newline character. The strange thing is that the saved textfile *does* contain the exact amount of newline characters you would expect... So, I did some further debugging and found that the modify_font call is the culprit. Put line 151 [self.textview.modify_font(self.font_desc)] in a comment and try again. All of the sudden, multiple newline characters are actually rendered as blank lines :) mvg, Dieter -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.16 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0El0oACgkQcdTd5T8YjL5s2ACfVByFyeICCxhdpRdb9wWaDc1O ykMAniFvMiw9pgbMtTWBABo/kacfnlXn =wfQr -END PGP SIGNATURE- ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
Dieter, I tried replacing all my Python and PyGTK files with older versions and that didn't help. What's odd is that I CAN split a line into two lines with the Enter key; I just can't create a blank line. What I think is that something I've installed may be interfering with the TextView. I'm going to try installing on another computer running Windows and see if the same thing happens. Most of my computers at home are running Linux, so I may end up trying at work. It is a great help to know that my program seems to work on Windows for other people, so I thank everyone who tried it. James Simmons On Sat, Dec 11, 2010 at 3:24 AM, Dieter Verfaillie wrote: > Quoting "James Simmons" : >> >> I tried it and it didn't work. I also tried replacing the GTK bundle >> with the older one, and the program would not accept it. I verified >> that the TextBuffer actually does contain the newlines. It's just >> that the TextView ignores them. Even if you have a text file that has >> newlines in there to begin with, visible in Notepad so I know the line >> endings are correct, the TextView seems to just compress them out. I >> verified with print statements that the lines are being added to the >> buffer. > > Strange. Everything works when I load an empty text file into your program. > Could you post the example image and text file the ocr package produced > you use for testing? Could be an encoding issue I can't reproduce here > with an empty text file... > > mvg, > Dieter > > > > This message was sent using IMP, the Internet Messaging Program. > > ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
Quoting "James Simmons" : I tried it and it didn't work. I also tried replacing the GTK bundle with the older one, and the program would not accept it. I verified that the TextBuffer actually does contain the newlines. It's just that the TextView ignores them. Even if you have a text file that has newlines in there to begin with, visible in Notepad so I know the line endings are correct, the TextView seems to just compress them out. I verified with print statements that the lines are being added to the buffer. Strange. Everything works when I load an empty text file into your program. Could you post the example image and text file the ocr package produced you use for testing? Could be an encoding issue I can't reproduce here with an empty text file... mvg, Dieter This message was sent using IMP, the Internet Messaging Program. ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
Stephen, I too notice the cursor issue, but it comes and goes. Sometimes it's there and sometimes it just disappears on you. It does this in both Linux and Windows. Thanks for giving me your versions. These are the ones I'm using on Windows XP Pro: Python version 2.7.1 GTK+version 2.22.0 pyGTK version 2.22.0 gobject version 2.26.0 cairo version 1.8.10 I tried replacing the GTK+ bundle with 2.16.6 but apparently when you do that you need to downgrade the other stuff too. I'll try using older versions of everything and see what happens. James Simmons On Fri, Dec 10, 2010 at 4:00 PM, Stephen George wrote: > > Hi James, > > Tried your program on windows and I could NOT see the problem you are > describing, to me it worked as expected. > > >> This program works flawlessly in Linux, but not in Windows. In >> Windows everything works *except* when you hit the Enter key in the >> TextView. It does not insert a new line. > > And here you are talking about a new line of text and not a newline > character[1] as a line ending - something that I think is confusing many of > the other replies. > > For me it did insert a new line, .. onto the text view. > Once closing the app, .. I can see the new line in the file also. > > It did not matter were the line was inserted at the end of the text or > somewhere in the middle. > > So unless you have changed the source to a working copy since posting this > message, I'm not sure why you are seeing the behaviour you are seeing.. > > Just to be sure you were not talking about line endings as the problem, I > also checked the line endings on the text file, .. under windows they were > . I then did a second test and started with a file that had linux > line endings, modified it in your program, and checked it after and ALL line > endings had been converted to windows format line endings. > > The only thing I found annoying was that there was no cursor in the text > view, so you had to use mouse to find the correct insert point, and wait > till the first character came out to check it was were you expected. > >> I'm using the very latest Python plus the very latest PyGTK, Cairo, >> PyGObject, and GTK+ bundle. >> > These are the versions when I tested it: > > Windows XP Home (in a virtual machine) > Python version 2.6.6 > GTK+ version 2.16.6 > pyGTK version 2.16.0 > gobject version 2.20.0 > cairo version 1.8.6 > > On Windows 7 64bit OS (32 bit python and gtk) > Python version 2.6.6 > GTK+ version 2.22.0 > pyGTK version 2.22.0 > gobject version 2.26.0 > cairo version 1.10.8 > > Steve > > [1] - newline = on windows, compared to on linux. > > ___ > pygtk mailing list pygtk@daa.com.au > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://faq.pygtk.org/ > ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
Hi James, Tried your program on windows and I could NOT see the problem you are describing, to me it worked as expected. > This program works flawlessly in Linux, but not in Windows. In > Windows everything works *except* when you hit the Enter key in the > TextView. It does not insert a new line. And here you are talking about a new line of text and not a newline character[1] as a line ending - something that I think is confusing many of the other replies. For me it did insert a new line, .. onto the text view. Once closing the app, .. I can see the new line in the file also. It did not matter were the line was inserted at the end of the text or somewhere in the middle. So unless you have changed the source to a working copy since posting this message, I'm not sure why you are seeing the behaviour you are seeing.. Just to be sure you were not talking about line endings as the problem, I also checked the line endings on the text file, .. under windows they were . I then did a second test and started with a file that had linux line endings, modified it in your program, and checked it after and ALL line endings had been converted to windows format line endings. The only thing I found annoying was that there was no cursor in the text view, so you had to use mouse to find the correct insert point, and wait till the first character came out to check it was were you expected. > I'm using the very latest Python plus the very latest PyGTK, Cairo, > PyGObject, and GTK+ bundle. > These are the versions when I tested it: Windows XP Home (in a virtual machine) Python version 2.6.6 GTK+version 2.16.6 pyGTK version 2.16.0 gobject version 2.20.0 cairo version 1.8.6 On Windows 7 64bit OS (32 bit python and gtk) Python version 2.6.6 GTK+version 2.22.0 pyGTK version 2.22.0 gobject version 2.26.0 cairo version 1.10.8 Steve [1] - newline = on windows, compared to on linux. ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
Dieter, I tried it and it didn't work. I also tried replacing the GTK bundle with the older one, and the program would not accept it. I verified that the TextBuffer actually does contain the newlines. It's just that the TextView ignores them. Even if you have a text file that has newlines in there to begin with, visible in Notepad so I know the line endings are correct, the TextView seems to just compress them out. I verified with print statements that the lines are being added to the buffer. James Simmons On Fri, Dec 10, 2010 at 5:10 AM, Dieter Verfaillie wrote: > Quoting "James Simmons" : >> >> >> http://git.sugarlabs.org/e-book-making-scripts/mainline/blobs/master/proofer.py > > Just a thought, but try changing line 84 from > etext_file = open(text_filename,"r") to > etext_file = open(text_filename,"rU") and see what happens... > > mvg, > Dieter > > > > This message was sent using IMP, the Internet Messaging Program. > > ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
Quoting "James Simmons" : http://git.sugarlabs.org/e-book-making-scripts/mainline/blobs/master/proofer.py Just a thought, but try changing line 84 from etext_file = open(text_filename,"r") to etext_file = open(text_filename,"rU") and see what happens... mvg, Dieter This message was sent using IMP, the Internet Messaging Program. ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with gtk.TextView in Windows, but not in Linux
Linux and windows use different types of line breaks. Linux uses \n and Windows \r\n (And mac \r I believe). So I think you should add an extra \r when your program is run on Windows and the user hits enter. I don't know why Textview doesn't do that itself. I'm a pygtk beginner myself... Regards, Leon From: pygtk-boun...@daa.com.au [pygtk-boun...@daa.com.au] on behalf of James Simmons [nices...@gmail.com] Sent: Friday, December 10, 2010 01:39 To: PyGTK Mailing List Subject: [pygtk] Problem with gtk.TextView in Windows, but not in Linux I have written a simple program for proofing and correcting OCR'd text that I'm going to include in a book I'm writing about making e-books. The program has a left pane and a right pane. The left pane is a gtk.TextView and the right pane is a gtk.Image. The idea is that the left pane shows the OCR'd text created from the image in the right pane. You use the text view to make corrections to the text and save them. You can see the code here: http://git.sugarlabs.org/e-book-making-scripts/mainline/blobs/master/proofer.py This program works flawlessly in Linux, but not in Windows. In Windows everything works *except* when you hit the Enter key in the TextView. It does not insert a new line. What's odd is that if you look at a file edited with the program in Windows in Linux then you DO see the inserted lines, so they are going into the text buffer but the TextView does not show them. Every other key works just fine in Windows. It's just the Enter key that's messed up. I'm using the very latest Python plus the very latest PyGTK, Cairo, PyGObject, and GTK+ bundle. If anyone has ideas on how to work around this I'd sure like to hear them. For myself I can use the program under Linux, but I want my readers to be able to use it under Windows and the Mac as well. James Simmons ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/ ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
[pygtk] Problem with gtk.TextView in Windows, but not in Linux
I have written a simple program for proofing and correcting OCR'd text that I'm going to include in a book I'm writing about making e-books. The program has a left pane and a right pane. The left pane is a gtk.TextView and the right pane is a gtk.Image. The idea is that the left pane shows the OCR'd text created from the image in the right pane. You use the text view to make corrections to the text and save them. You can see the code here: http://git.sugarlabs.org/e-book-making-scripts/mainline/blobs/master/proofer.py This program works flawlessly in Linux, but not in Windows. In Windows everything works *except* when you hit the Enter key in the TextView. It does not insert a new line. What's odd is that if you look at a file edited with the program in Windows in Linux then you DO see the inserted lines, so they are going into the text buffer but the TextView does not show them. Every other key works just fine in Windows. It's just the Enter key that's messed up. I'm using the very latest Python plus the very latest PyGTK, Cairo, PyGObject, and GTK+ bundle. If anyone has ideas on how to work around this I'd sure like to hear them. For myself I can use the program under Linux, but I want my readers to be able to use it under Windows and the Mac as well. James Simmons ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/