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

Tkinter: modify xview of entry widget #50951

Closed
paolo mannequin opened this issue Aug 14, 2009 · 2 comments
Closed

Tkinter: modify xview of entry widget #50951

paolo mannequin opened this issue Aug 14, 2009 · 2 comments

Comments

@paolo
Copy link
Mannequin

paolo mannequin commented Aug 14, 2009

BPO 6702

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 = <Date 2009-08-14.12:42:19.122>
created_at = <Date 2009-08-14.12:28:15.764>
labels = ['expert-tkinter']
title = 'Tkinter: modify xview of entry widget'
updated_at = <Date 2009-08-14.12:42:19.114>
user = 'https://bugs.python.org/paolo'

bugs.python.org fields:

activity = <Date 2009-08-14.12:42:19.114>
actor = 'gpolo'
assignee = 'none'
closed = True
closed_date = <Date 2009-08-14.12:42:19.122>
closer = 'gpolo'
components = ['Tkinter']
creation = <Date 2009-08-14.12:28:15.764>
creator = 'paolo'
dependencies = []
files = []
hgrepos = []
issue_num = 6702
keywords = []
message_count = 2.0
messages = ['91547', '91548']
nosy_count = 2.0
nosy_names = ['gpolo', 'paolo']
pr_nums = []
priority = 'normal'
resolution = 'duplicate'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue6702'
versions = ['Python 2.5']

@paolo
Copy link
Mannequin Author

paolo mannequin commented Aug 14, 2009

I wish to propose a useful and smart method modify in Tkinter Library:

Previously to scroll this widget we had to write an external function
(recalling xview_moveto and xview_scroll).

With my method this operation is cleared and the same as all other
widgets (just have to call xview).

----------------------------------------------------------
Modify Proposal:
----------------------------------------------------------
Change the method xview of entry so it works as all widget scrollable,
and it's compatible with 'old' xview.

So to scroll entry widget:

entry_widget['xscrollcommand']=scroll_widget.set
scroll_widget['command']=entry_widget.xview

The change in module Tkinter is:

def xview(self,*args):
    """Query and change horizontal position of the view."""
    #modify
    if not args:
        return self._getdoubles(self.tk.call(self._w, 'xview'))
    #old code
    index=args[0]
    self.tk.call(self._w, 'xview', index)

+
It's call the tk interpreter passing entry and xview without arguments;
returns a list containing two elements to pass to scrollbars via the
xscrollcommand option

If an argument (index) is passing, then display the character given by
index at the left edge of the window; it work as the original xview

With 'old' methon is impossible call xview without arguments, the change
has made possible this.

-----------------------------------------------------------------
To scroll entry without modify:
-------------------------------

import Tkinter as tk
root=tk.Tk()

def scollEntry(*args):
   if args[0]=='scroll':
        e.xview_scroll(args[1],args[2])
   if args[0]=='moveto':
        e.xview_moveto(args[1])

e=tk.Entry(width=10)
e.grid(row=0, sticky='e'+'w')

s=tk.Scrollbar(orient='horizontal')
s.grid(row=1, sticky='e'+'w')

e['xscrollcommand']=s.set
s['command']=scollEntry

root.mainloop()

With modify:
------------

import Tkinter as tk
root=tk.Tk()

e=tk.Entry(width=10)
e.grid(row=0, sticky='e'+'w')

s=tk.Scrollbar(orient='horizontal')
s.grid(row=1, sticky='e'+'w')

e['xscrollcommand']=s.set
s['command']=e.xview

root.mainloop()

It's work also with tk-8.5 and ttk
----------------------------------

import Tkinter as tk
import ttk
root=tk.Tk()

e=ttk.Entry(width=10)
e.grid(row=0, sticky='e'+'w')

s=ttk.Scrollbar(orient='horizontal')
s.grid(row=1, sticky='e'+'w')

e['xscrollcommand']=s.set
s['command']=e.xview

root.mainloop()

I tested with Python 2.5 and tk 8.4 and also tk 8.5 and module ttk

@paolo paolo mannequin added the topic-tkinter label Aug 14, 2009
@gpolo
Copy link
Mannequin

gpolo mannequin commented Aug 14, 2009

Please take a look on bpo-6180. Closing this as duplicate.

Also consider checking the bpo-1135, your comments are welcome on both
issues and may help getting the fix committed.

@gpolo gpolo mannequin closed this as completed Aug 14, 2009
@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
Projects
None yet
Development

No branches or pull requests

0 participants