Hello,
Is ListCtrlPrinter able to print to a pdf file when choosing the "Print to file option"? Furthermore, some characters get printed strange in the file even if they are properly shown on the page setup. For example, the spanish"�" character gets printed "ñ". Can anyone help?
Cheers!
Si no �s del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudar�s a estalviar aigua, energia i recursos forestals. GR�CIES!
Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!
Furthermore, some characters get printed strange in the file even if they are properly shown on the page setup. For example, the spanish"�" character gets printed "ñ". Can anyone help?
If I look at the example on my machine the "�" are not shown correctly either, I believe it is an encoding issue of the SpeciesQuery.py file.
What is your encoding for your editor?
Mine is set to :
import sys
sys.getdefaultencoding()
'utf-8'
Now if I change the encoding on the sample files to also use utf-8 and define the strings as unicode and re-enter "�" (i.e. any special character) and then save them I see the correct sign displayed.
Attached the edited sample, copy/pasted some print stuff from my code to see if the preview and print works for special characters.
Furthermore, some characters get printed strange in the file even if they are properly shown on the page setup. For example, the spanish"ń" character gets printed "Ăą". Can anyone help?
If I look at the example on my machine the "ă" are not shown correctly either, I believe it is an encoding issue of the SpeciesQuery.py file.
What is your encoding for your editor?
Mine is set to :
import sys
sys.getdefaultencoding()
'utf-8'
Now if I change the encoding on the sample files to also use utf-8 and define the strings as unicode and re-enter "ă" (i.e. any special character) and then save them I see the correct sign displayed.
Attached the edited sample, copy/pasted some print stuff from my code to see if the preview and print works for special characters.
Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES!
Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!
Si no �s del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudar�s a estalviar aigua, energia i recursos forestals. GR�CIES!
Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!
Furthermore, some characters get printed strange in the file even if they are properly shown on the page setup. For example, the spanish"ń" character gets printed "Ăą". Can anyone help?
If I look at the example on my machine the "ă" are not shown correctly either, I believe it is an encoding issue of the SpeciesQuery.py file.
What is your encoding for your editor?
Mine is set to :
import sys
sys.getdefaultencoding()
'utf-8'
Now if I change the encoding on the sample files to also use utf-8 and define the strings as unicode and re-enter "ă" (i.e. any special character) and then save them I see the correct sign displayed.
Attached the edited sample, copy/pasted some print stuff from my code to see if the preview and print works for special characters.
Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES!
Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!
Hello,
Your example files do not work for me. I have set up everything to use UTF-8, but I still get the spanish "ñ" or others such as "ó" or "à" not printed correctly. Here's my script header, where I set the encoding:
Furthermore, some characters get printed strange in the file even if they are properly shown on the page setup. For example, the spanish"ń" character gets printed "Ăą". Can anyone help?
If I look at the example on my machine the "ă" are not shown correctly either, I believe it is an encoding issue of the SpeciesQuery.py file.
What is your encoding for your editor?
Mine is set to :
import sys
sys.getdefaultencoding()
'utf-8'
Now if I change the encoding on the sample files to also use utf-8 and define the strings as unicode and re-enter "ă" (i.e. any special character) and then save them I see the correct sign displayed.
Attached the edited sample, copy/pasted some print stuff from my code to see if the preview and print works for special characters.
Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES!
Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!
Thank you so much jmf! Do you know
1) can ListCtrlPrinter print to pdf
2) why ListCtrlPrinter does not print characters such as "�" or "�" not properly even if they are properly shown in the print preview?
Cheers!
Dani
···
On 10/25/2010 07:42 PM, jmfauth wrote:
On Oct 25, 6:40 pm, Dani Valverde<dani.valve...@gmail.com> wrote:
On 10/25/2010 02:04 PM, werner wrote:
sys.setdefaultencoding('UTF-8')
DO NOT TOUCH THIS. NEVER.
This opaque sys attribute is and should be 'ascii' in Python 2
and 'utf-8' in Python 3.
(The sys attribute setdefaultencoding has been dropped in
Python 2.7 and Python 3).
Si no �s del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudar�s a estalviar aigua, energia i recursos forestals. GR�CIES!
Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!
I'm quite confortable with all the encoding stuff. Unfortnately,
I cann't figure out what your problem is (not enough informations,
libraries I'm not using, ...).
jmf
···
On Oct 25, 8:15 pm, Dani Valverde <dani.valve...@gmail.com> wrote:
On 10/25/2010 07:42 PM, jmfauth wrote:
> On Oct 25, 6:40 pm, Dani Valverde<dani.valve...@gmail.com> wrote:
>> On 10/25/2010 02:04 PM, werner wrote:
>> sys.setdefaultencoding('UTF-8')
> DO NOT TOUCH THIS. NEVER.
> This opaque sys attribute is and should be 'ascii' in Python 2
> and 'utf-8' in Python 3.
> (The sys attribute setdefaultencoding has been dropped in
> Python 2.7 and Python 3).
> jmf
Thank you so much jmf! Do you know
1) can ListCtrlPrinter print to pdf
2) why ListCtrlPrinter does not print characters such as "�" or "�" not
properly even if they are properly shown in the print preview?
Cheers!
Hello,
Your example files do not work for me. I have set up everything to use UTF-8, but I still get the spanish "ñ" or others such as "ó" or "à" not printed correctly. Here's my script header, where I set the encoding:
The alternative is to have "encode/decode" all over the place.
Either way one still has to pay attention to the encoding and think about it.
I use it in my application for a few years now (since I switched to use the Unicode build of wxPython and have all my character stuff defined as unicode and all my script files have "# -*- coding: utf-8 -*-#") and it hasn't caused me any problems but reduced the number of places where I needed to use encode/decode.
This opaque sys attribute is and should be 'ascii' in Python 2
and 'utf-8' in Python 3.
(The sys attribute setdefaultencoding has been dropped in
Python 2.7
I think it is still there in 2.7:
and Python 3).
Haven't touched Py 3 yet but is it not having a default of utf-8 or similar?
Werner
···
On 25/10/2010 19:42, jmfauth wrote:
On Oct 25, 6:40 pm, Dani Valverde<dani.valve...@gmail.com> wrote:
The alternative is to have "encode/decode" all over the place.
No, when working with a Unicode application you should only do
conversions on input/output points and use Unicode everywhere
internally.
Either way one still has to pay attention to the encoding and think about
it.
I use it in my application for a few years now (since I switched to use the
Unicode build of wxPython and have all my character stuff defined as unicode
and all my script files have "# -*- coding: utf-8 -*-#") and it hasn't
caused me any problems but reduced the number of places where I needed to
use encode/decode.
The '#-*- coding...' line has nothing to do with how strings and bytes
are interpreted within your application. That line is only to tell the
interpreter how to handle the text in your script.
What is "ListCtrlPrinter"? I don't think that this is a standard
wxPython class. But my guess would be that may be passing raw Unicode
bytes to whatever is being used to create the pdf, where that code is
expecting an encoded string.
Would suggest contacting the maintainer of whatever 3rd party
package(s) your using.
Cody
···
On Mon, Oct 25, 2010 at 1:37 PM, werner <wbruhin@free.fr> wrote:
On 25/10/2010 19:42, jmfauth wrote:
On Oct 25, 6:40 pm, Dani Valverde<dani.valve...@gmail.com> wrote:
sys.version
'3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit
(Intel)]'
---
sys.setdefaultencoding
Traceback (most recent call last):
File "<smid last command>", line 1, in <module>
AttributeError: 'module' object has no attribute 'setdefaultencoding'
---
hasattr(sys, setdefaultencoding)
Traceback (most recent call last):
File "<smid last command>", line 1, in <module>
NameError: name 'setdefaultencoding' is not defined
No, setdefaultencoding is removed from the sys module by the default site.py (IIRC) after it has set the default.
Python 2.7 (r27:82508, Jul 3 2010, 21:12:11)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.setdefaultencoding
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'setdefaultencoding'
>>> reload(sys)
<module 'sys' (built-in)>
>>> sys.setdefaultencoding
<built-in function setdefaultencoding>
>>>
Using reload(sys) makes it available again, but there is a reason why setdefaultencoding is removed, so IMO it seems like it's not a very good idea to change the default setting. There could be problems if you use any 3rd party modules that expect the default encoding is ascii.
···
On 10/25/10 12:11 PM, jmfauth wrote:
On Oct 25, 8:37 pm, werner<wbru...@free.fr> wrote:
No, setdefaultencoding is removed from the sys module by the default site.py (IIRC) after it has set the default.
Python 2.7 (r27:82508, Jul 3 2010, 21:12:11)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.setdefaultencoding
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'setdefaultencoding'
>>> reload(sys)
<module 'sys' (built-in)>
>>> sys.setdefaultencoding
<built-in function setdefaultencoding>
>>>
Using reload(sys) makes it available again, but there is a reason why setdefaultencoding is removed, so IMO it seems like it's not a very good idea to change the default setting. There could be problems if you use any 3rd party modules that expect the default encoding is ascii.
I think this is going off-topic as far as the OP is concerned.
The attached code is what he had a problem with. "special" characters (� etc) would not print/display correctly. I used his code and changed it to make it run correctly on Windows 7 with Py 2.6 and wxPython 2.8.11 Unicode but it sounds as it still does not run correctly on Linux for him.
ObjectListView/ListCtrlPrinter are wrappers around wx.ListCtrl and wx.Printout - any reason why the attached code would not produce the same result on *nix as it does on Windows 7?
1. Is is a unicode build of wxPython on both platforms?
2. Is the text with the problem sent to the wx APIs as a string or a unicode object?
3. Can the problem be replicated in a small standalone sample?
···
On 10/25/10 2:11 PM, werner wrote:
The attached code is what he had a problem with. "special" characters (�
etc) would not print/display correctly. I used his code and changed it
to make it run correctly on Windows 7 with Py 2.6 and wxPython 2.8.11
Unicode but it sounds as it still does not run correctly on Linux for him.
ObjectListView/ListCtrlPrinter are wrappers around wx.ListCtrl and
wx.Printout - any reason why the attached code would not produce the
same result on *nix as it does on Windows 7?
I run your test code on ubuntu and it works OK when displayed in
ObjectListView and in PrintPreview.
But then I print to a file, say test.ps, open it with evince and voilà
the latin1 chars don't display correct.
I suspect that it's a wxWidgets PostScript render issue.
This can be seen also in wxPython demo. Change the text "Hello world"
in ScrolledWindow.py and then run
to PrintFramework.py and print to a file, then open the file with
evince or some other postscript viewer.
Ricardo
···
On Mon, Oct 25, 2010 at 10:11 PM, werner <wbruhin@free.fr> wrote:
Hi all,
The attached code is what he had a problem with. "special" characters (ã
etc) would not print/display correctly. I used his code and changed it to
make it run correctly on Windows 7 with Py 2.6 and wxPython 2.8.11 Unicode
but it sounds as it still does not run correctly on Linux for him.
ObjectListView/ListCtrlPrinter are wrappers around wx.ListCtrl and
wx.Printout - any reason why the attached code would not produce the same
result on *nix as it does on Windows 7?
One more thing, if someone, on linux, is using the gnome print support
instead the wxWidget generic one, please do a quick test.
If you do not know what print "system" your wxPython is using, it's easy.
If the dialog that let you choose a print is the same as other gnome
apps than your are using the gnome print support, otherwise
you should have a generic wxWidget dialog - It's my case.
Ricardo
···
On Tue, Oct 26, 2010 at 1:25 AM, Ricardo Pedroso <rmdpedroso@gmail.com> wrote:
On Mon, Oct 25, 2010 at 10:11 PM, werner <wbruhin@free.fr> wrote:
Hi all,
The attached code is what he had a problem with. "special" characters (ã
etc) would not print/display correctly. I used his code and changed it to
make it run correctly on Windows 7 with Py 2.6 and wxPython 2.8.11 Unicode
but it sounds as it still does not run correctly on Linux for him.
ObjectListView/ListCtrlPrinter are wrappers around wx.ListCtrl and
wx.Printout - any reason why the attached code would not produce the same
result on *nix as it does on Windows 7?
I run your test code on ubuntu and it works OK when displayed in
ObjectListView and in PrintPreview.
But then I print to a file, say test.ps, open it with evince and voilà
the latin1 chars don't display correct.
I suspect that it's a wxWidgets PostScript render issue.
This can be seen also in wxPython demo. Change the text "Hello world"
in ScrolledWindow.py and then run
to PrintFramework.py and print to a file, then open the file with
evince or some other postscript viewer.
The attached code is what he had a problem with. "special" characters (�
etc) would not print/display correctly. I used his code and changed it to
make it run correctly on Windows 7 with Py 2.6 and wxPython 2.8.11 Unicode
but it sounds as it still does not run correctly on Linux for him.
ObjectListView/ListCtrlPrinter are wrappers around wx.ListCtrl and
wx.Printout - any reason why the attached code would not produce the same
result on *nix as it does on Windows 7?
I run your test code on ubuntu and it works OK when displayed in
ObjectListView and in PrintPreview.
But then I print to a file, say test.ps, open it with evince and voil�
the latin1 chars don't display correct.
I suspect that it's a wxWidgets PostScript render issue.
This can be seen also in wxPython demo. Change the text "Hello world"
in ScrolledWindow.py and then run
to PrintFramework.py and print to a file, then open the file with
evince or some other postscript viewer.
One more thing, if someone, on linux, is using the gnome print support
instead the wxWidget generic one, please do a quick test.
If you do not know what print "system" your wxPython is using, it's easy.
If the dialog that let you choose a print is the same as other gnome
apps than your are using the gnome print support, otherwise
you should have a generic wxWidget dialog - It's my case.
Werner
···
On 26/10/2010 02:39, Ricardo Pedroso wrote:
On Tue, Oct 26, 2010 at 1:25 AM, Ricardo Pedroso<rmdpedroso@gmail.com> wrote:
On Mon, Oct 25, 2010 at 10:11 PM, werner<wbruhin@free.fr> wrote: