954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

GUI variables

Okay, Im not sure how to put this.
So here is my first try, and if it aint clear enough I'll try to explain better.

I have made a few scripts that work perfectly fine, but now my client prefers it to come with a GUI.
My script needs 2 variables [the file to open, and if it is a genbank or fasta file].
I want my GUI to use radiobuttons for the genbank/fasta choice, and this works fine. But I want the file to open with a askopenfilename() and I can't pass the filename on to my other script.

Could anyone explain how to do this?

from Tkinter import *
from tkFileDialog import askopenfilename
import unicodedata

root = Tk();

var = StringVar()
var.set("1")
naam = []

root.title('Bio-Inf Toolkit')  

def openfile():
    een = askopenfilename()
    twee = unicodedata.normalize("NFKD",een).encode("ascii","ignore")
    naam.insert(0,twee)



def doOne():
    return var.get()

def ClickToRun():
    #print var.get()
    naam2 = ','.join(str(n) for n in naam)
    print naam2
    return naam2


Label(root,text='Bio-Inf \n TOOLKIT').pack(pady=10)
Label(root, text="Klik op de knop om een file te kiezen ").pack(pady=10)
Button(root, text='Choose File', command=openfile) .pack(side=TOP)


Label(root, text="Wat voor een type file is het? ").pack(pady=10)
Radiobutton(root, text="GenBank", value="GenBank", variable=var, command = doOne).pack()
Radiobutton(root, text="Fasta", value="Fasta", variable=var, command = doOne).pack()

Button(root, text='ClickToRun', command=ClickToRun) .pack(side=BOTTOM)

root.mainloop()

print naam2
print var.get()
zazga
Newbie Poster
1 post since Feb 2012
Reputation Points: 10
Solved Threads: 0
 
askandstudy
Newbie Poster
7 posts since Nov 2011
Reputation Points: 20
Solved Threads: 4
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You