question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QTimeEdit widgets

See original GitHub issue

Hey @tlambert03

first of all: Happy New Year! 🄳

I just programmed a magicgui-annotated function that has a time parameter (hh:mm:ss). When starting up the GUI, I receive this warning:

UserWarning: Unable to find the appropriate widget for function "_clearcontrol_loader", arg "time", type "<class 'datetime.time'>". Falling back to LiteralEvalEdit widget.
  warnings.warn(

When entering a time then in the fallback QLineEdit field, this error shows up:

ERROR:root:Unhandled exception:
Traceback (most recent call last):
  File "C:\Users\rober\miniconda3\envs\clustering\lib\site-packages\magicgui\core.py", line 526, in __call__
    _kwargs = self.current_kwargs
  File "C:\Users\rober\miniconda3\envs\clustering\lib\site-packages\magicgui\core.py", line 500, in current_kwargs
    return {param: getattr(self, param) for param in self.param_names}
  File "C:\Users\rober\miniconda3\envs\clustering\lib\site-packages\magicgui\core.py", line 500, in <dictcomp>
    return {param: getattr(self, param) for param in self.param_names}
  File "C:\Users\rober\miniconda3\envs\clustering\lib\site-packages\magicgui\core.py", line 96, in __get__
    return api.getter_setter_onchange(widget).getter()
  File "C:\Users\rober\miniconda3\envs\clustering\lib\site-packages\magicgui\_qt\widgets\eval_lineedit.py", line 12, in text
    return literal_eval(super().text())
  File "C:\Users\rober\miniconda3\envs\clustering\lib\ast.py", line 59, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "C:\Users\rober\miniconda3\envs\clustering\lib\ast.py", line 47, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    1:00:00
     ^
SyntaxError: invalid syntax

My use case is quite specific: I’d like to select a defined timepoints from a larger dataset for loading and we image over multiple days with variable temporal resolution.

Nevertheless, I think supporting QTimeEdit as widget type would be cool.

Let me know if I can help making this happen.

No hurry btw. I do have a functional workaround for now.

Cheers, Robert

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tlambert03commented, Jan 1, 2021

yeah, sorry, it was a big change. v0.1.x was a great proof of principle, but I regretted a lot of things and now is the time to change. Things should start settling down now. in v0.2.1+ you can set min/max with {'min': -1000, 'max': 1000}. After a little discussion, we chose to go with the ipywidgets API over the Qt API, to stick with the general python datascience vibe.

In general, if you’re wondering what parameter/widget specific options you can use, you can look at the documentation for the constructor of the corresponding widget type. For instance, for your float values, you’d be able to use any of the options for the FloatSpinBox widget (or, more generally, any of the Ranged Widgets).

We can gradually add back things like displayFormat for strings, or validators and stuff like that, but we’ll do so in an explicit magicgui API way, rather than an implicit ā€œpass to Qtā€ sort of way.

1reaction
tlambert03commented, Jan 1, 2021

Hey @haesleinhuepf! That should definitely be included and will be easy to do.

In the meantime, there is a DateTimeEdit widget if you annotate using datetime.datetime instead of datetime.time (and deal with the annoyance of having the date in their as well)

Read more comments on GitHub >

github_iconTop Results From Across the Web

QTimeEdit Class | Qt Widgets 6.4.1
The QTimeEdit class provides a widget for editing times based on the QDateTimeEdit widget. More... Header: #include <QTimeEdit>. CMake: find_package(Qt6Ā ...
Read more >
QTimeEdit Class | Qt Widgets | Qt Documentation (Pro) - Felgo
The QTimeEdit class provides a widget for editing times based on the QDateTimeEdit widget. Many of the properties and functions provided by QTimeEdit...
Read more >
Qt 4.8: QTimeEdit Class Reference
The QTimeEdit class provides a widget for editing times based on the QDateTimeEdit widget. Many of the properties and functions provided by QTimeEdit...
Read more >
QTimeEdit Class | Qt Widgets 5.12.3
The QTimeEdit class provides a widget for editing times based on the QDateTimeEdit widget. Many of the properties and functions provided by QTimeEdit...
Read more >
QTimeEdit - Codetorial
The QTimeEdit widget allows users select and edit time. We'll create a QTimeEdit object in this example and set it to display as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found