lllllIllIlllI 178 Veteran Poster

Here is what i would do. I would have something that is the Main function, that calls room1 to start off with... Then IF room1 wants to call room2 it returns a special value that means i know the Main function has to call room2.

def room1():
    #is you need to call room two then:
    if something:
        #return the number 2
        return 2

def room2():
    print "ROOM 2"

def Main():
    var = room1()
    if var == 2:
        room2()

So by having return values you can make it a lot easier to see what is going on as there is only one place to look (the Main function) as well as you don't get stuck in some massive recursive loop.

Hope that helps :)

lllllIllIlllI 178 Veteran Poster

Just go to the "Daniweb Community Feedback" forum, there is a whole topic on the situation that explains a lot about what is going on.

lllllIllIlllI 178 Veteran Poster

Personally i like the site as a whole. I love the bar down the bottom. I think it is a lot cleaner than the old sidebar. Though i still think it needs cleaning up. when i click 'My favourite forums' it doesn't align them very well and it looks really messy, especially on forums with long names.

I'm sure i'll get used to it. :)

Edit: also, the edit button has "Edit/Delete"... though i don't think we are really meant to delete posts on daniweb.. it could be a glitch. I'm not sure.

EDIT 2: It is just me or do the pages load faster now??

lllllIllIlllI 178 Veteran Poster

If you have to make your own sort algorithm i would look at the wikipedia pages for sorts such as the bubble sort. It is a very simple sort and the pseudo-code can be very easily translated into python.
http://en.wikipedia.org/wiki/Bubble_sort

From wikipedia pseudo code

procedure bubbleSort( A : list of sortable items ) defined as:
  do
    swapped := false
    for each i in 0 to length(A) - 2 inclusive do:
      if A[i] > A[i+1] then
        swap( A[i], A[i+1] )
        swapped := true
      end if
    end for
  while swapped
end procedure

Hope that helps :)

lllllIllIlllI 178 Veteran Poster

just an FYI as to what split is for (i am assuming you are new to python) is that is automatically splits up a string into its separate words. Such as

'Hello i am Paul'.split()
#Would give the result of a list:
['Hello','i','am','Paul']

The argument you can give it is what so split by in case you don't want to split by spaces. For your case it appears that you have a colon distinguishing your keyword from your value. Therefore the previous poster is correct in saying that x.split(':') should be perfect for you as it will split the string instead of by the spaces but by the colon.

Hope that helps

lllllIllIlllI 178 Veteran Poster

Sounds cool. Unfortunately living in Oz means that tomorrow will be about halfway into the afternoon. Oh well :P
Can't wait to see it in action, im happy as long as "My Favourite Forums" stays.

jonsca commented: Does your Australian browser render it "Favourite" on the screen? ;) +0
lllllIllIlllI 178 Veteran Poster

Can't wait for the new update! :)

lllllIllIlllI 178 Veteran Poster

Here is a quick program to get all the current ones. But it really doesn't matter if you overwrite them for the most part anyway. The chance of you doing that is also very small

import wx

for f in dir(wx):
    if f.startswith("ID_"):
        print f, eval('wx.'+f)

This will print the name of the ID with the corresponding value. They are all four digit though, so you could get around your problem by having 1,2,3,5,6 or 7 digit numbers.

Hope that helps! :D

lllllIllIlllI 178 Veteran Poster

If you knew that the array is only two deep (2D array) then you could do it:

for listIndex, subList in enumerate(myList):
    try:
        ind = subList.index('sheep')
        break
    except ValueError:
        print "Not in list number",listIndex
print "It is in list number",listIndex
print "and index number",ind,"of that list"

What that does is it goes through all the lists inside your larger list, looks for the string and if it finds the string it breaks from the loop and gives the two values, one is the list that it is in inside the larger list (from 0) and the other is the index of the string in that sublist.

hope that helps :)

lllllIllIlllI 178 Veteran Poster

<CannedResponseforhomework>
So, what have you done?
Remember here at daniweb we aren't here just to do your homework:
http://www.daniweb.com/forums/announcement114-2.html

When you have shown effort, we will show some too.
</CannedResponseforhomework>

lllllIllIlllI 178 Veteran Poster

Nah that is very very simple. See you get the text with the GetValue() method. If you look at the link i posted you will see that on that page it shows that the return value for the GetValue() function is a string.. sounds like what you want eh?

Next, you can give that string to any function you like, thats obvious to do.

And to put it onto the richtextctrl you will need another method, now logically think, if there was a GetValue() method, then there is probably a SetValue( value ) method, and voila! There is. All you need to do is give the method an argument of the string that you want to set the value to and you are done.

