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

Please provide forced (synchronous) redraw from Julia #32

Closed
RalphAS opened this issue Jan 8, 2017 · 6 comments
Closed

Please provide forced (synchronous) redraw from Julia #32

RalphAS opened this issue Jan 8, 2017 · 6 comments

Comments

@RalphAS
Copy link

RalphAS commented Jan 8, 2017

I am building an application which triggers a Julia function that runs for several minutes and provides status updates as it goes. I want to show those updates in the GUI, but I have not found a way to get the Qt window redrawn before the Julia function returns. The objects I am aiming to update are Text objects and JuliaDisplay panels. All I see now is the final version of these. (I have tried interposing sleep() and readline() calls in Julia to yield to anything scheduled, and to calling the show() method of the ApplicationWindow from a signal, all to no avail.) For now, I would be content with some way to call into Qt to force a redraw with up-to-date object states. I am using Qt 5.7.1 on Linux, Julia 0.5 and QML 0.2.0.

barche added a commit that referenced this issue Jan 8, 2017
@barche
Copy link
Collaborator

barche commented Jan 8, 2017

I have added an example for this in example/progressbar.jl (QML in example/qml/progressbar.qml)

The key is to use the QTimer and call a function every time it fires. On the Julia side, you can then use a task to run a simulation step when the timer fires. As long as this step runs, the GUI is blocked and between each step the GUI is updated, including processing of input events.

The example should also work on QML.jl 0.2.0, if you prefer not to Pkg.checkout. If you do Pkg.checkout, you need to do that for CxxWrap too and run Pkg.build("QML").

@RalphAS
Copy link
Author

RalphAS commented Jan 8, 2017

Thanks, this is a reasonable workaround. I got a toy case more like my project to work with tasks and a timer, following your example. (It will take some time to fit the pattern into my real project.) I did observe that with the default timer only about half of the window redraws were actually done (both for my toy case and yours). I found that setting timer.interval = 10 before starting the timer gets every update to redraw in the simple cases.

@barche
Copy link
Collaborator

barche commented Jan 9, 2017

Yes, I had noticed that when taking smaller steps it also jumps quickly to about 20% and then moves slowly. Ideally this should be done using threads of course, but the obstacles there are that all Julia code must run in the main thread for now, and for OS X the GUI too has too run in the main thread. The QTimer solution is also officially recommended in the Qt docs, however.

@JeffreySarnoff
Copy link

I tried this example on Linux with both v0.5 and nightly.
When I press the start button, this happens:

LLVM ERROR: Inline asm not supported by this streamer because we don't have an asm parser for this target

@barche
Copy link
Collaborator

barche commented Jan 11, 2017

Are you using a Gallium-3D based graphics driver by any chance? If so, setting the environment variable:

export GALLIUM_DRIVER="softpipe"

before running Julia should fix it.

@ufechner7
Copy link
Member

Closing this, because example how to do this is provided now.

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

No branches or pull requests

4 participants