Splash-screen doesn't show it contents - pygtk

I'm having some trouble showing a splashscreen during some heavy work in my application in Python-gtk. I've been searching on Google and found this link: http://code.activestate.com/recipes/577919-splash-screen-gtk/. Since the example is quite clear, I downloaded the program and ran it on my computer. However, the splashscreen didn't show its contents.
Could it be that some configuration parameter of Gtk is set wrong? How come adding the code:
while gtk.events_pending():
gtk.main_iteration()
right after showing the splashscreen doesn't work in my case?
Thanks for your help

I tried adding:
while gtk.events_pending():
gtk.main_iteration()
right after the self.window.show_all() in splashScreen, and that worked. Before that, it didn't display the text, "This shouldn't take too long... :)".
This works because it ensures that the splash screen is rendered immediately, rather than leaving it to chance, which I guess must randomly work for some people (the guy who wrote this code and the other guy who replied here) and not for others (you and me).

I tested the code in the link you gave and it does display the splashscreen's components. But it may have appeared to not display them for you perhaps because the splashscreen window isn't given a size? I added:
self.window.set_size_request(300,300)
to the sample code and sure enough the label does appear.

I know this is a very old question, but I had the same issue with Gtk+3, and using Gtk.events_pending() had no effect, so I took a different route.
Basically, I just put a button to manually clear the splash screen, which I've seen plenty of commercial apps do. Then I call window.present() on the splash screen after creating the main window to keep the splash screen in front. This seems to be just the pause Gtk+3 needs to actually show the splash screen content before showing the main window opening behind it.
class splashScreen():
def __init__(self):
#I happen to be using Glade
self.gladefile = "VideoDatabase.glade"
self.builder = Gtk.Builder()
self.builder.add_from_file(self.gladefile)
self.builder.connect_signals(self)
self.window = self.builder.get_object("splashscreen")
#I give my splashscreen an "OK" button
#This is not an uncommon UI approach
self.button = self.builder.get_object("button")
#Button cannot be clicked at first
self.button.set_sensitive(False)
#Clicking the button will destroy the window
self.button.connect("clicked", self.clear)
self.window.show_all()
#Also tried putting this here to no avail
while Gtk.events_pending():
Gtk.main_iteration()
def clear(self, widget):
self.window.destroy()
class mainWindow():
def __init__(self, splash):
self.splash = splash
#Tons of slow initialization steps
#That take several seconds
#Finally, make the splashscreen OK button clickable
#You could probably call splash.window.destroy() here too
self.splash.button.set_sensitive(True)
if __name__ == "__main__":
splScr = splashScreen()
#Leaving this here, has no noticeable effect
while Gtk.events_pending():
Gtk.main_iteration()
#I pass the splashscreen as an argument to my main window
main = mainWindow(splScr)
#And make the splashscreen present to make sure it is in front
#otherwise it gets hidden
splScr.window.present()
Gtk.main()

Related

UI Automation Error: UI TESTING FAILURE-APP failed to quiesce within 30.0s

