Show More
@@ -138,6 +138,11 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
138 | 138 | |
|
139 | 139 | #------ Protected class variables ------------------------------------------ |
|
140 | 140 | |
|
141 | # control handles | |
|
142 | _control = None | |
|
143 | _page_control = None | |
|
144 | _splitter = None | |
|
145 | ||
|
141 | 146 | # When the control key is down, these keys are mapped. |
|
142 | 147 | _ctrl_down_remap = { QtCore.Qt.Key_B : QtCore.Qt.Key_Left, |
|
143 | 148 | QtCore.Qt.Key_F : QtCore.Qt.Key_Right, |
@@ -182,8 +187,6 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
182 | 187 | layout = QtGui.QStackedLayout(self) |
|
183 | 188 | layout.setContentsMargins(0, 0, 0, 0) |
|
184 | 189 | self._control = self._create_control() |
|
185 | self._page_control = None | |
|
186 | self._splitter = None | |
|
187 | 190 | if self.paging in ('hsplit', 'vsplit'): |
|
188 | 191 | self._splitter = QtGui.QSplitter() |
|
189 | 192 | if self.paging == 'hsplit': |
@@ -533,13 +533,15 b' class IPythonWidget(FrontendWidget):' | |||
|
533 | 533 | """ Set the style sheets of the underlying widgets. |
|
534 | 534 | """ |
|
535 | 535 | self.setStyleSheet(self.style_sheet) |
|
536 | if self._control is not None: | |
|
536 | 537 | self._control.document().setDefaultStyleSheet(self.style_sheet) |
|
537 | if self._page_control: | |
|
538 | self._page_control.document().setDefaultStyleSheet(self.style_sheet) | |
|
539 | ||
|
540 | 538 | bg_color = self._control.palette().window().color() |
|
541 | 539 | self._ansi_processor.set_background_color(bg_color) |
|
542 | 540 | |
|
541 | if self._page_control is not None: | |
|
542 | self._page_control.document().setDefaultStyleSheet(self.style_sheet) | |
|
543 | ||
|
544 | ||
|
543 | 545 | |
|
544 | 546 | def _syntax_style_changed(self): |
|
545 | 547 | """ Set the style for the syntax highlighter. |
@@ -174,7 +174,7 b' class PygmentsHighlighter(QtGui.QSyntaxHighlighter):' | |||
|
174 | 174 | def _get_format_from_document(self, token, document): |
|
175 | 175 | """ Returns a QTextCharFormat for token by |
|
176 | 176 | """ |
|
177 | code, html = self._formatter._format_lines([(token, 'dummy')]).next() | |
|
177 | code, html = self._formatter._format_lines([(token, u'dummy')]).next() | |
|
178 | 178 | self._document.setHtml(html) |
|
179 | 179 | return QtGui.QTextCursor(self._document).charFormat() |
|
180 | 180 |
@@ -190,6 +190,7 b' class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):' | |||
|
190 | 190 | kernel_manager.start_channels() |
|
191 | 191 | widget = self.widget_factory(config=self.config, |
|
192 | 192 | local_kernel=True) |
|
193 | self.init_colors(widget) | |
|
193 | 194 | widget.kernel_manager = kernel_manager |
|
194 | 195 | widget._existing = False |
|
195 | 196 | widget._may_close = True |
@@ -212,6 +213,7 b' class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):' | |||
|
212 | 213 | kernel_manager.start_channels() |
|
213 | 214 | widget = self.widget_factory(config=self.config, |
|
214 | 215 | local_kernel=False) |
|
216 | self.init_colors(widget) | |
|
215 | 217 | widget._existing = True |
|
216 | 218 | widget._may_close = False |
|
217 | 219 | widget._confirm_exit = False |
@@ -230,6 +232,7 b' class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):' | |||
|
230 | 232 | local_kernel = (not self.existing) or self.ip in LOCAL_IPS |
|
231 | 233 | self.widget = self.widget_factory(config=self.config, |
|
232 | 234 | local_kernel=local_kernel) |
|
235 | self.init_colors(self.widget) | |
|
233 | 236 | self.widget._existing = self.existing |
|
234 | 237 | self.widget._may_close = not self.existing |
|
235 | 238 | self.widget._confirm_exit = self.confirm_exit |
@@ -246,7 +249,7 b' class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):' | |||
|
246 | 249 | |
|
247 | 250 | self.window.setWindowTitle('Python' if self.pure else 'IPython') |
|
248 | 251 | |
|
249 | def init_colors(self): | |
|
252 | def init_colors(self, widget): | |
|
250 | 253 | """Configure the coloring of the widget""" |
|
251 | 254 | # Note: This will be dramatically simplified when colors |
|
252 | 255 | # are removed from the backend. |
@@ -264,6 +267,10 b' class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):' | |||
|
264 | 267 | style = self.config.IPythonWidget.syntax_style |
|
265 | 268 | except AttributeError: |
|
266 | 269 | style = None |
|
270 | try: | |
|
271 | sheet = self.config.IPythonWidget.style_sheet | |
|
272 | except AttributeError: | |
|
273 | sheet = None | |
|
267 | 274 | |
|
268 | 275 | # find the value for colors: |
|
269 | 276 | if colors: |
@@ -284,30 +291,27 b' class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):' | |||
|
284 | 291 | else: |
|
285 | 292 | colors=None |
|
286 | 293 | |
|
287 |
# Configure the style |
|
|
288 | widget = self.widget | |
|
294 | # Configure the style | |
|
289 | 295 | if style: |
|
290 | 296 | widget.style_sheet = styles.sheet_from_template(style, colors) |
|
291 | 297 | widget.syntax_style = style |
|
292 | 298 | widget._syntax_style_changed() |
|
293 | 299 | widget._style_sheet_changed() |
|
294 | 300 | elif colors: |
|
295 | # use a default style | |
|
301 | # use a default dark/light/bw style | |
|
296 | 302 | widget.set_default_style(colors=colors) |
|
297 | else: | |
|
298 | # this is redundant for now, but allows the widget's | |
|
299 | # defaults to change | |
|
300 | widget.set_default_style() | |
|
301 | 303 | |
|
302 | 304 | if self.stylesheet: |
|
303 | # we got an expicit stylesheet | |
|
305 | # we got an explicit stylesheet | |
|
304 | 306 | if os.path.isfile(self.stylesheet): |
|
305 | 307 | with open(self.stylesheet) as f: |
|
306 | 308 | sheet = f.read() |
|
307 | widget.style_sheet = sheet | |
|
308 | widget._style_sheet_changed() | |
|
309 | 309 | else: |
|
310 | 310 | raise IOError("Stylesheet %r not found."%self.stylesheet) |
|
311 | if sheet: | |
|
312 | widget.style_sheet = sheet | |
|
313 | widget._style_sheet_changed() | |
|
314 | ||
|
311 | 315 | |
|
312 | 316 | def init_signal(self): |
|
313 | 317 | """allow clean shutdown on sigint""" |
@@ -327,7 +331,6 b' class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):' | |||
|
327 | 331 | super(IPythonQtConsoleApp, self).initialize(argv) |
|
328 | 332 | IPythonConsoleApp.initialize(self,argv) |
|
329 | 333 | self.init_qt_elements() |
|
330 | self.init_colors() | |
|
331 | 334 | self.init_signal() |
|
332 | 335 | |
|
333 | 336 | def start(self): |
General Comments 0
You need to be logged in to leave comments.
Login now