Ok, so I am definitely new to Python so please bear with my ignorance.
I am writing a practice interactive function with PyCharm.
Basically, I want to generate an interactive window with two text input fields and two buttons.
One button (QUIT) will quit the app, and the other one (Run DNA Scan) starts it.
The first text input field takes a DNA sequence (ex: atgcagatgac) and the other one takes a smaller 'search' sequence (ex: cag).
The plan is that once the two text fields are filled in, pressing the 'Run DNA Sequence' will start the DNA_scan() function - which I wrote and works fine when called on its own.
The problem is, the 'QUIT' button works the way it should, but the 'Run DNA Sequence' button does nothing.
Thanks in advance!
Here is my code as I have it now:
import tkinter
from tkinter import *
class Application(Frame):
def DNA_scan(self): #this is a search function I wrote myself - it works fine on its own
dataf = str(input())
s = str(input())
datar = dataf[::-1]
print('Your data input contains ' + str((dataf.count(s))) + ' instances of your search input on the FORWARD strand:')
data = dataf.lower()
b = s.lower()
c = b.upper()
print(data.replace(b,c))
datar = datar.lower()
i = 0
reverse = ''
s = s.lower()
for ch in datar:
if ch == 'a':
ch = 't'
reverse = reverse + ch
i = i+1
elif ch == 't':
ch = 'a'
i = i+1
reverse = reverse + ch
elif ch == 'c':
ch = 'g'
i = i+1
reverse = reverse + ch
elif ch == 'g':
ch = 'c'
i = i+1
reverse = reverse + ch
print('And, your data input contains ' + str((reverse.count(s))) + ' instances of your search input on the REVERSE strand:')
a = reverse.lower()
b = s.lower()
c = b.upper()
print(a.replace(b,c))
def createWidgets(self):
root.title("DNA scan")
Label (text="Please enter your DNA sequence:").pack(side=TOP,padx=10,pady=10)
dataf = Entry(root, width=10).pack(side=TOP,padx=10,pady=10)
Label (text="Please enter your search sequence:").pack(side=TOP,padx=10,pady=10)
s = Entry(root, width=10).pack(side=TOP,padx=10,pady=10)
self.button = Button(root,text="Run DNA scan",command=self.DNA_scan)
self.button.pack()
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.QUIT.pack({"side": "left"})
def __init__(self, master=None):
Frame.__init__(self, master)
self.filename = None
self.pack()
self.createWidgets()
root = Tk()
root.title("DiNA")
root.quit()
app = Application(master=root)
app.mainloop()