954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Bitmap button without any border, and changing the picture while pressed?

So, this seems like it should be the default to me... if you're going to make your own picture for a button, I don't see why you'd want the default border around it, but I can't for the life of me figure out how to get rid of it.

I also need to change the picture of the button while it's pressed (and change back once it's released) so you can tell that you're actually pressing it.

I actually did figure this out yesterday (It literally took all day though.), but deleted the code because I decided not to use that button, and now I can't figure it out again. (Gotta remember to save these things. =/)

Could you give me an example of how to do it?

Lemony Lime
Newbie Poster
23 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

Can I add one more question to this? (It doesn't let me edit the first post anymore, sorry.)

Before, when I had the borderless bitmap button, if it overlapped something else, it would cause part of the other object to become invisible, where the border would have been. Is there a way to stop that from happening? Basically, the border is still there, it's just invisible, and when it overlaps things, it obstructs them.

Lemony Lime
Newbie Poster
23 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

Hello friend ,will first the first question , i tried to add ",highlightthickness=0" to the propreties of your Button like :

select = Button(destination, text = "Parcourir",highlightthickness=0, command = deuxfonctions)


Good luck

Ismatus3
Junior Poster in Training
78 posts since Dec 2011
Reputation Points: 23
Solved Threads: 2
 

Why would you use Button, instead of for example Canvas if this is what you need?

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

I don't know exactly what is the probleme

Ismatus3
Junior Poster in Training
78 posts since Dec 2011
Reputation Points: 23
Solved Threads: 2
 

Here is an example ...

# show a Tkinter button without border
# see also Button at:
# http://infohost.nmt.edu/tcc/help/pubs/tkinter/tkinter.pdf

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

root = tk.Tk()
root.title("A button without border")

# pick a GIF image you have in the working directory
# or give full path
image = tk.PhotoImage(file='Farm.gif')

# create a button to display the image
# use bd or borderwidth zero for no border
button = tk.Button(root, image=image, bd=0)
# position the widgets
button.grid(row=1, column=1)

root.mainloop()
Attachments Farm.gif 78.22KB
vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: