Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pywin32 #4737

Open
1 task done
Laztef opened this issue Jan 18, 2025 · 0 comments
Open
1 task done

use pywin32 #4737

Laztef opened this issue Jan 18, 2025 · 0 comments

Comments

@Laztef
Copy link

Laztef commented Jan 18, 2025

Duplicate Check

Describe the bug

I have this working code,
But if i use "flet build windows" to build the app return this error:
Traceback (most recent call last):
File "", line 94, in
File "", line 229, in run_module
File "", line 88, in _run_code
File "C:[path]\flet\app\main.py", line 16, in
import win32print
ModuleNotFoundError: No module named 'win32print'.
Any fix for this?.
"subprocess" library does not meet my needs in this occassion.

Code sample

Code
[
from PIL import Image
import win32print
import win32ui
from flet import Page, Container, Column, ElevatedButton, app

def main(page: Page):
    
    def print(e):
       hprinter = win32print.OpenPrinter(printer_name)
        
        barcode_command = (
            b"\x1d\x68\x50"  # Altura del código de barras (80 puntos)
            b"\x1d\x77\x02"  # Ancho de las barras (2 puntos)
            b"\x1d\x6b\x49"  # Comando para iniciar Code 128
            + bytes([len("J7PR-MOIP-TECN")])  # Longitud de los datos
            + b"J7PR-MOIP-TECN"  # Datos del código de barras
        )
        text_command = b"\x1d\x21\x00\x1b\x61\x00J7PR-MOIP-TECN\n\n\x1d\x56\x00"
        final_barcode = barcode_command+text_command+b"\n\n\x1d\x56\x00"
        try:
            hjob = win32print.StartDocPrinter(hprinter, 1, ("Test", None, "RAW"))
            win32print.StartPagePrinter(hprinter)
            win32print.WritePrinter(hprinter, final_barcode)
            win32print.EndPagePrinter(hprinter)
            win32print.EndDocPrinter(hprinter)
        finally:
            win32print.ClosePrinter(hprinter)
            
    page.add(
        Container(
            Column(
                [
                    ElevatedButton("Imprimir", on_click=print)
                ]
            )
        )
    )
app(main)    

]

To reproduce

later of build

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

10

Flet version

0.25.2

Regression

No, it isn't

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant