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

Never mind i have found out the answer to my question. What i wanted to do was change a style of a button/TextCtrl/ListBox/Frame mid way through my program. I found out i can do this with:

#Change a panel for example
self.panel.SetWindowStyleFlag(self.panel.GetWindowStyleFlag()|STYLE TO ADD)
#This will add all the ones already there as well as the other one you add on.

Thanks for trying, i will mark this as solved now.

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

Hi everyone
What i am doing now is creating a program that the user can change the way buttons look half way through. My problem is i couldnt work out how to update the wx.Button's style while the program is running. I was wondering if anyone could help me for this.

Thanks!

lllllIllIlllI 178 Veteran Poster

Hi
What i am trying to do is make a wx.FileDialog() show Import as the label on the button. I know you can change it to such things as open and save but i cant find a way to let me change it to a label saying import.

Any help would be greatly appreciated. :)

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

why do they need to be different files, couldn't you just make them definitions in the one file and then just call them when they are needed?

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

How about this
Where are the nearest Toilets - Ahi Nai Ta Pai

lllllIllIlllI 178 Veteran Poster

Oh that is so mean! The poor people. The chimps looked pretty into it though! :)

lllllIllIlllI 178 Veteran Poster

Py2exe is probably the easiest one to use and there are code snippets helping you to use it as well. Vegaseat did this one -
http://www.daniweb.com/code/snippet499.html

lllllIllIlllI 178 Veteran Poster

Oh i'm so sorry Ene. The program uses the mouse to draw the picture. I should have said that above. Also it is best to try a small picture otherwise it will take some time to do. The amount of beeps will tell you how many minutes. Anyhow dont worry about it. I think i should do some more coding before i post it again. Thanks for trying though and sorry!

lllllIllIlllI 178 Veteran Poster

Hey everyone
I am interested in learning Pygame as a GUI that is suited to making games and i was wondering if it was worth it?

My question is, is it good for anything else than games or animations?

lllllIllIlllI 178 Veteran Poster

Hi guys
Im pretty new to java after programming with python for about a year i thought i'd give it a go. I did have a quick question though.
How would i check for membership in a string.
For example

String str1="Hello world";
String str2 = "world";

Is there any way to check if str2 in str1?

Thanks!

lllllIllIlllI 178 Veteran Poster

Sorry to double post and all its just i thought it might be useful to people if i posted the links to all of the modules this code needs so they could run it.

Win32 modules - python.net/crew/mhammond/win32/Downloads.html

Sendkeys - http://www.rutherfurd.net/python/sendkeys/

pyHook - http://sourceforge.net/project/showfiles.php?group_id=65529

wxPython - http://www.wxpython.org/download.php

Python Imaging Libary - http://www.pythonware.com/products/pil/

Sorry there is so many modules that people might not have.
Oh i will also attach the .py file this time in case people want to help. It is in the zip file i attach.

lllllIllIlllI 178 Veteran Poster

I am not trying to do that.
What i want to do is have it so you supply an image in the program and the program then draws it in paint. I really dont want to just shortcut and re-save it.

The point of the program is to see the actual image being drawn in paint. If you want just grab the source code i have attached to the previous post and have a look.

lllllIllIlllI 178 Veteran Poster

Hi guys

I have been making a program over the last few days that grabs an image and re-paints it in paint in 256 colour. The main thing this program is for is so you can watch it getting painted in paint.

It works perfectly on my computer but i find that as soon as i take it to faster computers the whole thing goes haywire. It just stuffs up the whole image becuase the program seems to just get ahead of itself. I am finding it difficult to debug as i do not have access to a computer that is fast enough to make is stuff up and so i was wondering if anybody out there with a fast computer is willing to lend a hand and help find a way to fix it so nothing goes wrong.

Note that you will need the Win32 extensions to python installed as well as PyHook so the program can exit when you press the Q key (to do this try it while it is changing colour otherswise it sometimes wont work). You will also need Sendkeys.

Any help would be appreciated!

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

you counld use string.replace
For example:

words = 'hello i enjoy eating rasberry muffins'
words = words.replace('rasberry muffins','toasted bread')
print words
# this will output 'hello i enjoy eating toasted bread'

Hope this solves your problem. :)

lllllIllIlllI 178 Veteran Poster

Well it worked fine for wxPython. Though it didnt work when i had it in window mode rather than console mode.

Its not perfect but never the less its still cool.

lllllIllIlllI 178 Veteran Poster

Everyone loves a game. So why not make a series of Dice games such as Two up and Yahtzee.

For an extra challenge make an AI to play with and also add a GUI!

lllllIllIlllI 178 Veteran Poster

yeah thanks everyone. They all worked really well.
I especially liked the Gpy2exe. It is really easy to use, it lets you automatically add an icon. So thanks guys for all the help. It is all looking a lot lot better now. :)

lllllIllIlllI 178 Veteran Poster

Hi
I have made a program that uses a GUI for most of its functions but as soon as i change it to an exe using py2exe all the buttons turn all square and everythin looks like it came from windows 98 rather than XP.

Is there any way to change this so the program keeps its XP styling?

lllllIllIlllI 178 Veteran Poster

