I have written the following code to create a gui in python and then using lambda i am calling another file. This code is showing some indent problem . roshan/pre.sh is the path of shell script from where I am calling another python file. I want to create multiple buttons like this and using a function I will call a different shell script.
There should be 5 buttons (named GRAPH1, GRAPH2, GRAPH3, GRAPH4, GRAPH5) and on each button click I wish to load another file where i will put my graphs.
For example, when I click on the GRAPH1 button another file which i have named image1.py will load and will show graphs.
#!/usr/bin/python
import Tkinter, subprocess
class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
self.grid()
clusterB = Tkinter.Button(self, text ="preprocessing",width=13,font = "Georgia 10 bold")
clusterB.grid(row=5,sticky=Tkinter.W,padx=3)
clusterB.config(command = lambda:clusters())
def clusters():
process = subprocess.Popen(["roshan/pre.sh"],shell=False,
stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
while True:
out = process.stdout.readline()
if out == '' and process.poll() is not None:
break
print out
return
if __name__ == "__main__":
app = simpleapp_tk(None)
app.title('Results and Graphs')
app.mainloop()
lambda? It's not related to the problem, but it's unnecessary extra code.