Hope that helps

lllllIllIlllI 178 Veteran Poster

One thing to always look into when using wxPython is the api. The one for the richtextCtrl is found here:
http://www.wxpython.org/docs/api/wx.richtext.RichTextCtrl-class.html
There you will find methods to set and get values, and by using these intelligently you should be able to achieve what you want.

lllllIllIlllI 178 Veteran Poster

Sheesh man who really cares. I hope you're not going to be getting that many infractions that the grammar actually annoys you.. :P

lllllIllIlllI 178 Veteran Poster

Hahaha.. well if you watch the news over here barely a night goes by that we do not hear about america and what is going on with the latest political situation and/or economic scenario. When the finance report goes on the news our currency is always compared to the US dollar. "The aussie dollar is trading 89.9 us cents today" would be something you would probably hear if you heard an australian news report.

So we get a lot of media from the US in the form of TV shows and music and such and we compare ourselves to it economically.

And i think because of the fact that though we do hear a LOT about the latest news over there and get the latest TV shows. It is rare that we actually get to see an average american (except for the ones you meet having a holiday)

So i don't know if the stereotype is a bad one per-say, more the fact that i didn't really know what to expect as most of the American interaction comes from news and TV. So i was pleasantly surprised and had a great time touring through America.

people here LOVE to talk about politics. Perhaps the level of discussion here is different than where you come from, i cant say

What i meant by "Don't talk politics" is more the fact that people (that we talked to) seemed a lot more passionate about their political views than i …

lllllIllIlllI 178 Veteran Poster

I have no experience with wx.Config so i can't help you there, but there is a way you could do this without that and just using a file.

#... inside your frame/panel class

    def LoadCtrl(self):
        #Assuming listctrl is called listOne
        #and the file is fileOne

        f = open(fileOne)
        for item in fileOne:
            listOne.append(item)

    def SaveCtrl(self):
        f = open(fileOne, "w")

        #Loop through and save each item on its own line
        for itemIndex in listOne.GetItemCount():
            f.write(str(listOne.GetItemText(itemIndex) + "\n"))

That demonstrates my idea, if you want to implement that it shouldn't be too hard :)

hope that helps :)

lllllIllIlllI 178 Veteran Poster

That is very sad news. I didn't know anything about that. Thanks for letting us know Aia.

lllllIllIlllI 178 Veteran Poster

A couple of days ago i just got back from my first overseas trip. Where did i choose to go for this trip of mine? No other place than the fabled USA.

As the first Paul to go there since Paul Hogan with Crocodile Dundee it was important to observe the environment around me to bring back to Australia my finding from thousands of miles away.

Overall i was pleasantly surprised. Rather then seeing the stereotypical idea that we see on the TV, i instead discovered that the general american is very, very different from the stereotype indeed. Though... some things arent.

So, what i learnt from America.

  • Walmart is freaking huge!! There is enough space for a McDonalds in it :P
  • Highways are hugs as well. Here in Oz we conider 3 lanes big. In the US 6 lanes seems like the big ones
  • Everything in McDonalds is bigger
  • There is A LOT of unsecured wireless.. someone needs to secure that stuff
  • People like guns.
  • Politics is not something to talk about. It's a touchy subject
  • So is healthcare
  • Socialism is a very very very bad thing
  • Healthcare is very expensive. And i heard, the number one way people are put into bankruptcy
  • Everything is cheaper
  • The associate australians with odd things sometime
  • Just a tip for americans. Australians hardly ever say "You beauty mate" unless you're in the outback
  • Vegas is crazy :)

But in the end my holiday was not only …

lllllIllIlllI 178 Veteran Poster

Wow, this is all so confusing i must say. I'm on my holiday in the US at the moment. Driving trip around California, as well as driving on the 'wrong' side of the road, all this tipping buisines is making this holidays even more complicated :P

we have been sticking with 15% as a good amount, though i agree with vega, 10% is a lot easier for the maths.

But anyway, i'll hardly be posting for the next few weeks. Having fun on my holidays, US is good fun :)

lllllIllIlllI 178 Veteran Poster

It isn't the third line that is having the issues. It is line 37. If you look there, there is an if yet no indentation after it. Though i assume all you need to do is backspace that if a couple of times to get it on the correct level.

Like this:

def getEnergyAndMana(magicExp, energyExp, maxYourMana, bonus, energyLevel, bonus1):
    magicLevel = 0
    if magicExp >= 0:
        magicLevel = 0
        maxYourMana = 50 + bonus
    if magicExp >= 550:
        magicLevel = 1
        maxYourMana = 100 + bonus
    if magicMax >= 1150:
        magicLevel = 2
        maxYourMana = 150 + bonus
    if magicExp >= 1750:
        magicLevel = 3
        maxYourMana = 200 + bonus
    if magicExp >= 2350:
        magicLevel = 4
        maxYourMana = 250 + bonus
    if magicExp >= 3050:
        magicLevel = 5
        maxYourMana = 300 + bonus
    if magicExp >= 3750:
        magicLevel = 6
        maxYourMana = 350 + bonus
    if magicExp >= 4650:
        magicLevel = 7
        maxYourMana = 400 + bonus
    if magicExp >= 5050:
        magicLevel = 8
        maxYourMana = 450 + bonus
    if magicExp >= 5750:
        magicLevel = 9
        maxYourMana = 500 + bonus
    if magicExp >= 6350:
        magicLevel = 10
        maxYourMana = 550 + bonus

    if energyExp >= 0:
        energyLevel = 0
        maxYourEnergy = 50 + bonus1
    if energyExp >= 550:
        energyLevel = 1
        maxYourEnergy = 100 + bonus1
    if energyExp >= 1150:
        energyLevel = 2
        maxYourEnergy = 150 + bonus1
    if energyExp >= 1750:
        energyLevel = 3
        maxYourEnergy = 200 + bonus1
    if energyExp >= 2350:
        energyLevel = 4
        maxYourEnergy = 250 + bonus1
    if energyExp >= 3050:
        energyLevel = 5
        maxYourEnergy = 300 + bonus1
    if energyExp >= 3750:
        energyLevel = 6
        maxYourEnergy = 350 + bonus1
    if energyExp >= 4650:
        energyLevel = 7
        maxYourEnergy = 400 + bonus1
    if energyExp >= 5050:
        energyLevel = 8
        maxYourEnergy = 450 + bonus1
    if energyExp >= 5750:
        energyLevel = 9
        maxYourEnergy = 500 + bonus1
    if energyExp >= 6350:
        energyLevel = 10
        maxYourEnergy = 550 + bonus1
    yourEnergy = maxYourEnergy
    yourMana = maxYourMana
    return maxYourEnergy, maxYourMana, yourMana, yourEnergy

Also, your code was mixing tabs and spaces.. thats a dangerous thing to do. Try just using spaces for the best results.

Hope that helps :)

lllllIllIlllI 178 Veteran Poster

Yeah... i might own that :P

EDIT: Woops, didn't see that this was just a bumped thread

lllllIllIlllI 178 Veteran Poster

If i remember correctly wxPython is not looking to port to python 3.x any time soon. So if you are interested in using that then i would reccomend that you don't change.

Personally i have not moved, i have tried it out but i never really found a reason to stick with it in the end so i have stayed with python 2.6 and i will until there is a major reason to change and at the moment there really isnt.

vegaseat commented: good point +10
lllllIllIlllI 178 Veteran Poster

Well i would start by re-downloading the file. Something may have gone wrong that caused the download to stop halfway through.

So try that, if you haven't already :)

lllllIllIlllI 178 Veteran Poster

And what have you done? Remember we are not just here to hand out free homework.

Show Effort

lllllIllIlllI 178 Veteran Poster

Yup, i think my count is one out :P

lllllIllIlllI 178 Veteran Poster

*claps* wow, congratulations. :P

lllllIllIlllI 178 Veteran Poster

Well i can help with your first problem.
I had trouble with this for a bit, but looking at the wxPython Demo's code i noticed that instead of just appending it, they first add a "StringItem" and get the return value of that (which is the index of the string item) and then just add values/colours to that.

#!/usr/bin/python

import wx
import sys

class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, (550, 350))

        self.List = wx.ListCtrl(self, wx.ID_ANY, style = wx.LC_REPORT)

        self.List.InsertColumn(0,"Title")
        self.List.InsertColumn(1,"Artist")
        self.List.InsertColumn(2,"Album")

        index =  self.List.InsertStringItem(sys.maxint,"We didn't start the fire")
        self.List.SetStringItem(index, 1, "Billy Joel")
        self.List.SetStringItem(index, 2, "Unknown")
        self.List.SetItemBackgroundColour(index,"light blue")
                                            
        index =  self.List.InsertStringItem(sys.maxint,"Take it easy")
        self.List.SetStringItem(index, 1, 'Eagles')
        self.List.SetStringItem(index, 2, 'The complete greatest hits')
        self.List.SetItemBackgroundColour(index,"green")
       

       

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, 'wxCAKE')
        frame.Centre()
        frame.Show(True)
        return True
    
app = MyApp(0)
app.MainLoop()

This shows how it is done. You should be able to see the vast difference from the last one, even though it looks like a lot more code, with a smart 'for' loop you should be able to get it a bit cleaner

hope that helps :)

lllllIllIlllI 178 Veteran Poster

I have a feeling that you could use a listctrl in a better way. If you use the style wx.LC_REPORT i think it is, you can have a look just like you want in just one widget.

Ill just give you an example.

#!/usr/bin/python

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, (550, 350))

        self.List = wx.ListCtrl(self, wx.ID_ANY, style = wx.LC_REPORT)

        self.List.InsertColumn(0,"Title")
        self.List.InsertColumn(1,"Artist")
        self.List.InsertColumn(2,"Album")

        self.List.Append(("We didn't start the fire", "Billy Joel", "Unknown"))
        self.List.Append(("Take it easy",'Eagles','The complete greatest hits'))

        sizer = wx.BoxSizer()

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, 'wxCAKE')
        frame.Centre()
        frame.Show(True)
        return True
    
app = MyApp(0)
app.MainLoop()

Hope that helps :) its amazing how much the widget changes just because of changing one style isnt it?

HAve a look at the wx api if you want to know more about the wx.ListCtrl and what you can do with it.
http://www.wxpython.org/docs/api/wx.ListCtrl-class.html

Cheers :)

lllllIllIlllI 178 Veteran Poster

Yeah, okay, sure a couple of members dont like it. But its not like you see this all the time. Just ignore it. Simple

lllllIllIlllI 178 Veteran Poster

Anyway, i thought this might be a good time to introduce myself in the Community Introductions board :P
http://www.daniweb.com/forums/post1147100.html#post1147100

lllllIllIlllI 178 Veteran Poster

Well, i am doing this because i think i should introduce finally.
So i am
Paul Thompson
16 years old
I live in Newcastle Australia

Probably the coolest thing that has happened in my life is that i lived on a boat for 3 years sailing up and down the Great Barrier Reef and the Whitsundays.

My interests revolve around my love for learning. I do gymnastics, not seriously, just for fun. I do piano and have been doing so for the past decade. I like to sail, kayak, surf and go camping, bushwalking and drama.
I go to an academically selective school where i did my first uni course, achieving a distinction in first year chemistry.

My background in programming is very little, i started programming 2 and a bit years ago when i did a google search for an assignment for school about hackers. In the article it was talking about programming languages that are used by these hackers and it mentioned python. I downloaded it and started learning instantly. Never was interested in hacking though :P

From there i have had a go at a few other languages, completing a university course in Java and getting a High Distinction as well as C, C++, C#, perl, ruby and javascript.


And thats me :)

lllllIllIlllI 178 Veteran Poster

hahaha, thanks guys :)

lllllIllIlllI 178 Veteran Poster

Well just then i hit 1000 posts, one of my prouder moments at daniweb :) http://www.daniweb.com/forums/thread264325.html

It's good to reach that number, and get a star on my profile. Does this mean i can count myself as a regular now? :P

Anyway, 1000 posts in i'm still loving it, so ill be sticking around for a while longer

Cheers
Paul :)

Nick Evan commented: congtrats! +0
diafol commented: Congrats on the big millennium! +0
Ancient Dragon commented: Yea! +0
jonsca commented: WTG +0
kvprajapati commented: Congrats! +0
lllllIllIlllI 178 Veteran Poster

This shows that your data inside the incoming_data list is of type long. You can just 'add' (+) strings and longs together. You can do one of two things.
You can do something like this using the comma

>>>print "Hello this uses a comma to add an int to the end",15
Hello this uses a comma to add an int to the end 15

Or you can use the str() method to change the int/long to a string and the add it together using the + sign.

>>> print "This uses the str method: "+str(15)
This uses the str method:15

I would reccomend either changing your code to

sql_cmd = \
        "INSERT INTO customer_synch " + \
        "VALUES ( " + \
        "'A', " , \
        incoming_data[0] , "," , \
        incoming_data[1] , "," , \
        incoming_data[2] , "," , 
        #you get the point by now

or

sql_cmd = \
        "INSERT INTO customer_synch " + \
        "VALUES ( " + \
        "'A', " + \
       str( incoming_data[0]) + "," + \
       str (incoming_data[1]) + "," + \
        str(incoming_data[2]) + "," + \

I hope that helps you out :)

BTW: one thousand posts!!!! YAY :)

Gribouillis commented: congrats for the 1000 posts +3
lllllIllIlllI 178 Veteran Poster

Perhaps just put it in the same directory as your executable. That could help, i have never really used icons on my programs so i'm not super sure, but when i use files in my executables such as .txt and .jpg i need to make sure that they are either bundled into the program (a bit of work) or in the same directory as the exe.


