Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item not shown when using mouse wheel to scroll for Listbox/Combobox #90959

Open
Jason990420 mannequin opened this issue Feb 20, 2022 · 2 comments
Open

Item not shown when using mouse wheel to scroll for Listbox/Combobox #90959

Jason990420 mannequin opened this issue Feb 20, 2022 · 2 comments
Labels
3.8 only security fixes 3.9 only security fixes topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@Jason990420
Copy link
Mannequin

Jason990420 mannequin commented Feb 20, 2022

BPO 46803
Nosy @stevendaprano, @jason990420
Files
  • PeS9r.png: Screeeshot
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2022-02-20.06:30:30.008>
    labels = ['3.8', 'type-bug', 'expert-tkinter', '3.9']
    title = 'Item not shown when using mouse wheel to scroll for Listbox/Combobox'
    updated_at = <Date 2022-02-20.08:58:44.564>
    user = 'https://github.com/Jason990420'

    bugs.python.org fields:

    activity = <Date 2022-02-20.08:58:44.564>
    actor = 'steven.daprano'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tkinter']
    creation = <Date 2022-02-20.06:30:30.008>
    creator = 'Jason990420'
    dependencies = []
    files = ['50634']
    hgrepos = []
    issue_num = 46803
    keywords = []
    message_count = 2.0
    messages = ['413564', '413565']
    nosy_count = 2.0
    nosy_names = ['steven.daprano', 'Jason990420']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue46803'
    versions = ['Python 3.8', 'Python 3.9']

    @Jason990420
    Copy link
    Mannequin Author

    Jason990420 mannequin commented Feb 20, 2022

    When scrolled items by mouse wheel in tk.Listbox/ttk.Combobox, some items not shown.

    Is it a bug ? or I did something wrong ?

    In following case, 'Wednesday' will not shown when scroll mouse wheel at

    • tk.Listbox or vertical scrollbar of tk.Listbox, or
    • listbox of ttk.Combo
    from tkinter import *
    from tkinter import ttk
    
    font = ('Courier New', 24)
    lst = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
    
    root = Tk()
    
    frame1 = Frame(root)
    frame1.pack(side=LEFT)
    vsb1 = Scrollbar(frame1, orient='v')
    vsb1.pack(side=RIGHT, fill='y')
    var = StringVar()
    var.set(lst)
    listbox = Listbox(frame1, width=10, height=3, listvariable=var, font=font, yscrollcommand=vsb1.set)
    listbox.pack(side=LEFT)
    vsb1.configure(command=listbox.yview)
    
    frame2 = Frame(root)
    frame2.pack(side=LEFT, fill='y')
    combobox = ttk.Combobox(frame2, values=lst, width=10, height=3, font=font)
    combobox.pack()
    
    root.mainloop()

    Platform: WIN10

    @Jason990420 Jason990420 mannequin added 3.8 only security fixes 3.9 only security fixes topic-tkinter type-bug An unexpected behavior, bug, or error labels Feb 20, 2022
    @stevendaprano
    Copy link
    Member

    Replicated on Linux, Python 3.10.

    It looks like mousewheel scrolling jumps by the wrong amount as it pages down (or up), and consequently some lines never appear in the view area.

    I ran a slightly modified version of the code that had 16 entries instead of just seven. By default, just three entries are visible at a time. If we number the lines 1-16, and start with lines 1-3 visible, then we get:

    • Initial view: lines 1, 2, 3 visible, 4-16 below the view area.
    • Scrollwheel down.
    • Lines 6-8 visible, 1-5 above the view area, 9-16 below.
    • Scrollwheel down.
    • Lines 11-13 visible, 1-10 above the view area, 14-16 below.
    • Scrollwheel down.
    • Lines 14-16 visible, 1-13 above the view area.

    So the scrollwheel scrolls down by: 5 lines, 5 lines, 3 lines.

    Going back the otherway, the scrollwheel scrolls up by 5, 5, 3.

    Why five lines? My guess is that it might have something to do with 16//3 = 5.

    I don't know if this is something we can fix, or we're stuck with whatever tk/tcl does.

    I don't know if this is related, or should be a separate issue, but I see that the keyboard PageUp and PageDown keys don't scroll up or down by a page, but by a single line -- and they don't correctly highlight the selected line either.

    Paging should scroll up or down by N-1 lines, where N is the number of visible lines in the view area.

    Likewise for clicking in the scrollbar's PageUp/PageDown region, which also scrolls by a single line.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant