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


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

Re: How to make a tkinter GUI work on top of a CUI program?

Started byJerry Hill <malaclypse2@gmail.com>
First post2014-01-04 01:35 -0500
Last post2014-01-04 01:35 -0500
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to make a tkinter GUI work on top of a CUI program? Jerry Hill <malaclypse2@gmail.com> - 2014-01-04 01:35 -0500

#63113 — Re: How to make a tkinter GUI work on top of a CUI program?

FromJerry Hill <malaclypse2@gmail.com>
Date2014-01-04 01:35 -0500
SubjectRe: How to make a tkinter GUI work on top of a CUI program?
Message-ID<mailman.4893.1388817335.18130.python-list@python.org>
On Fri, Jan 3, 2014 at 9:44 PM, Beinan Li <li.beinan@gmail.com> wrote:
> But some console programs have their own shell or ncurse-like CUI, such as
> cscope.
> So I figured that I need to first subprocess.popen a bidirectional pipe and
> send command through stdin and get results from stdout and stderr.
>
> But in such a case I found that communicate('cmd') will freeze.

Right.  communicate() waits for the subprocess to end, and the
subprocess is still waiting for you to do something.  Instead, you'll
need to read() and write() to the subprocess' stdin and stdout
attributes, probably something like this (untested):

def OnClickBtn(self, event):
    print('OnClickBtn')
    self.subProc.stdin.write('symbolName\n')
    print(self.subProc.stdout.read())

It looks like cscope has both a screen-oriented mode and a line-based
mode.  When you're working with a subprocess like this, you're going
to want to be in the line-based mode, so you'll probably want to add
-l or -L to your command line.

-- 
Jerry

[toc] | [standalone]


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


csiph-web