Hope that helps :)

ooh 999 posts, cant wait for the next one

lllllIllIlllI 178 Veteran Poster

Yeah, i got that. Its easily fixed by taking out the manifest. I didn't have this problem with windows XP but i am getting it with 7.
So i would use gui2exe like suggested above and just make sure that XP manifest file is unticket down the bottom

Hope that helps :)

lllllIllIlllI 178 Veteran Poster

You should put your code in

[code]

#your code here

[/code]
the code tags. This makes it a lot easier to see what your code is doing. It will keep indentation and highlight key words.

:)

lllllIllIlllI 178 Veteran Poster

Grib, i have a feeling this is for some kind of python assignment.

Essentially that pseudo-code works. I really never found pseudo-code that useful in python though. The actual code is just so similar to it that it almost makes no sense to make it. :)

lllllIllIlllI 178 Veteran Poster

Not really.. The links on my sig shouldn't count as spammy at all. They are not selling anything, i don't get a profit from anything, and they are all very programming related.

First one sends you to my site i made, a site *solely* devoted to wxPython tutorials. Very relevant to people who visit the python forum where i mainly post.

The others are links to a chat client that will connect the user to the daniweb irc channel.. again, i am failing to see in any way how that could be spam.

I think here that you are i have different definitions of spam.

MosaicFuneral commented: No excuses spammy-mc-spamming-pants. +0
lllllIllIlllI 178 Veteran Poster

You know what i found funny. On the post that i was agreeing with the whole idea of no up/down arrows and stuff a while back i got loads of people giving me up arrows on that post... Confusing much?

lllllIllIlllI 178 Veteran Poster

And also give them the power to be able to ban users with spammy sigs! That ReplicaWatches thing is really annoying me :S

Nick Evan commented: We should start a petition +0
Will Gresham commented: Agreed +0
lllllIllIlllI 178 Veteran Poster

You could just use the Show(False) function on all of the children of the panel.

lllllIllIlllI 178 Veteran Poster

Maybe you should just search for the module win32print and put it in the same directory as the executable. Thats what i would do. I know there are more complicated py2exe scripts that include these kind of things, you could look into those as well.

lllllIllIlllI 178 Veteran Poster

Do you get any error message? There should be a log file if you get an error while running the executable.

lllllIllIlllI 178 Veteran Poster

Perhaps have a dictionary?

>>> def FFunc():
	print "This is the F function"

	
>>> def BFunc():
	print"This is the B function"

	
>>> def DFunc():
	print "This is the D function"

	
>>> randomstuff = ['F','B','D','F','B']
>>> funcdict = {'F':FFunc,'B':BFunc,"D":DFunc}
>>> for f in randomstuff:
	funcdict[f]()

	
This is the F function
This is the B function
This is the D function
This is the F function
This is the B function
>>>

See by using the dictionary i could link the strings to a function, you could add functions and strings to the dictionary easily.

That was just a quick example made with IDLE but i think it illustrates the power of a dictionary and how it can be useful in these situations. :)

hope that helps :)

EDIT: Just re-read the question.. not so sure if this is relevant anymore :S

lllllIllIlllI 178 Veteran Poster

Glad i could help :)

lllllIllIlllI 178 Veteran Poster

Also, its good practice to not have functions that are using names that are already taken. Such as print, int, str, list bool and so on. So it's probably best if you change your list() function to another name. :)

lllllIllIlllI 178 Veteran Poster

This page explains it very clearly
http://www.network-theory.co.uk/docs/pytut/Packages.html

One thing i noticed quickly though, you are not meant to have

my_package/
	__init.py__
	sub_pack/
		__init.py__
		test.py

in your actual code for __init__.py Its just meant to be the way you organise the filesystem. From the first __init__.py you should be able to go something like

import subpack.test.py

and that should come back error free :)

hope that helps

lllllIllIlllI 178 Veteran Poster

If you are using python 3 then the above code will not work. What you will need to do then is slightly different as input() in python 3 returns a string.

choice = input("Press 1 to hit or 0 to stay")
if int(choice) == 1:
    print "Lets hit it!"
elif int(choice) == 0:
    print "nothin doing"

Hope that helps :)

lllllIllIlllI 178 Veteran Poster

Yeah, i was in favour of that "Up to" rep system back when Dave first suggested it, i'm surprised there hasn't been more talk on the subject. It sounds like a great idea.

lllllIllIlllI 178 Veteran Poster

Yeah i agree with vegaseat, we need to see the code for MyFrame, thats where the problem most likely is.

Also just to make sure, are you actually getting any errors? Or is it just not updating?