PYGUI
From DreamsteepWiki
Interactive listbox using my tkinter class interface
from Tkinter import Tk, END #was *
import sys_tkinter_gui
class GUI:
def __init__(self):
self.WIDGETS = []
##............................##
##............................##
def clearallboxtext(self):
self.WIDGETS[0].delete(0,END )
self.WIDGETS[1].delete(0,END )
##............................##
def appendBox1(self,appenddata):
if appenddata !='':
self.WIDGETS[0].insert(END,appenddata )
##............................##
def appendBox1_indx(self,index,appenddata):
if appenddata !='':
self.WIDGETS[0].insert(index,appenddata )
##............................##
def deleteBox1_indx(self,index):
self.WIDGETS[0].delete(index )
##............................##
def replaceBox1_indx(self,index,appenddata):
self.deleteBox1_indx(index)
self.appendBox1_indx(index,appenddata)
##............................##
def appendBox2(self,appenddata):
if appenddata !='':
self.WIDGETS[1].insert(END,appenddata )
##............................##
def updategui(self):
self.clearallboxtext()
##UPDATE PANE 1
self.appendBox1('#NCR_DATA#')
self.appendBox1('#NCR_DATA1#')
self.appendBox1('#NCR_DATA2#')
##UPDATE PANE 2
self.appendBox2('#NCROPS#')
##............................##
def query(self):
if self.WIDGETS:
print 'i still got it DEBUG '
#print self.WIDGETS[0].curselection()
indexsel= self.WIDGETS[0].curselection()
print indexsel[0]
return indexsel[0]
if self.WIDGETS==[]:
print 'widgets are empty debug '
return None
####################################
####################################
def replace_sel1(self):
ind = self.query()
self.replaceBox1_indx(ind,'fooey')
##............................##
def remove_b1(self):
ind = self.query()
self.deleteBox1_indx(ind)
##............................##
def change_sel(self):
ind = self.query()
self.appendBox1_indx(ind,'changethis')
##............................##
def NCROPGUI(self):
##
UPG = self.updategui
QUERY1 = self.query
CLEAR = self.clearallboxtext
changer = self.change_sel
delitm = self.remove_b1
replace = self.replace_sel1
###
br = [1 ,5 ,10]
frt = ['a' ,'b' ,'c','d']
wid = ['textfield' ,'textfield' ,'button' ,'button' ,'button' ,'button' ,'button' ,'button' ]
widnams = ['textbox' ,'textbox2' ,'UPDATE' ,'clear' ,'QeurySel1' ,'remove' ,'replace' ,'changer' ]
cmds = [ 'eee' , 'ere' ,UPG ,CLEAR ,QUERY1 ,delitm ,replace ,changer ]
toplevel_window = Tk()
#instantiate class
app = sys_tkinter_gui.buildGuiSimple(toplevel_window)
app.orient ='vert'
#setup values
app.setOptions(br,frt,wid,widnams,cmds)
#create a gui
app.buildGUI()
self.WIDGETS = app.returnwidgets()
#execute
self.updategui()
toplevel_window.mainloop()
######
gooey = GUI()
gooey.NCROPGUI()

