1. Ben Antwi
  2. Valentina Reports ADK
  3. Dienstag, Februar 22 2022, 09:15 AM
  4.  Abonnieren via E-Mail
HI,
i'm new to valentina suite. I saw the tutorials on how to download and install valentina studio,valentina server and valentina ADK. I want to embed valentina report in my python code but I can't find any video tutorial on that. i saw saw for java implementation. I would appreciate if I'm assisted with the steps to achieve this task. Thanks in advance.
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Hello Ben,

There is no video yet. Did you try to run the examples?
The reports example is Examples/report.py
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
@Sergey Pashkov Yes I did run the report.py script and I got this error message "NameError: name 'valentina' is not defined"
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
@Sergey Pashkov Yes I did run the report.py script and I got this error message "NameError: name 'valentina' is not defined". Do I have to copy some files to a location before running the script because I tried to install valentina in Pycharm but I only saw Pyvalentina.
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Yes, it is necessary to add 'valentina' extension to 'site-packages' of your python3 installation, the standard location can be retrieved using the following command:
python3 -m site

What OS do you use? I tried PyCharm on macOS some time ago.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
I'm using Windows 10, I tried to run python3 -m site and I got this error message
" Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings"
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Strange, so any script ends up with this error, right?

What version of python is used? Just a normal installation from
https://www.python.org/downloads/windows/
?

Also, there are some suggestions for such an error:
Referenzen
  1. https://faun.pub/no-module-named-encodings-a-common-import-error-found-in-python-3-8775436140de
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
I'm using python version 3.7.9
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
@Sergey Pashkov I reinstalled python and copied the valentina python extension module file into my working directory with no error when I run the report.py script this time, but I don't see anything happening like a popup for saying the report or printing the report.
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Valentina Reports engine doesn't show dialogs.
The location for the resulting PDF is passed to printToDisk method:


# Print result as PDF
report.printToDisk('./Report_FilmList.pdf')
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Sergey Pashkov It worked fine after adding the location. Does the free version of Valentina Studio has a demo watermark as on the Report_FilmList pdf example?
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
It depends:

  • New projects and reports created in Valentina Studio Free - has a watermark
  • Existing projects created in Valentina Studio Pro and opened in Valentina Studio Free - no watermark
.

Also, any changes (new reports, etc) made in Valentina Studio Free are not saved to disk.
Referenzen
  1. https://valentina-db.com/docs/dokuwiki/v12/doku.php?id=valentina:products:vstudio:features_demo#report_editor
  2. http://www.valentina-db.com/docs/dokuwiki/v12/doku.php?id=valentina:faqs:vreport
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Is it possible to also embed Valentina charts such as bar charts and Pie charts on python dashboard? pyqt5 to be specific.
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
It is possible to generate a report with a chart as a picture and use it in QLabel instance (that’s how it is done in Valentina Studio Forms).
So pyqt should work as well.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Sergey Pashkov What about just previewing the report instead of printing, is there any example as such available?
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
No, we have generic examples only, without additional frameworks that are required for GUI apps.

So it is necessary to preview one page of the report in the pyqt5 GUI application?

Approach is the same - generate one page as a picture, e.g.:
buf = report.printToBuffer(kind=valentina.PNG,start=2,end=2)

And show it on QLabel using QImage and QPixmap classes.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Sergey Pashkov I have created sqlite3 database and the file is located in my working directory. When I copy that location of the sqlite3 database file and replace it with that of the valentina_sakila_bl.vdb. And also replace ./valentina_sakila_reports.vsp with my designed test_report.vsp, I get the error below.

project = valentina.project.connect('C:/Users/LT-K101-LAB/Desktop/EC-PROJECT/HR_report_test.vsp')
RuntimeError: [ConnectionParameters] Unable to parse port: /Users/LT-K101-LAB/Desktop/EC-PROJECT.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Now my problem is how to connect to sqlite3 database and print my customized .vsp file to printer.
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
The path to SQLite database is specified in the DSN parameter:

# Make report instance
report = project.report(name='Report_FilmList', dsn="sqlite://path_to_db/db.sqlite")


As for the printer - currently, this functionality is not implemented.
We'll try to add it as soon as possible.

But "printing to printer" functionality doesn't rely on system dialogs - so in some cases (depending on programming language) it is necessary to implement own print dialogs
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Example 1. when I do it this way I get no report output with no error .

# Open local project
project = valentina.project.connect('./first_report_test.vsp')




Example 2.
When I add the full path to the .vsp file location say I get error message
# Open local project
project = valentina.project.connect('C:/Users/LT-K101-LAB/Desktop/PROJECT/V_firstreport.vsp')

error message
RuntimeError: [ConnectionParameters] Unable to parse port: /Users/LT-K101-LAB/Desktop/PROJECT.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
@Sergey Pashkov your example code you mentioned is

dsn="sqlite://path_to_db/db.sqlite"
. As shown below but my sqlite database is myDatabase.db instead of .sqlite.
Could you please explain I'm a bit confused with the sqlite database extension part.

# Make report instance
report = project.report(name='Report_FilmList', dsn="sqlite://path_to_db/db.sqlite";)
Kommentar
There are no comments made yet.
  • Seite :
  • 1
  • 2
  • 3
  • 4


There are no replies made for this post yet.
However, you are not allowed to reply to this post.