Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ed7d279
refactor TextFrame, extracting just the basic scrollable text widget
taleinat Jul 26, 2019
f67f6b9
use a scrollable text widget for the font config page's preview
taleinat Jul 26, 2019
0092a93
highlight page sample also a fixed-sized, scrollable text widget
taleinat Jul 26, 2019
3380193
refactor: make self.font_sample and self.highlight_sample consistent
taleinat Jul 26, 2019
b1dc2dd
rename for clarity: add_config_hook -> add_config_callback
taleinat Jul 26, 2019
48e97ce
Omit unneeded extra line number.
terryjreedy Jul 26, 2019
f78427a
Use horizontal scroller for font sample.
terryjreedy Jul 26, 2019
221e051
Condense 'font_sample_scrollable_frame' to 'font_sample__frame.
terryjreedy Jul 26, 2019
34c218a
Blurb.
terryjreedy Jul 26, 2019
b954c06
Meaningful names for callback functions.
terryjreedy Jul 27, 2019
72015a9
rename 'text' input param to 'contents' and use 'text' as local var
taleinat Jul 27, 2019
b5c467d
fix double-underscore typo
taleinat Jul 27, 2019
7100ec9
re-instate use of 'text' local variable in ScrollableTextFrame code
taleinat Jul 27, 2019
977c219
simplify ScrollableTextFrame, removing the config callback
taleinat Jul 27, 2019
3d8729d
Rename AutoHiddenScrollbar to AutoHideScrollbar
terryjreedy Jul 27, 2019
501fde2
Fix textview htest.
terryjreedy Jul 27, 2019
52cfa62
Restore coverage, reduced in prior issue, to 100%.
terryjreedy Jul 27, 2019
2cbf9e5
Double space between classes.
terryjreedy Jul 27, 2019
59eba51
Spacing
terryjreedy Jul 27, 2019
f6ac725
Combine configuration.
terryjreedy Jul 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use a scrollable text widget for the font config page's preview
  • Loading branch information
taleinat committed Jul 26, 2019
commit f67f6b99c1b2c7b641d6b346f375e51234517da1
15 changes: 10 additions & 5 deletions Lib/idlelib/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from idlelib.parenmatch import ParenMatch
from idlelib.format import FormatParagraph
from idlelib.squeezer import Squeezer
from idlelib.textview import ScrollableTextFrame

changes = ConfigChanges()
# Reload changed options in the following classes.
Expand Down Expand Up @@ -194,7 +195,7 @@ def cancel(self):

def destroy(self):
global font_sample_text
font_sample_text = self.fontpage.font_sample.get('1.0', 'end')
font_sample_text = self.fontpage.font_sample.text.get('1.0', 'end')
self.grab_release()
super().destroy()

Expand Down Expand Up @@ -556,8 +557,11 @@ def create_page_font_tab(self):
frame_font_param, variable=self.font_bold,
onvalue=1, offvalue=0, text='Bold')
# frame_sample.
self.font_sample = Text(frame_sample, width=20, height=20)
self.font_sample.insert(END, font_sample_text)
# self.font_sample = Text(frame_sample, width=20, height=20)
# self.font_sample.insert(END, font_sample_text)
self.font_sample = ScrollableTextFrame(frame_sample)
self.font_sample.text.config(wrap='word', width=1, height=1)
self.font_sample.text.insert('1.0', font_sample_text)
# frame_indent.
indent_title = Label(
frame_indent, justify=LEFT,
Expand All @@ -568,8 +572,9 @@ def create_page_font_tab(self):

# Grid and pack widgets:
self.columnconfigure(1, weight=1)
self.rowconfigure(2, weight=1)
frame_font.grid(row=0, column=0, padx=5, pady=5)
frame_sample.grid(row=0, column=1, rowspan=2, padx=5, pady=5,
frame_sample.grid(row=0, column=1, rowspan=3, padx=5, pady=5,
sticky='nsew')
frame_indent.grid(row=1, column=0, padx=5, pady=5, sticky='ew')
# frame_font.
Expand Down Expand Up @@ -657,7 +662,7 @@ def set_samples(self, event=None):
font_name = self.font_name.get()
font_weight = tkFont.BOLD if self.font_bold.get() else tkFont.NORMAL
new_font = (font_name, self.font_size.get(), font_weight)
self.font_sample['font'] = new_font
self.font_sample.text['font'] = new_font
self.highlight_sample['font'] = new_font

def load_tab_cfg(self):
Expand Down
6 changes: 3 additions & 3 deletions Lib/idlelib/textview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""
from tkinter import Toplevel, Text, TclError,\
HORIZONTAL, VERTICAL, N, S, E, W, NSEW, NONE, WORD, SUNKEN
HORIZONTAL, VERTICAL, NS, EW, NSEW, NONE, WORD, SUNKEN
from tkinter.ttk import Frame, Scrollbar, Button
from tkinter.messagebox import showerror

Expand Down Expand Up @@ -76,8 +76,8 @@ class TextWithConfigHook(Text):
self.yscroll = AutoHiddenScrollbar(self, orient=VERTICAL,
takefocus=False,
command=self.text.yview)
self.yscroll.grid(row=0, column=1, sticky=NS)
self.text['yscrollcommand'] = self.yscroll.set
self.yscroll.grid(row=0, column=1, sticky=N+S)

# horizontal scrollbar
self.xscroll = None
Expand All @@ -94,8 +94,8 @@ def _set_wrapping(self, wrap):
self.xscroll = AutoHiddenScrollbar(self, orient=HORIZONTAL,
takefocus=False,
command=self.text.xview)
self.xscroll.grid(row=1, column=0, sticky=EW)
self.text['xscrollcommand'] = self.xscroll.set
self.xscroll.grid(row=1, column=0, sticky=E+W)
elif wrap != NONE and self.xscroll is not None:
self.text['xscrollcommand'] = ''
self.xscroll.grid_forget()
Expand Down