11
11
12
12
# Third party imports
13
13
from qtpy .QtCore import Qt
14
- from qtpy .QtWidgets import (QGridLayout , QGroupBox , QHBoxLayout , QLabel ,
15
- QVBoxLayout )
14
+ from qtpy .QtWidgets import (
15
+ QGridLayout ,
16
+ QGroupBox ,
17
+ QHBoxLayout ,
18
+ QLabel ,
19
+ QMessageBox ,
20
+ QVBoxLayout ,
21
+ )
16
22
17
23
# Local imports
18
24
from spyder .api .translations import _
21
27
22
28
class IPythonConsoleConfigPage (PluginConfigPage ):
23
29
30
+ def __init__ (self , plugin , parent ):
31
+ super ().__init__ (plugin , parent )
32
+
33
+ self .buffer_spin = None
34
+ self .apply_callback = self .warn_if_large_buffer
35
+
24
36
def setup_page (self ):
25
37
newcb = self .create_checkbox
26
38
@@ -42,7 +54,7 @@ def setup_page(self):
42
54
'show_elapsed_time' ,
43
55
tip = _ ("Display the time since the current console was started "
44
56
"in the tab bar" ),
45
- )
57
+ )
46
58
47
59
display_layout = QVBoxLayout ()
48
60
display_layout .addWidget (banner_box )
@@ -118,21 +130,19 @@ def setup_page(self):
118
130
119
131
# Output group
120
132
output_group = QGroupBox (_ ("Output" ))
121
-
122
- # Note: The maximum here is set to a relatively small value because
123
- # larger ones make Spyder sluggish.
124
- # Fixes spyder-ide/spyder#19091
125
- buffer_spin = self .create_spinbox (
133
+ self .buffer_spin = self .create_spinbox (
126
134
_ ("Buffer:" ),
127
135
_ (" lines" ),
128
136
'buffer_size' ,
129
- min_ = - 1 ,
130
- max_ = 5000 ,
137
+ min_ = 100 ,
138
+ # >10k can make Spyder slow, see spyder-ide/spyder#19091
139
+ max_ = 50_000 ,
131
140
step = 100 ,
132
141
tip = _ (
133
142
"The maximum number of output lines "
134
- "retained in each console at a time."
135
- "\n Specifying -1 means no limit (not recommended)."
143
+ "retained in each console at a time.\n "
144
+ "Warning; Buffer sizes greater than 10000 lines can slow "
145
+ "down Spyder."
136
146
),
137
147
)
138
148
sympy_box = newcb (
@@ -146,7 +156,7 @@ def setup_page(self):
146
156
)
147
157
148
158
output_layout = QVBoxLayout ()
149
- output_layout .addWidget (buffer_spin )
159
+ output_layout .addWidget (self . buffer_spin )
150
160
output_layout .addWidget (sympy_box )
151
161
output_group .setLayout (output_layout )
152
162
@@ -182,7 +192,7 @@ def setup_page(self):
182
192
(inline , 'inline' ),
183
193
(automatic , 'auto' ),
184
194
("Qt" , 'qt' ),
185
- ("Tk" , 'tk' )
195
+ ("Tk" , 'tk' ),
186
196
]
187
197
188
198
if sys .platform == 'darwin' :
@@ -234,21 +244,31 @@ def setup_page(self):
234
244
tip = _ ("Only used when the format is PNG. Default is 144." ),
235
245
)
236
246
width_spin = self .create_spinbox (
237
- _ ("Width:" )+ " " , " " + _ ("inches" ),
238
- 'pylab/inline/width' , min_ = 2 , max_ = 20 , step = 1 ,
239
- tip = _ ("Default is 6" ))
247
+ _ ("Width:" ) + " " ,
248
+ " " + _ ("inches" ),
249
+ 'pylab/inline/width' ,
250
+ min_ = 2 ,
251
+ max_ = 20 ,
252
+ step = 1 ,
253
+ tip = _ ("Default is 6" ),
254
+ )
240
255
height_spin = self .create_spinbox (
241
- _ ("Height:" )+ " " , " " + _ ("inches" ),
242
- 'pylab/inline/height' , min_ = 1 , max_ = 20 , step = 1 ,
243
- tip = _ ("Default is 4" ))
256
+ _ ("Height:" ) + " " ,
257
+ " " + _ ("inches" ),
258
+ 'pylab/inline/height' ,
259
+ min_ = 1 ,
260
+ max_ = 20 ,
261
+ step = 1 ,
262
+ tip = _ ("Default is 4" ),
263
+ )
244
264
fontsize_spin = self .create_spinbox (
245
265
_ ("Font size:" ) + " " ,
246
266
" " + _ ("points" ),
247
267
'pylab/inline/fontsize' ,
248
268
min_ = 5 ,
249
269
max_ = 48 ,
250
270
step = 1.0 ,
251
- tip = _ ("Default is 10" )
271
+ tip = _ ("Default is 10" ),
252
272
)
253
273
bottom_spin = self .create_spinbox (
254
274
_ ("Bottom edge:" ) + " " ,
@@ -452,3 +472,19 @@ def setup_page(self):
452
472
_ ("Advanced" ),
453
473
[autocall_group , autoreload_group , prompts_group , windows_group ]
454
474
)
475
+
476
+ def warn_if_large_buffer (self ):
477
+ """Warn the user if the Console buffer size is very large."""
478
+ if "buffer_size" not in self .changed_options :
479
+ return
480
+
481
+ msg = None
482
+ buffer_size = self .buffer_spin .spinbox .value ()
483
+
484
+ # >10k line buffers can make Spyder slow, see spyder-ide/spyder#19091
485
+ if buffer_size > 10_000 :
486
+ msg = _ ("Buffer sizes over 10000 lines can slow down Spyder" )
487
+ elif buffer_size == - 1 :
488
+ msg = _ ("Unlimited buffer size can slow down Spyder severely" )
489
+ if msg :
490
+ QMessageBox .warning (self , _ ("Warning" ), msg , QMessageBox .Ok )
0 commit comments