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


Groups > comp.lang.python > #63137

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

References <CAPbpa4R0HBbztNKjj9e+S4ATCtMU8bAreopjxUUqOLDrtvH_oA@mail.gmail.com> <CADwdpyYGmfV7wbEpWj0YXMZ=8kSep4EPQ6H181ungJwoF=0Vgg@mail.gmail.com> <CAPbpa4Si0wyFyWVegOhf6+h3Tk6=h3QH1swkujkCOjJTJXiPPQ@mail.gmail.com>
Date 2014-01-04 11:31 -0500
Subject Re: How to make a tkinter GUI work on top of a CUI program?
From Beinan Li <li.beinan@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.4907.1388853075.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

... and thanks to Chris too.
Now I got the better idea how the subprocess module works.


On Sat, Jan 4, 2014 at 11:29 AM, Beinan Li <li.beinan@gmail.com> wrote:

> Thank you so much Jerry.
> I should have read though the man page more carefully.
> The available online cscope tutorials never mentioned the line-oriented
> mode.
>
>
>
> On Sat, Jan 4, 2014 at 1:35 AM, Jerry Hill <malaclypse2@gmail.com> wrote:
>
>> 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
>>
>
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to make a tkinter GUI work on top of a CUI program? Beinan Li <li.beinan@gmail.com> - 2014-01-04 11:31 -0500

csiph-web