Hi
I am facing a problem with listvariable of listbox.
I have a global sequence is python. which I am assignning as listvarible to a listbox widget.
Listbox is neither showing default nor runtime values of sequence.
Can anybody help

Recommended Answers

All 2 Replies

Here is sample program of what i want to acheive.

#!/usr/local/env/python
import sys, re, string, os,tkFileDialog,time
import Tkinter as Tk
from lib_axi_logger import *

#Sample prgogram
my_list =[]
def add_nu():
#begin funtion
if len(my_list)==0:
#begin if clause
my_list.append(1)
#end if clause
else:
#begin else cluase
last_element = my_list[len(my_list)-1]
my_list.append(last_element+1)
#end else cluase
#end funtion

root = Tk.Tk()
listbox = Tk.Listbox(root,listvariable=my_list)
button = Tk.Button(root,text="Add No",command=add_nu)
listbox.pack()
button.pack()
Tk.mainloop()

In my original work I have many list varibales which are dynamically changed. Most of the list are list of object that have been created during execution.
There was no plan to have gui but now i want gui feature. So I want to display those list in list box and whatever changes done in the listvariable to be reflected directly.

The listbox with listvariable works well in TK. But its not working in Tkinter/Python.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.