Entering edit mode
7.6 years ago
uxue33
▴
20
I'm beginning to learn how to use python and need to develop some applications for a lab project.
I am trying to create a GUI to select a couple of files I want to pass as arguments to another program. The GUI part seems to work, but when I try to call the external script using Popen method but the variables allegedly captured through the GUI are not being passed to the Popen call.
I request your kind advice to solve this problem because it seems to be still a little beyond my current knowledge and I really need to use a Tk/GUI as interface for this project.
Here is my code:
def button_fasta_callback():
fasta = tkFileDialog.askopenfile(parent=root,mode='rb',title='Choose a FASTA')
if fasta != None:
data_fasta = fasta.read()
fasta.close()
def button_lista_callback():
lista = tkFileDialog.askopenfile(parent=root,mode='rb',title='Choose a list')
if lista !=None:
data_lista = lista.read()
lista.close()
#####Create the buttons#######
root = Tk()
root.title("Sequence extractor")
button_fasta = Button(root,
text="Choose a FASTA",
command=button_fasta_callback)
button_fasta.pack(padx=150, pady=50)
button_lista = Button(root,
text="Choose a list",
command=button_lista_callback)
button_lista.pack(padx=150, pady=50)
entry = Entry(root, width=50)
root.mainloop()
######Calling the external script#######
caller = Popen(['C:\\Python_programs\\Seq_extractor.py', '-l', lista, '-f', fasta])
Thank you all!