Skip to content
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

Merge vnotebook into master to add VNotebook widget #53

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

sbordeyne
Copy link
Member

@sbordeyne sbordeyne commented Dec 8, 2019

PR Details:

Description

A Notebook with vertical tabs

Checklist

  • Widget in a separate file in the appropriate folder
  • Widget functions properly on both Windows and Linux
  • Widget code includes docstrings with parameter descriptions
  • Included an example file in /examples
  • Widget is covered by unitttests in /tests
  • Widget includes required assets files
  • Reference to widget in AUTHORS.md
  • Entry in sphinx documentation

Dogeek and others added 4 commits December 8, 2019 22:30
Rename TestVNotebook.add_test_frame() to prevent this method to be
executed as part of the tests with no arguments which lead to the
previous error.
@j4321
Copy link
Member

j4321 commented Dec 18, 2019

I think the error in the python 3.4 test with Appveyor is because ttkthemes is used in the example_vnotebook.py and probably the older version of pip or setuptools does not recognize requirements properly so we should add it explicitly in .appveyor.yml. However I am reluctant to add ttkthemes as a dependency just for the sake of one example, we could use the 'clam' theme instead.

@sbordeyne sbordeyne requested a review from j4321 December 19, 2019 01:25
Copy link
Member

@j4321 j4321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The widget does not seems fully finished, there is the callback method which is documented but not implemented and the add() and insert() method behavior should be improved for already existing tabs. I will help addressing my comments.

:return: ID for the new Tab
:rtype: int
"""
tab_id = kwargs.pop("id", hash(child))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have noticed a weird behavior with the add() method: When adding a widget which is already inside the notebook, a new tab is created, but the old one is not deleted and they are both activated simultaneously. I think we should add code to check whether the widget is already in the notebook and just update its properties with kwargs like the ttk.Notebook does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fixed this

check my latest commit

:param compound: Location of the Buttons
:type compound: str
:param callback: Callback called upon change of Frame
:type callback: callable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callback option does not seem to have been implemented yet, is that so?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, wouldn't it be more consistent with the ttk.Notebook widget to use a virtual event, e.g. <<VNotebookTabChanged>> instead of a callback?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. A virtual event should be the way to go as it's more consistent with the rest of tkinter and ttk. It's also much easier to implement, and easier to document. Now, what data should the event argument hold in that case?

Copy link
Member

@j4321 j4321 Dec 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I make tkinter print the <<NotebookTabChanged>> event, I get <VirtualEvent event x=0 y=0> so I think we don't have to pass any specific argument to the event, the new tab id and everything else can be recovered from the notebook's methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the 'callback' argument from the documentation, there didn't seem to be any code to remove with that change. I'll let you handle the event generation since you seem to be doing that.

for option in self.options:
attr = "_{}".format(option)
setattr(self, attr, kwargs.pop(option, getattr(self, attr)))
return ttk.Frame.configure(**kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using .configure() I get the error

Traceback (most recent call last):
  File "/media/DATA/Divers/ttkwidgets/tests/test_vnotebook.py", line 77, in test_configure
    notebook.config(padding=6)
  File "/media/DATA/Divers/ttkwidgets/ttkwidgets/frames/vnotebook.py", line 264, in configure
    setattr(self, attr, kwargs.pop(option, getattr(self, attr)))
AttributeError: 'VNotebook' object has no attribute '_takefocus'

I think we need to had the line
self._takefocus = kwargs.pop("takefocus", False)
in __init__() to fix that. And the one for callback is missing as well but the option is not implemented yet.

Moreover, there is a self missing at l. 265: return ttk.Frame.configure(self, **kwargs)

Finally, if all arguments are in self.options, then kwargs is emptied and therefore the dict of all the frame options is returned which is a bit weird.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the self missing, shouldn't we just use super() instead of calling ttk.Frame directly ? It's much cleaner after all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can use super() though I have not taken the habit to use it yet, but this does not solve the issue of the behavior of the function. I don't think that many people use .configure("<key>") since the output is not really usable in python (e.g. ('width', 'width', 'Width', 0, 0)). So maybe we can return nothing and just use the method for its main purpose which is to change the options of the widget.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the call to ttk.Frame, in favor of a super() call. We could just return whatever ttk.Frame.configure returns, that way it stays consistent with the rest of the tkinter framework.

from tkinter import ttk
# Module to test
from ttkwidgets.frames import VNotebook

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add some more tests, like for the configure() method. I can write some.

ttkwidgets/frames/vnotebook.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants