work, just need break text before
This commit is contained in:
parent
c36686d3a8
commit
fa9bcb6afc
|
@ -12,34 +12,37 @@ class ExportAndRunScript(inkex.EffectExtension):
|
||||||
|
|
||||||
# Get the current selection
|
# Get the current selection
|
||||||
selection = self.svg.selected
|
selection = self.svg.selected
|
||||||
inkex.errormsg(selection)
|
|
||||||
|
|
||||||
# If there's no selection, show an error and exit
|
# If there's no selection, show an error and exit
|
||||||
if not selection:
|
if not selection:
|
||||||
# inkex.dialogs.errormsg("No selection to export.")
|
|
||||||
inkex.errormsg("No selection to export.")
|
inkex.errormsg("No selection to export.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Export the selection to PNG
|
# Get the IDs of the selected elements
|
||||||
self.export_selection_to_png(selection, png_file_path)
|
selected_ids = ",".join(element.get('id') for element in selection.values())
|
||||||
|
|
||||||
|
# Run the Inkscape CLI command to export the selection to a PNG
|
||||||
|
self.run_export_command(selected_ids, png_file_path)
|
||||||
|
|
||||||
# Run the bash script on the exported PNG
|
# Run the bash script on the exported PNG
|
||||||
self.run_script_on_png(png_file_path)
|
self.run_script_on_png(png_file_path)
|
||||||
|
|
||||||
def export_selection_to_png(self, selection, png_file_path):
|
def run_export_command(self, selected_ids, png_file_path):
|
||||||
# Create a command that calls Inkscape's command line interface to export the selection to a PNG
|
# 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)]
|
command = [
|
||||||
|
"inkscape",
|
||||||
# Add the IDs of the selected items to the command
|
"--export-type=png",
|
||||||
for id, item in selection.items():
|
"--export-id={}".format(selected_ids),
|
||||||
command.append("--export-id={}".format(id))
|
"--export-filename={}".format(png_file_path),
|
||||||
|
self.options.input_file
|
||||||
|
]
|
||||||
|
|
||||||
# Run the command
|
# Run the command
|
||||||
subprocess.check_call(command)
|
subprocess.check_call(command)
|
||||||
|
|
||||||
def run_script_on_png(self, png_file_path):
|
def run_script_on_png(self, png_file_path):
|
||||||
# Define the path to your bash script
|
# Define the path to your bash script
|
||||||
bash_script_path = "print.sh"
|
# bash_script_path = "print.sh"
|
||||||
|
|
||||||
# Create a command that calls the bash script with the PNG as an argument
|
# Create a command that calls the bash script with the PNG as an argument
|
||||||
command = ["sudo", "brother_ql", "-b", "pyusb", "--model", "QL-570", "-p", "usb://0x04f9:0x2028/000M6Z401370", "print", "-l", "62", png_file_path]
|
command = ["sudo", "brother_ql", "-b", "pyusb", "--model", "QL-570", "-p", "usb://0x04f9:0x2028/000M6Z401370", "print", "-l", "62", png_file_path]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user