I'm writing a python program to take user input for input file and output directory and then take a dd image of the input file using the subprocess module. I have written the following code. I am not able to use the variables i use in one def, in some other def part. Please help me out with this as i'm new to Python.
def open_dir():
o_file = subprocess.call(["zenity","--file-selection","--directory","--title=Select Destination Directory"])
o_var = StringVar()
o_var.set(o_file)
def quit_root():
root.destroy()
def get_input():
msg1 = subprocess.call(["df","-h"])
msg2 = StringVar()
msg2.set(msg1)
msg = Message(labelframe, textvariable=msg1)
msg.pack()
in_file=subprocess.check_output(["zenity","--entry"])
var=StringVar()
var.set(in_file)
def dev_img():
global var
global o_var
input_file=var
output_file=o_var+"device.img"
out = subprocess.check_output(["dd","if="+input_file,"|pv|","of="+output_file,"bs=1024"], stderr=subprocess.STDOUT)
var1 = StringVar()
var1.set(out)
label1 = Message(labelframe, textvariable=var1)
label1.pack()
Please suggest me some way so that i can use the 'var' and 'o_var' variables from open_dir() and get_input() and use those varibales in dev_img().