Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 5th, 2003, 06:58 PM
telex4's Avatar
telex4 telex4 is offline
Wacky hack
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 512 telex4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 29 sec
Reputation Power: 8
text ui development

Hullo,

I'm currently trying to find a good way to rewrite the text-based interface to QuickRip. At the moment, it just uses print statements and pipes to open the "clear" command, which works OK but has major drawbacks:

1) If the contents is bigger than the screen, the top is pushed off the screen
2) Getting user input isn't as intuitive as it should be

I've been pulling my hair out playing with curses, which is quite frankly horrible to code with, and I'm getting nowhere slowly.

Has anyone stumbled across any good text-based UIs? Got any of their own code to make life easier in the shell?

Any discussion is really appreciated at the moment!

Reply With Quote
  #2  
Old August 5th, 2003, 10:43 PM
percivall percivall is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 133 percivall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I don't know if it'll help, but look at cmd.py in your python distribution.

"A generic class to build line-oriented command interpreters."

Might be less than you want, or plain wrong. Anyway, there it is.

Reply With Quote
  #3  
Old August 6th, 2003, 05:21 AM
telex4's Avatar
telex4 telex4 is offline
Wacky hack
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 512 telex4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 29 sec
Reputation Power: 8
I'll have a look... thanks for the tip.

At the moment I'm persevering with curses as the only option. It's really annoying that about 5 years ago someone wrote a wrapper for curses called Tinker which is exactly what I want, but it no longer exists!

Reply With Quote
  #4  
Old August 6th, 2003, 03:43 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Hi Telex,

I dont know if this is what your looking for but the ui bit attracted me, and since it mentions Tk and well , anyway here's the link

http://www.pythonware.com/products/uitoolkit/

Mark.

Reply With Quote
  #5  
Old August 6th, 2003, 03:47 PM
telex4's Avatar
telex4 telex4 is offline
Wacky hack
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 512 telex4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 29 sec
Reputation Power: 8
Thanks for that link Mark. They only seem to have Tk 'bindings' at the moment, so it's not much use to me. I'm still blundering on with curses, trying to force it to behave the way I want. If I end up getting it to work, I might try to release a module that makes some useable widgets using curses, just so the next fool who decides to try this has something useful to work with

Reply With Quote
  #6  
Old August 20th, 2003, 02:50 AM
TheBlackMamba TheBlackMamba is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 25 TheBlackMamba User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to TheBlackMamba Send a message via Yahoo to TheBlackMamba
I don't know a thing about curses, but heres some code i'm using for my ui:

#Prompt: The prompt text (colon automagically added)
#Type: 0 for str, 1 for num input
#ValidResp: a list of Valid Responses
def Prompter(Prompt, Type=0, ValidResp=[]):
Valid = 0
while Valid == 0:
if Type == 0:
Resp = raw_input(Prompt + ": ")
if ValidResp != []:
for Case in ValidResp:
if Resp == Case:
Valid = 1

if Valid == 0:
print "Error - Invalid Input (" + `Resp` + ")"
else:
Valid = 1

elif Type == 1:
try:
Resp = input(Prompt + ": ")
if ValidResp != []:
for Case in ValidResp:
if Resp == Case:
Valid = 1

if Valid == 0:
print "Error - Invalid Input (" + `Resp` + ")"
else:
Valid = 1

except ValueError:
print "Error - Invalid Input"
except NameError:
print "Error - Invalid Input"
except SyntaxError:
print "Error - Invalid Input"
return Resp

#Banner: a title for the menu
#OptDict: a dict with the keys as the display text, and the values as #the functs to be called
def Menu(Banner, OptDict):
print Banner
print "-"*(len(Banner) + 3)
print
Order = [Key for Key in OptDict]
Order.sort()
Counter = 1
for Key in Order:
print "(" + `Counter` + ")", Key
Counter += 1
print
Choice = Prompter("Enter your choice", 1, [i for i in range(0, Counter)])
OptDict[Choice]()

Don't know if it'll help much, but good luck!

Reply With Quote
  #7  
Old August 20th, 2003, 05:42 AM
telex4's Avatar
telex4 telex4 is offline
Wacky hack
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 512 telex4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 29 sec
Reputation Power: 8
It's quite similar to the code I already have, or rather the more modular code I've been considering to replace the current CLI code.

I'm dropping curses because it's just too painful to work with.

p.s. any chance you could format that code using the forum's code tags? That way the indentation would be kept...

Reply With Quote
  #8  
Old August 20th, 2003, 08:59 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Hey guys, what are curses? There seems to be allot of talk about them and I have no idea what hey are

Mark.

Reply With Quote
  #9  
Old August 20th, 2003, 10:27 AM
telex4's Avatar
telex4 telex4 is offline
Wacky hack
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 512 telex4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 29 sec
Reputation Power: 8
curses is an API for command line interfaces. It's useful when developing complex CLIs, though it'd really awful to work with. Lots and lots of GNU tools use ncurses (ncurses being the Free version of curses)

Reply With Quote
  #10  
Old August 20th, 2003, 10:38 AM
percivall percivall is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 133 percivall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
telex4, I don't know how far you've got, but have you checked out Pyncurses or PySlang? They might bring something new to what you're trying to do.

There's also the Python Dialog project, and pyrepl, a replacement for the readline module in python.

And what about Iface? Might it be something?

Also, I guess you've already checked out the Charming Python: Curses Programming article.

If you already know about these, they might help someone else.

Last edited by percivall : August 20th, 2003 at 10:45 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > text ui development


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway