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 9205965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:04:44+00:00 2026-06-18T00:04:44+00:00

I’m trying to manipulate a listbox in Tkinter but I’m having some troubles. I

  • 0

I’m trying to manipulate a listbox in Tkinter but I’m having some troubles. I used to have everything in one class, on one page, and it worked fine. I separated the methods into different classes on two different pages (one for displaying things, one for modifying them) and now I’m having some issues.

I’m getting the following error AttributeError: Actions has no attribute ‘listbox’. I’m assuming it’s something inheritance related because it worked fine before I split it into two files.

Here’s the first file

from Tkinter import *
import Tkinter
import SortActions

class MakeList(Tkinter.Listbox):

    def BuildMainWindow(self):
        menubar = Frame(relief=RAISED,borderwidth=1)
        menubar.pack()

        mb_file = Menubutton(menubar,text='file')
        mb_file.menu = Menu(mb_file)
        mb_file.menu.add_command(label='open', command = self.BuildListbox)
        mb_file.pack(side=LEFT)

        mb_edit = Menubutton(menubar,text='edit')
        mb_edit.menu = Menu(mb_edit)
        mb_edit.pack(padx=25,side=RIGHT)

        mb_file['menu'] = mb_file.menu
        mb_edit['menu'] = mb_edit.menu
        return 

    def BuildListbox(self):
        self.listbox = Tkinter.Listbox()
        index = SortActions.Actions()
        self.listbox.bind('<<ListboxSelect>>', index.GetWindowIndex)
        MoveItem = SortActions.Actions()
        self.listbox.bind('<B1-Motion>', index.MoveWindowItem)
        for item in ["one", "two", "three", "four"]:
            self.listbox.insert(END, item)    
        self.listbox.insert(END, "a list entry")
        self.listbox.pack()
        #print self.listbox.get(0, END)
        return

if __name__ == '__main__':
    start = MakeList()
    start.BuildMainWindow()
    mainloop()

And the second file, the one that I’m having issues with

from FileSort import MakeList


class Actions(MakeList):

    #gets the current item that was clicked in the window
    def GetWindowIndex(self, event):
        w = event.widget
        self.curIndex = int(w.curselection()[0])

    #moves the current item in the window when clicked/dragged
    def MoveWindowItem(self, event):
        i = self.listbox.nearest(event.y) #here is where the error is occurring 
        print i

I assumed since I inherit the MakeList class I should have access. I also tried changing it so I directly accessed MakeList (an object) but instead of the error saying “Actions instance has no….” it said “MakeList has no attribute…”

I posted something previously but I accidentally ran an older version of the code, so I was referencing the wrong error. Sorry if you saw that post. It’s gone now

  • 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-18T00:04:45+00:00Added an answer on June 18, 2026 at 12:04 am

    As I see it, there’s no reason for the Actions to be in a class …

    #SortActions.py
    
    #gets the current item that was clicked in the window
    def GetWindowIndex(self, event):
        w = event.widget
        self.curIndex = int(w.curselection()[0])
    
    #moves the current item in the window when clicked/dragged
    def MoveWindowItem(self, event):
        i = self.nearest(event.y) #here is where the error is occurring 
        print i
    

    Now you can use the actions:

       ...
       def BuildListbox(self):
            #self.listbox = Tkinter.Listbox()  #??? This has no master widget ...
            #Since this is already a listbox, there's no point in building another ...
    
            self.bind('<<ListboxSelect>>', lambda e:SortActions.GetWindowIndex(self,e))
    
            self.bind('<B1-Motion>', lambda e:SortActions.MoveWindowItem(self,e)
            for item in ("one", "two", "three", "four"):
                self.insert(END, item)    
            self.insert(END, "a list entry")
            self.pack()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.