-1

The list which is generating via is in "data" which I am printing, but I want that list or 'data' on my interface "label" with scrollbar. How can I do it?

I have tried all the ways that get(), relief, etc

import tkinter as tk  
from tkinter import ttk
from tkinter import *
import pandas as pd


window = tk.Tk()

#menubar = Menu(window) 


window.title('Automatic Extraction Of Examiners List')   
width = 500
height = 500
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
         window.geometry("%dx%d" % (width, height))
         window.resizable(1000,1000)

    #file = Menu(window,menubar,tearoff=0)
    #menubar.add_cascade(label='File',menu=file)


    window.config(bg="white")
    #
    data = pd.read_csv("E:/ResumePDF/ResumeCSVv4.csv") 
    #name = tk.StringVar()      
    #nameEntered = ttk.Entry(window, width = 12, textvariable =name).grid(column= 4, row = 0)  

    variable = tk.StringVar()
    variable.set("Choose your subject") # default value
    w = ttk.OptionMenu(window, variable,"Choose your subject", "Big Data", "Machine Learning").place(x=200,y=50)

    def click():
        if variable.get() == "Big Data":
           #lbl = ttk.Label(window).place(x= 200, y = 150)
           print("List For Big Data Examiners: \n")
           data.sort_values("BigData", ascending=False, inplace=True)
           print(data[['Name','Email']],"\n")
           #res = "This is a one"+ print(data1)
           #lbl.config(text=data1)
           lbl.data.get()
           #r = 0
           #for col in data:
                #c = 0
                #for row in col:
             # i've added some styling
                     #label = ttk.Label(window, width = 10, height = 2, text = 
                     row, relief = ttk.RIDGE)
                     #label.grid(row = 50, column = 100)
                     #c += 1
                #r += 1


        elif variable.get() == "Machine Learning":
            print("List For Machine Learning Examiners: \n")
            data.sort_values("MachineLearning", ascending=False, inplace=True)
            print(data[['Name','Email']],"\n")

    button = ttk.Button(window, text = "SHOW", command=click).place(x = 150 , y = 100) 
    button1 = ttk.Button(window, text = "EXIT", command=window.destroy).place(x=300,y=100)
    lbl = ttk.Label(window).place(x= 200, y = 150)



    window.mainloop()

When code comes to this line "lbl.data.get()"

Exception in Tkinter callback lbl.data.get() AttributeError: 'NoneType' object has no attribute 'data'

  • As the error said, the value of your `lbl` is `None`. Read [Tkinter: AttributeError: NoneType object has no attribute get](https://stackoverflow.com/questions/1101750/tkinter-attributeerror-nonetype-object-has-no-attribute-get). – Henry Yik May 29 '19 at 08:07
  • and I add that lbl.data doesn't exist, you had to perhaps use textvariable in you lbl? – 1966bc May 29 '19 at 08:14

1 Answers1

0

lbl is a tkinter Label, which does not have a data attribute. If you want your data in a scrollbar you can use the ListBox and Scrollbar widget instead of a single lable. You can easily add elements to it and also the user can select one of the entries.

Here is an example from this ref, how to use the scrollbar widget:

from tkinter import *

root = Tk()
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill = Y )

mylist = Listbox(root, yscrollcommand = scrollbar.set )
for line in range(100):
   mylist.insert(END, "This is line number " + str(line))

mylist.pack( side = LEFT, fill = BOTH )
scrollbar.config( command = mylist.yview )

mainloop()
lidrariel
  • 79
  • 6