How to cancle process in Orange Canvas? - python

Hey I started to use the graphical orange canvas toolbox for data mining. Connecting nodes on the workspace can cause the execution of the associated tasks. I know that these automatic apply can be disabled, but in the case I missed that and accidently start a realy heavy process like outliner detection on a big dataset is there a way to stop the current pipeline task without killing the hole system process?

Unfortunately there is no such stopping functionality in Orange yet.
The developers of Orange are working towards making widgets compute in threads, which can let us control stopping. The Test & Learn widget, for example, already works in a separate thread. There, if the user changes options while widget is already working, it stops the current computation and starts a new one. But even there, there is no GUI option to just stop the computation.

Related

How to launch a NAO's behaviour by using dialog?

I found a way to start a behaviour by creating a dialog in Choregraphe, but it does not work.
The script of the dialog is the following:
u(keyword / key sentence): robot_response (optional)
^start(applicationID/behaviour_1)
^wait(applicationID/behaviour_1)
The robot (NAO, version 2.8.6.23) catches my keyword, says the expected response, but the behaviour does not start: the robot goes into stand-by and I have often to restart it. Anyway, the application seems to be running (by looking at active content). I tried to run manually the behaviour and it works well, so I don't understand what I'm doing wrong...
PS: Both the application and the dialog are installed on robot applications, of course.
Does your other behavior use dialogue? What could be happening is that applicationID/behaviour_1 tries to start listening / activate dialogue, and fails right away because there is already a dialogue running (the one you showed us).
^start is intended for simple behaviors like animations, if you want to actually launch another activity with it's own logic etc. you should use ^switchFocus instead of ^start - what that will do is stop your current behavior that has this dialogue (so, no need for the ^wait), and start a new one. This will only work if Autonomous Life is active - Autonomous Life's job is to orchestrate activities so that only one is active at a given time, to prevent bugs caused by a bit of background code in one behavior causing problems in another.
("activities" are basically behaviors that are intended to be "top level", like applications or games, as opposed to little things like animations that are fine to run in the background)

How can I allow buttons to stop an otherwise infinite loop in PyQt5?

I am making a genetic algorithm program that can go on forever but I want the user to be able to stop and start the execution at will. My idea was to have a button that sets a bool value that is checked at the final stage of the generation creation and if False the execution stops but keeps everything as it is so it can be continued from where it was paused however I do not know how to implement it such that I can interact with my programs UI and thus emit the signal to change the boolean.
Is the only way to do this by using a thread? I am not really sure how to use them specifically but I could learn. If this is the recommended method should I use QThread or just normal python threading? Will this cause a noticeable slow down of my program?

Inactivate pyside-generated windows for the duration of background task

I have a simple gui application written in python with pyside. There is a main window and also some modal QDialogs. Depending on the user's actions in some of these dialogs, the application might have to connect to a database and perform corresponding tasks in it.
The problem is: database actions might take a few seconds to complete and my users tend to think that the program is stuck, so they start furiously clicking around and mashing keys. To prevent this erratic behavior I want to deactivate all the windows and display some loading symbol to calm things down.
What I need to create (left - normal state, right - busy state):
This is not the actual app, just an approximate schema of what I want to achieve.
I think some kind of QMovie should do the trick, but I have no idea how to cover a dialog with semi-transparent white and to display the loading symbol on top of it. I am also considering QProgressBar, but I am not sure if it's the right solution for the task.
I would appreciate any advice or a link to similar tasks solved (for some reason I was unable to google anything relevant myself, maybe I am using wrong keywords).
Generally, the way you would do this is with some sort of progress indicator, either a QProgressBar or a QProgressDialog.
With the QProgressDialog, you can launch it modally to prevent users from interacting with the base QDialog or QMainWindow.
Either way, you should still be doing the slow-running task in another thread; otherwise, the GUI is just going to freeze. The user won't be able to move the window or dialog, it won't respond to their clicks, and any progress updates you're making won't be shown in the GUI.

Force update GUI in kivy

I am writing an app in kivy which does cpu-heavy calculations at launch. I want the app to display what it's doing at the moment along with the progress, however, since the main loop is not reached yet, it just displays empty white screen until it finishes working. Can I force kivy to update the interface?
Basically I'm looking for kivy's equivalent of Tkinter's root.update()
I could create a workaround by defining a series of functions with each calling the next one through Clock.schedule_once(nextFunction, 1), but that would be very sloppy.
Thanks in advance.
Leaving aside the question of whether you should be using threading or something instead (which possibly you should), the answer is just that you should move your cpu calculations to somewhere else. Display something simple initially (i.e. returning a simple widget from your build method), then do the calculations after that, such as by clock scheduling them.
Your calculations will still block the gui in this case. You can work around this by doing them in a thread or by manually breaking them up into small pieces that can be sequentially scheduled.
It might be possible to update the gui by manually calling something like Clock.tick(), but I'm not sure if this will work right, and even if so it won't be able to display graphics before they have been initialised.

Pygame and Multiprocessing Strategy

I'm developing a game in pygame and i don't know which tasks should go to which process.
I have two processes connected by a pipe, one will have the window another will do calculations.
My question is: Which parts of the main loop should go to the other process?
In my game i will have to do event handling, collision detection, AI, drawing and heavy calculations(2D lighting system).
I'm afraid that if i put to much stuff on the other process the main one will have to wait for input and the FPS will freeze.
PS: For now i'm just starting to code the game so i can't show you much code.
There is the observer pattern
I would suggest the following architecture for creating a PyGame with two processes:
You divide your program into two parts:
model
all the game logic is kept in the subprocess, computing the whole game.
Whenever there is something noteworthy changed, it notifies the other process.
responsibilities:
update the game e.g. in a loop
do physics
send updates to the gui
gui
The gui is in the main process because it starts several games.
When a game is started it starts to observe important parts of the game.
responsibilities
handle user input e.g. right arrow pressed
send modifications to the model e.g. player walks righth
render views of model elements when updates are received
Note that I do not really know much of PyGame.
But keeping model and view apart is possible.
You can have a look at the MVC pattern, too. But it is really heavy. Just merging View and Controller is enough if the program shall not be distributed across computers.
Then I heard about MVVM pattern. Not sure whether this is too much again since you only need to split your game into two parts and not three.

Categories

Resources