1. Ben Antwi
  2. Valentina Reports ADK
  3. Вторник, Февраль 22 2022, 09:15 AM
  4.  Подписаться через email
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.
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
Hello Ben,

There is no video yet. Did you try to run the examples?
The reports example is Examples/report.py
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
@Sergey Pashkov Yes I did run the report.py script and I got this error message "NameError: name 'valentina' is not defined"
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
@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.
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
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.
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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"
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
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:
Ссылки
  1. https://faun.pub/no-module-named-encodings-a-common-import-error-found-in-python-3-8775436140de
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
I'm using python version 3.7.9
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
@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.
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
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')
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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?
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
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.
Ссылки
  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
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
Is it possible to also embed Valentina charts such as bar charts and Pie charts on python dashboard? pyqt5 to be specific.
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
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.
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
Sergey Pashkov What about just previewing the report instead of printing, is there any example as such available?
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
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.
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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.
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
Now my problem is how to connect to sqlite3 database and print my customized .vsp file to printer.
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
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
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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.
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
@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";)
Комментарий
There are no comments made yet.
  • Страница :
  • 1
  • 2
  • 3
  • 4


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

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories