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.

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.

# 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.set_env("dev")
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.0.tar.gz (462.6 kB view details)

Uploaded Source

Built Distribution

docmaker-0.1.0-py3-none-any.whl (491.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for docmaker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af5bd2e3504fca7503e3b9b02617a7c7ef482b34c1edce13e11386d9c3acb797
MD5 d212e78e45c081052291c14f828c1b45
BLAKE2b-256 b2692af3ce25a830842d09836375ed8b32e93d2e3fbd8d2858bfc9f94c980e11

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for docmaker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33fe2cfe95e393d42339bfd035ea236448d6fccb577c5a7e8b4acdce152986fb
MD5 b795a26d3c011b087903a19c6670652c
BLAKE2b-256 4cd37f7e1850af99df6cc7972f1f83c03620e2a3c8c65827d6bc3e5d4f26f608

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