Hi.
I created the following two scripts:
The main one called: simple-console.py
import Tix
from DeployDialog3 import DeployDialog3
class Deploycontentpane:
def __init__(self, tkRoot):
self.tkRoot = tkRoot
self.menuBar = Tix.Menu(self.tkRoot, tearoff=0)
self.deploymentMenu = Tix.Menu(self.menuBar, tearoff=0)
self.menuBar.add_cascade(label="Deployment", menu=self.deploymentMenu)
self.deploymentMenu.add_command(label="Run...", command=Deployment_Run(tkRoot).asAction())
self.tkRoot.config(menu=self.menuBar)
self.tkRoot.rowconfigure(0, weight=1)
self.tkRoot.columnconfigure(0, weight=1)
class ActionBase:
def asAction(self):
return lambda s = self : self.execute()
class ClickActionBase(ActionBase):
def __init__(self, parentList):
self.parentList = parentList
def execute(self, clickEvent):
clickEvent.item = int(self.parentList.curselection()[0])
self.executeClick(clickEvent)
class Deployment_Run(ActionBase):
def __init__(self, tkRoot):
self.tkRoot = tkRoot
def execute(self):
number=0
ALF_DeployDialog3 = DeployDialog3(self.tkRoot, number)
tkRoot = Tix.Tk()
tkRoot.option_add("*Menu.active.Background","darkblue")
tkRoot.option_add("*Menu.active.Foreground","white")
deployContent = Deploycontentpane(tkRoot)
tkRoot.mainloop()
and the DeployDialog3.py:
import Tkinter
class DeployDialog3:
def __init__(self, tkRoot, i):
self.tkRloot = tkRoot
self.top = Tkinter.Toplevel(tkRoot)
self.label=Tkinter.Label
self.top.rowconfigure(0, weight=1)
self.top.columnconfigure(0, weight=1)
self.RefreshButton = Tkinter.Button(self.top, text='Refresh', command=lambda s = self: s.handleRefresh(alf_label))
self.RefreshButton.grid(row=2, column=1)
alf_label=self.label(self.top, text=i)
alf_label.grid(row=3, column=0, sticky=Tkinter.NSEW)
def handleRefresh(self,alf_label):
global i
i=i+1
alf_label.grid_remove()
alf_label=self.label(self.top, text=i)
alf_label.grid(row=3, column=0, sticky=Tkinter.NSEW)
i = 0
The idea is to run the main one, then click on Deployment --> Run that opens another window
and then, clicking on refresh, the "number" increases from 0 to 1, from 1 to 2 and so on.
Can you tell me how I can modify these scripts so that the refresh happens automatically (say every 5 seconds) without clicking the "Refresh" button?
Thanks,
Alfonso.