lllllIllIlllI 178 Veteran Poster

Yeah i did it a while ago and i remember getting to level 10

lllllIllIlllI 178 Veteran Poster

Oh its good. Actually i was wondering, do you rekon anyone from here has finished it?

lllllIllIlllI 178 Veteran Poster

If you ever need the values of wx ID's as well as any other constants in wxPython here is a way to do it:

import wx

class MainFrame(wx.Frame):
    def __init__ (self):
        wx.Frame.__init__(self,None,title = "ID's and Values", size=(400, 400))
        self.text = wx.TextCtrl(self, wx.ID_ANY, style = wx.TE_MULTILINE)
        
       
        for f in wx.__dict__:
            if f.startswith("ID_"):
                t = f+'  -->  '+str(wx.__dict__[f])+'\n'
                self.text.write(t)
        self.Show()
        

app = wx.App(False)
f = MainFrame()
app.MainLoop()

If you want a full dictionary of values try this:

import wx

class MainFrame(wx.Frame):
    def __init__ (self):
        wx.Frame.__init__(self,None,title = "ID's and Values", size=(400, 400))
        self.text = wx.TextCtrl(self, wx.ID_ANY, style = wx.TE_MULTILINE)
       
        for f in wx.__dict__:
            try:
                t =  f+'  -->  '+str(int(wx.__dict__[f]))+'\n'
                self.text.write(t)
            except:
                pass
        
        self.Show()
        

app = wx.App(False)
f = MainFrame()
app.MainLoop()

Notive that bit where is goes str(int(wx.__dict__[f])) ? Thats to make sure that anything that has a value that isnt an int will not work as there will be an error and the program will skip it.

lllllIllIlllI 178 Veteran Poster

Have you tried the python challenge?
http://www.pythonchallenge.com/
It is a bit obscure sometimes yet a lot of fun and can really test how efficient your code can be.

lllllIllIlllI 178 Veteran Poster

I used to do this is i wanted to restart the file:

exec file("File Name Here")

That will re-open your python program again.

lllllIllIlllI 178 Veteran Poster

Ah! Got it. i have been looking at your code and i notice this:

print p.Hi()

the problem is that you dont need to print it becuase the printing is done INSIDE the method, so for this just delete the print statement and just have:

class add:
    def __init__(self, name):
        self.name = name
    def Hi(self):
        
        print self.name, "just joined"
        
while True:                          
    i = raw_input("command>")
    if i.split()[0] == 'add':
        p = add(i.split()[1])      
                                    
        p.Hi()                    #dont print a function that does not return anything
        
    else:
        print "no"

The only times in which you can PRINT a function is when it returns something, in this case the function p.Hi() didnt return anything so the value None was given.
Hope that helps.

lllllIllIlllI 178 Veteran Poster

So you want the user to be able to specify which class to use?
Well a way to do that would be to split the string and do some if statements such as:

i = raw_input()
if i.split()[0] == 'add':
    p = add(i)
    p.hi

If thats not it could you just maybe clarify it for us.
Thanks

lllllIllIlllI 178 Veteran Poster

when you go.

if word in tuplelist:
    #do stuff

That is a problem. The reason is your comparing something that looks like this:

"Hello"

To something that looks like this

[("hello","something you say as a greeting")]

Now those dont look quite the same right?
So what you need to do is say,

if True in [word == f[0] for f in tuplelist]:
    #do stuff

That might not be the most efficient way but it will work better.

lllllIllIlllI 178 Veteran Poster

yeah that did the trick. Thanks a lot.

lllllIllIlllI 178 Veteran Poster

I cant get the link to work. It says this:

You have attempted to access code for an article that does not exist. Create this article first. If the article used to exist, it may have been deleted.

Am i the only one getting this problem?

lllllIllIlllI 178 Veteran Poster

Just a tip. If you want other people to be able to play this game you need to fix a few things. The one that instantly comes to mind is that you spell beggar like "begger" when the actuall spelling is beggar. For this reason some people will find it more difficult to play your game.

and the problem is on line 467. There you say

if prompt == 'look around' or 'look':
    #do stuff

The problem is that python will check if prompt is equal to "look around" and then for the next one is does not check if prompt is equal to look. If you wanted this to work then you would have to go

if prompt == "look around" or prompt == "look":

Cause at the moment it checks the first statement and it returns false because prompt does not equal "look around" but then seeing there is nothing being compared to "look" the program returns True becuase "Look" is not an empty string and therefore returns true in the case of an if statement when nothing is being compared.

lllllIllIlllI 178 Veteran Poster

What functions dont work? I mean there are a lot of functions you need to be a bit more specific then to just say my functions dont work. Do all of them not work, or just one or two?

lllllIllIlllI 178 Veteran Poster

okay, i know this is not exactly what you asked but in your code i noticed a lot of:

print ""

You dont need to do that as just going

print

Without the "" marks will do the exact same thing. Or you could use

print """\n\nIn this game you will live your life in a completely text based world, the world of Tekstovia."""

and that will stop the need for those other prints.

Also, put this whole thing through some kind of spellchecker because there are so many spelling mistakes.

lllllIllIlllI 178 Veteran Poster

Have you had a look at the wx.ProgressBar? Becuase in the Docs and Demos they show a way to do just that. You might have to decipher the un-needed code though.

lllllIllIlllI 178 Veteran Poster

