Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Maximize already running tkinter program on invocation

Reply
Thread Tools

Maximize already running tkinter program on invocation

 
 
Steven Kauffmann
Guest
Posts: n/a
 
      07-27-2011
Hi all,

I have written a small GUI application in python 3.x using the tkinter
module. Program is running fine, but multiple instances of the program
can now be created. I would like to reduce the number of instances of
the program to only 1 instance. I know that this is possible by using
a singleton class. This way it's possible to check if the program is
already running or not.

When I invoke the program and it detects that the program is already
running, is it then possible to maximize the already running program?

I can find a lot of examples about singleton classes in python on the
web, but nothing about showing the already running application when 1
instance of the program already exists. Is there a way to realize this
in python?

I'm now doing the development on a linux machine, but the final
program should work on Windows.

Cheers,

Steven
 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      07-27-2011
Steven Kauffmann wrote:

> I have written a small GUI application in python 3.x using the tkinter
> module. Program is running fine, but multiple instances of the program
> can now be created. I would like to reduce the number of instances of
> the program to only 1 instance. I know that this is possible by using
> a singleton class. This way it's possible to check if the program is
> already running or not.
>
> When I invoke the program and it detects that the program is already
> running, is it then possible to maximize the already running program?
>
> I can find a lot of examples about singleton classes in python on the
> web, but nothing about showing the already running application when 1
> instance of the program already exists. Is there a way to realize this
> in python?
>
> I'm now doing the development on a linux machine, but the final
> program should work on Windows.


The singleton pattern will help you ensure that you can create only one
instance of the class per process, it doesn't limit the number of processes
running the same program.

I think a generic way to inform a process about an already running instance
of the program is to occupy a previously agreed-upon resource like a file or
socket. The Python cookbook has a few recipes, e. g.

http://code.activestate.com/recipes/576891/

but the details are tricky to get right and I cannot vouch for the sanity of
the one I linked.


 
Reply With Quote
 
 
 
 
Francesco Bochicchio
Guest
Posts: n/a
 
      07-27-2011
On 27 Lug, 10:18, Steven Kauffmann <steven.kauffm...@gmail.com> wrote:
> Hi all,
>
> I have written a small GUI application in python 3.x using the tkinter
> module. Program is running fine, but multiple instances of the program
> can now be created. I would like to reduce the number of instances of
> the program to only 1 instance. I know that this is possible by using
> a singleton class. This way it's possible to check if the program is
> already running or not.
>
> When I invoke the program and it detects that the program is already
> running, is it then possible to maximize the already running program?
>
> I can find a lot of examples about singleton classes in python on the
> web, but nothing about showing the already running application when 1
> instance of the program already exists. Is there a way to realize this
> in python?
>
> I'm now doing the development on a linux machine, but the final
> program should work on Windows.
>
> Cheers,
>
>

The multiprocesing module could help you in making sure that two
instances of the same program are not started ( for instance using
multiprocessing.Queue) as well as to signal the already running
instance that it sould maximize its window ( for instance using
multiprocessing.Queue ). Just make sure that what you use is supoorted
on your target operating system(s).

However, the integration of any form of inter-process communication
with Tkinter main loop is going to be tricky ...


Ciao
-----
FB

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to maximize a Tkinter Window in python TK??? d4v.jung@googlemail.com Python 3 12-13-2007 06:32 AM
How to check for already running program? Nick Sinclair C Programming 4 07-04-2005 05:09 AM
How to ensure Maximize button shows in Linux/Unix (Tkinter) Harlin Seritt Python 4 03-29-2005 08:56 AM
Tkinter zoom box = maximize/unmaximize box/button Philippe C. Martin Python 1 01-03-2005 05:12 PM
How to determine if an instance of your program is already running? Mike Python 5 12-28-2003 08:26 AM



Advertisments