-
Does anyone know why subprocess fails with a concatenated string? It works just fine with a string literal. # Uses Imported mode for py5
import javafx
import subprocess
import os
str1 = ""
str2 = ""
strConcat = ""
def btn1Action(event):
global str1
print("btn1 was hit.")
str1 = "python3 "
def btn2Action(event):
global str2
print("btn2 was hit.")
str2 = "/Users/xxxxx/hworld.py"
def btn3Action(event):
global strConcat
print("btn3 was hit.")
strConcat = str1 + str2
print(strConcat)
s = subprocess.check_call(strConcat, shell=True)
def setup():
size(300, 200, FX2D)
window_title('JavaFX Concatenation Demo')
canvas = get_surface().get_native()
root = canvas.getParent()
hbox = javafx.scene.layout.HBox(20)
btn1 = javafx.scene.control.Button('Str1')
btn1.setOnAction(btn1Action)
btn2 = javafx.scene.control.Button('Str2')
btn2.setOnAction(btn2Action)
btn3 = javafx.scene.control.Button('Join')
btn3.setOnAction(btn3Action)
hbox.getChildren().addAll(btn1,btn2,btn3)
root.getChildren().add(hbox) |
Beta Was this translation helpful? Give feedback.
Answered by
vsquared
Jul 1, 2025
Replies: 1 comment 4 replies
-
Not sure. What error message are you getting? Does |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works better but the output goes to Thonny console instead of logArea of editor.
runStr = ('%s %s') % (pyStr,fileStr)
Need to use the following to direct output to logArea:
s = subprocess.check_output(runStr, shell=True)
Original post was edited and should work as expected after changes.