Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10376 > unrolled thread

Maximize already running tkinter program on invocation

Started bySteven Kauffmann <steven.kauffmann@gmail.com>
First post2011-07-27 10:18 +0200
Last post2011-07-27 11:17 -0700
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Maximize already running tkinter program on invocation Steven Kauffmann <steven.kauffmann@gmail.com> - 2011-07-27 10:18 +0200
    Re: Maximize already running tkinter program on invocation Peter Otten <__peter__@web.de> - 2011-07-27 13:54 +0200
    Re: Maximize already running tkinter program on invocation Francesco Bochicchio <bieffe62@gmail.com> - 2011-07-27 11:17 -0700

#10376 — Maximize already running tkinter program on invocation

FromSteven Kauffmann <steven.kauffmann@gmail.com>
Date2011-07-27 10:18 +0200
SubjectMaximize already running tkinter program on invocation
Message-ID<mailman.1529.1311754757.1164.python-list@python.org>
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

[toc] | [next] | [standalone]


#10383

FromPeter Otten <__peter__@web.de>
Date2011-07-27 13:54 +0200
Message-ID<j0ouaj$a0e$1@solani.org>
In reply to#10376
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.

[toc] | [prev] | [next] | [standalone]


#10394

FromFrancesco Bochicchio <bieffe62@gmail.com>
Date2011-07-27 11:17 -0700
Message-ID<7c2816d3-5813-4341-9219-95169aad783a@t9g2000vbs.googlegroups.com>
In reply to#10376
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web