Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 3222  / 1 Year ago, tue, may 9, 2023, 3:05:21

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.


More From » python

 Answers
0

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.


[#37324] Tuesday, May 9, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raldership

Total Points: 222
Total Questions: 115
Total Answers: 124

Location: North Korea
Member since Fri, Nov 4, 2022
2 Years ago
;