Since xCode updated i'm having trouble running any ui test case. It gives me this error when its expected to do a simple tapping action for example:
XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *passwordSecureTextField = app.secureTextFields[#"Password"];
[passwordSecureTextField tap];
Anyone have any ideas why am i getting this error? I've searched on google and here but haven't found any solutions.
Thank you.
Make sure you don't have any animations on screen during UI Automation tests. We had a text alert flashing on the login screen for debug/test builds of our app, and it would cause the "failed to quiesce" error until it was removed.
There are some other posts about this error that mention issues with UIRefreshControl, so I would suspect animating that or UIActivityIndicatorView would cause the same problem.
It might help to turn on the "All Exceptions" breakpoint. I used it and I recall getting the same error. It will break at the line with the problematic code and should show you the stack trace of the error with more info.
I had a similar error - as well as the simulator running very slowly. In my case it was fixed very simply by the method given in the accepted answer here: Xcode simulator extremely slow.
To save you a click: The issue was that I had accidentally pressed Cmd + T at some point, enabling "Slow animations".
I had to turn off the "Personal Hotspot" in order to get a working test environment (Because the blue bar in the top apparently disturbed XCTestRunner)
But as some tests need internet connection I can't do testing when being in the wild:-(
Anthony F's answer says it all. Likely something is still animating. The system seems to wait for the app UI to "settle" (go idle) and when that happens, it performs the tap action. However, when the UI constantly runs animations, it will never settle.
Xcode Console Output
Enable the console output in Xcode to see what happens when running the test.
Below is an example of the log, when it works well. The system waits for the app to go idle and when that has happened, it goes to find the button in the hierarchy.
t = 16.95s Tap "#go" Button
t = 16.95s Wait for app to idle
t = 17.00s Find the "#go" Button
t = 17.00s Snapshot accessibility hierarchy for XXX
t = 17.09s Find: Descendants matching type Button
t = 17.09s Find: Elements matching predicate '"#go" IN identifiers'
t = 17.10s Wait for app to idle
t = 17.15s Synthesize event
t = 17.41s Wait for app to idle
Below is an example when it fails. The system waits for the app to settle so that it can look for the button in the hierarchy. Since, it does not settle, it waits "forever" finally running into the timeout.
t = 18.88s Set device orientation to Unknown
t = 18.93s Tap "#go" Button
t = 18.93s Wait for app to idle
t = 79.00s Assertion Failure: UI Testing Failure - App failed to quiesce within 60s
In my case the "failed to quiesce" was caused, because at time t=18.90s, demo data was generated which caused repeated updates of a UIProgressView. From then on the app UI never settled ("quiesced").
("quiesce" as a word is not in my active vocabulary, which certainly has delayed my recognition of what was going on. The console output pushed me into the right direction. I'd bet "idle" rings more bells than "quiesce" for many developers.)

Qt: render QML window to buffer

My code looks like this:
QApplication app(argc, argv);
QQmlApplicationEngine app_engine;
app_engine.load("qml/main.qml");
return app.exec();
Could somebody please help me how to make Qt render everything to the buffer I provide? OpenGL must be avoided. I could make this work with QWebPage, but this appears to be much more difficult to me...
I've found the way to get the QML output as QImage, but it works only if the QML window has focus. Incomplete code snippet follows:
QApplication app(argc, argv);
QQmalApplicationEngine *appEngine = new QQmlApplicationEngine(this);
appEngine->load(script_path);
...
app.exec();
While app is running, you can grab window contents like this:
QQuickWindow *win = qobject_cast<QQuickWindow *>(appEngine->rootObjects().first());
QImage grabbed = win->grabWindow();
It has several drawbacks (i.e. cursor disappears when the input focus is lost, grabWindow() is very slow etc.).
Furthermore, it's also possible to redirect QML page rendering to a custom FBO, this provides a much faster solution but also suffers from some issues.

Node-Webkit - Starting Maximized

I don't want a fullscreen application, but I would like to start a Node-Webkit application maximized. Can this be done? I am guessing its something to do with package.json, but can't seem to find what needs to be done.
I don't think the manifest has an option to do that. Instead, call nw's Window.maximize() on startup. Something like:
// Load native UI library
var ngui = require('nw.gui');
// Get the current window
var nwin = ngui.Window.get();
Sometime later, in onload or some other point where you're ready to show the window:
onload = function() {
nwin.show();
nwin.maximize();
}
This is described in the node-webkit wiki. I don't think you can call maximize before showing the main window though (if it's hidden in manifest), but I haven't really dug into it.
You may want to consider saving the window position, from a UX standpoint. The wiki has an example for doing this.

How to set a JavaFX Stage/Frame to Maximized

I'm using JavaFX 2. I want my frame to open maximized but I'm not seeing a way. I searched a bit on the internet without success. For the stage I see setFullScreen() and setIconified() but I don't see anything like setMaximized().
The Java 8 implementation of the Stage class provides a maximized property, which can be set as follows:
primaryStage.setMaximized(true);
When evaluating the sourcecode of the Ensemble.jar provided with the samples of JavaFX 2.0 SDK, the currently valid way to achieve window maximizing is
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
primaryStage.setX(bounds.getMinX());
primaryStage.setY(bounds.getMinY());
primaryStage.setWidth(bounds.getWidth());
primaryStage.setHeight(bounds.getHeight());
(you find similar code in WindowButtons.java)
The 'maximize' button is still enabled and when clicking it, the windows will grow a bit more (Windows OS). After this the 'maximize 'button is disabled. In the provided example the standard buttons are replaced. Maybe this is still an issue.
Better use Multi-Screen compatible maximize logic:
// Get current screen of the stage
ObservableList<Screen> screens = Screen.getScreensForRectangle(new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()));
// Change stage properties
Rectangle2D bounds = screens.get(0).getVisualBounds();
stage.setX(bounds.getMinX());
stage.setY(bounds.getMinY());
stage.setWidth(bounds.getWidth());
stage.setHeight(bounds.getHeight());
try this simpler code
primaryStage.setMaximized(true);
and it fills up the whole screen
. note that if you remove maximize/minise buttons the application will fill the whole screen as well as remove the taskbar so mnd your initStyles if you have any
Use this to remove the Minimise, Maximise Buttons :
primaryStage.initStyle(StageStyle.UTILITY);
Where primaryStage is your Stage object.

PyGtk: change image after window's main() method?

I'm using a gtk.Image widget to display a picture in a gtk window. I can set the image to be displayed before I call window.main(), but after I've done that the image won't change any more. Basically:
import pygtk
pygtk.require('2.0')
import gtk
(...)
window= Window()
window.canvas= gtk.Image()
window.window.add(sprite.window.canvas)
window.canvas.show()
window.canvas.set_from_file("pic1.gif")
window.main()
window.canvas.set_from_file("pic2.gif")
pic1.gif will be displayed. Is there a proper way of changing the image (I don't care if I have to use a widget other than gtk.Image)? All I can think of is destroying the window and creating a new one.
Edit:
I realized my mistake... I called window.main() for every window and any window's destroy event called gtk.main_quit(). Had to make slight adjustments, but it works now. Even after calling window.main() :)
As Rawing hasn't yet accepted his own answer, I'll post it to get this off the top of the unanswered questions page, and to help out anyone skimming this from a search engine clickthrough by providing a comprehensive answer. (Rawing, feel free to post your answer yourself, all the same.)
In your code, you're declaring window as Window(), as opposed to gtk.Window. If you're building in one window, you should not need to do this every time. Create the window once, add what you need to it. If you need additional windows, declare them separately in this module, and call them from code (instead of from main).
Furthermore, don't name your objects with a "window." at the beginning...that just gets overly confusing. Give it a simple name, add it where you need it. Python will do the rest.
A cleaned up version of your code above would probably look like this:
window = gtk.Window()
#You may need additional arguments above, such as to make it top level.
canvas = gtk.Image()
window.add(canvas)
canvas.show()
canvas.set_from_file("pic1.gif")
Now, just change the image in an event or another "def", like this:
def ChangePicture():
canvas.set_from_file("pic2.gif")
Canvas should update the picture automatically.