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 6927497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:03:48+00:00 2026-05-27T11:03:48+00:00

Hi all I have this code that doesnt seem to be working. I think

  • 0

Hi all I have this code that doesnt seem to be working. I think its because my birthCalc method is trying to access variables within an init method. My question is how should I change this so that my program can access those gui elements and their stored values.

*Note that im trying to access the variables at the beginning of the birthCalc method.

class GUI:
    def __init__ (self):
        self.app=Tk()
        bottomFrame=Frame(self.app)
        bottomFrame.pack(side="bottom",pady=10)
        self.app.title("When will you be 1 billion seconds old? ")
        Label(self.app,text="Please enter your birthday").pack()
        Label(self.app, text="Month").pack(side="left",padx=2)
        month=IntVar()
        month.set(1)
        months=range(1,13)
        monthMenu=OptionMenu(self.app,month, *months)
        monthMenu.pack(side="left")

        Label(self.app, text="Day").pack(side="left",padx=2)
        day=IntVar()
        day.set(1)
        days=range(1,32)

        dayMenu=OptionMenu(self.app,day, *days)
        dayMenu.pack(side="left")

        Label(self.app, text="Year").pack(side="left",padx=2)
        year=IntVar()
        year.set(1901)
        years=range(1901,2012)
        yearMenu=OptionMenu(self.app,year, *years).pack(side="left")

        Label(self.app, text="Hour").pack(side="left",padx=2)
        hour=IntVar()
        hour.set(0)
        hours=range(0,25)
        hourMenu=OptionMenu(self.app,hour, *hours).pack(side="left")

        Label(self.app, text="Minute").pack(side="left",padx=2)
        minute=IntVar()
        minute.set(0)
        minutes=range(00,60)
        minuteMenu=OptionMenu(self.app,minute, *minutes).pack(side="left")

        Label(self.app, text="Second").pack(side="left",padx=2)
        second=IntVar()
        second.set(0)
        seconds=range(0,60)
        secondMenu=OptionMenu(self.app,second, *seconds).pack(side="left")

        Button(bottomFrame,text="Calculate", command=self.birthCalc).pack()
        textVar=StringVar()
        textVar.set("You will turn 1 billion seconds old on: ")
        Label(bottomFrame,text=textVar.get()).pack(side="bottom",pady=5)


    def birthCalc(self):
        YEARSEC=31104000 #Values used for converting specified unit into seconds
        MONTHSEC=2592000 #Ex. There are 60 seconds in a minute
        DAYSEC=86400
        HOURSEC=360
        MINUTESEC=60

        year=self.(yearMenu).get() #Get input
        month=self.monthMenu.get()-1    
        day=self.dayMenu.get()-1          #Note that 1 is subtracted because months/days start at 01 (Not 00 as python assumes)
        hour=self.hourMenu.get()
        minute=self.minuteMenu.get()
        second=self.secondMenu.get()
  • 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-27T11:03:49+00:00Added an answer on May 27, 2026 at 11:03 am

    Inside __init__ function you should add your elements into class as atributes.
    I.e. change monthMenu=OptionMenu(self.app,month, *months) into self.monthMenu=OptionMenu(self.app,month, *months)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code that is giving me trouble. I know all
I have some C# code that generates google maps. This codes looks at all
Hi all I have this code to check if an item from a textbox
I have this code to connect to Active Directory and get all the groups
I have this code which gets WP posts, but it gets all the posts
I have this code: $li = $(li, this) Which is selecting all of the
Problem Hello all! I have this code which takes my jpg image loops through
I have this block of code: users = Array.new users << User.find(:all, :conditions =>
I have borrowed code from this link PHP regex templating - find all occurrences
Hey all, this is the code i have to check for a day thats

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.