Image on disabled button

Discussion in 'Python' started by Richard Townsend, Sep 1, 2003.

  1. 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
     
    Richard Townsend, Sep 1, 2003
    #1
    1. Advertising

  2. Richard Townsend

    Jeff Hobbs Guest

    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
     
    Jeff Hobbs, Sep 9, 2003
    #2
    1. Advertising

  3. >
    > 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};
     
    Richard Townsend, Sep 9, 2003
    #3
  4. >
    > (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...
     
    Richard Townsend, Sep 10, 2003
    #4
  5. >
    > 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.
     
    Richard Townsend, Sep 10, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    Replies:
    2
    Views:
    6,565
    rick74
    May 27, 2008
  2. Bob Schroeder

    disabled button still posts back?

    Bob Schroeder, Jul 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    422
    John Saunders
    Jul 6, 2004
  3. NH
    Replies:
    0
    Views:
    598
  4. Dustan
    Replies:
    3
    Views:
    258
    Dustan
    May 18, 2009
  5. Replies:
    0
    Views:
    322
Loading...

Share This Page