Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Image on disabled button

Reply
Thread Tools

Image on disabled button

 
 
Richard Townsend
Guest
Posts: n/a
 
      09-01-2003
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


 
Reply With Quote
 
 
 
 
Jeff Hobbs
Guest
Posts: n/a
 
      09-09-2003
Richard Townsend wrote:

> 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.

--
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
Tcl Support and Productivity Solutions

 
Reply With Quote
 
 
 
 
Richard Townsend
Guest
Posts: n/a
 
      09-09-2003
>
> 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};



 
Reply With Quote
 
Richard Townsend
Guest
Posts: n/a
 
      09-10-2003
>
> (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...
 
Reply With Quote
 
Richard Townsend
Guest
Posts: n/a
 
      09-10-2003
>
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Photoimage on button appears pixelated when button is disabled Dustan Python 3 05-18-2009 10:31 PM
Button disabled and re-enabled in client side not firing server-side click event. =?Utf-8?B?QmluIFNvbmcsIE1DUA==?= ASP .Net 2 05-27-2008 09:57 AM
IE vs Firefox Button Disabled On Back Button Click Issue ryanp@ungerboeck.com Javascript 0 08-01-2006 04:04 PM
Sometimes IE's Back Button is getting disabled in ASP.NET Page with few .Net Controls. NH ASP .Net 0 08-18-2004 03:05 PM
disabled button still posts back? Bob Schroeder ASP .Net 1 07-06-2004 03:31 PM



Advertisments