This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tkinter scrollbar missing 'state' option
Type: enhancement Stage: resolved
Components: Tkinter Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: azeeman, cheryl.sabella, gpolo, serhiy.storchaka
Priority: normal Keywords:

Created on 2019-03-03 19:00 by azeeman, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (6)
msg337041 - (view) Author: Anthony Zeeman (azeeman) Date: 2019-03-03 19:00
The scrollbars in both tkinter and Tkinter don't have the 'state' option and cannot be disabled.
msg337051 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-03-03 23:37
You need to use the ttk Scrollbar to access state.  The standard tk Scrollbar doesn't have it.

Take a look at the doc page for ttk:
https://docs.python.org/3/library/tkinter.ttk.html

And the New Mexico Institute pages for ttk:
https://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Scrollbar.html
https://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Widget.html
msg337052 - (view) Author: Anthony Zeeman (azeeman) Date: 2019-03-03 23:46
Cheryl, here is the option listing from the ttk scrollbar configure method:
TTK Scrollbar options: {'command': ('command', 'command', 'Command', '', '140274415153928offsetChanged'), 'orient': ('orient', 'orient', 'Orient', <index object: 'vertical'>, <index object: 'vertical'>), 'takefocus': ('takefocus', 'takeFocus', 'TakeFocus', '', ''), 'cursor': ('cursor', 'cursor', 'Cursor', '', ''), 'style': ('style', 'style', 'Style', '', ''), 'class': ('class', '', '', '', '')}
Here is the listing from the tk scrollbar configure method:
TK Scrollbar options: {'activebackground': ('activebackground', 'activeBackground', 'Foreground', '#ececec', '#ececec'), 'activerelief': ('activerelief', 'activeRelief', 'Relief', 'raised', 'raised'), 'background': ('background', 'background', 'Background', '#d9d9d9', '#d9d9d9'), 'bd': ('bd', 'borderWidth'), 'bg': ('bg', 'background'), 'borderwidth': ('borderwidth', 'borderWidth', 'BorderWidth', '1', '1'), 'command': ('command', 'command', 'Command', '', '140677242826952offsetChanged'), 'cursor': ('cursor', 'cursor', 'Cursor', '', ''), 'elementborderwidth': ('elementborderwidth', 'elementBorderWidth', 'BorderWidth', '-1', '-1'), 'highlightbackground': ('highlightbackground', 'highlightBackground', 'HighlightBackground', '#d9d9d9', '#d9d9d9'), 'highlightcolor': ('highlightcolor', 'highlightColor', 'HighlightColor', '#000000', '#000000'), 'highlightthickness': ('highlightthickness', 'highlightThickness', 'HighlightThickness', '0', '0'), 'jump': ('jump', 'jump', 'Jump', '0', '0'), 'orient': ('orient', 'orient', 'Orient', 'vertical', 'vertical'), 'relief': ('relief', 'relief', 'Relief', 'sunken', 'sunken'), 'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '300'), 'repeatinterval': ('repeatinterval', 'repeatInterval', 'RepeatInterval', '100', '100'), 'takefocus': ('takefocus', 'takeFocus', 'TakeFocus', '', ''), 'troughcolor': ('troughcolor', 'troughColor', 'Background', '#b3b3b3', '#b3b3b3'), 'width': ('width', 'width', 'Width', '11', '11')}
The option is missing for both variants of the scrollbar.

    On Sunday, March 3, 2019, 6:37:47 p.m. EST, Cheryl Sabella <report@bugs.python.org> wrote:  

Cheryl Sabella <cheryl.sabella@gmail.com> added the comment:

You need to use the ttk Scrollbar to access state.  The standard tk Scrollbar doesn't have it.

Take a look at the doc page for ttk:
https://docs.python.org/3/library/tkinter.ttk.html

And the New Mexico Institute pages for ttk:
https://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Scrollbar.html
https://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Widget.html

----------
nosy: +cheryl.sabella

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue36171>
_______________________________________
msg337054 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-03-04 00:01
That's because state isn't an option.  :-)

