Make ghost.py's QWebView react to user actions (attach an event loop thread?) - pyside

I'm opening a web page in ghost.py in IPython interactive console and showing its window to see the effect of my actions:
import ghost
s=ghost.Ghost().start()
s.open('https://google.com')
s.show()
The window shows the page's content but doesn't do anything if I try to e.g. drag or resize it, or use its scrollbars, and its title is appended with "(Not Responding)". Looks like the window's event loop is not running.
Since I'm working in the interactive console, I need the event loop to run, and do that in a background thread or something. How do I do that?

Running the %gui qt IPython magic command before invoking ghost.Ghost().start() does the trick.
Judging by IPython/terminal/pt_inputhooks/qt.py, it creates a global Qt even loop and pumps events while the console is idle or something.

Related

How to prevent wxWidgets window from blinking in the taskbar when created?

If my wxWidgets application creates a new window while the application does not have focus, its taskbar icon blinks yellow until I switch to it, as shown here:
This is annoying. How can I prevent this from happening?
EDIT: The original version of this question suggested the blinking was happening during startup. After further investigation, this is not occurring right at application startup; rather, it occurs if I create an additional window while the application does not have focus.
To give a bit more background: my application is a sort of server, that opens windows in response to network events. If I boot up the application, then switch focus to something else and a network event comes in while the focus is elsewhere, my application will open a new window in the background (not grabbing focus) and this blinking will occur.
The windows are wxFrames; the application constructs them and their child widgets, then calls Show(true) on the frame.
Also, I've attempted to set a breakpoint on the FlashWindow Win32 API function, hoping to trap wherever in WX it's getting called, but haven't been able to make that work.
Maybe the following would work:
wxTopLevelWindow::ShowWithoutActivating ( )
http://docs.wxwidgets.org/trunk/classwx_top_level_window.html#a03e526f505716568318d601318527bd0
Yes. If you create a new top level window while the app does not have focus, then the task bar icon will flash. This is the intended behaviour of the windows operating system.

Preventing application exit in TideSDK

I am trying to prevent the user from closing the window when they click on the close button. I would like to have the application dock to the system tray.
My first step is to recognize when the user attempts to close the window and prevent the default behavior on that event. I would expect this code to work, but it does not.
var appWindow = Titanium.UI.getCurrentWindow();
appWindow.addEventListener('app.exit', function(event){
event.preventDefault();
})
I tried using the exit event and the event constants themselves to no avail.
This wont work because all your doing when you call preventDefault is stopping the default behavior in the WebKit browser page, not the native application wrapper itself.
The close command is a native function call to the underlying wrapper, it just passes an event to the listener, it does not pass control.
Also, this sounds somewhat dangerous, not allowing a user to close an application seems problematic. Maybe instead you should register a background service to run instead?
one trick might be to open an 'invisible' window for the app, so even if the user closes the 'application' window, the app should still be running.

REALBasic: How to make code run after the window has fully loaded

I am doing a REALBasic project. I want to make code run after the window has loaded automatically.
If I put the code in the Open event handler, the code runs when the window opens, but the window doesn't appear until the code has finished executing.
So I would like to have the Window open and be on the screen, and then the code run automatically without having to click anything.
Is this possible?
Thanks.
Place your code in a Timer with its Mode set to ModeSingle and a short Period (say 10 milliseconds). The Timer will fire once the GUI finishes loading.
Or you can put your code in a thread and start the thread in the Window.Open event. That way if the code takes a while your entire application doesn't 'freeze' on you.
More info on threads in Real Studio at http://docs.realsoftware.com/index.php/Thread
One word of caution though with Threads. Directly updating GUI controls can be a bad thing - especially with Cocoa built applications.

Quickly + GtkWindow default close button

I made a gtk app with Ubuntu quickly tool.But I have encountered a few problems with the window close button(the one in the top left of the window).So here's the thing: I want my app to close in the system tray ,so I write the code in a method ,create a button on my window and connect the "clicked" signal to my method.Everything is working as it should.Now I want my window close button to do the same thing.When i look up on the code written by quickly i found this method:
def on_destroy(self, widget, data=None):
# Clean up code for saving application state should be added here.
Gtk.main_quit()
So instead of Gtk.main_quit() I called my handler for the button I deployed on my window.The thing now is that my app is hiding on the system tray but when i want to unhide it there is no window,although I can see the process of my app is alive.
I want to say that when I use the button i created I can see my app when I unhide it ,so it's quite obvious that when I press the system close button there's more than one signal.
So my question is what other signals are called when I close my window from system button?And where is the place quickly implements the handler for the other signals?
Thank for your time!
Your window is "destroy". Connecting to that signal allows you to run some code, but, your window is still destroyed. If you're aren't breaking out of the main loop with Gtk.main_quit() then your app is still running. To re-display the window you would need to recreate it.
Another option is to instead connect a callback function to the "delete-event" of the window. In this signal handler if you return True then the window will not be destroyed. In other words, you could hide the window and return True and then re-show the window later. If you return False from this signal handler then the window will continue to be destroyed.

Create a background process in windows

How do I make a process go the background programatically?
What I want is for the user to double-click the process executable, and it just goes into the background ... and does not open a window while executing.
Any code snippet in visual c++ would be very helpful
Have you considered creating a Windows Service instead? They're specifically designed to run in the background without showing a UI.
Otherwise, just create an application without a window.
I know this is old, but I thought I would post something for when people find this through search.
While I like Cody Gray's answer for design correctness, sometimes you don't have a choice.
If you want to launch a program without jumping to the new window (it appears in the background or minimized) or not create a window at all try looking at the ShellExecute and ShellExecuteEx functions. The argument nShowCmd (or nShow) gives you (among others) the options:
SW_HIDE
Hides the window and activates another window.
SW_SHOWMINNOACTIVE
Displays the window as a minimized window. The active window remains active.
As the documentation says, SW_HIDE creates a process running the executable you give it, but if this program would normally create a window, none appears.
This might help: http://ss64.com/nt/start.html
I tried this way and it worked fine:
Create a console application and write your codes in the sub main as any other console application.
Now change the application type in the project properties to windows Forms application from Console application
thats it

Resources