Skip to main content

No project description provided

Project description

Docmaker

Docmaker is a framework to create forms to generate docx documents. It uses docxtpl and pyside6 libs.

Install

You need to have python 3.11 installed and install dockmaker with command below:

pip install docmaker

Creating models

In order to create a model you have to create a new instance of DocModel defining the templates folder and the widget matrix as example below. You have to point the folder where your templates docx are.

# app.py
from docmaker.gui import widgets as wt
from docmaker.gui.widgets.types import ValidationError
from docmaker.converters import StringListConverter, DateConverter
from docmaker import DocModel
from docmaker import App
from pathlib import Path
import os

SCRIPT_DIR = Path(os.path.dirname(os.path.realpath(__file__)))

def convert_pericia(value: str) -> dict:
    ret = {}
    try:
        parts = value.split("/")
        ret['seq'], ret['rg'], ret['ano'] = int(
            parts[0]), int(parts[1]), int(parts[2])
        return ret
    except:
        raise ValidationError("Valor incorreto")


celular_model = DocModel(
    "Celular", 
    templates_folder=SCRIPT_DIR / "models/celular/templates",
    lists_folder=SCRIPT_DIR / "models/celular/listas",
)

celular_model.widgets = [
    [
        wt.SText("pericia", label="Pericia", placeholder="SEQ/RG/ANO", converter=convert_pericia),
        wt.SText("requisitante", label="Requisitante"),
        wt.SText("procedimento", label="Procedimento", placeholder="RAI ou inquérito"),
        wt.SText("ocorrencia_odin", label="Ocorrência ODIN"),
        wt.SSpinBox("n_objetos", label="N de objetos", required=True, default=1)
    ],
    [
        wt.SText("data_odin", label="Data ODIN", converter=DateConverter()),
        wt.SText("inicio_exame", label="Inicio Exame", converter=DateConverter()),
        wt.SText("data_recimento", label="data de recebimento", converter=DateConverter()),
    ],
    [
        wt.SText("n_quesito", label="Número quesito"),
        wt.SText("autoridade", label="Autoridade"),
    ],
    [
        wt.SText("relatores", label="Relatores", placeholder="Relatores separados por vírgula",
                 required=True, converter=StringListConverter()),
        wt.SText("revisores", label="Revisores", placeholder="Revisores separados por vírgula", converter=StringListConverter()),
    ],
    [
        wt.SText("lacre_entrada", label="Lacre entrada"),
        wt.SText("lacre_saida", label="Lacre saída"),
        wt.SComboBox("n_midias", "Nº Mídias", choices="opcoes_midias")
    ]
]

@celular_model.pre_process()
def pre_process(context):
    context['peritos'] = context['relatores'] + context['revisores']
    return context

app = App()
app.add_docmodel(celular_model)
app.run_gui()  

Run application

python app.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docmaker-0.1.1.tar.gz (481.5 kB view details)

Uploaded Source

Built Distribution

docmaker-0.1.1-py3-none-any.whl (510.7 kB view details)

Uploaded Python 3

File details

Details for the file docmaker-0.1.1.tar.gz.

File metadata

  • Download URL: docmaker-0.1.1.tar.gz
  • Upload date:
  • Size: 481.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.5 Linux/6.6.1-arch1-1

File hashes

Hashes for docmaker-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e7aaf92e16ac7bf6cf631d1461aa1c94b4eccd29d173625372f8e366e8c03fed
MD5 d923efa0e27fdd367295f14627fbc7bf
BLAKE2b-256 535e62cd57ec58aaf280867ed1b18b3302e64d52fb0491efdcc5cd531fd3b559

See more details on using hashes here.

File details

Details for the file docmaker-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: docmaker-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 510.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.5 Linux/6.6.1-arch1-1

File hashes

Hashes for docmaker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d1814c817ccd233825fcca6de37d04a3ea7f2771f978ea57e9df9518862153f4
MD5 87a4226dc5f8928c11991b13fbdf8167
BLAKE2b-256 d45ba402c1e2c22c83a40db1d457e7c0736d90c69785fb6f27a8d9e7a2f71644

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page