From: Ronald D S. <rd...@ea...> - 2001-10-18 23:36:42
|
I am not qualified technically to have an opinion, so please disregard evrything I say if it does not apply or if it annoys. Still I admire what you all are doing, especially Kevin, and I wish you the best. I'd lvoe to see PythonCard do great things, but I know I probably can't contibute anything to it. With those caveats, here goes: My interest has always been to see a very easy to learn and easy to use event driven GUI builder. When I was trying to choose between wxPython and Tkinter, someone brought up the idea of HyperCard. Although I never owned a Mac and therefore never used HyperCard, I was generally aware of it and had a good impression of it. PythonCard seemed like a great idea. I have used the PythonCard prototype, primarily to try to create a GUI version of a simple program I wrote in Python called Decision Analysis, which can be found at http://www.awaretek.com/Decision_Analysis_Beta27.py but which I have updated and cleaned up a lot but not posted yet to my webswite, so I will attach that code at the end of this message. Well, in playing around with PythonCard in order to create a GUI version of Decison Analysis, I began to study wxPython and then Tkinter a little more, to the point where I think I could now do a gui version of Decision Analysis in Tkinter easier than I could in PythonCard (at this stage of PythonCard). The reason being that, to me, at its current stage, PythonCard seems more complicated than wxPython or Tkinter. And with Tkinter being so well documented, it would be the easiest for me. And I wouldn't have to use resource files at all, which to me only complicate things. I assume that when PythonCard is finished, including documentation of some sort and an "environment" it will be easier and better for me. On top of that for now, I am all of a sudden consumed in my hobby-dom more by writing an "major " ;-))) extension of Decision Analysis that answers questions of fact by making web queries using Pythons url libraries and the re module for regular expressions. Which brings up a point: The reason I love programming in Python is becauase I can remember the syntax more or less completely, even as a weekend duffer, and just code things that are interesting to me. I think there are potentially millions (OK , at least hundreds of thousands) of folks like me, in that they will program for the love of it, but not if the programming tools require more "drudge" work than they are worth. So what the world needs, I think, is a "python" for gui event driven programs. I hope PythonCard can be that. I have never really used VB, although I did buy version 1.0 years ago; but it was not all that inviting at that time. I have never used Delphi/Kylix. So I guess you can say that I have almost no gui programming experience at all. I have played around with Boa and I like it; but it does not yet meet my desire for a "python" like gui programming expereince. Can PythonCard be a "python" like easy to learn and use gui programming tool? I can't resist showing my ignorance by speculating: 1. Visual Basic and Delphi and even Boa Constructor are one class of very visual gui programming tools, let's say. But Boa is already attempting this for Python, so why should anyone duplicate it? Besides, Kevin, your stated dislike for code generators tends to work against this sort of approach. Besides, Boa seems over complicated anyway. 2. HyperCard, as I imagine, in my ignorance, it must be, seems to be another kind of visual programming tool. An awful lot of folks who used it loved it, so it had something going for it. While I never used it, I find the general idea of a card like metaphor appealing. (As an aside, I still use an old M$ windows 3.0 applet called cardfile as a roll o dex type database of business contacts, phone numbers etc. Everybody knows how to use a rolodex) How would a HyperCard like PythonCard work? a. Could it use a metaphor in which each card was an object? That seems simple and appealing to me, but I have no idea if it make sense; and would it require mixing data with code? Not necessarily, because each card could contain its own widgets, including their associated event-handlers; but the whole stack of cards comprising a program could be scripted by one master Python program. b. Alternately, could each card be a Class? I guess I like (a.) better, but anyway using a HyperCard like metaphor would sure be nice. 3. Or, one could avoid the visual metaphor entirely. After all, Python itself is not Visual and it certainly meets my criteria for ease of learning/use. Who says a command-line gui programming tool could not be the easiest and best of all? Truthfully, in my ignorance, I don't see why this could not be done. Just give me simple widget names, event names and definitons, etc. Ideally, I could envison a PythonCard that used both (2) and (3) of my above options in combination; that is, a hyperCard like visual metaphor combined with a truly good command line python-like tool. Most of all, it should be consistent and make sense intuitively. But, if there is no HyperCard like metaphor at all, maybe the name should be change. I do think names are important, by the way. But if a card like metaphor of any kind is used, I would suggest keeping the PythonCard name, which I really like. Finally, I am sure you are going to create somethng great, Kevin. If the great thing you create happens to be an easier to learn/use gui creator than wxPython, I am pretty sure I'll be using it and enjoying it. Oh, one other thing; I think wxPython is the right base for PythonCard. It was the best choice. Why ry to support more than one gui foundation, it will only create alot of extra work? Finally, and most importanly to me, if there is any one idea I would like to contribute or endorse or back up, it is this. I hope that Kevin can get a lot of help. And I think one best way, I am hoping anyway, is for some one or few coders can join in to focus on the highest level programming environment or IDE aspect of PythonCard. cp...@em... (Chris Ryland) spoke up recently and expressed an interest in possibly coding a Real Basic like Python tool. If he could be coaxed into joining up with PythonCard and focus almost exclusively on the high end environment, wouldn't that be great? Why do another visual tool like Boa. Maybe Cris Barker could also join in. Most of all, it should be consistent and make sense intuitively. A Tall order, no doubt!!! ;-))))) Ron Stephens P.S. What one thing would I most like to see done next? ...a High End easy to use programming environment of some sort. Decision Analysis: print "A General Decision Analysis Program." print print "Have You Ever Had to Make Up Your Mind?" print import sys def get_number(prompt, lower=sys.maxint * -1, upper=sys.maxint): """ get_number(prompt) -> float This function prompts for a number. If the user enters bad input, such as 'cat' or '3l', it will prompt again. Now checks for upper and lower bounds. """ res = None while res is None: try: res = float(raw_input(prompt)) try: assert lower <= res <= upper except AssertionError: print "Value must be between", lower, \ "and", upper res = None except ValueError: pass return res def get_list(heading, prompt): print heading print print "(enter a blank line to end the list)" ret = [] i = 1 while 1: line = raw_input(prompt % i) if not line: break ret.append(line) i=i+1 print return ret def get_user_rankings(criteria): # Next, get the user to rank his criteria. I use a system where higher # is better, so that an undesirable characteristic can be given a negative # weight. # # {} is a dictionary, it can be indexed by (nearly) any expression, # and we will index it with the names of the criteria. rankings = {} print print "Enter relative importance of criteria (higher is more important)" print for c in criteria: rankings[c] = get_number("Criterion %s: " % c) return rankings def get_user_scores(options, criteria): # Next, get the user to score each option on all the criteria. # Scores are stored as a two-dimensional dictionary, like so: # {'option1': {'criteria1': 100, 'criteria2': 10}, # 'option2': {'criteria1': 50, 'criteria2': 10} # } scores = {} print print "Enter score for each option on each criterion" print for o in options: scores[o] = {} print print "Scores for option %s" % o print for c in criteria: scores[o][c] = get_number("Criterion %s: " % c) return scores def calculate_results(options, scores, rankings): # Calculate the resulting score for each option. This equation # is different from Rod Stephen's original program, because I # make more important criteria have higher rankings, and even let # bad criteria have negative rankings. # The "result" dictionary is indexed with the names of the options. result = {} # Criteria can be found automatically, doesn't need to be # passed as an argument. criteria = scores[options[0]].keys() for o in options: value = 0 for c in criteria: # print o, c, rankings[c], scores[o][c] value = value + rankings[c] * scores[o][c] result[o] = value return result def ranked_list(results): # Now, I want to take the dictionary result, and turn it into a ranked list results = results.items() # A list of tuples (key, value) results.sort(lambda x, y: -cmp(x[1], y[1])) # Sort the list using the reverse of the # "value" of the entry, so that higher # values come first return results def generic_decision_analyzer(options, criteria): pass def decisionanalysis(): # This code is placed in the public domain print print "This is a general decision program, and you can define your choices and criteria." print print "When prompted, please enter the options or choices that you need to decide amongst." print print "Then, when prompted, enter the criteria for making this decision." # First, ask the user to enter the lists options = get_list("Enter your options:", "Option %d: ") criteria = get_list("Now, enter your criteria:", "Criterion %d: ") print "A program to help you make decisions." rankings = get_user_rankings(criteria) scores = get_user_scores(options, criteria) results = ranked_list(calculate_results(options, scores, rankings)) print print "Results, in order from highest to lowest score" print print "%5s\t%s" % ("Score", "Option") # Take the pairs out of results in order, and print them out for option, result in results: print "%5s\t%s" % (result, option) # Here's the scores used by the language-choice functions. language_scores = {"Python": {"ease of learning":100, "ease of use":100, "speed of program execution":10, "quality of available tools":70, "popularity":50, "power & expressiveness":100, "cross platform?":100, "cost":100}, "Perl": {"ease of learning":50, "ease of use":60, "speed of program execution":20, "quality of available tools":50, "popularity":85, "power & expressiveness":70, "cross platform?":100, "cost":100}, "Ruby": { "ease of learning":50, "ease of use":100, "speed of program execution":20, "quality of available tools":20, "popularity":10, "power & expressiveness":100, "cross platform?":80, "cost":100}, "Tcl": {"ease of learning":100, "ease of use":100, "speed of program execution":10, "quality of available tools":50, "popularity":40, "power & expressiveness":10, "cross platform?":100, "cost":100}, "JavaScript": {"ease of learning":70, "ease of use":75, "speed of program execution":10, "quality of available tools":50, "popularity":100, "power & expressiveness":40, "cross platform?":50, "cost":100}, "Visual Basic": {"ease of learning":50, "ease of use":100, "speed of program execution":20, "quality of available tools":100, "popularity":100, "power & expressiveness":50, "cross platform?":1, "cost":1}, "Java": {"ease of learning":15, "ease of use":50, "speed of program execution":50, "quality of available tools":100, "popularity":90, "power & expressiveness":100, "cross platform?":100, "cost":100}, "C++": {"ease of learning":10, "ease of use":25, "speed of program execution":90, "quality of available tools":90, "popularity":80, "power & expressiveness":100, "cross platform?":90, "cost":100}, "C": {"ease of learning":15, "ease of use":20, "speed of program execution":100, "quality of available tools":80, "popularity":80, "power & expressiveness":80, "cross platform?":110, "cost":100}, "Lisp": {"ease of learning":40, "ease of use":50, "speed of program execution":80, "quality of available tools":60, "popularity":25, "power & expressiveness":110, "cross platform?":80, "cost":90}, "Delphi": {"ease of learning":50, "ease of use":110, "speed of program execution":85, "quality of available tools":100, "popularity":30, "power & expressiveness":100, "cross platform?":80, "cost":10} } def ProgramLanguageFinal(): print "This is a program to help give you an idea which programming languages you should consider learning." print "While there are any number of languages you might consider, this program considers only 11 of the most popluar ones." print print "The program will ask you to input a ranking or weighting for a number of criteria that may be of importance" print "in choosing your next programming language." # First look up the criteria listed in the scores. # To do that, we need a language name, which can also # be looked up from the scores. languages = language_scores.keys() some_language = languages[0] criteria = language_scores[some_language].keys() rankings = get_user_rankings(criteria) results = ranked_list(calculate_results(languages, language_scores, rankings)) # Take the pairs out of results in order, and print them out for option, result in results: print "%5s\t%s" % (result, option) def ProgramLanguageScript(): print print "This is a program to help you choose a scripting language." print print "You will be asked to rank some important criteria as to their relative importance to you." print "These criteria are 'ease of learning', 'ease of use', 'speed of program execution'" "'quality of available tools', 'popularity', and 'power & expressiveness'" print print "Please rank each of the criteria with a number from 1 to 100 when prompted." print print "100 means of highest relative importance, 1 means of least importance." # This time we want a subset of languages, so I'm going to specify them. options = ["Python", "Perl", "Ruby", "Tcl", "JavaScript", "Visual Basic"] criteria = language_scores[options[0]].keys() rankings = get_user_rankings(criteria) results = ranked_list(calculate_results(options, language_scores, rankings)) # Take the pairs out of results in order, and print them out for option, result in results: print "%5s %s" % (result, option) def Basketball(): print "This is a program to help you decide which team will win a basketball game" print print "When prompted, enter a number ranking each team on the prompted team skill" print "on a scale from 1 to 100, with 1 being terrible and 100 being the best imaginable" print team_one = raw_input ("What is the name of team one: ") team_two = raw_input ("What is the name of team two: ") teams = (team_one, team_two) rankings = {"speed":100, "size":66, "jumping_ability":50, "defense":60, "shooting":75, "ballhandling":50, "rebounding":50} criteria = rankings.keys() scores = {team_one: {}, team_two: {}} for c in criteria: for team in (team_one, team_two): scores[team][c] = get_number("rank the team %s of %s on a scale of 1 to 100: " % (c, team), 1, 100) results = calculate_results(teams, scores, rankings) for team in teams: print "%s has a power ranking of %d" % (team, results[team]) # Now, who won? ranked_results = ranked_list(results) # Compare the scores. if ranked_results[0][1] == ranked_results[1][1]: print "the two teams are a toss-up!!!" else: print "%s wins!!" % ranked_results[0][0] def YesNo(): print "Program to help you make a Yes or No decision." options = ["Yes", "No"] criteria = get_list("Enter your criteria ...", "Criterion %d: ") rankings = get_user_rankings(criteria) scores = get_user_scores(options, criteria ) print `scores` results = ranked_list(calculate_results(options, scores, rankings)) print print "The results are" print print "%5s %s" % ("Score", "Option") for option, result in results: print "%5s %s" % (result, option) if results[0] > results[1]: print "You should decide Yes!!!" else: print print "You should decide No!!!" print ###### MAIN LOOP ############ while 1: # loop forever print "Please enter the number for the type of decision you wish to analayze:" print "1. General Decision Analysis, you choose the options, criteria, etc." print "2. Help in Choosing Programming Language amongst 11 popular languages" print "3. Help in choosing scripting programming language amongst 6 scripting languages" print "4. Which Basketball Team will win the Game???" print "5. Questions with Yes or No type answers" choice = get_number("Please type in the number of the type of decision-program you wish to run from above and hit enter:", 1, 5) if choice ==1: decisionanalysis() elif choice ==2: ProgramLanguageFinal() elif choice ==3: ProgramLanguageScript() elif choice ==4: Basketball() elif choice ==5: YesNo() elif choice =="quit": break # exit from infinite loop else: print "Invalid operation" |