GTK builder: Empty dialog window after WM-kill - pygtk

I used glade to build my GUI.
Now i have a transient top level dialog window that pops up. If i kill this dialog window with a window manager shortcut, it gets deleted/destroyed. I catch those signals an do a dialog_window.hide() but if i reopen the dialog window an empty window appears.
Am i missing some glade settings?
Or do i have to rebuild the dialog window each time? - When yes, how?
Here is my glade-file: http://codepad.org/dP7NOlob
The window i'm talking about is named edit_account_window

If the WindowManager kills the window all widgets get deleted, so the window needs to be rebuild. This can be done like this:
def buildFooWindow(self):
self.builder.add_objects_from_file( 'glade_file_path', ['foo_window'] )
self.builder.connect_signals({'foo_window_cancel': self.fooWindowCancel})
So you have to call this function each time you want to show the window.

Related

Set focus to child window in PyGtk

I am writing a simple application in python using PyGObject and glade. The application has a main window and a functional window (Generate logs, also a Window object) which opens up on clicking a menu item.
The Generate logs window is supposed to:
Show options to generate log for a particular date
Be minimizable and should close automatically when the task is complete (OR)
Be able to be closed manually if the user wishes so
The problem is, once I show up the Generate logs window, I am directly able to select the main window as well. Then, I can go to the menu and bring up as many Generate logs windows as I want.
I have tried several options (Is Focus, setting up main window as Transient parent etc) but nothing worked. How can I fix this?
First you say PyGTK, then you say PyGObject, this are 2 different things. I'm going to answer for PyGTK (my sources are from GTK+ 2 docs) since it's in the title and maybe people looking for that will end up here. But never fear, because for this question, the answer is practically (I think exactly) the same for both.
What I understand is that you want you "Generate log" window to be modal. That means other windows can't be used while your modal window is up, just like a Dialog window. Also you should set the main window to be the parent of your modal window, since this helps the OS Window Manager i.e. keep the dialog on top of the main window.
Yo can do both of this things directly from Glade (if you've created both windows in the same project, not always the case) selecting the Modal atribute to True and the Transient for Window attribute to your main window, in the General Properties section of your Generate log window.
Also you can do it programmatically using the set_modal() and the set_transient_for(parent_window) method of your child window.
Let's say your parent window is called main_window and the child window is generate_log_window, then you can do it like this:
generate_log_window.set_modal(gtk.TRUE)
generate_log_window.set_transient_for(main_window)
If you want it to show center top of your main window, do this
generate_log_window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
To your second point, the ability to minimize can be set from Glade.
Sources:
GTK+ 2 GtkWindow reference set_modal
GTK+ 2 GtkWindow reference set_transient_for
PyGTK FAQ: How do I get my windows to show up where I want
PyGTK FAQ: How do I make a dialog block the whole application, so the user is forced to answer it?
create several windows (see your other post).
Upload them in init
Show them with "signals" in glade using "show" and "hide"
class GUIxxxx
#...
def action1(self, widget, data=None):
self.window1.show()
def action2(self, widget, data=None):
# do something here
self.window1.hide()

Open window such that is shows on all desktops

I have a screenshot thing, what it does is it takes a screenshot of the current visible stuff, then opens a full screen window covering everything. However this opens on the desktop of the parent window which is on desktop 1. And if a user had desktop 2 focused (due to like fullscreen app or something) then the window that opened will not show on desktop 2.
So I was wondering if there is a window level or something (I tried all the window levels) that will make it such that a window appears on all desktops.
Thanks
This sounds like either NSWindowCollectionBehaviorCanJoinAllSpaces or NSWindowCollectionBehaviorStationary. Set it as the collectionBehavior of the window.
(You probably want to set the window level, too, but that's about ordering rather than collection/Spaces behavior. And if you have a Window menu, then you probably also want NSWindowCollectionBehaviorIgnoresCycle.)

How to prevent a dialog to popup while build?

I have a project that use a dll which always shows a popup window while building. It's very annoying and I want to get rid of it.
The problem is the popup window prevents me from doing the automate build because nobody can click on the automate build server.
If you know popup window Title you can write a simple application to find window's Handle and simulate Button click.

Disable interaction with main window, while other window is open

I have a main window where all the work is done.
When i open the preference panel I would like to freeze the main windows as long as the preference panel is open.
For example iTunes: as soon as i open the preferences i just can interact with preference panel and nothing else.
Is there an easy way to archive this behavior?
Code:
[NSApp runModalForWindow:theWindow];

Closing frontmost window in Cocoa in an app without a menu bar

I am building a StatusBar App in Cocoa, therefore I have no menu. Having no menu implies not having a "File > Close" menu item, which normally listens to the shortcut "Command + W".
From my StatusBar App the user may open a window to change the preferences and that's where I'm running into problems: The user can only close the window by pressing the red dot with the mouse. However, like alle applications I want to support the "Command + W" shortcut as well.
At the moment I see two possibilities to solve this issue:
Place an invisible button on the window which listens to the shortcut.
Add an application-wide listener for the shortcut and contact the window manually.
Both solutions feel like a misuse of the system. The first solution can lead to unexpected behaviour (the window closes if the user hits the invisible button by chance) and the second solution will still result in a beep, since the window does not know that it handles such a shortcut.
Is there an elegant way to solve this problem? Since the view should know what to do, a solution with just Interface Builder would be perfect. If there is no elegant way, is there a way to enhance the solutions mentioned?
Thanks in advance!
If you put a File > Close menu item in your MainMenu nib, the shortcut will work, even though the menu isn't visible.
If you choose to implement an app-wide listener for the shortcut instead, you can get rid of the beep by returning nil from the block, so that the original event doesn't get passed on.