If you want to can use the pyHook module
Download-http://sourceforge.net/project/showfiles.php?group_id=65529
Here is a program that will listen for any keystrokes really easily:

import pythoncom, pyHook 

def OnKeyboardEvent(event):
  print 'MessageName:',event.MessageName
  print 'Message:',event.Message
  print 'Time:',event.Time
  print 'Window:',event.Window
  print 'WindowName:',event.WindowName
  print 'Ascii:', event.Ascii, chr(event.Ascii)
  print 'Key:', event.Key
  print 'KeyID:', event.KeyID
  print 'ScanCode:', event.ScanCode
  print 'Extended:', event.Extended
  print 'Injected:', event.Injected
  print 'Alt', event.Alt
  print 'Transition', event.Transition
  print '---'

# return True to pass the event to other handlers
  return True

# create a hook manager
hm = pyHook.HookManager()
# watch for all mouse events
hm.KeyDown = OnKeyboardEvent
# set the hook
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()

Oh you also need pythomcom, i think that is in the win32 package which you can get from here:
python.net/crew/mhammond/win32/Downloads.html
as i said i only think it is in there.

lllllIllIlllI 178 Veteran Poster

That first module worked a treat! It is also so simple to use, ill show you a quick demo:

from SendKeys import SendKeys
SendKeys('Hello{SPACE}world{ENTER}')

This still needs some special characters to be put in differently but other then that it is really simple to use, great for running macros.

Thanks Grib :)

lllllIllIlllI 178 Veteran Poster

Hi
What i want to do for this is to have my program run in the background simulate pressing a button such as ENTER every 10 seconds or so. I have trauled the net and found solutions for VB and C++ but none for python.

Is this possible in python and if so how would i do it?

lllllIllIlllI 178 Veteran Poster

What kind of editing? Do you mean automated resizing or drawing new things onto the picture and then saving it?

wxPython has a lot of cool image/paint tools so you could check that out but in the end it really depends on exactly what kind of editing you want to do.

lllllIllIlllI 178 Veteran Poster

Hi
I have been trying to do one of the projects in the projects for beginners section that asks you to get your computer to log off after a certain amount of time has passed without any mouse or keyboard movement. I am not yet up to that bit, in fact i can't work out how to log off/shut down. It says to use the os module but i cant find anything that will do the trick.

I was wondering if anybody could point me in the right direction? Thanks in advance :).

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

Vegaseat gives a few options in this post:
http://www.daniweb.com/forums/thread34434.html
They include alternatives to Winsound.

lllllIllIlllI 178 Veteran Poster

how would i do that?

lllllIllIlllI 178 Veteran Poster

Hi
I have a weather forecasting program that uses a few threads. These threads stop and start at different times throughout the program so there is no set amount of threads at one time. My problem is when i try and close the main thread the program keeps going because there are still threads alive.

Seeing as the threads which are alive change all the time i was wondering if there was any way to kill all threads.

Any help would be greatly appreciated :)

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

Hi Guys

What i am trying to do here is have a tuple of numbers, lets say X. Then i have a list of a few other tuples. I want the program to find the tuple that is closest in value.

x = (214,521)
lis = [(200,500),(250,550),(300,600)]

I am doing this becuase i want to find where a person clicks on screen and then work out which function to run by finding which one in the list the person clicked closest to. Im having trouble getting started here so any help would be greatly appreciated.

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

Okay this is my solution

  • Go to Control Panel
  • Click System
  • Click the Advanced Tab
  • Click environment variables down the bottom
  • In the bottom scrollbox click on Path
  • Click edit
  • To the end of the list add this: ;C:\python25;C:\python25\scripts
  • If your python is not python 2.5 or is installed in a different directory you will need to change the paths to point to python.exe and the place where you keep your scripts.
  • Click okay
  • Now if you type python in the command line it should change to the python.exe interpreter

Hope that works

lllllIllIlllI 178 Veteran Poster

yeah. I really think Bill has been really charitable and well i understand why he would retire. I mean he would be super rich. Its not like he needs to save for his super annuation is it!

lllllIllIlllI 178 Veteran Poster

Could you hook the modem to the wired router and then run a CAT-5 cable or something to the wireless router?

also This site looks like it has some ideas to.

lllllIllIlllI 178 Veteran Poster

I dunno but thats what the site says that they are doing at the moment. They got about 13 million downloads and that must have to count for something at least!

lllllIllIlllI 178 Veteran Poster

that is one of the most Random games i have ever played! I got 70%

lllllIllIlllI 178 Veteran Poster

Are you running it in something like IDLE because if so getch wont work. Try using the python command window.

yeah i just checked the code in the command window and it works a-okay! :)

lllllIllIlllI 178 Veteran Poster

For easy 3d design programs you can't go past the free Google Sketchup

http://sketchup.google.com/

I also really like ashampoo CD and DVD burner, there is a free version wich is still quite good.

lllllIllIlllI 178 Veteran Poster

Sorry for unmarking it as solved but i had one more question.

Is there another way apply a bitmap to a panel without making it static?

lllllIllIlllI 178 Veteran Poster

Yeah that works without a hitch.
Thanks vega!