Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbautista committed Sep 29, 2024
1 parent 6f70a04 commit 5d3c768
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 41 deletions.
1 change: 0 additions & 1 deletion qtconsole/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from qtconsole.jupyter_widget import JupyterWidget
from qtconsole.usage import gui_reference


def background(f):
"""call a function in a simple thread, to prevent blocking"""
t = Thread(target=f)
Expand Down
41 changes: 1 addition & 40 deletions qtconsole/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from qtpy import QtCore, QtGui

from traitlets import default, HasTraits, TraitType, Unicode, observe
from traitlets.config import LoggingConfigurable

#-----------------------------------------------------------------------------
# Metaclasses
Expand Down Expand Up @@ -44,46 +45,6 @@ def __init__(mcls, name, bases, classdict):
# Classes
#-----------------------------------------------------------------------------

class ShortcutManager(HasTraits):
"""Default shortcuts definition and changes event handler."""

# Define traits for shortcuts
shortcut_print = Unicode('Ctrl+P').tag(config=True)
shortcut_select_all = Unicode('Ctrl+A').tag(config=True)
shortcut_cut = Unicode().tag(config=True)
shortcut_copy = Unicode().tag(config=True)
shortcut_paste = Unicode().tag(config=True)
shortcut_save = Unicode().tag(config=True)
shortcut_copy_raw = Unicode('Ctrl+Shift+C').tag(config=True)


@default('shortcut_save')
def _default_shortcut_save(self):
return QtGui.QKeySequence(QtGui.QKeySequence.Save).toString()

@default('shortcut_cut')
def _default_shortcut_cut(self):
return QtGui.QKeySequence(QtGui.QKeySequence.Cut).toString()

@default('shortcut_copy')
def _default_shortcut_copy(self):
return QtGui.QKeySequence(QtGui.QKeySequence.Copy).toString()

@default('shortcut_paste')
def _default_shortcut_paste(self):
return QtGui.QKeySequence(QtGui.QKeySequence.Paste).toString()

@observe('shortcut_copy_raw')
def _on_shortcut_changed(self, change):
print(f"Shortcut for {change['name']} changed to: {change['new']}")

@observe('*')
def _on_shortcut_changed(self, change):
print(f"Shortcut for {change['name']} changed to: {change['new']}")

shortcut_manager = ShortcutManager()


def superQ(QClass):
""" Permits the use of super() in class hierarchies that contain Qt classes.
Expand Down

0 comments on commit 5d3c768

Please sign in to comment.