Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7011231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:06:02+00:00 2026-05-27T22:06:02+00:00

I am using Tkinter to help me build a FTP client, in this client

  • 0

I am using Tkinter to help me build a FTP client, in this client I am trying to get the selected information from a tk listbox. So I have a button that starts the download but what ever the reason is it pops up with the error “

Exception in Tkinter callback
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1410, in __call__
    return self.func(*args)
  File "/Volumes/LEGO FLASH/ftp.py", line 23, in Download
    filename = stuff
NameError: global name 'stuff' is not defined" 

Below I have the code for you to look at:

# Import the FTP object from ftplib
from ftplib import FTP
from Tkinter import *
import os

app = Tk()
app.title("FTP")
app.geometry("300x300")

lines = []
#[lines.replace(",", "\n")for lines in lines]
#lines = lines.replace(',','\n')

def handleDownload(block):
    file.write(block)
    print ".",

def append_line(line):
    lines.append(line)

#This is where I am caught-------> 
def Download():

    filename = stuff

    file = open(filename, 'wb')

    ftp.retrbinary('RETR ' + filename, handleDownload)


    ftp.close()

def login():
    try:
        ftp.login(username.get(),password.get())
    except:
        error = Label(app, text = "Invalid USERNAME OR PASSWORD")


    label2 = Label(app, text = "Welcome to Steam Engine").pack()
    username.forget()
    password.forget()
    button.forget()

    app.geometry("800x500")

    download = Button(app, text = "Download!!!!!", command = Download)
    download.pack(side = "left", pady = "5")

    scrollBar.pack(fill = Y, side = "right", padx = "2")

    #ftp.cwd('The_Store')

    stuff = Listbox(app, height = "700", width = "500")
    ftp.retrlines('NLST', append_line)
    for i in lines:
        stuff.insert(END, i)
    stuff.pack(padx = "10", pady = "10")

    stuff.config(yscrollcommand = scrollBar.set)
    scrollBar.config(command = stuff.yview)



ftp = FTP('sciphigames.com')
label = Label(app, text = "Login").pack(pady = "10")

scrollBar = Scrollbar(app)

username = StringVar(None)
username = Entry(app, text = "Username: ")
username.pack(pady = "2")

password = StringVar(None)
password = Entry(app, text = "Password: ")
password.pack(pady = "2")

button = Button(app, text = "Login!", command = login)
button.pack(pady = "10")

app.mainloop()

Any help would be appreciated!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:06:02+00:00Added an answer on May 27, 2026 at 10:06 pm

    I am not entirely sure what the purpose is with your stuff variable, but the problems you are experiencing probably stem from the way you are using it.

    First, you are using it as argument to login (which, by the way should take no arguments). You assign to this variable from the login function, and refer to another variable with the same name in your Download function.

    Again, not being sure what I understand what you want to do with the stuff variable, I would try something like

    .....
    
    app.geometry("300x300")
    
    stuff = None # <<<<----
    
    lines = []
    
    .....
    
    #This is where I am caught-------> 
    def Download():
        global stuff # <<<<----
    
        filename = stuff
    
        ......
    
        ftp.close()
    
    def login():
        global stuff # <<<<----
    
        ......
    
        stuff = Listbox(app, height = "700", width = "500")
        ftp.retrlines('NLST', append_line)
        for i in lines:
            stuff.insert(END, i)
        stuff.pack(padx = "10", pady = "10")
    
        stuff.config(yscrollcommand = scrollBar.set)
        scrollBar.config(command = stuff.yview)
    
    
    ......
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know how to create a Listbox using Tkinter but this only allows me
Using Tkinter I have a Toplevel named self.edit_window, a Frame named frame and a
So I have the following code creating a grid of buttons using tkinter: class
I'm using Tkinter in Python, and trying to create code to run when a
I'm trying to create a GUI in Python using the Tkinter module, and part
I made this code into an executable with py2exe: # File: zipfile-example-1.py from Tkinter
I'm new to using tkinter and GUI programming in general so this may be
I've written a simple GUI program in python using Tkinter. Let's call this program
I have just started using Tkinter for a programming class and am having a
I am trying to write a VERY simple UI in Python using Tkinter. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.