9
9
# Standard library imports
10
10
import os
11
11
import os .path as osp
12
- import sys
13
12
14
13
# Third party imports
15
14
from qtpy .QtWidgets import (QButtonGroup , QGroupBox , QInputDialog , QLabel ,
@@ -68,18 +67,18 @@ def setup_page(self):
68
67
pyexec_bg = QButtonGroup (pyexec_group )
69
68
pyexec_label = QLabel (
70
69
_ (
71
- "Select the default Python interpreter to create new IPython "
72
- "consoles and to provide code completion in the Editor "
70
+ "Select the default Python interpreter for new IPython consoles "
71
+ "and Editor code completion"
73
72
)
74
73
)
75
74
pyexec_label .setWordWrap (True )
76
75
self .def_exec_radio = self .create_radiobutton (
77
- _ ("Internal (i.e. the same used by Spyder)" ),
76
+ _ ("Internal (same used by Spyder)" ),
78
77
'default' ,
79
78
button_group = pyexec_bg ,
80
79
)
81
80
self .cus_exec_radio = self .create_radiobutton (
82
- _ ("Use the following interpreter:" ),
81
+ _ ("Selected interpreter:" ),
83
82
'custom' ,
84
83
button_group = pyexec_bg ,
85
84
)
@@ -117,40 +116,39 @@ def setup_page(self):
117
116
118
117
# UMR Group
119
118
umr_group = QGroupBox (_ ("User Module Reloader (UMR)" ))
120
- umr_label = QLabel (_ ("UMR forces Python to reload modules which were "
121
- "imported when executing a file in a Python or "
122
- "IPython console with the <i>runfile</i> "
123
- "function." ))
119
+ umr_label = QLabel (
120
+ _ (
121
+ "UMR forces Python to reload imported modules when "
122
+ "running a file in an IPython console."
123
+ ),
124
+ )
124
125
umr_label .setWordWrap (True )
125
126
umr_enabled_box = newcb (
126
127
_ ("Enable UMR" ),
127
128
'umr/enabled' ,
128
- msg_if_enabled = True ,
129
- msg_warning = _ (
129
+ msg_info = _ ( "This change will only be applied to new consoles" ) ,
130
+ tip = _ (
130
131
"This option will enable the User Module Reloader (UMR) "
131
- "in Python/IPython consoles. UMR forces Python to "
132
- "reload deeply modules during import when running a "
133
- "Python file using the Spyder's builtin function "
134
- "<b>runfile</b>."
135
- "<br><br><b>1.</b> UMR may require to restart the "
136
- "console in which it will be called "
132
+ "in IPython consoles. UMR forces Python to perform a "
133
+ "deep reload of imported modules when running Python files "
134
+ "with Spyder's <code>Run</code> command.<br><br>"
135
+ "After being enabled, UMR requires a console restart "
137
136
"(otherwise only newly imported modules will be "
138
- "reloaded when executing files)."
139
- "<br><br><b>2.</b> If errors occur when re-running a "
140
- "PyQt-based program, please check that the Qt objects "
141
- "are properly destroyed (e.g. you may have to use the "
142
- "attribute <b >Qt.WA_DeleteOnClose</b > on your main "
143
- "window, using the <b >setAttribute</b > method)"
137
+ "reloaded when running files).<br><br> "
138
+ "If errors occur when re-running a PyQt-based program, "
139
+ "please check that the Qt objects are properly destroyed "
140
+ "(e.g. you may have to use the attribute "
141
+ "<code >Qt.WA_DeleteOnClose</code > on your main window, "
142
+ "using the <code >setAttribute</code > method). "
144
143
),
145
144
)
146
145
umr_verbose_box = newcb (
147
- _ ("Show reloaded modules list " ),
146
+ _ ("Print list of reloaded modules" ),
148
147
'umr/verbose' ,
149
- msg_info = _ ("Please note that these changes will "
150
- "be applied only to new consoles" ),
148
+ msg_info = _ ("This change will only be applied to new consoles" ),
151
149
)
152
150
umr_namelist_btn = QPushButton (
153
- _ ("Set UMR excluded (not reloaded) modules " ))
151
+ _ ("Select modules to exclude from being reloaded " ))
154
152
umr_namelist_btn .clicked .connect (self .set_umr_namelist )
155
153
156
154
umr_layout = QVBoxLayout ()
@@ -166,43 +164,13 @@ def setup_page(self):
166
164
vlayout .addStretch (1 )
167
165
self .setLayout (vlayout )
168
166
169
- def warn_python_compatibility (self , pyexec ):
170
- if not osp .isfile (pyexec ):
171
- return
172
-
173
- spyder_version = sys .version_info [0 ]
174
- try :
175
- args = ["-c" , "import sys; print(sys.version_info[0])" ]
176
- proc = programs .run_program (pyexec , args , env = {})
177
- console_version = int (proc .communicate ()[0 ])
178
- except IOError :
179
- console_version = spyder_version
180
- except ValueError :
181
- return False
182
-
183
- if spyder_version != console_version :
184
- QMessageBox .warning (
185
- self ,
186
- _ ('Warning' ),
187
- _ ("You selected a <b>Python %d</b> interpreter for the "
188
- "console but Spyder is running on <b>Python %d</b>!.<br><br>"
189
- "Although this is possible, we recommend you to install and "
190
- "run Spyder directly with your selected interpreter, to "
191
- "avoid seeing false warnings and errors due to the "
192
- "incompatible syntax between these two Python versions."
193
- ) % (console_version , spyder_version ),
194
- QMessageBox .Ok ,
195
- )
196
-
197
- return True
198
-
199
167
def set_umr_namelist (self ):
200
- """Set UMR excluded modules name list"""
168
+ """Set UMR excluded module names list."""
169
+ example_excludes = "<code>numpy, scipy</code>"
201
170
arguments , valid = QInputDialog .getText (
202
171
self ,
203
172
_ ('UMR' ),
204
- _ ("Set the list of excluded modules as this: "
205
- "<i>numpy, scipy</i>" ),
173
+ _ ("List of excluded modules (e.g. {})" ).format (example_excludes ),
206
174
QLineEdit .Normal ,
207
175
", " .join (self .get_option ('umr/namelist' )),
208
176
)
@@ -222,15 +190,15 @@ def set_umr_namelist(self):
222
190
QMessageBox .warning (
223
191
self ,
224
192
_ ('UMR' ),
225
- _ ("The following modules are not "
226
- "installed on your machine:\n %s" ) % invalid ,
193
+ _ (
194
+ "The following modules are not installed:\n {}"
195
+ ).format (invalid ),
227
196
QMessageBox .Ok ,
228
197
)
229
198
QMessageBox .information (
230
199
self ,
231
200
_ ('UMR' ),
232
- _ ("Please note that these changes will "
233
- "be applied only to new IPython consoles" ),
201
+ _ ("Changes will only be applied to new IPython consoles" ),
234
202
QMessageBox .Ok ,
235
203
)
236
204
else :
@@ -254,6 +222,3 @@ def perform_adjustments(self):
254
222
self .cus_exec_combo .combobox .clear ()
255
223
self .cus_exec_combo .combobox .addItems (custom_list )
256
224
self .pyexec_edit .setText (executable )
257
-
258
- # Show warning compatibility message.
259
- self .warn_python_compatibility (executable )
0 commit comments