error message

Previous topic - Next topic

Zaza

Hi,
I test the script from here : https://github.com/RaffertyR/Monthly-calendar-script-for-Scribus/
but I have this message :

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "<string>", line 1164, in <module>
  File "<string>", line 1155, in main
  File "C:\Program Files\Scribus 1.6.4\python\lib\locale.py", line 608, in setlocale
      return _setlocale(category, locale)
  locale.Error: unsupported locale setting

The calendar is create but I have no moon phase drawing.

What can I do ?

hjh

Hi Zaza

I tried out the script as well with language=German and font=Arial regular on MSWindows with Scribus 1.6.4.

It went through smoothly but only showed the full moon and the empty moon. It means that the font must support all the moon symbols.

Which language did you use?

I also realize that the error is at the line
https://github.com/RaffertyR/Monthly-calendar-script-for-Scribus/blob/e656ff77d82ffd4e3804d88caf695ddd4fad973e/MonthlyCalendar.py#L1155


This is where the locale information is set back to the original value stored earlier in the variable original_locale1.


The code in question is the main program
def main():
    """ Application/Dialog loop with Scribus sauce around """
    try:
        statusMessage('Running script...')
        progressReset()
        original_locale1=locale.getlocale(locale.LC_CTYPE)
        original_locale2=locale.getlocale(locale.LC_TIME)
        root = Tk()
        app = TkCalendar(root)
        root.mainloop()
        locale.setlocale(locale.LC_CTYPE, original_locale1)
        locale.setlocale(locale.LC_TIME, original_locale2)
    finally:
        if haveDoc() > 0:
            redrawAll()
        statusMessage('Done.')
        progressReset()

So a thing to try out is to forget about saving the original locale information and setting it back by commenting it out by adding a hash # sign in front of the program line.

def main():
    """ Application/Dialog loop with Scribus sauce around """
    try:
        statusMessage('Running script...')
        progressReset()
        # original_locale1=locale.getlocale(locale.LC_CTYPE)
        # original_locale2=locale.getlocale(locale.LC_TIME)
        root = Tk()
        app = TkCalendar(root)
        root.mainloop()
        # locale.setlocale(locale.LC_CTYPE, original_locale1)
        # locale.setlocale(locale.LC_TIME, original_locale2)
    finally:
        if haveDoc() > 0:
            redrawAll()
        statusMessage('Done.')
        progressReset()

You might then later set back your locale information manually (maybe by restarting Scribus?)
In any case the script wants to set a locale information which does not exist in your case. In the case I tested out it went through without problems.

Below I have inserted in the code that message boxes are shown before and after execution of the main loop script. This will help for debugging purposes.

HTH

Hannes


For debugging purposes it might also be useful to insert
messagebox.showinfo("INFO:",'locale.LC_CTYPE=' + str(original_locale1)) 
which in my case gave back
locale.LC_CTYPE=('English_Switzerland','1252')before the script run and
locale.LC_CTYPE ('de_DE','cp1252') after the script ran.

def main():
    """ Application/Dialog loop with Scribus sauce around """
    try:
        statusMessage('Running script...')
        progressReset()
        original_locale1=locale.getlocale(locale.LC_CTYPE)
        original_locale2=locale.getlocale(locale.LC_TIME)
        messagebox.showinfo("INFO:",'locale.LC_CTYPE=' + str(original_locale1))       
        root = Tk()
        app = TkCalendar(root)
        root.mainloop()
        messagebox.showinfo("INFO:",'locale.getlocale(locale.LC_CTYPE)' + str(locale.getlocale(locale.LC_CTYPE)))     
        locale.setlocale(locale.LC_CTYPE, original_locale1)
        locale.setlocale(locale.LC_TIME, original_locale2)
    finally:
        if haveDoc() > 0:
            redrawAll()
        statusMessage('Done.')
        progressReset()


Zaza

#2
Thank you I have no more error message.

I've tried with the Roboto regular font as in the pdf example and I have no moon phases.
Today I tried with the Arial regular font and I have the full moon and the empty moon too. I don't know why it doesn't work with the Roboto font as in example.

I have to try with other fonts until I find the right one.


-----
I have the four moon drawings with the "Yu Gothic UI" font.

rafferty

Hi Zaza,

1) If your language and unicode page is not defined in lines 92-116 of the 'MonthlyCalendar.py'-file, then open the file with a simple text editor and change an existing line or add a new line in between with your language and unicode page parameters.

2) As stated in the 'Monthly Calendar Instructions.pdf'-file under the moonphases section, you have to find a font for the moonphases that contains these characters.

Regards,
Rafferty