Using Python 3.74 on a windows 10 machine. I took your code as is and just defined currentfn and it worked for me.
Here is my entire code listing
## ------------------------------------------------------------------------
## Generic Template Program
## ------------------------------------------------------------------------
## ------------------------------------------------------------------------
## Imports
## ------------------------------------------------------------------------
from tkinter import *
from tkinter import ttk
from tkinter import simpledialog
## ------------------------------------------------------------------------
## ToDo List
## ------------------------------------------------------------------------
## ------------------------------------------------------------------------
## Constants
## ------------------------------------------------------------------------
prog_id = {'progname':'Sample Template',
'title':'Simple gui template',
'version':'1.0',
'date':'05 March 2020',
'rev_date':'',
'author':'Peter Hedlund',
'description':'Create simple template file.'}
## ------------------------------------------------------------------------
## Variables
## ------------------------------------------------------------------------
_debug_ = 0
currentfn='test'
## ------------------------------------------------------------------------
## Functions
## ------------------------------------------------------------------------
class PasswordDialog(simpledialog.Dialog):
def body(self, master):
Label(master, text="Password for file "+currentfn).grid(row=0, sticky=W)
self.e1 = Entry(master,show='*')
self.e1.grid(row=0, column=1)
self.attributes("-topmost", True)
return self.e1
def apply(self):
p = self.e1.get()
self.result = p
## ------------------------------------------------------------------------
## Controls
## ------------------------------------------------------------------------
def quit_prog():
root.destroy()
def test_btn():
PasswordDialog(root, "Password Test")
## ------------------------------------------------------------------------
##
## Main GUI Starts Here
##
## ------------------------------------------------------------------------
root = Tk()
# prevent window resizing.
root.resizable(0, 0)
root.title(prog_id['title'] + " Ver " + prog_id['version'])
mainframe = ttk.Frame(root, padding='3', height=590, width=850)
mainframe.grid(column=1, row=2, sticky=(N, W, E, S))
mainframe.grid_propagate(0)
# Style Section
s1 = ttk.Style()
s1.configure('red.TButton', background='Red')
# String variables
fbus_cw = StringVar()
# Integer variables
reportType = IntVar()
# Label Widget
lab0 = Label(mainframe, text='', width=15)
lab0.grid(column=0, row=5)
# Button Widgets
savelog = ttk.Button(mainframe, text='Test', command=test_btn)
savelog.grid(column=0, row=8)
quitProg = ttk.Button(mainframe, text='Quit', style='red.TButton',
command=quit_prog)
quitProg.grid(column=0, row=10)
for child in mainframe.winfo_children():
child.grid_configure(padx=5, pady=5)
root.mainloop()