I'm fairly new to making GUI's in tk so I downloaded activestates GUI builder from sourceforge. It has a very straightforward drag and drop interface and is easy to pick up. However I ran into a problem trying to edit the widgets it creates. It makes 2 files, the first just initializes the widgets and you are not supposed to edit and the second breaks down every option for the widget you create. You're supposed to be able to edit everything from the second file however I cannot find the right syntax to reference a listbox from file #1 and insert text into it. Here are the files from a simple dialog.
#file #1
import Tkinter
import os # needed for relative image paths
# Using new-style classes: create empty base class object
# for compatibility with older python interps
#if sys.version_info < (2, 2):
# class object:
# pass
class Testgui(object):
_images = [] # Holds image refs to prevent GC
def __init__(self, root):
# Widget Initialization
self.a_listbox = Tkinter.Listbox(root,
height = 0,
width = 0,
)
# widget commands
self.a_listbox.configure(
xscrollcommand = self.a_listbox_xscrollcommand
)
self.a_listbox.configure(
yscrollcommand = self.a_listbox_yscrollcommand
)
# Geometry Management
self.a_listbox.grid(
in_ = root,
column = 1,
row = 1,
columnspan = 1,
ipadx = 0,
ipady = 0,
padx = 0,
pady = 0,
rowspan = 1,
sticky = "news"
)
# Resize Behavior
root.grid_rowconfigure(1, weight = 0, minsize = 114, pad = 0)
root.grid_columnconfigure(1, weight = 0, minsize = 288, pad = 0)
########################################################
#and the second file::::::::::::
from Tkinter import *
from testgui_ui import Testgui
# BEGIN USER CODE global
# END USER CODE global
class CustomTestgui(Testgui):
pass
# BEGIN CALLBACK CODE
# ONLY EDIT CODE INSIDE THE def FUNCTIONS.
# a_listbox_xscrollcommand --
#
# Callback to handle a_listbox widget option -xscrollcommand
def a_listbox_xscrollcommand(self, *args):
pass
# a_listbox_yscrollcommand --
#
# Callback to handle a_listbox widget option -yscrollcommand
def a_listbox_yscrollcommand(self, *args):
pass
# END CALLBACK CODE
# BEGIN USER CODE class
# END USER CODE class
def main():
# Standalone Code Initialization
# DO NOT EDIT
try: userinit()
except NameError: pass
root = Tk()
demo = CustomTestgui(root)
root.title('testgui')
try: run()
except NameError: pass
root.protocol('WM_DELETE_WINDOW', root.quit)
root.mainloop()
if __name__ == '__main__': main()
From the second file how to I edit the widgets created in the first file?
I've tried 'Testgui.a_listbox.insert(0,"whatever")
Testgui._init_.a_listbox.insert(0,"whatever")
I cant figure out how to edit instances created in the former class..
thanks