GithubHelp home page GithubHelp logo

Comments (6)

tlambert03 avatar tlambert03 commented on June 12, 2024 1

We'll have to look at the internal representation of the table to see how easy it is to delete a row "in place".

there's a private method that does it ... so it should just be a matter of handing the UI interaction

from affinder.

tlambert03 avatar tlambert03 commented on June 12, 2024 1

I'll play with it, but do you think that this should be part of the public API? But I'm happy to use at my own risk for now.

I can see a world in which it's added, but have a couple thoughts:

  • most of the magicgui API is about stuff that modifies the state of the widget. less so about stuff that mutates the data itself. (questions of performance aside: you could, for example, use any regular method of removing a row from your data and reset the widget.value)
  • so, if I understand correctly, this particular question seems to be more about the UI, and less about the programmatic API right? you wanted the user to be able to delete a row in the widget, right? That part seems to be a bit more about what additional buttons/keybindings we add?

anyway, I think it's important to nail down exactly what the goal is here before determining what APIs are needed.

if the table is all floats as input and I write a float in a cell, does the data become a string or does it stay float?

pretty sure it stays a float. I think that was the one type that was dealt with

As a side note, is an output widget the right model here @tlambert03?

since it's something that you want the user to be able to edit directly, it kinda seems more like an input widget? I don't know, I probably need to look into what you're discussing more, but I probably wouldn't have started with an output widget. Just rather made an additional table widget and added it to the container. Not sure about magic_class and what API's it would be offering here... what part of magic class were you thinking might help here?

from affinder.

tlambert03 avatar tlambert03 commented on June 12, 2024 1

the above flow reminded me of our discussion where you pointed out that maybe functions were the wrong model for this — when you have repeated interactions where you modify the data, rather than inputs and outputs, a class that holds all the state and gets modified might be a more natural model?

yeah, that's why I added the dataclass representation: https://pyapp-kit.github.io/magicgui/dataclasses/

from affinder.

tlambert03 avatar tlambert03 commented on June 12, 2024

I also expect that people will expect that editing the values in the table actually edits the point coordinates, but let's call that a stretch goal for now.

for that you could connect to the Table.changed signal:

it emits a dict like this:

In [6]: t.changed.connect(print)
Out[6]: <function print at 0x1039c5080>

{'data': 8, 'row': 1, 'column': 1, 'column_header': 'b', 'row_header': '1'}
{'data': 12, 'row': 0, 'column': 1, 'column_header': 'b', 'row_header': '0'}
{'data': None, 'row': 1, 'column': 0, 'column_header': 'a', 'row_header': '1'}
{'data': 34, 'row': 1, 'column': 0, 'column_header': 'a', 'row_header': '1'}

probably one of the first annoyances you'll run into is restriction/validation on column types (pyapp-kit/magicgui#216)

from affinder.

jni avatar jni commented on June 12, 2024

there's a private method that does it ... so it should just be a matter of handing the UI interaction

I'll play with it, but do you think that this should be part of the public API? But I'm happy to use at my own risk for now.

probably one of the first annoyances you'll run into is restriction/validation on column types

Thanks for the link! Since these are all float columns I don't expect to run into it — if a user types some non-float thing I'll happily ignore it and restore the table to the previous value. 😂 If I understand the issue correctly? Actually maybe I don't — if the table is all floats as input and I write a float in a cell, does the data become a string or does it stay float? And if the latter, what happens if I type some text?

As a side note, is an output widget the right model here @tlambert03? Or maybe I should move to a magic_class...? I'm seeing now that the result_widget appears to be "hardcoded" to a LineEdit widget? Or is that just a docstring issue?

from affinder.

jni avatar jni commented on June 12, 2024

you could, for example, use any regular method of removing a row from your data and reset the widget.value

you wanted the user to be able to delete a row in the widget, right? That part seems to be a bit more about what additional buttons/keybindings we add?

Well, yes. Basically, my plan before you pointed me to that method, after playing around with backspace clearing the whole row, was indeed to hook into the Table.changed event, check for any rows that are all None, and then updating the whole table. This way, in my specific widget, clearing a row with backspace would immediately delete it. So, yes, it's about keybindings, but in the absence of keybindings, I could just use an API (ideally public), which could have a performance advantage vs updating the whole table, depending on the internal implementation.

pretty sure it stays a float. I think that was the one type that was dealt with

🥳

Edit: accidentally pressed cmd enter, rest of response:

since it's something that you want the user to be able to edit directly, it kinda seems more like an input widget?

Not sure about magic_class and what API's it would be offering here... what part of magic class were you thinking might help here?

Sure, I was calling it an output widget because affinder is an early (maybe the earliest) magic_factory implementation, you might recall that you added the self-reference in magic_factory for this 😃, so it's a function that takes in image layers, and then makes points layers, and the user adds points — at which point we get a table. So from a functional description, it seems like an output.

I brought up magic_class because the above flow reminded me of our discussion where you pointed out that maybe functions were the wrong model for this — when you have repeated interactions where you modify the data, rather than inputs and outputs, a class that holds all the state and gets modified might be a more natural model?

from affinder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.