Application closed entirely when closing a pyopengl window - glut

I have a GUI developed with pyside2, i have a button in this GUI, when clicking on it, a pyopengl window appears and showing what is needed. The problem is that when closing this window, the entire GUI closed. I want to continue using the GUI after closing the opengl window.
I'm using GLUT to create the window.
my_GUI_mainwindow.py:
import pyopengl
...
...
...
self.Btn.clicked.connect(self.opengl)
def opengl(self):
pyopengl(file_m)
my_pyopengl.py:
glutInit()
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
glutInitWindowSize(pyopengl.g_Width, pyopengl.g_Height)
glutCreateWindow(self.fileName)
self.init()
glutReshapeFunc(self.reshape)
glutDisplayFunc(self.display)
glutMouseFunc(self.mouse)
glutMotionFunc(self.motion)
glutKeyboardFunc(self.keyboard)
glutMainLoop()

Related

I'm having trouble with the resolution of the just the window size of IntelliJ

I am having trouble with the window size of IntelliJ when I'm starting a new project. For instance, when I open IntelliJ and click on import project I don't see the "OK", "Cancel" button at the bottom of the window, plus the window cannot be maximized to full screen and I cannot scroll down.
I tried searching in the setting but I just don't understand what setting to click on. I recently started using IntelliJ and I don't wanna enable some setting that i"m not sure of and get into a new mess.
If you look at the pictures above, you can see the buttons or the options are just hidden because of the window size or the resolution of the window.

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()

PyGtk - Can't open the same window twice

I've been using PyGtk to make an indicator that will show a preferences window when a button is pressed. The window is built once and opened using show_all() on a button press. When opened a second time, however, there widgets in the window disappear. Is there a way I can show and close the same window multiple times? The following code will reproduce the problem after closing it for the first time
#! /usr/bin/python
import gtk
def show():
window.show_all()
return True
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
gtk.timeout_add(2000, show)
gtk.main()
You need to hide the window instead of closing it.
Adding the following code will hide the window when the close button is clicked.
def hide_window(window, event):
window.hide()
return True
window.connect('delete-event', hide_window)
From the PyGTK FAQ:
http://faq.pygtk.org/index.py?req=show&file=faq10.021.htp

Move a window to another workspace

This is what I am doing progamatically:
User is currently focused in worksapce 2 because from the main workspace they clicked "fullscreen" green button. 10 seconds later, while they user is in workspace 2, programmatically from my app in main workspace this happens:
Main workspace:
1) Open new window
2) Full screen it
3) activateIgnoringOtherApps so it brings my app to top
Step 3. This causes animation and change from the Workspace 2 to main workspace.
I was thinking after step 1 i should move the window i am opening (after 10sec countodwn) to "Workspace 2" I was thinking of using this code here: How can I programatically move one Terminal.app window to another space? I am hoping this will not make it change workspace.
My goal is to support 10.6+, will the code in linked topic do the trick so that my window is moved to current workspace, and doing activateIgnoringOtherApps will not cause scroll all the way to left.
Demo
To see exactly what I mean by scrolling workspace you can install my firefox addon: https://addons.mozilla.org/en-US/firefox/addon/nativeshot/
Then please Shift + Click two times my addon button the gets added to toolbar, then make fullscreen any other app other then firefox. As 10 sec countdown is finished you will see the scroll to newly opened window (which is an image editor on a screenshot)
Here is a youtube screencast showing the issue: https://www.youtube.com/watch?v=ihl8PHjO8fI

GTK builder: Empty dialog window after WM-kill

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.