The problem is that loop1 exists in two places. In the global scope and in the function scope. This means that the loop1 in the function is different to the loop1 in the main body. To get around this you can add global loop1 to your program.

lllllIllIlllI 178 Veteran Poster

Why use the getattr? I think gribs way of doing it probably is what you want.

lllllIllIlllI 178 Veteran Poster

Are you using wxPython?
In that case the event you are looking for is: wx.EVT_LEFT_DOWN

lllllIllIlllI 178 Veteran Poster

What do you want re-arranged. That piece of code looks perfect.

lllllIllIlllI 178 Veteran Poster

Jargon is programming terms such as variables, definitions, modules. At least thats how i understand it to be.

lllllIllIlllI 178 Veteran Poster

Yeah i definitly agree with steve. Cause what is happening at the moment is that your program makes a BoxSizer and then you instantly overwrite it with a FlexSizer so i would reccomend you get rid of one of them really im just echoing steves words but they are very true.

lllllIllIlllI 178 Veteran Poster

Have you tried self.Refresh? I know it dosent do that much but i find it helps in many circumstances.

lllllIllIlllI 178 Veteran Poster

Remember to mark the post as solved if you have solved your problem! :)

lllllIllIlllI 178 Veteran Poster

Why are you using a flex Grid Sizer? You could do exactly what you want with just a wx.Sizer.

lllllIllIlllI 178 Veteran Poster

you can use such flags as

wx.TOP
wx.BOTTOM
wx.LEFT
wx.RIGHT

#Here is an example
self.sizer.Add(self.Tree,proportion=1,flag = wx.TOP|wx.BOTTOM)
#Now that would only expand top and botton
# I cant remember if you need wx.EXPAND in there too....

to tell the sizers which ways it is allowed to expand.

lllllIllIlllI 178 Veteran Poster

Could we see a sample of code perhaps?

lllllIllIlllI 178 Veteran Poster

I think you might we able to use sizers to do this. There is a flag you can use when making a sizer called wx.ALIGN_CENTER and this will keep it in the center no matter what.

lllllIllIlllI 178 Veteran Poster

Hi
Just download the wxPython Docs and Demos and go to the wxWidgets Reference. I think that might help.

lllllIllIlllI 178 Veteran Poster

It would be cool if you could have a text file full of all of the words so the user could add their own.

Your text file could look like this:
Python:yothnp
spam:apms

This was the user could add their own and you could just import it to a dictionary at the start like:

f = open("Words.txt")
for thing in f.split(":"):
    dictionary[thing[0]]=thing[1]
lllllIllIlllI 178 Veteran Poster

I tried it and liked it. I thought it was nice to just have a web browser that was so simple for once.

As much as it is good i just cant see why google needed to enter the web browser wars!

lllllIllIlllI 178 Veteran Poster

I think this might have a lot to do with the competition being held in Australia for High School Students in python at the moment, it sound suspiciously like a problem that is stumping almost all of the people on the final week.

lllllIllIlllI 178 Veteran Poster

just quickly i wanted to remind Darkangel or the NCSS Challenge rules. Rule 3 stated that:

"The solutions you submit must be your own. It is fine to discuss the problems, and to read code in books or on web sites to get ideas, but you must be the author of any code you submit. It is not okay to copy anybody else's code and submit that as if it is your own."

This just means discuss it all you like but you are not allowed to directly use code that other people have made.
People at Daniweb just remember for this comp that people are not meant to do get direct answers.

lllllIllIlllI 178 Veteran Poster

This is how i do it:

a=b=c=None

Hope that helps! :)

lllllIllIlllI 178 Veteran Poster

you could change the 'while play' to something else that was an integer that equalled 10 and then every time the person has their turn you subtract one away from it until it is zero and the program ends.

import random

words = ['sprinkles', 'computer', 'mouse', 'shooter', 'edge', 'guard', 'python']
myword = random.choice(words)
guesses = "aeiou"
turns = 10

while turns:
    turns-=1
    print "Do you want to play a game?"
    play = raw_input('Answer (y) yes or (n) no:')
    if play == 'y':
        print 'Let\'s begin'
        print ""
        for letter in random.choice(words):
            if letter in guesses:
                print letter,
            else:
                print '_',
        break
    if play == 'n':
        
        print 'Good-Bye.'
        break

Oh and also a quick question. Why are you breaking at line 20. Remember a break will end the loop forever so i dont see why you would want it there?

lllllIllIlllI 178 Veteran Poster

yeah i get this error a lot. What i do to fix it is to go Ctrl+Alt+Del and then go to processes and then stop and python process.

Hope that works! :)

lllllIllIlllI 178 Veteran Poster

You could always do something like this:

m= int(start[1])*60+int(start[4])
n= int(finish[1])*60+int(finish[4])

That will make M and N integers so you do not need to convert them at all but i did my own program to do the same thing to see if i could change anything and this is what i got:

def length(): #using a function
    print 'Please enter the start of the show in the format 03,16'
    start = raw_input(">")
    print "Please enter the end of the show in the format 03,16"
    end = raw_input(">")
    m = int(start[:2]) *60+int(start[3:])
    n = int(end[:2]) *60+int(end[3:])
    length = n-m
    print "the show lasted for %i minutes" %length


while True: 
    length()
    print "Press enter to restart and x to exit"
    f = raw_input()
    if f.lower() == 'x':
        break
    else:
        pass
lllllIllIlllI 178 Veteran Poster

yeah that [0] was only there becuase there was a tuple in the previous versions of code