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
Comments
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 With my method this operation is cleared and the same as all other ---------------------------------------------------------- So to scroll entry widget: entry_widget['xscrollcommand']=scroll_widget.set 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) + If an argument (index) is passing, then display the character given by With 'old' methon is impossible call xview without arguments, the change ----------------------------------------------------------------- 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 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 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 root.mainloop() I tested with Python 2.5 and tk 8.4 and also tk 8.5 and module ttk |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: