2 threads; 1 more Tkinter and 1 more terminal. problem

Discussion in 'Python' started by ChrisChia, Aug 15, 2010.

  1. ChrisChia

    ChrisChia Guest

    Hi all,
    i am trying to do a GUI with Tkinter package, but i am stuck no matter
    what...
    The problem right now is that my GUI has a label= 'A' (where 'A' is
    the text on display)

    i wish to run a program with 2 threads... one for my GUI and the other
    for the terminal where the terminal will keep listening to the user
    input (let's say if he enters 'B'), the GUI will update it's label to
    'B'.

    It's easy to let the terminal wait after the user has entered the
    input.
    But the problem is that when the GUI loads up... the

    root.mainloop()

    doesn't seem to release the control, hence my thread cannot work on
    GUI.

    Is there a way to solve this problem?
    2 threads; 1 more GUI and 1 more terminal.
     
    ChrisChia, Aug 15, 2010
    #1
    1. Advertising

  2. ChrisChia

    Terry Reedy Guest

    On 8/15/2010 10:22 AM, ChrisChia wrote:
    > Hi all,
    > i am trying to do a GUI with Tkinter package, but i am stuck no matter
    > what...
    > The problem right now is that my GUI has a label= 'A' (where 'A' is
    > the text on display)
    >
    > i wish to run a program with 2 threads... one for my GUI and the other
    > for the terminal where the terminal will keep listening to the user
    > input (let's say if he enters 'B'), the GUI will update it's label to
    > 'B'.


    Makes no sense to me. GUI = graphics user interface. Interface = input
    from and output to the user. Additional threads for for other activities
    that may block or be compute intensive, not a separate text user interface.

    > It's easy to let the terminal wait after the user has entered the
    > input.
    > But the problem is that when the GUI loads up... the
    >
    > root.mainloop()
    >
    > doesn't seem to release the control,


    That seems to be the point of a GUI

    --
    Terry Jan Reedy
     
    Terry Reedy, Aug 15, 2010
    #2
    1. Advertising

  3. ChrisChia

    ChrisChia Guest

    On Aug 16, 4:17 am, Terry Reedy <> wrote:
    > On 8/15/2010 10:22 AM, ChrisChia wrote:
    >
    > > Hi all,
    > > i am trying to do a GUI with Tkinter package, but i am stuck no matter
    > > what...
    > > The problem right now is that my GUI has a label= 'A' (where 'A' is
    > > the text on display)

    >
    > > i wish to run a program with 2 threads... one for my GUI and the other
    > > for the terminal where the terminal will keep listening to the user
    > > input (let's say if he enters 'B'), the GUI will update it's label to
    > > 'B'.

    >
    > Makes no sense to me. GUI = graphics user interface. Interface = input
    > from and output to the user. Additional threads for for other activities
    > that may block or be compute intensive, not a separate text user interface.
    >
    > > It's easy to let the terminal wait after the user has entered the
    > > input.
    > > But the problem is that when the GUI loads up... the

    >
    > > root.mainloop()

    >
    > > doesn't seem to release the control,

    >
    > That seems to be the point of a GUI
    >
    > --
    > Terry Jan Reedy



    The idea has is that the interface acts as a window to display the
    text type from the terminal.
    It's a crazy idea but i wish to implement something that way.

    The GUI in the case will display any text that the user enters from
    the terminal...

    Any idea to make both the processes running and listening at the same
    time?
     
    ChrisChia, Aug 16, 2010
    #3
  4. ChrisChia

    Jemy Guest

    On Mon, Aug 16, 2010 at 5:13 AM, 金鑫鑫 <> wrote:

    > Hi Man,
    > I have done that according to your requirements
    > Here is the code
    > {code}
    >
    >> #!/usr/bin/python
    >>
    >> import Tkinter
    >>
    >> import threading
    >>
    >>
    >>> root=Tkinter.Tk()

    >>
    >> root.geometry("100x100")
    >>
    >> v=Tkinter.StringVar()
    >>
    >> label=Tkinter.Label(root,textvariable=v,fg="red")
    >>
    >> label.pack(fill=Tkinter.X,expand=1)
    >>
    >>
    >>>
    >>> def getInput():

    >>
    >> while True:
    >>
    >> global v
    >>
    >> inputStr=raw_input("Enter>>")
    >>
    >> v.set(inputStr)
    >>
    >> t1=threading.Thread(target=getInput,args=())
    >>
    >> t1.start()
    >>
    >>
    >>> Tkinter.mainloop()

    >>
    >>
    >> {code}

    >
    > 2010/8/16 ChrisChia <>
    >
    > On Aug 16, 4:17 am, Terry Reedy <> wrote:
    >> > On 8/15/2010 10:22 AM, ChrisChia wrote:
    >> >
    >> > > Hi all,
    >> > > i am trying to do a GUI with Tkinter package, but i am stuck no matter
    >> > > what...
    >> > > The problem right now is that my GUI has a label= 'A' (where 'A' is
    >> > > the text on display)
    >> >
    >> > > i wish to run a program with 2 threads... one for my GUI and the other
    >> > > for the terminal where the terminal will keep listening to the user
    >> > > input (let's say if he enters 'B'), the GUI will update it's label to
    >> > > 'B'.
    >> >
    >> > Makes no sense to me. GUI = graphics user interface. Interface = input
    >> > from and output to the user. Additional threads for for other activities
    >> > that may block or be compute intensive, not a separate text user

    >> interface.
    >> >
    >> > > It's easy to let the terminal wait after the user has entered the
    >> > > input.
    >> > > But the problem is that when the GUI loads up... the
    >> >
    >> > > root.mainloop()
    >> >
    >> > > doesn't seem to release the control,
    >> >
    >> > That seems to be the point of a GUI
    >> >
    >> > --
    >> > Terry Jan Reedy

    >>
    >>
    >> The idea has is that the interface acts as a window to display the
    >> text type from the terminal.
    >> It's a crazy idea but i wish to implement something that way.
    >>
    >> The GUI in the case will display any text that the user enters from
    >> the terminal...
    >>
    >> Any idea to make both the processes running and listening at the same
    >> time?
    >> --
    >> http://mail.python.org/mailman/listinfo/python-list
    >>

    >
    >



    --
    Hi,I am Jemy
     
    Jemy, Aug 16, 2010
    #4
    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. Chris
    Replies:
    4
    Views:
    366
    Charles Sanders
    Apr 19, 2007
  2. Chris
    Replies:
    8
    Views:
    708
    Chris
    May 9, 2007
  3. gaurav kashyap
    Replies:
    3
    Views:
    6,653
    Paul Boddie
    Oct 31, 2008
  4. Steve
    Replies:
    2
    Views:
    935
    edicionsdigitals.com edicions digitals xarxa socia
    Dec 7, 2010
  5. Une bévue
    Replies:
    0
    Views:
    141
    Une bévue
    Jun 14, 2006
Loading...

Share This Page