PyGObject and glade send window to the front - python

im having some problems to send to the front a GTK window.
I have a main window (window_root) with a button that launches another window (window_programs).
with this commands:
window_root.hide()
window_programs.show()
then, in window_programs, i have a button that displays another window (window_list) with the command:
window_list.show()
window_list is modal.
The problem was that window_list appeared at the back of window_programs.
so i did some research and i found window_list.show().
The problems is that window_list appears at the front, but when i click it window_programs comes to the front!
it makes some time that i'm looking for the solution, any help will be appreciated!

You are looking for the transient-for property of the modal window (which should be available in Glade). If the modal window needs to be transient to either of the two other windows, then you need to use gtk_window_set_transient_for() as needed since the modal can only be transient for one window at a time.

Related

Tkinter: What's the difference between grab and focus?

In tkinter I am creating a Toplevel widget to prompt the user with "Are you sure you want to exit?" every time they try to exit my application. While this is happening, I want the Toplevel widget to have full focus of my application and the user to be unable to click anything on the root window, if possible.
While trying to figure out to do this, I discovered grabs and the ability to set the focus of the application. What is the difference between these two things?
Thanks in advance.
Focus means that your window will receive all keyboard events until some other window gets the focus. A grab tells the window manager that your window should have the focus until you explicitly tell it that it is allowed to take it away (ungrab).

Is wait_window() required for creating a modal dialog in Python Tkinter?

I try to create a modal dialog using Python Tkinter. I found no difference between using and not using wait_window().
import tkinter as tk
def button_click():
dlg = tk.Toplevel(master=window)
tk.Button(dlg, text="Dismiss", command=dlg.destroy).pack()
dlg.transient(window) # only one window in the task bar
dlg.grab_set() # modal
#window.wait_window(dlg) # why?
window = tk.Tk()
tk.Button(window, text="Click Me", command=button_click).pack()
window.mainloop()
I've seen some examples in that use wait_window() for creating a modal dialog. So I'm not sure whether the function is required for creating a modal dialog.
I'm using Python 3.5.
Strictly speaking, no, wait_window() is not required to make a modal dialog box. What makes a dialog modal is the grab that you put on the window.
Often, however, once the window is destroyed you may need to run some other code. You can use wait_window() for this purpose, as it will wait for the window to be destroyed before continuing. You can then have code after that, such as a return statement, or some cleanup code. In your case there's nothing to do, so you don't need to call wait_window.
running your code using window.wait_window(dlg) won't change anything as dlg.grab_set() already creates a modal dialog. this does only mean that you cannot close window while dlg is still alive. you cannot close window as the modal dialog grabs all mouse events from window and redirects them to null.
If you want to create a modal dialog without grab_set(), you would need to bind all mouse events to one handler and then decide if they should be allowed or dismissed and use wait_window.
As a modal dialog is defined by "is anything outside the dialog and in my application available to be clicked" == False , you already have a modal dialog only using grab_set().
If your application shall not be able to programatically close window, you would need wait_window() as well.
Hope I made everything clear.

Create a click through window for Linux

I want to make a click through window. A window which I click but the click pass to the window below it.
I've found this two solutions for windows:
How to make click-through windows PyQt
I have a form that can "click through", i.e. direct clicks to the window below. How can I undo my changes after the event?
But I want it to work in linux. I study the xlib mechanisms but cannot understand how the window stack works. Actually I can get all the windows with XQueryTree() and found the ones under my window. But I don't know witch one are above.

Make a window appear on top of another, block access to other windows until button clicked

Python 2.7, PyQt4.8.5
I want to have a main app window and then a second pop up window to display com port settings. This window should always be on top of the parent window until either the ok or the cancel button is clicked; closing the child window. (sort of like a required answer i.e. cant process until you choose the settings from the child window)
Is there a Python Qt command to do this?
Apologies if this has been asked/answered before, my search returned nothing useful.
You want a modal dialog. For example:
dialog = QInputDialog()
dialog.exec_()
You can either implement your own dialog widget (by subclassing QDialog) or use one of the several available.

don't show on panel

I am trying to write a simple aplication (a continuously changing label on a window on the upper left side of the screen) and I don't want it to be seen on panel but only on system tray.Because it will run for a long time. How can I do that? Thanks.
PS: I am using python and pyqt on Linux. I tried SplashScreen but when I clicked on the window it disapears. I have a contexmenu on the window, so I must click on it.!
http://www.qtcentre.org/attachment.php?attachmentid=4686&d=1274802065
I found the solution. I set the window flag as "Qt.Popup". Now there in no window on the panel.

Categories

Resources