Am using easygui to make a game but there is no way of closing - easygui

Am trying to make a game using easygui but the only way to shut is to shut python down completely because the X button won't work. How do I get it to shut the game?

A method I like to use is this at the end of the script:
raw_input("Press enter to exit...")
When Python runs a program, it brings up the black Command Prompt and then runs the program. To exit the command prompt when the program is done is always done by pressing the ENTER key.
This will only work in the end of the code. It can also work in any part of the code where the game ends.

I am not an expert in Python myself, but after your code is written...just use this:
import sys
sys.exit(0)
Besides, python has got a built-in exit command. Personally I only use exit to shut down python.
have a read:
http://docs.python.org/2/library/sys.html#sys.exit

Just try
print "Game Ended"
"""This area should be for what happens after game ends."""
It should close the easygui window when clicked, but keep the program running.
Hope this works!

Related

Exit editor without exiting psql

When I run \dt (and other commands of psql like \l) this thing appears. What is this? Is this an editor?
Most importantly, when I click Ctrl+Z, I get thrown out of psql completely. How do I exit it without exiting psql?
I am totally new to Ubuntu, so sorry if its a dumb question. Thanks for your time on advance!
You seem to come from Windows.
The pager that gets invoked whenever a query result does not fit on your screen is something similar to Windows' more, so you exit it by typing q.
If you don't want a pager at all, set the environment variable PAGER to an empty string:
PAGER='' psql
Typing Ctrl+Z will not send an End-of-file on Linux, it will suspend the current foreground process, which continues to lurk in the background. You can rescue it from there with the command fg.

Run python kivy application in "kiosk mode"

I've created a simple python application running in raspbian using kivy. The application runs already nicely in full screen mode. however I would like to be sure it cannot be interrupted with ctrl-c or any other command using the keyboard, and the application must never lose focus if something happens in the OS (for example some kind of dialog opens - I'm not sure if this actually can happen). I'd appreciate things that should be taken care of.
My app doesn't need to be bullet-proof, but it should endure a "casual user".
You can catch Ctrl+c or other signals with the signal module.
import signal
def signal_handler(signal, frame):
pass
signal.signal(signal.SIGINT, signal_handler)
This code prevent the user to exit by sending the SIGINT signal, corresponding to ctrl + c.
Other signals: https://unix.stackexchange.com/questions/317492/list-of-kill-signals

How to exit hotkey function and continue the script (AutoHotKey)?

Thanks for reading. :)
Let's give an example of what I say. I press shift+g and I execute one function. In the middle of executing it, I want to stop it by pressing shift+h, then execute another function, and then return the script so as it to stay waiting for another keystroke.
I thought about reloading the program, but I couldn't execute the following commands that way. Or, I could execute another program and reload the first one, but it is getting too complicated.
Any ideas will be greatly appreciated! :)
The easiest way is to put the script in a separate file and run it as an external program. Use #SingleInstance Force to be sure only one copy is running, and if you want to kill it use Process, Close with the PID you can get back from the Run statement.
I do this all the time with long complicated scripts that fail frequently. I mostly do that so if the script fails I just hit the hotkey again to restart. It kills the first instance and restarts. Interrupting a running script is just another special case.
Note that you'll need to run AutoHotkey.exe and pass the name of the script and any parameters. Don't try to run the script itself.
As pointed out the easiest way is to put the script in a separate file and run it as an external program. something like this:
RunWait %A_AhkPath% test1.ahk
Then in test1.apk put ExitApp in a hotkey. like this:
+t::
msgbox killing myself!
Exitapp
very simple!

How can I stop executing .wlua files?

Is it possible to force stop a .wlua file? I figured that I would have to use the Lua Command Line to do this, but I can't seem to find out how to stop them.
If it's possible, how can it be done?
Because wlua.exe doesn't open the console window (that's the purpose) and you can't send Ctrl-C, the only way to terminate such application is to use Processes window in Task Manager. Note, however, that the process name will be wlua.exe for every file opened that way.
Of course, it's meant only to be used when the application isn't responding. Your GUI application should provide a way to close it, such as close button, listening for ESC key etc.

Keep App in Focus

I use wscript to launch an application on my machine. I then use this app for 30 seconds before I kill it. I do this using python -
import win32com.client
import time
shell = win32com.client.Dispatch("WScript.Shell")
shell.Run("My App")
time.sleep(0.5)
shell.SendKeys('%f')
...
I was wondering if it is possible to ensure that the launched app receives the SendKeys instructions and not another app that I might accidentally give focus to under this 30 second period.
Thanks,
Barry.
Problem
how to guarantee a wsh script SendKeys event goes to a specifically targted application
Workaround
in lieu of a straightforward solution to targeting a specific process with SendKeys you can use the "wait" variant of ShellRun
Example
Change "Before" into "After"
Before
WshShell.Run(run_name)
After
WshShell.Run(run_name,1,true)

Resources