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

Binding a callback function to a ToggleFrame button #602

Closed
kencomputes opened this issue Nov 4, 2019 · 5 comments
Closed

Binding a callback function to a ToggleFrame button #602

kencomputes opened this issue Nov 4, 2019 · 5 comments
Milestone

Comments

@kencomputes
Copy link

kencomputes commented Nov 4, 2019

Let me start by thanking you for all of the hard work that has been put into appJar! I've really been enjoying working with it so far.

I have been reading through the documentation and the source code and can't seem to figure out how to make my app's window size increase/decrease when a toggleFrame is toggled. This seems like it should be simple, but I can't seem to figure out a way to bind another callback function to my toggleFrame's button. I know I could register an event and constantly check the state of my frame with .getToggleFrameState and make adjustments based off of that, but that seems like overkill for my use case.

I read in pythonEvents about "Registering Other Event Types" with app.getEntryWidget("widget_name").bind("<FocusOut>", function_name, add="+"). I was trying to add something like .bind('<Button-1>', resizeWindow) but I can't seem to figure out how to actually get my ToggleFrame object or its button so I can try binding an event to it. I also can't seem to find any functionality for checking whether or not a widget or frame is hidden. Does this exist?

Any help with this would be much appreciated!

I also have a few notes regarding the documentation. I think it might be helpful to note that while getMeter() returns the value as a float between 0.0 and 1.0, setMeter() expects the value as an int or float between 0 and 100. This threw me off for a minute. It might also be helpful to note somewhere that the default window BG color is gray94 and perhaps add a link to the TK color constants.

Finally, under pythonWidgetOptions I think it would be helpful to provide more info regarding .set XXX Width(name, value) and .set XXX Height(name, value). I was trying to put some DirectoryEntry widgets into a ScrollPane. Through trial and error I landed on a width value of 71 to make my DirectoryEntry span the entirety of the ScrollPane, but I have no idea what that value is actually referring to (it doesn't appear to be a pixel or percentage value since the window width is 800px and the DirectoryEntry spans almost all of that).

Again, thanks for all of the hard work that has gone into developing this library and thanks in advance for any help you can provide!

Version Information


appJar: 0.94.0 Python: 3.7.2 TCL: 8.6, TK: 8.6 Platform: Windows pid: 26464
locale: en_US

@jarvisteach jarvisteach added this to the 1.0 milestone Nov 5, 2019
@jarvisteach
Copy link
Owner

jarvisteach commented Nov 5, 2019

Hi @kencomputes - thanks for the feedback!

Currently there is no way to register a change event on toggle frames - but will be easy to add in to the next release.

When you create the ToggleFrame, it should be returned, so you can get at it that way:

with app.toggleFrame as tf:
    tf.toggleButton ...

Or:

tf = app.startToggleFrame()

@jarvisteach
Copy link
Owner

I'll get the meter documents updated so that they are clearer.

@jarvisteach
Copy link
Owner

I think any widgets where text entry happens behave a bit strangely when it comes to their dimensions. I don't quite remember, but I think 71 may be something to do with the number of characters and perhaps the width of a character in the particular font...

I'll need to do some research and check back through the code...

@kencomputes
Copy link
Author

@jarvisteach Thanks for the quick response! I think that being able to register callback events on a toggle frame's state change will be useful. For the meantime I've just registered an event loop to check for a few flags that I'm setting whenever I show/hide different widget frames in my UI.

Is there a method to check whether a widget or frame is hidden or visible? It's not a major issue since I can just set boolean flags whenever I show or hide something, but I imagine this could be a useful method in some cases.

Regarding the text entry widget widths, it looks like you're correct about the width value referring to the number of characters that can be displayed without scrolling. I just tested my directory entry field and it fits exactly 71 characters. Thanks for clarifying that for me!

jarvisteach added a commit that referenced this issue Mar 14, 2020
Ability to register 'change' event on toggle frame. Some work on PagedWindow event

Issue #602
jarvisteach added a commit that referenced this issue Mar 14, 2020
@jarvisteach
Copy link
Owner

This is in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants