rageworx / GIA-Practice-Tests

𝘗𝘺𝘵𝘩𝘰𝘯 𝘢𝘱𝘱 𝘸𝘩𝘪𝘤𝘩 𝘳𝘦𝘱𝘳𝘰𝘥𝘶𝘤𝘦𝘴 𝘵𝘩𝘦 𝘛𝘩𝘰𝘮𝘢𝘴 𝘎𝘐𝘈 𝘵𝘦𝘴𝘵𝘴 𝘧𝘰𝘳 𝘱𝘳𝘢𝘤𝘵𝘪𝘤𝘦 𝘱𝘶𝘳𝘱𝘰𝘴𝘦𝘴.
Apache License 2.0
0 stars 0 forks source link

Error occurs when generate Spatial Visualization #1

Open rageworx opened 1 year ago

rageworx commented 1 year ago

Error occurs when generate Spatial Visualization

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 861, in callit
    func(*args)
  File "/Users/raphaelkim/Projects/GIA/GIA-Practice-Tests/main.py", line 91, in countdown_timer
    show_score()
  File "/Users/raphaelkim/Projects/GIA/GIA-Practice-Tests/main.py", line 77, in show_score
    spatial_visualisation.save_report()
  File "/Users/raphaelkim/Projects/GIA/GIA-Practice-Tests/spatial_visualisation.py", line 114, in save_report
    print_report_to_pdf(pdf, self.report)
  File "/Users/raphaelkim/Projects/GIA/GIA-Practice-Tests/spatial_visualisation.py", line 34, in print_report_to_pdf
    pdf.image(line[column], w=10, h=10, x=x_cord, y=y_cord)
  File "/usr/local/lib/python3.11/site-packages/fpdf/fpdf.py", line 150, in wrapper
    return fn(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fpdf/fpdf.py", line 960, in image
    if not name in self.images:
           ^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'Image'
rageworx commented 1 year ago

It is must be here ...

image

I don't understand why is it works on Python.

rageworx commented 1 year ago

I don't imagine what is image from report ? from line[column]. How it become to an image ?

Refer to FPDF, https://pyfpdf.github.io/fpdf2/Images.html.

Python is mysterious ...

rageworx commented 1 year ago

Fixed to using right way for python 3.11.x

image

as result is :

image
rageworx commented 1 year ago

Still I don't understand why Python is not so plainness.

rageworx commented 1 year ago

It should be enhanced to write image to /tmp or private tmp directory .. But I don't know Python has some predefined paths to determine where is temporary directory.

rageworx commented 1 year ago

Method changed -> writes temporary PNG file in reports directory and remove it after insert to PDF.