2

I am fairly new to python and gtk and I am writing an app for the Ubuntu App Showdown using Quickly. I want to make a new instance of the main window when the user clicks on 'New'.

I have the button and menu item linked up, i.e. I can make it make it print 'new' to the command line when they are clicked. However I have searched and cannot find how to make a new instance.

2 Answers 2

2

If you want to start a new window of your application in the same process, you can just create a new instance of the window class that Quickly created for you.

My app is called quickly-gtk, and in the python module ./quickly_gtk/init.py I have the following lines (at the bottom of the file):

# Run the application.    
window = QuicklyGtkWindow.QuicklyGtkWindow()
window.show()

If you call that again it start a new instance of your primary window. However, the code Quickly produces is really meant to run one instance of this window at a time, so you will have some side effects you will need to code around.

For example, Quickly connects the window closing event to a callback that ends your whole process. If you have multiple windows, you'll need to override the on_destroy() method of your window. There are likely to be other issues you'll come up against doing this.

-1

You make a new window by creating the window object, then showing it Here is an example piece of code:

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.show()

There are, however, may useful resources to also help, such as the PyGTK reference: http://developer.gnome.org/pygtk/stable/

Also, there is a few more tutorials at: http://pygtk.org/pygtk2tutorial/

2
  • I don't think that's what I want. I basically want to run a new instance of the program.
    – Luke
    Jun 25, 2012 at 14:48
  • That's not the way to go. Quickly wants you to use Glade. Your documentation links point to GTK 2, Apps for the Showdown use GTK 3. See developer.gnome.org/gtk3/stable for docs.
    – f4lco
    Jun 26, 2012 at 20:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .