This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Python 2.7 Tk filedialog calling external programs

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!

tkinter python

Hello uxue33!

We believe that this post does not fit the main topic of this site.

I'm sorry, this question is not related to bioinformatics. You should ask stackoverflow.com

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

0 answers

No answers yet.

Log in to answer this question.