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

added uiEntry + fixed a wrong function call #27

Merged
6 commits merged into from
Oct 22, 2016
Merged

added uiEntry + fixed a wrong function call #27

6 commits merged into from
Oct 22, 2016

Conversation

superzazu
Copy link
Contributor

@superzazu superzazu commented Oct 22, 2016

I added uiEntries + fixed a wrong function call in pylibui/libui/checkbox.py

In the file examples/entry.py, I temporarily commented app.close() to avoid crashes (and added a comment that links to the issue #18)

Note: the deletion of "raise" in tests is already done in another branch (here). I'll make more PR (this one among two others which fixes #23 & #24) when this one is merged

What do you guys think ?

"""
Sets the text of the entry.

:param text: the text of the entry
Copy link

Choose a reason for hiding this comment

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

What about making this just string instead of the text of the entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right


def getReadOnly(self):
"""
Sets whether the entry is read only or not.
Copy link

Choose a reason for hiding this comment

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

This should be Gets...

Copy link

Choose a reason for hiding this comment

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

Or Returns 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops

:return: string
"""

return bool(clibui.uiEntryReadOnly(entry))
Copy link

Choose a reason for hiding this comment

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

This cast should be in wrapper I think, and return value should be int instead of string, in docstring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right. The reason I did not do it is simply because I wrote the code before the issue was submitted. (24 Jun)
I can fix it on this PR; however I already did another branch -which I will submit in a PR after this one- which removes all the casts in pylibui/libui/*.py files. It's which one you prefer :-)

Concerning the "int" instead of "string", you are right

Copy link

Choose a reason for hiding this comment

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

I see. It's okay, we can merge this one, then send the others 👍

Sets whether the entry is read only or not.

:param entry: uiEntry
:param read_only: bool
Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right

super().setUp()
self.entry = Entry()
self.password_entry = PasswordEntry()
self.search_entry = SearchEntry()
Copy link

Choose a reason for hiding this comment

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

Did you used password_entry and search_entry in this file, am I overlooking them? If you didn't use I think we can remove them because they all share the same functions, am I wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I do not need these two variables. I just instanced them here at first, but don't need it.

self.assertEqual(self.entry.getReadOnly(), False)

def test_onChanged_is_called(self):
raise # TODO: how do we simulate mouse press ?
Copy link

Choose a reason for hiding this comment

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

If we will remove all lines like this, why did you add one here, maybe a mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as comment above, because I wrote the code before. I already did another commit to remove these raises (https://github.com/superzazu/pylibui/commit/4a4f7f6e66db6506a9eef020a372e3595ed61eb5)

@superzazu
Copy link
Contributor Author

Okay, thanks for the feedback (and sorry for the typos...), I'm going to do another commit :-)

As I said, concerning the two comments about" removing the raise in tests" + "putting the casts in controls"; it is because this code is a bit old.
I thought it'd be cleaner to remove them all at once in specific commits (already wrote these commits, will submit two PRs as soon as this one is merged). However, I can remove them in this PR if you'd like. :)

@ghost
Copy link

ghost commented Oct 22, 2016

No, it will be better if they come in another PR. Sorry for comments, I haven't fully understood why you're mentioning about other two PRs in this one, now it's clear 👍

@ghost
Copy link

ghost commented Oct 22, 2016

BTW, what is your output after executing all test suite? It seems you've fixed the segmentation thing in checkbox, for me.

@superzazu
Copy link
Contributor Author

On my mac, I never had any problems with segfaults while running tests (only when running examples). Here's the complete output:

.E.....E.........E.........E..E.........
======================================================================
ERROR: test_onClick_is_called_when_user_presses_button (tests.test_button.ButtonTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nikkos/Documents/pylibui/tests/test_button.py", line 28, in test_onClick_is_called_when_user_presses_button
    raise  # TODO: how do we simulate mouse press ?
RuntimeError: No active exception to reraise

======================================================================
ERROR: test_onToggle_is_called_when_user_toggles_checkbox (tests.test_checkbox.CheckboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nikkos/Documents/pylibui/tests/test_checkbox.py", line 42, in test_onToggle_is_called_when_user_toggles_checkbox
    raise  # TODO: how do we simulate mouse press ?
RuntimeError: No active exception to reraise

======================================================================
ERROR: test_onChanged_is_called (tests.test_entry.EntryTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nikkos/Documents/pylibui/tests/test_entry.py", line 41, in test_onChanged_is_called
    raise  # TODO: how do we simulate mouse press ?
RuntimeError: No active exception to reraise

======================================================================
ERROR: test_onChanged_is_called_when_user_changes_sliders_value (tests.test_slider.SliderTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nikkos/Documents/pylibui/tests/test_slider.py", line 29, in test_onChanged_is_called_when_user_changes_sliders_value
    raise  # TODO: how do we simulate mouse press ?
RuntimeError: No active exception to reraise

======================================================================
ERROR: test_onChanged_is_called_when_user_changes_spinbox_value (tests.test_spinbox.SpinboxTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/nikkos/Documents/pylibui/tests/test_spinbox.py", line 29, in test_onChanged_is_called_when_user_changes_spinbox_value
    raise  # TODO: how do we simulate mouse press ?
RuntimeError: No active exception to reraise

----------------------------------------------------------------------
Ran 40 tests in 0.170s

FAILED (errors=5)

@superzazu
Copy link
Contributor Author

Erm, I'm dumb. :D Of course I did something to the checkboxes : f60452d

I was calling a wrong method (uiButtonOnClicked instead of uiCheckboxOnToggled). That may be the problem you were having while running tests.

I commited the fixes to these typos.

@ghost
Copy link

ghost commented Oct 22, 2016

Weird. This one is just testing control, FYI. And I still have an segfault about while testing window.

.....F
======================================================================
FAIL: test_visible_initial_value (tests.test_control.ControlTest)
Tests the control's `visible` initial value is True.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/enes/Code/GitHub/spzzpyl/tests/test_control.py", line 19, in test_visible_initial_value
    self.assertEqual(self.control.getVisible(), True)
AssertionError: 0 != True

----------------------------------------------------------------------
Ran 6 tests in 0.046s

FAILED (failures=1

@ghost
Copy link

ghost commented Oct 22, 2016

I saw your change and I'm now suspecting about another wrong call in window.

@superzazu
Copy link
Contributor Author

superzazu commented Oct 22, 2016

Weird. I don't have this problem here:

nikkos@debbie:pylibui $ p -m unittest tests/test_control.py              master
......
----------------------------------------------------------------------
Ran 6 tests in 0.068s

OK

I checked window files, I did not see anything obvious like the "wrong call" I just fixed.

EDIT: I noticed there is no "bool" cast in "uiControlVisible" nor in "Control.getVisible()". Maybe is it the source of the problem ? It's weird...

@ghost
Copy link

ghost commented Oct 22, 2016

Let's focus on this PR and merge it, I will try to find the problem soon.

password_entry = PasswordEntry()

vbox = VerticalBox()
vbox.setPadded(10)
Copy link

Choose a reason for hiding this comment

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

Why are you using 10 here? I thought it expects a bool value here, am I wrong?

Copy link
Contributor Author

@superzazu superzazu Oct 22, 2016

Choose a reason for hiding this comment

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

Yes, is it a mistake. I have to correct this

By the way, I think we should replace the occurrences of ".setMargined(1)" / ".setPadded(1)" by something like ".setMargined(True)" (in the examples). I'll open an issue for that.

@ghost ghost merged commit 1cfa09f into joaoventura:master Oct 22, 2016
@ghost
Copy link

ghost commented Oct 22, 2016

Thanks for PR :octocat:

@ghost
Copy link

ghost commented Oct 25, 2016

See, you have another 10 on the line window.setMargined, please fix it as
well.

22 Eki 2016 19:07 tarihinde "Nicolas Allemand" [email protected]
yazdı:

@superzazu commented on this pull request.

In examples/entry.py #27:

  • def onChanged(self, data):
  •    print('entry changed!')
    
    +app = App()
    +
    +window = MyWindow('Entry example')
    +window.setMargined(10)
    +
    +entry = MyEntry()
    +search_entry = SearchEntry()
    +password_entry = PasswordEntry()
    +
    +vbox = VerticalBox()
    +vbox.setPadded(10)

Yes, is it a mistake. I have to correct this

By the way, I think we should replace the occurrences of ".setMargined(1)"
by ".setMargined(True)", and so on (as always, only in the pythonic
wrapper). I'll open an issue for that.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#27, or mute the thread
https://github.com/notifications/unsubscribe-auth/AQFXIoYM8mBIR4G1QNigRx3wlPlmRG91ks5q2jTBgaJpZM4Kdziy
.

@superzazu
Copy link
Contributor Author

The setPadded and setMargined calls have been corrected in #31 . I searched in the project (master) and did not find any occurrences to setPadded(10) and setMargined(10). Maybe I missed something ?

@ghost
Copy link

ghost commented Oct 26, 2016

Sorry for that. I've sent that comment four days ago via Gmail. It took a bit late to appear here 😑 I was talking about line 30 in entry example.

@ghost ghost mentioned this pull request Dec 21, 2016
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove unwanted casting in wrappers
1 participant