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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:43:09+00:00 2026-05-23T02:43:09+00:00

I am learning pygame and want a graphic for a button with the three

  • 0

I am learning pygame and want a graphic for a button with the three states: normal, hover, and pressed. I have an image like this one …

Three button states, stacked vertically

… and I want to get a new Surface using a portion of it.

I’m loading the image with this code:

 buttonStates = pygame.image.load(os.path.join('image','button.png'))

How can I make a new surface using just a portion of that graphic?

  • 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-23T02:43:09+00:00Added an answer on May 23, 2026 at 2:43 am
    cropped = pygame.Surface((80, 80))
    cropped.blit(buttonStates, (0, 0), (30, 30, 80, 80))
    

    The blit method on a surface ‘pastes’ another surface on to it. The first argument to blit is the source surface. The second is the location to paste to (in this case, the top left corner). The third (optional) argument is the area of the source image to paste from — in this case an 80×80 square 30px from the top and 30px from the left.

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

Sidebar

Related Questions

Still learning JSP Web Applications here. I have been doing this for a while
learning about loops (still a beginner) in VB.net. I have got the below code
Im learning Spring (2 and 3) and i got this method in a ClientDao
im learning to make things to other windows like resize the ie or any
Learning my way through this stuff and could use some help. I'm trying to
Still learning my ways around C# generics... is it possible to achieve this functionality?
--still learning rails here.. I want to write a conditional statement such as: if
Learning C++, came upon function templates. The chapter mentioned template specialization. template <> void
In learning Core Animation, I learned very quickly that if you don't do it
im learning Objective-C with XCode. Im tying to get the User full path directory,

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.