This commit is contained in:
devdesk
2023-06-11 12:20:57 +03:00
parent 0dc0b7dc9b
commit 15a2e4d070
5 changed files with 115 additions and 6 deletions

2
inkscape/print.sh Normal file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
sudo brother_ql -b pyusb --model QL-570 -p usb://0x04f9:0x2028/000M6Z401370 print -l 62 ~/text285.png

13
inkscape/thermo.inx Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>therma</_name>
<id>org.inkscape.effect.exportandrunscript</id>
<dependency type="executable" location="extensions">thermatext/thermo.py</dependency>
<effect>
<object-type>all</object-type>
</effect>
<script>
<command reldir="extensions" interpreter="python">thermatext/thermo.py</command>
</script>
<category>Fx</category>
</inkscape-extension>

49
inkscape/thermo.py Normal file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env python3
import inkex
import os
import subprocess
class ExportAndRunScript(inkex.EffectExtension):
def effect(self):
# Define the export file path
png_file_path = "~/yair/exported.png"
# Get the current selection
selection = self.svg.selected
# If there's no selection, show an error and exit
if not selection:
inkex.dialogs.errormsg("No selection to export.")
return
# Export the selection to PNG
self.export_selection_to_png(selection, png_file_path)
# Run the bash script on the exported PNG
self.run_script_on_png(png_file_path)
def export_selection_to_png(self, selection, png_file_path):
# Create a command that calls Inkscape's command line interface to export the selection to a PNG
command = ["inkscape", "--export-area-drawing", "--export-dpi=96", "--export-background-opacity=0", "-o", "{}".format(png_file_path)]
# Add the IDs of the selected items to the command
for id, item in selection.items():
command.append("--export-id={}".format(id))
# Run the command
subprocess.check_call(command)
def run_script_on_png(self, png_file_path):
# Define the path to your bash script
bash_script_path = "print.sh"
# Create a command that calls the bash script with the PNG as an argument
command = ["bash", bash_script_path, png_file_path]
# Run the command
subprocess.check_call(command)
if __name__ == "__main__":
ExportAndRunScript().run()