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

  • Home
  • SEARCH
  • 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 8719227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:44:34+00:00 2026-06-13T06:44:34+00:00

As the title implies I’m trying to select items from one list box, press

  • 0

As the title implies I’m trying to select items from one list box, press a button, and add it to a second list box.

When I click the button to move, the value is printed in command prompt, but the listbox itself isn’t updating.

I copied and pasted so I realize that everything should be tabbed over one spot.

class Actions: 

def openfile(self): #select a directory to view files
    directory = tkFileDialog.askdirectory(initialdir='.')
    self.directoryContents(directory)


def filename(self):
    Label (text='Please select a directory').pack(side=TOP,padx=10,pady=10)

files = []
fileListSorted = []

#display the contents of the directory
def directoryContents(self, directory): #displays two listBoxes containing items
    scrollbar = Scrollbar() #left scrollbar - display contents in directory
    scrollbar.pack(side = LEFT, fill = Y) 

    scrollbarSorted = Scrollbar() #right scrollbar - display sorted files 
    scrollbarSorted.pack(side = RIGHT, fill = Y, padx = 2, pady=100)

    fileList = Listbox(yscrollcommand = scrollbar.set) #files displayed in the left listBox
    for filename in os.listdir(directory):
        fileList.insert(END, filename)
        global files 
        self.files.append(filename) #insert the values into the files array so we know which element we want to enter in moveFile
    fileList.pack(side =LEFT, fill = BOTH)
    scrollbar.config(command = fileList.yview)


    global fileListSorted #this is for the filelist in the right window. contains the values the user has selected
    fileListSorted = Listbox(yscrollcommand = scrollbarSorted.set) #second listbox (button will send selected files to this window)
    fileListSorted.pack(side=RIGHT, fill = BOTH)
    scrollbarSorted.config(command = fileListSorted.yview)

    selection = fileList.curselection() #select the file
    b = Button(text="->", command=lambda:self.moveFile(fileList.curselection()))#send the file to moveFile to be added to fileListSorted
    b.pack(pady=5, padx =20)


##moveFile addes files to the array fileLIst2, which is the fileList on the right
def moveFile(self,File):
    insertValue = int(File[0]) #convert the item to integer
    global files
    insertName = self.files[insertValue] #get the name of the file to be inserted

    global fileListSorted
    self.fileListSorted.append(str(insertName)) #append the value to the fileList array
    print self.fileListSorted #second listbox list
  • 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-06-13T06:44:35+00:00Added an answer on June 13, 2026 at 6:44 am

    It’s quite difficult to follow that code — For example, where is self.fileListSorted defined? — You have a global fileListSorted and an instance variable self.fileListSorted and they’re different things. However, you seem to be getting them confused (for example, why is there a line

    global fileListSorted
    

    in moveFile when you never use fileListSorted in there?) Also note that to add items into a ListBox, you typically use the insert method, which you haven’t used in moveFiles as far as you’ve shown anyway…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi so as the title implies im trying to get two values from a
As the title implies, how does one extract the sub- and superdiagonal of a
Just as the title implies, I am trying to create a parser and trying
As the title implies I am trying to get an understanding of why in
As the title implies I'm trying to generate Facebook Open Graph meta tags dynamically,
As the title implies, I need to fetch data from certain website which need
As the title implies, is there any way I could do this? I'm trying
As the title implies, I am trying to asynchronously load tableview images via NSURLConnection.
As the title implies, I am using AFNetworking in an iOS project in which
Just as the title implies, is it acceptable to create and use a collection

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.