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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:56:53+00:00 2026-05-26T19:56:53+00:00

I am new to making GUIs with Python and what I am trying to

  • 0

I am new to making GUIs with Python and what I am trying to do should be pretty simple. Essentially, I have a dialog class that I use to instantiate a dialog in my program. One of the things on this dialog is a button that I want to use to change color. I want the user to be able to click the button, be taken to a color chooser, then return to the dialog with the button changing to the color that was chosen. In my dialog class, here is where I define the button.

def body(self, master):

  Label(master, text="Track URL:").grid(row=0)
  Label(master, text="Short label:").grid(row=1)
  Label(master, text="Long label:").grid(row=2)
  b = Button(master, text="Color",bg="white",command=self.chooseColor).grid(row=3)

  self.e1 = Entry(master)
  self.e2 = Entry(master)
  self.e3 = Entry(master)

  self.e1.grid(row=0, column=1)
  self.e2.grid(row=1, column=1)
  self.e3.grid(row=2, column=1)

  return self.e1 # initial focus

Then I just want a simple function to choose the color

   def chooseColor(self):
   color = askColor()
   b["bg"] = color

I understand that b is now out of scope, so I can’t change it, but I don’t understand how to get the color chosen in a place where I can change the button color. Any help would be greatly appreciated.

  • 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-26T19:56:53+00:00Added an answer on May 26, 2026 at 7:56 pm

    Make b a member variable:

    self.b = Button(.....)
    

    Then self.chooseColor can “see” self.b and make changes to it:

    def chooseColor(self):
        color = askColor()
        self.b["bg"] = color # or however you change a color in python/tkinter
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a new Android app that essentially mirrors data available on our website.
I'm making a new OSX app and I'm trying to copy the flow that
I am making a simple game in order to learn a new language. I
I'm a new Python programmer who is making the leap from 2.6.4 to 3.1.1.
I have a program which iterates over an array, deterministically making new row-vectors which
I have a set of structured data, that I'm trying to merge together, based
I always have problems making new prefixes in xaml. Most of the time, i
General question here: If I'm making a new class, and it's only private field
I am new to making WordPress themes but I have managed to include the
There are several libraries like ncurses that assist in making command-line GUIs. Simply put,

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.