Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

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/

share|improve this answer
    
I don't think that's what I want. I basically want to run a new instance of the program. –  Luke Jun 25 '12 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. –  phineas Jun 26 '12 at 20:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.