Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
757 views
in Technique[技术] by (71.8m points)

user interface - console application gui for python

We have console application option in C#, but how do I can make a console GUI in python? I should note I want to compile and use my program in windows. Also I want to select Items in Python GUI by Enter button.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you're using Windows you will ultimately need to integrate with the win32 console API to create a console GUI (aka. a Text UI or TUI). Your options are basically:

  1. Write your TUI using curses or the packages that sit on top of it, like urwid or npyscreen. To do this you either need to install cygwin or PDcurses to make it work.
  2. Write to the win32 API directly using something like pywin32.
  3. Use a package that simplifies the win32 API like effbot's console package.

I found all the above unsatisfactory as I didn't want all the hassle of installing 3rd party binaries for Windows and wanted an API that I could use anywhere (after a simple pip install), so I wrote a cross-platform package (asciimatics) to fix it. This package takes all the hassle away and provides a clean, documented API with a set of widgets for TUI applications.

For example the following is a screenshot of the contacts list sample code referenced in the previous docs link, showing some of the basic text and button widgets.

Sample screenshot


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...