Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6639647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:34:42+00:00 2026-05-25T23:34:42+00:00

I’m attempting to write a GUI searchable bacteria database with the database array embedded

  • 0

I’m attempting to write a GUI searchable bacteria database with the database array embedded in the code using tkinter python 2.7. Choosing certain criteria via radiobuttons selectively searches the array, then hitting the ‘Identify’ button should print out the id of all bacteria which match those selections as a label.

I’ve posted the nonfunctional snippet [idbuttonclick(self)] below.

What the snippet def idbuttonclick(self) is supposed to do:

1) Search the matrix/array named ‘data’ for which columns 1-4 represent a radiobutton string variable option and each row a bacteria id

2) Select the rows in ‘data’ whose variable options match the radiobutton selections

3) Prints the bacteria ids in data column 0 from the selected rows as a label in the self.id_frame if the number of ids is 1-20. Otherwise, print the message label “Error: Not enough data.”

def idbuttonclick(self):

    def column(matrix, i):

        if column(data, 1)!=self.gram_option.get(): line.destroy()  
        if column(data, 2)!=self.meta_option.get(): line.destroy() 
        if column(data, 3)!=self.cat_option.get(): line.destroy() 
        if column(data, 4)!=self.oxi_option.get(): line.destroy() 

        column(data, 0)==id

    if id.count >= 20 or id.count == 0:
       Label(self.id_frame, text = "Error: Not enough data", background = "white").pack(side=TOP, anchor = N)
    else: Label(self.id_frame, text = id, background = "white").pack(side=TOP, anchor = N)

I’ve gotten the code to give me id.frame labels based on radiobutton selections, but still can’t link the radiobutton selections to coordinates in the array to then provide id.frame labels based on the radiobutton/array coordinate matches.

It is now specifically an array, not a matrix, as matrices and lists of lists and tuples apparently cannot store elements using a coordinate index (i,j).

Here’s my new draft below, which includes array and idbutton click command.

How this should work:
Any bacteria name in array column 1 with a ‘+’ value in array column 2 within the same row should appear in the id.frame label if the radiobutton self.gram_option=(‘+’) is selected.
So, the label should read: ‘Acetobacter aceti, Pseudomonas sp.’
Additionally clicking self.meta_option.get() should then correspond to column 2, narrowing the selection: a ‘fac anaerobe’ value would label ‘Acetobacter aceti’ and an ‘aerobe’ value would label ‘Pseudomonas sp.’

    data = array([
        ['Acetobacter aceti','+', 'fac anaerobe', '+', '--'],
        ['Citrobacter freundii','--', 'fac anaerobe', '+', '--'], 
        ['Pseudomonas sp','+', 'aerobe', '--', '--']])

    data.readlines()



def idbuttonclick(self, event):

    self.id_frame.destroy()
    self.id_frame = Frame(self.main_right_frame, borderwidth=5, height=50, background="white")
    self.id_frame.pack(side=TOP, fill=BOTH)

    if data[i,1]==self.gram_option.get(): 
        id = data [i,0]
        Label(self.id_frame, text = id, background = "white").pack(side=LEFT, anchor = N)

    if data[i,2]==self.shape_option.get(): 
        id = data [i,0]
        Label(self.id_frame, text = id, background = "white").pack(side=LEFT, anchor = N)

    if data[i,3]==self.meta_option.get(): 
        id = data [i,0]
        Label(self.id_frame, text = id, background = "white").pack(side=LEFT, anchor = N)

    if data[i,4]==self.cat_option.get(): 
        id = data [i,0]
        Label(self.id_frame, text = id, background = "white").pack(side=LEFT, anchor = N)

    else: Label(self.id_frame, text = 'Error: Not enough data', background = "white").pack(side=LEFT, anchor = N)

If I’m not stating my array coordinates correctly or someone knows a workable way to arrange the above scenario in python code…
I’ve gotten 56 views on this question over a period of about two weeks, but no code-writing feedback from the community. Hopefully, this new version better addresses what I originally had in mind and what needs tweaking.

Sincerely,

Jeff

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:34:42+00:00Added an answer on May 25, 2026 at 11:34 pm

    This solution uses a probability comparison instead of + and – (i.e., each bacteria has X probability of getting a + score and 1-X probability of getting a – score.) But this code will tie in the radiobuttons to the data matrix and then rank the top ten scoring bacteria accordingly. All the pieces are cooperating.

    def idbuttonclick(self, event):
    
        self.id_frame.destroy()
        self.id_frame = Frame(self.main_right_frame, borderwidth=5, height=50, background="white")
        self.id_frame.pack(side=TOP, fill=BOTH)
    
    
        if (self.gram_option.get()=="+" and
        self.meta_option.get()=="aerobe"):
            Label(self.id_frame, text = "Gram Positive Aerobe", background = "white").pack(side=TOP, anchor = N)
    
    
            bac=[('Aeromonas',0.95,0.05),
            ('Bacillus',0.05, 0.95),
            ('Hafnia',0.51, 0.51)]
    
    
    
        else: Label(self.id_frame, text = "Error: Not enough data", background = "white").pack(side=TOP, anchor = N)
    
        def plus(matrix, i):
            return [row[i] for row in matrix]
    
        def minus(matrix, i):
            return [1.00-row[i] for row in matrix]
    
        def average(lst):
            return sum(lst) / len(lst)
    
        bact=zip(*bac)
        bact2=bact[0:1]
        bact3=bact[0:1]
    
        if self.cat_option.get()=="+":
            bact2.append(plus(bac,1))
            bact3.append(plus(bac,1))
        if self.cat_option.get()=="--":
            bact2.append(minus(bac,1))
            bact3.append(plus(bac,1))
    
        if self.oxi_option.get()=="+":
            bact2.append(plus(bac,2))
            bact3.append(plus(bac,2))
    
        if self.oxi_option.get()=="--":
            bact2.append(minus(bac,2))
            bact3.append(plus(bac,2))
    
        bac2=zip(*bact2)
        bac3=zip(*bact3)
    
        #experimental additive probability
        #bac4 = [(bac2[0],reduce(mul,bac2[1:])) for bac2 in bac2]
    
        #experimental mean probability
        bac4 = [(bac2[0], average(bac2[1:])) for bac2 in bac2]
    
    
        #experimental additive probability / expected outcome additive probability
        #bac4 = [(bac2[0],reduce(mul,bac2[1:])/reduce(mul,bac3[1:])) for (bac2,bac3) in zip(bac2,bac3)]
    
        bac5 = tuple(sorted(bac4, key=lambda item: item[1], reverse=True))
    
    
        Label(self.id_frame, text = bac5[0], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[1], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[2], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[3], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[4], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[5], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[6], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[7], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[8], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[9], background = "white").pack(side=TOP, anchor = W)
        Label(self.id_frame, text = bac5[10], background = "white").pack(side=TOP, anchor = W)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.