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

When the program is not responding, if you accidentally click on the GUI during the process, it will run again after running. #3291

Open
13299118606 opened this issue Oct 12, 2023 · 2 comments
Labels
enhancement Feature requests and enhancements interaction anything event related Observables

Comments

@13299118606
Copy link

13299118606 commented Oct 12, 2023

When the program is not responding, if you accidentally click on the GUI during the process, it will run again after running. Is there any way to avoid this phenomenon.

GLmakie is very powerful. I sometimes use it to design GUI directly, but there are small problems during the process. For example, the following program is designed. When the click program is short (run 1s), the response is very fast. But when the program takes a long time (run 10s), the interface will remain unresponsive. During this period, if the mouse is accidentally clicked, there will be no response. The GUI will automatically run the next program after the program is finished running. The program itself takes a long time. I want to pause it as if the program is running on other threads. Ctrl+C has no effect. Is there any way to avoid this phenomenon?
I thought of three ideas

1. For unresponsive programs, if you click on the interface during this process, it will click to a other position by default. This will avoid the bug that the program identifies as clicking the same again.
2. Design an additional judgment condition for the button function. Only by pressing and releasing the mouse for a short time can the program be executed.
3. There are ways to pause and terminate programs running through the GUI. For example Ctrl+C.

The program code is

f = GLMakie.Figure()
btrun =Button(f[1,1],label="run 1s",tellwidth=false)

on(btrun.clicks) do s
    println("1button clicks: ",s)
    sleep(1)
end
btrun2 =Button(f[1,2],label="run 10s",tellwidth=false)

on(btrun2.clicks) do s
    println("10button clicks: ",s)
    sleep(10)
end

f

When the interface of the program becomes unresponsive, it remains stuck on this interface.
image
The output is, clicks 2 3 is the result of automatic operation

10button clicks: 1
10button clicks: 2
10button clicks: 3
@13299118606 13299118606 added the enhancement Feature requests and enhancements label Oct 12, 2023
@SimonDanisch
Copy link
Member

On the latest makie version, we have:

       f = GLMakie.Figure()
       btrun =Button(f[1,1],label="run 1s",tellwidth=false)

       Makie.on_latest(btrun.clicks) do s
           println("1button clicks: ",s)
           sleep(1)
       end
       btrun2 =Button(f[1,2],label="run 10s",tellwidth=false)

       Makie.on_latest(btrun2.clicks) do s
           println("10button clicks: ",s)
           sleep(10)
       end
       scatter(f[2, :], 1:4)
       f

@13299118606
Copy link
Author

Makie.on_latest

This is indeed very useful. Thank you very much. There is another problem. Programs run using the GUI cannot be paused through Ctrl+C. Programs run through the direct repl command can be paused.

Normal code runs

     for i=1:10
         println("run progrem: ",i)
         sleep(1)
     end

julia>run progrem: 1
run progrem: 2
^C
ERROR: InterruptException:

GUI program:

f = GLMakie.Figure()
btrun =Button(f[1,1],label="run 10s",tellwidth=false)

Makie.on_latest(btrun.clicks) do s
     for i=1:10
         println("button run progrem: ",i)
         sleep(1)
     end
end
f

Press Ctrl + C after clicking the button:

button run progrem: 1
button run progrem: 2
button run progrem: 3
julia> ^C

julia> button run progrem: 4
button run progrem: 5
button run progrem: 6
button run progrem: 7
button run progrem: 8
button run progrem: 9
button run progrem: 10

@ffreyer ffreyer added interaction anything event related Observables labels Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests and enhancements interaction anything event related Observables
Projects
None yet
Development

No branches or pull requests

3 participants