0

I'm making a log/chat system in my program (just Tkinter default looks) and i came across a problem where I can't add or change a listbox. Here is what I'm trying to do:

import tkinter
from tkinter import *
from tkinter import messagebox
import random

window = tkinter.Tk()
window.geometry("250x195")
window.title(" ")
window.iconbitmap("icon.ico")

global loglength, log

log = []
loglength = len(log)
inventorylist = []
    
def sendmessage(event):
    chatstring = chatentry.get()
    log.append(chatstring)
    print(log, loglength)
    checknew() #dont worry abt this it works

serverlog = tkinter.Listbox(
    width=20,
    height=11,
    bg="darkgray",
    listvariable=log
).place(x=128,y=-2)

I want to add items to the listbox. Here is an image of my program:

listbox

When I press enter (the key bound to the function to add the string to the listbox) this happens:error :/

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
spelis123
  • 9
  • 2

1 Answers1

-1

is Listbox like a program u want? if u want a program that will make u program list in tkinder this is the code :

from tkinter import *        
a= Tk()  
a.geometry("400x400")  
a.title("test")  
Lb1 = Listbox(a,bg = "pink", bd = 10, fg = "black",\  
              font = "Castellar", cursor = "target")  
Lb1.insert(1, "lion")  
Lb1.insert(2, "tiger")  
Lb1.insert(3, "zebra")  
Lb1.insert(4, "elephant")  
Lb1.insert(5, "deer")  
Lb1.insert(6, "fox")  
Lb1.insert(7, "Wolf")  
Lb1.insert(8, "Gorilla")  
Lb1.insert(9, "Jackal")  
Lb1.insert(10, "Otter")  
Lb1.pack()  
a.mainloop() 

hope that i helped u.