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


Groups > comp.lang.python > #63099

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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.037
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'systems.': 0.12; 'programs.': 0.14; 'does,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'stdout': 0.16; 'streams.': 0.16; 'subject:GUI': 0.16; 'subject:make': 0.16; 'subject:program': 0.16; 'subject:top': 0.16; 'ui,': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'command': 0.22; 'input': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'keyboard': 0.24; 'text,': 0.24; 'text.': 0.24; 'fairly': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'lines': 0.31; 'keys': 0.31; 'pipe': 0.31; 'such.': 0.31; 'stuff': 0.32; 'quite': 0.32; 'actual': 0.34; 'trouble': 0.34; 'maybe': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'writes': 0.38; 'handle': 0.38; 'whatever': 0.38; 'pm,': 0.38; 'read': 0.60; 'easy': 0.60; 'simple,': 0.60; 'most': 0.60; 'first': 0.61; "you'll": 0.62; 'such': 0.63; 'more': 0.64; 'different': 0.65; 'land': 0.65; 'results': 0.69; 'incoming': 0.72; "'make'": 0.84; 'burning': 0.84; 'end.': 0.84; 'streams': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=diF8KH68y+LYlq4YL1PIOB5OiTQxbBKN7Qlhemk41YI=; b=i0Dx853MtvBoKa8lSwPzfu4FUNXJ+dJ9qYvQ/mzbPvhY9HS08A1uTry0nO428y5Fl6 ouHpFCv+3HQ78A9B67SEMCTLNtcQ578mw7Bj1BKKlYkP9UHKeB+5yVwLZ+sI/gvkk7+/ x8W6LrxSCDpslsc+KuEiatUN+oYTX0vRD0EpggeEhLW6BxX5iCe+6dra7gMp9pvZFV/r Xj5i190YfeZe6BP2+4rlKgWC1Mm3NRGbYqKjVDZVxER2iCv9u+bCGCyuAGRCwX23VsQE gVjkFF4OZQChhV4ZyksqhSbf8ynxfH5HPGFT8wAY97KBttcKhpEEHa9EXTTXNGt1QsKb 9e+Q==
MIME-Version 1.0
X-Received by 10.68.66.1 with SMTP id b1mr99506268pbt.43.1388804115655; Fri, 03 Jan 2014 18:55:15 -0800 (PST)
In-Reply-To <CAPbpa4R0HBbztNKjj9e+S4ATCtMU8bAreopjxUUqOLDrtvH_oA@mail.gmail.com>
References <CAPbpa4R0HBbztNKjj9e+S4ATCtMU8bAreopjxUUqOLDrtvH_oA@mail.gmail.com>
Date Sat, 4 Jan 2014 13:55:15 +1100
Subject Re: How to make a tkinter GUI work on top of a CUI program?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4877.1388804119.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1388804119 news.xs4all.nl 2911 [2001:888:2000:d::a6]:60097
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63099

Show key headers only | View raw


On Sat, Jan 4, 2014 at 1: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.

You can't use communicate(), as it'll wait for the process to end. But
there are several quite different types of console UI, some of which
you'll be able to use and some you won't:

1) There's the simple, straight-forward writing to stdout/stderr.
Maybe it's a long-running 'make' or the burning of a DVD, but whatever
it does, it takes no input and writes to the standard streams. Easy to
work with - just read and handle incoming text.

2) There are interactive shell-type systems. You'll need to send them
more than just lines of text, probably, as you might need to send
command keys and such. But still fairly workable.

3) Then there's stuff that doesn't actually use the standard streams
at all, or uses them and uses something else as well. You can pipe
something into 'less', but it'll still look for actual keyboard input
for its control. You'll have a lot more trouble manipulating those
programs.

Something that uses ncurses is most likely to land in box 3.

ChrisA

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? Chris Angelico <rosuav@gmail.com> - 2014-01-04 13:55 +1100

csiph-web