-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR: Add the possibility to rename IPython consoles #4092
PR: Add the possibility to rename IPython consoles #4092
Conversation
@tjolive awesome, thanks for the help! Could you paste some screenshots of the process or maybe an animation? Maybe use something like http://www.cockos.com/licecap/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made some style and code comments ;-)
spyder/plugins/ipythonconsole.py
Outdated
@@ -1509,3 +1515,8 @@ def _create_client_for_kernel(self, connection_file, hostname, sshkey, | |||
|
|||
# Register client | |||
self.register_client(client) | |||
|
|||
def tab_name_editor(self): | |||
"""Triggers the tab name editor""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add a .
at the end a docstring is a sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trigger (without the s).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
spyder/widgets/tabs.py
Outdated
@@ -48,6 +48,12 @@ def __init__(self, parent, ancestor): | |||
self.setAcceptDrops(True) | |||
self.setUsesScrollButtons(True) | |||
|
|||
# Tab name editor | |||
self.rename_tabs = rename_tabs | |||
if self.rename_tabs is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.rename_tabs is True
this is redundant, we can just use
if self.rename_tabs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually I use this as an implicit "assert isinstance(rename_tabs, bool)" but I'll align with your code style
spyder/widgets/tabs.py
Outdated
self.rename_tabs = rename_tabs | ||
if self.rename_tabs is True: | ||
# Creates tab name editor | ||
self.tab_name_editor = EditTabNamePopup(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is only getting created if true, so maybe we should define a
self.tab_name_editor = None
above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, missed that
spyder/widgets/tabs.py
Outdated
|
||
|
||
def mouseDoubleClickEvent(self, event): | ||
"""Override Qt method to trigge the tab name editor""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
at the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trigger (missing r)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
spyder/widgets/tabs.py
Outdated
# Tab is valid, call tab name editor | ||
self.tab_name_editor.edit_tab(index) | ||
else: | ||
# Even is not interessant, raise to parent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Event ? missed a t?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, thanks for spotting
spyder/widgets/tabs.py
Outdated
"""Popup on top of the tab to edit its name""" | ||
|
||
def __init__(self, parent): | ||
QLineEdit.__init__(self, parent=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add the same docstring here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
spyder/widgets/tabs.py
Outdated
self.setFrame(False) | ||
|
||
# Align with tab name | ||
self.setTextMargins(9, 0, 0, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to check how this looks on other OS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are these cross-platform tests usually performed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks nice on Linux 😄
I only noticed the QLineEdit a little oversized when the tab isn't active (you need to double-click a little fast in a non active tab)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you post some video? On OSX works also (see below comment).
But I can't see the cursor, will fix it.
spyder/widgets/tabs.py
Outdated
self.setTextMargins(9, 0, 0, 0) | ||
|
||
# Track with tab is being edited | ||
self.tab_index = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have a similar structure to how other widgets work
# Instance variables
# Widgets
# Widget setup
# Layouts
# Signals and slots
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have any template for such documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, but most of the widgets follow that convention
class SomeWidget():
# Variables
self.some_variable = None
# Widgets
self.super_widget = SomeSuperWidget()
# Widget setup
self.super_widget.setSomething(True)
# Layouts
layout = QVBoxLayout()
layout.addWidget(self.super_widget)
self.setLayout(layout)
# Signals and slots
self.super_widget.sig_some_signal.connect(self.some_other_method)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goanpeca We need to document that somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will align the code with this.
Took the liberty to add to the wiki the docstring format as mentioned here:
https://github.com/spyder-ide/spyder/wiki/Dev:-Coding-Style#docstrings
spyder/widgets/tabs.py
Outdated
self.tab_index = None | ||
|
||
def eventFilter(self, widget, event): | ||
"""Catches clicks outside the object and ESC key press""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
at the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catch (infinitive form)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
spyder/widgets/tabs.py
Outdated
return QLineEdit.eventFilter(self, widget, event) | ||
|
||
def edit_tab(self, index): | ||
"""Activates the edit tab""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
at the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Activate (infinitive form)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on Linux and works well. I just left some style comments.
spyder/plugins/ipythonconsole.py
Outdated
@@ -756,6 +756,10 @@ def get_plugin_actions(self): | |||
_("Open a new IPython console connected to an existing kernel"), | |||
triggered=self.create_client_for_kernel) | |||
|
|||
rename_tab_action = create_action(self, _("&Rename tab"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just "Rename tab"
(without the &) is ok, this menu won't be accessible using shortcuts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
spyder/plugins/ipythonconsole.py
Outdated
@@ -1509,3 +1515,8 @@ def _create_client_for_kernel(self, connection_file, hostname, sshkey, | |||
|
|||
# Register client | |||
self.register_client(client) | |||
|
|||
def tab_name_editor(self): | |||
"""Triggers the tab name editor""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trigger (without the s).
spyder/widgets/tabs.py
Outdated
|
||
|
||
def mouseDoubleClickEvent(self, event): | ||
"""Override Qt method to trigge the tab name editor""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trigger (missing r)
spyder/widgets/tabs.py
Outdated
self.tab_index = None | ||
|
||
def eventFilter(self, widget, event): | ||
"""Catches clicks outside the object and ESC key press""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catch (infinitive form)
spyder/widgets/tabs.py
Outdated
return QLineEdit.eventFilter(self, widget, event) | ||
|
||
def edit_tab(self, index): | ||
"""Activates the edit tab""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Activate (infinitive form)
Tested on OSX Sierra 10.12.2 (16C67, Python 2.7.13 64bits, Qt 5.6.2, PyQt5 5.6 on Darwin When editing, the text is not as aligned as in windows, maybe because the close icon is rendered on the left. In any way it looks nice and intuitive. The cursor is also missing in OSX, did you have the same behaviour on linux? |
This is looking great |
Hi guys, new commit addresses all feedback (I hope) and adds a blinking cursor, which I felt was missing. But now the Travis CI is failing on something that I didn't change and was working on the first commit.
Any ideas? Do you need any more changes on this PR? Cheers, |
Please merge with the 3.x branch to fix that error. |
@tjolive I think you made a mistake :-|, cause now the PR is $^%^ You were supposed to merge with 3.x not master :-( |
Argh, I see, I tried to do via the github desktop app and it defaulted to master. Reverting and merging with 3.x... |
If you are not sure how to fix this @tjolive, just start from scratch on a new PR and be more careful next time ;-) |
Revert was ok. Merged with 3.x but it didn't trigger a re-check... Will try something else, otherwise I'll issue a new PR |
@gaw89: I have this as closed on my end, the coding part is done and
tested, now it's up to the owner to integrate this.
…On 29 June 2017 at 19:34, gaw89 ***@***.***> wrote:
@tjolive <https://github.com/tjolive>, are you planning to come back to
this PR at some point to see if it can get pushed through? I would be very
interested in having this feature available in Spyder.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4092 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYLgJTYgdqwzAdNg6vKSS4gMfMBgymg5ks5sI-BDgaJpZM4L03CB>
.
|
@tjolive, I see. I asked you because of the conflicting files listed in the PR status. Is that your responsibility to figure out the conflict? @ccordoba12, what needs to be done in order to get this PR accepted? If I can help, I'm happy to do so. |
@gaw89: i see the conflict now, i don't recall having it when i concluded
the coding some months ago. Let me take a look and revert.
Anyway, @ccordoba12 <https://github.com/ccordoba12> can we have your view
on this one?
On 30 Jun 2017 14:33, "gaw89" <notifications@github.com> wrote:
@tjolive <https://github.com/tjolive>, I see. I asked you because of the
conflicting files listed in the PR status. Is that your responsibility to
figure out the conflict?
@ccordoba12 <https://github.com/ccordoba12>, what needs to be done in order
to get this PR accepted? If I can help, I'm happy to do so.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4092 (comment)>,
or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AYLgJWagatd4i2flLc8YMmJEI_htm8lIks5sJOr_gaJpZM4L03CB>
.
|
@tjolive, I see. Perhaps the conflict cropped up since you submitted the PR. If there's anything I can do to help, let me know. This feature would be incredibly useful for me and a great addition to an already great IDE! |
@tjolive, don't worry about the conflict. We need to fix a couple of things before merging your work, but we'll keep working on your branch. |
@gaw89, this will be part of Spyder 3.2. |
@ccordoba12, awesome! I'll keep an eye out for it. Is there a release date for 3.2? |
Hopefully in a couple of weeks. |
Conflicts: - spyder/plugins/ipythonconsole.py - spyder/widgets/ipythonconsole/client.py
…name is possible or not
@tjolive @ccordoba12 Is there an option to rename the tabs from the command line itself? E.g. |
No, there isn't. |
@ccordoba12 Is it technically possible? E.g. can the spyder gui elements be controlled from the ipython console? If so, how, then I can make a PR to create this functionality. |
Fixes #1962
Tabs and TabBar classes (spyder/widgets/tabs.py) accept now a parameter (rename_tabs) to enable the tab renaming - defaults no disable but IPythonConsole instantiates Tabs with rename_tabs=True. If activated, the TabBar creates a new object EditTabNamePopup which is triggered by right double clicking on a tab.
The EditTabNamePopup instantiates QLineEdit and places it on top of the tab when activated. While activated, if the user clicks outside the QLineEdit of presses the ESC key, the changes are discarded (i.e. QLineEdit gets invisible).
Structure: IPythonConsole > Tabs > TabBar > EditTabNamePopUp
Some details that could be further improved: