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