Image on disabled button

  • Thread starter Richard Townsend
  • Start date
R

Richard Townsend

Is there a known problem with images on disabled buttons on Tk8.4.4 ?

If I create a button widget using a bitmap as the image and make the button
disabled, not all of the image becomes stippled. The 3 left hand columns of
pixels and the bottom 3 rows of pixels are left unchanged. This is most
obvious if you use a black square as the bitmap.

If I run the same application using Tk8.3.4 this doesn't happen - the
stipple is applied to the whole image.

I am using Python2.3 + Tkinter to test this.

RT
 
J

Jeff Hobbs

Richard said:
Is there a known problem with images on disabled buttons on Tk8.4.4 ?

If I create a button widget using a bitmap as the image and make the button
disabled, not all of the image becomes stippled. The 3 left hand columns of
pixels and the bottom 3 rows of pixels are left unchanged. This is most
obvious if you use a black square as the bitmap.

If I run the same application using Tk8.3.4 this doesn't happen - the
stipple is applied to the whole image.

I am using Python2.3 + Tkinter to test this.

Do you have a sample bitmap and code snipper (Tcl/Tk or Tkinter) that
one can repro this with? There were some fixes that went in for
compound buttons (those that display both image and text), but I don't
think anything changed for regular bitmaps.
 
R

Richard Townsend

Do you have a sample bitmap and code snipper (Tcl/Tk or Tkinter) that
one can repro this with? There were some fixes that went in for
compound buttons (those that display both image and text), but I don't
think anything changed for regular bitmaps.

Hi Jeff,

I have done further experiments. The original problem occurred on HP-UX11i.
I cannot reproduce it on Linux (SuSE 8.2).
Both systems were running Tk-Tcl 8.4.4 plus Python 2.3 (both built from
source). It also happens with Tk-Tcl 8.4.3.

However it DOES also occur on Windows 2000, running the standard Python 2.3
installation.

Example code is below.

If I uncomment the Button's width and height options, then the effect is
even more marked (the stipple is even further offset to the northeast).

(From memory) the following options added after creating the root window
prevent the bug occurring on HP-UX11i

self.root.option_add('*background', 'grey75')
self.root.option_add('*disabledBackground', '')

however they do not appear to have any effect on Windows.

----------------------------------------------------------------------------
--------------------------------------------
# icon_button.py
----------------------------------------------------------------------------
--------------------------------------------

import Tkinter

class Demo:

def __init__(self):

self.root = Tkinter.Tk()

self.bitmap = Tkinter.BitmapImage(file='square.xbm',
foreground='black')


self.button = Tkinter.Button(self.root,
image=self.bitmap,
#width=50,
#height=50,
anchor='center')
self.button.pack(side='top', padx=20, pady=20)

frame= Tkinter.Frame(self.root)
frame.pack(side='top', expand=True, fill='both')

b = Tkinter.Button(frame, text='Disable', command=self.disable)
b.pack(side='left')

b = Tkinter.Button(frame, text='Enable', command=self.enable)
b.pack(side='left')

b = Tkinter.Button(frame, text='Quit', command=self.quit)
b.pack(side='left')

self.root.mainloop()


def disable(self):

self.button.configure(state='disabled')


def enable(self):

self.button.configure(state='normal')


def quit(self):

self.root.quit()



if __name__ == '__main__':

Demo()


----------------------------------------------------------------------------
--------------------------------------------
square.xbm
----------------------------------------------------------------------------
--------------------------------------------

#define square.xbm_width 32
#define square.xbm_height 32
static unsigned char square.xbm_bits[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
R

Richard Townsend

(From memory) the following options added after creating the root window
prevent the bug occurring on HP-UX11i

self.root.option_add('*background', 'grey75')
self.root.option_add('*disabledBackground', '')

I have now checked again on HP-UX and have found that you must also set:

self.root.option_add('*disabledForeground', '')

to stop the bug appearing...
 
R

Richard Townsend

I have now checked again on HP-UX and have found that you must also set:

self.root.option_add('*disabledForeground', '')

to stop the bug appearing...

It also works on Windows 2000.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,006
Latest member
MelinaLema

Latest Threads

Top