Open running processes

Discussion in 'Python' started by DeRRudi, Jun 28, 2005.

  1. DeRRudi

    DeRRudi Guest

    Hi all,

    I have a programm. In this program i've made the restriction that only
    one instance can run at the time. (done with mutex).
    Now i'd like it to open the running (make visible) instance when
    someone want's to open it a second time.
    Does anybody know how to do this? I hope you all understand what i
    mean. My English isn't to good...

    Greetz Rudi
     
    DeRRudi, Jun 28, 2005
    #1
    1. Advertising

  2. DeRRudi

    DeRRudi Guest

    It is a wxWindow app. It is a kind of datamanager. it is possible to
    minimize it to the systray.

    hmm.. i've thought of an solution using memorymapping. see if it
    works.. don't know if it is the 'best' or 'safest' way.. but ok.

    Greetz.

    ps. I'm always willing to learn! :D
     
    DeRRudi, Jun 28, 2005
    #2
    1. Advertising

  3. DeRRudi

    DeRRudi Guest

    Well it doesnt work yet, but its gonna! ;)
    i've tested it with a little app. There is my main app (called it
    server) wich contains a thread. This thread listens to a mm (memory
    mapping) when an other program sets a flag
    (finished_producing_event.set() ) it just calls self.iconize(false)

    I'm not sure what pieces of code i have to post here.. posting all of
    it makes it too large i believe :)

    From server:


    ID_MESSAGECH = wxNewId()

    def EVT_RESULT(win, func):
    win.Connect(-1, -1, ID_MESSAGECH, func)

    class ResultEvent(wxPyEvent):

    def __init__(self):
    wxPyEvent.__init__(self)
    self.SetEventType(ID_MESSAGECH)

    class listener(Thread):
    def __init__(self, frame):
    Thread.__init__(self)
    self.frame = frame
    self.setDaemon(1)

    self.stopped = False

    #shared_memory = mmap.mmap (0, common.SHARED_MEMORY_SIZE,
    common.SHARED_MEMORY_NAME)
    #ready_to_consume_event = events.Win32Event
    (common.READY_TO_CONSUME)
    #finished_producing_event = events.Win32Event
    (common.FINISHED_PRODUCING)

    def run(self):
    while not self.stopped:
    try:
    finished_producing_event.wait()
    wxPostEvent(self.frame,ResultEvent(None))
    except Exception,e:
    print "Error: " , e

    def stop(self):
    self.stopped = True



    within the frame:
    [code:1:080343f1b1]
    listen = listener(self)
    listen.start()

    EVT_RESULT(self, self.OnChange)

    def OnChange(self, event):
    shared_memory.seek(0)
    tekstding = shared_memory.readline()
    if(tekstding.strip() ==
    "maximize"):
    self.Iconize(False)
    self.Show(False)
    elif(tekstding.strip() ==
    "minimize"):
    self.Iconize(True)
    self.Show(True)
    self.panel.tekst.SetValue(tekstding)
    [/code:1:080343f1b1]

    Hope you can see now how it works! Greetz
     
    DeRRudi, Jun 29, 2005
    #3
  4. DeRRudi

    DeRRudi Guest

    Well i want a external app to maximize and minimize my app.
    And later on i want the external one to send some data. Thought this
    would be the most easy (and fast) way!

    Greetz
     
    DeRRudi, Jun 30, 2005
    #4
  5. DeRRudi

    DeRRudi Guest

    Re: RE: Open running processes

    > Tim Goldenwrote:

    >
    > Rudi. I, at least, am reading this via the mailing list, not
    > via Usenet nor via Google. This means that if you don't put
    > any kind of context in what you post, I have to guess at what
    > you're responding to. (All I see is the exact text you typed,
    > nothing else).
    >
    > Assuming that you're answering my question: why use mmap and
    > not just two events? I understand what your overall plan is,
    > and it looks like you have a way to solve it. It just seemed
    > that you might be able to achieve the same thing with two
    > events: one for maximize and one for minimize. Why would
    > this be better? Well, only because it seems to me slightly simpler
    > than one event and a separate mmap mechanism. But I've never
    > done what you're doing, so I may well be completely wrong.
    >
    > TJG
    >


    Hi Tim,

    I'm sorry did not realize it!
    U are right! (i believe) at first i put in the minimize for testing.
    I'm only using the maximize.
    But it seemed handy to do it this way and beeing abled to send over
    data from an other programm. That's what i want to use the mmap for.
    Or am i missing something. because i'm not really seeing what your
    point is. Because it is a complete different process what is calling
    the maximize (or minimize) i can't just create an event and call it
    (or can i?)

    Greetz
     
    DeRRudi, Jun 30, 2005
    #5
  6. DeRRudi

    DeRRudi Guest

    Re: RE: RE: Open running processes

    > Tim Goldenwrote:

    > If you wanted to send over arbitrary data from another application,
    > then this is certainly a way to do it. (Another way might be to use

    a
    > Windows pipe, for example). My point was only that if you are

    signalling
    > an event as a wake-up call plus an atom of extra information saying


    > "max" or "min", and you weren't considering any expansion of this
    > vocabulary to include other commands, then two distinct events might


    > be simpler, one signalling "maximize", the other "minimize".
    >
    > Please don't take this as any criticism of your work: there's no

    one
    > right design decision here; I was merely curious as to the reasons
    > behind yours.
    >
    > TJG
    >


    Thanx for thinking with me! It really helps to have some other
    opinions! It might look simpeler to make two distinct events. But
    reading out the mm is really easy to do. So i didn't make more events
    for maximizing and minimizing. But further on i'm gonna use it. I
    think by now i have all the thing's i need to solute my problems.
    Thnx

    Rudi
     
    DeRRudi, Jun 30, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Divyang M
    Replies:
    4
    Views:
    1,054
    Divyang M
    Feb 17, 2005
  2. Rusty Shackleford

    Worker Processes Running counter?

    Rusty Shackleford, Oct 5, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    422
    Rusty Shackleford
    Oct 5, 2005
  3. rads
    Replies:
    2
    Views:
    3,198
  4. Jeff Rodriguez
    Replies:
    23
    Views:
    1,203
    David Schwartz
    Dec 9, 2003
  5. Marc Heiler
    Replies:
    1
    Views:
    191
    Robert Klemme
    May 24, 2009
Loading...

Share This Page