I should have included the link to the ttk scrollbar manpage.
https://www.tcl.tk/man/tcl/TkCmd/ttk_scrollbar.htm

You'll see on that page that 'state' is listed as a Widget Command and not an Option:
    STANDARD OPTIONS

        -class, undefined, undefined 
        -cursor, cursor, Cursor 
        -style, style, Style 
        -takefocus, takeFocus, TakeFocus 

    WIDGET-SPECIFIC OPTIONS

        -command, command, Command 
        -orient, orient, Orient 

    WIDGET COMMAND

        pathName cget option 
        pathName configure ?option? ?value option value ...? 
        pathName get 
        pathName identify x y 
        pathName instate statespec ?script? 
        pathName set first last 
        pathName state ?stateSpec? 

    INTERNAL COMMANDS

        pathName delta deltaX deltaY 
        pathName fraction x y 

    SCROLLING COMMANDS

        prefix moveto fraction 
        prefix scroll number units 
        prefix scroll number pages 

If you notice, your listing of the options includes the 6 options listed above: command, orient, takefocus, cursor, style, class.  It doesn't list any of the other widget commands, such as cget or configure.  state is like those and not like the options.

In other words, you would use `w.state(['!disabled', 'selected'])` as shown in the example on the New Mexico Tech link.
msg337057 - (view) Author: Anthony Zeeman (azeeman) Date: 2019-03-04 00:06
Cheryl, thank you for your help.

    On Sunday, March 3, 2019, 7:02:47 p.m. EST, Cheryl Sabella <report@bugs.python.org> wrote:  

Cheryl Sabella <cheryl.sabella@gmail.com> added the comment:

That's because state isn't an option.  :-)

I should have included the link to the ttk scrollbar manpage.
https://www.tcl.tk/man/tcl/TkCmd/ttk_scrollbar.htm

You'll see on that page that 'state' is listed as a Widget Command and not an Option:
    STANDARD OPTIONS

        -class, undefined, undefined 
        -cursor, cursor, Cursor 
        -style, style, Style 
        -takefocus, takeFocus, TakeFocus 

    WIDGET-SPECIFIC OPTIONS

        -command, command, Command 
        -orient, orient, Orient 

    WIDGET COMMAND

        pathName cget option 
        pathName configure ?option? ?value option value ...? 
        pathName get 
        pathName identify x y 
        pathName instate statespec ?script? 
        pathName set first last 
        pathName state ?stateSpec? 

    INTERNAL COMMANDS

        pathName delta deltaX deltaY 
        pathName fraction x y 

    SCROLLING COMMANDS

        prefix moveto fraction 
        prefix scroll number units 
        prefix scroll number pages 

If you notice, your listing of the options includes the 6 options listed above: command, orient, takefocus, cursor, style, class.  It doesn't list any of the other widget commands, such as cget or configure.  state is like those and not like the options.

In other words, you would use `w.state(['!disabled', 'selected'])` as shown in the example on the New Mexico Tech link.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue36171>
_______________________________________
msg337058 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-03-04 00:47
You're welcome.
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80352
2019-03-04 00:47:55cheryl.sabellasetstatus: open -> closed
resolution: not a bug
messages: + msg337058

stage: resolved
2019-03-04 00:06:08azeemansetmessages: + msg337057
2019-03-04 00:01:34cheryl.sabellasetmessages: + msg337054
2019-03-03 23:46:15azeemansetmessages: + msg337052
2019-03-03 23:37:42cheryl.sabellasetnosy: + cheryl.sabella
messages: + msg337051
2019-03-03 19:11:10SilentGhostsetnosy: + gpolo, serhiy.storchaka

type: enhancement
versions: + Python 3.8
2019-03-03 19:00:40azeemancreate