title: How can I display a path using string variables in python?
body: <p>So I want to make an application that takes files from one directory and then replace a file in another directory with that file. I have been trying to figure out how to take the string variables and display them as a path string. I do know that <code>os.replace()</code> doesn't accept string variables so I tried making a variable that takes the string variable and turns it into a string.</p>
  
  <pre class="lang-py prettyprint-override"><code>import tkinter as tk
  from tkinter import filedialog, ttk
  from tkinter import *
  import os
  
  root = Tk()
  root.resizable(False, False)
  root.geometry("600x600")
  
  def search1():
      global file1_path
      filename1 = filedialog.askopenfilename()
      file1_path.set(filename1)
      print(filename1)
  
  def search2():
      global file2_path
      filename2 = filedialog.askopenfilename()
      file2_path.set(filename2)
      print(filename2)
  
  def browse_button():
      global folder_path
      filename = filedialog.askdirectory()
      folder_path.set(filename)
      print(filename)
  
  def replacefile():
      os.replace(f'{folder}/game/scripts.rpa', f'{file1}')
      os.replace(f'{folder}/game/images.rpa', f'{file2}')
  
  folder_path = StringVar()
  file1_path = StringVar()
  file2_path = StringVar()
  
  file1 = str(file1_path)
  file2 = str(file2_path)
  folder = str(folder_path)
  
  button1 = ttk.Button(text="Browse", command=search1)
  button1.place(relx = 1.1, rely = 1.01)
  button1.place(relx = .6, rely = .5)
  
  button3 = ttk.Button(text="Browse", command=search2)
  button3.place(relx = 1.1, rely = 1.01)
  button3.place(relx = .6, rely = .54)
  
  button4 = ttk.Button(text="Browse", command=browse_button)
  button4.place(relx = 1.1, rely = 1.01)
  button4.place(relx = .6, rely = .58)
  
  button2 = ttk.Button(text="Replace", command=replacefile)
  button2.place(relx = 0.01, rely = 1.01)
  button2.place(relx = 0.01, rely = .8)
  
  mainloop()
  </code></pre>
  
  <p>It brings up this error in console when I try to replace:</p>
  
  <pre><code>FileNotFoundError: [WinError 3] The system cannot find the path specified: 'PY_VAR0/game/scripts.rpa' -&gt; 'PY_VAR1'
  </code></pre>
  
  <p>Python sees this as just a variable rather than part of string. I'm kinda new to python so I have no idea why this is happening. If anybody knows how I can fix this it would be much appreciated.</p>