a1eio 16 Junior Poster

hmm cant seem to get it working, it doesnt display anything at all...
EDIT: it works now, thanks again

a1eio 16 Junior Poster

yes, thanks
it's just for a small app i'm runing on my computer at schol, which i doubt will ever change from windows, thanks for the help!!

a1eio 16 Junior Poster

thanks! i'm gonna try and look into it myself, but i've got deadlines on my back so i don't know if i'll get the time.

thanks again,
alex

a1eio 16 Junior Poster

Hi,

I've got a small program, that would be really useful if it could stay on top of other windows programs, i don't think there is a method for that in Tkinter,
if anyone has any experience or ideas on this topic, please let me know

thanks

a1eio 16 Junior Poster

your putting ':' after the def WordCount() line arn't you, simple i know, but just checking...

a1eio 16 Junior Poster

i was just messing about, not really making anything, i have this little script i run at school to tell me when the teacher turns the monitoring software on, it basically does a netstat and checks for the port, but i have to keep opening a netstat pipe, i just thought it would maybe be faster if i just opened a dos shell through python and kept sending the same command. nothing really important i was just intreeged about the write part but i could never get it working.

>>> import os
>>> a = os.popen("cmd","w")
>>> a.write('echo test')

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in -toplevel-
    a.write('echo test')
IOError: [Errno 22] Invalid argument
>>>

IOError: [Errno 22] Invalid argument is the error i tend to get all the time

cheers for the help :)

a1eio 16 Junior Poster

hi,

The following code is the find function part of your code but with part of the solution
it now prints the index (location) of the begining of a string or letter but i havn't a clue how to highlight text.

def find():
    findStr = tkSimpleDialog.askstring("Find", "Find:") # Prompts user to enter a string, if nothing is entered, function returns None
    if findStr: # Test to see if the function returned a string or None
        print findStr
        start = 1.0
        while 1:
            position = text.search(findStr, start, stopindex=END)
            if not position:
                break
            print "string was found at ", position
            start = position + "+1c"
    else:
        print 'nothing was entered'

the text widget uses index's, 1.0 would mean the first row (1) and the first column (0)
just picture the text widget as a grid, with one character in each square

so when you enter a string to search, it returns either nothing (if nothing was found) or the index for the first character in the string.

at the end of the while loop, the "+1c" means +1 column.

www.pythonware.com has documentation for all of Tkinter

a1eio 16 Junior Poster

yea i know, i could have just done 'start' or 'cmd' or something like that but it's the write bit where i get problems, all other cases i get an error EXCEPT for if i use

a = os.popen("cmd","w")
a.write("bla")

that gives me no error, but i also see f*all

and yea i can imagine it is from the program.

a1eio 16 Junior Poster

i was thinking msdos, as in i do summit simple to test like:

popen('start command.com').write('echo test')

something similiar to that?

a1eio 16 Junior Poster

yea i kinda got that it's the write bit i'm interested in, and i havn't managed to actually write anything without getting an error, lol i'll play with it

a1eio 16 Junior Poster

i don't understand the use of the os.popen function, i've used it to read things, for example:

>>> a = os.popen("netstat")
>>> for line in a.readlines():
	print line

	


Active Connections

>>>

i understand that, but there is also a buffersize and a write ability, but i've played about with it and i keep getting error's and stuff, i'm wondering if someone happens to know anything about the writing ability, i was thinking it would be cool if i could open some kind of pipe and write to it.

thanks

a1eio 16 Junior Poster

hehe bumsfeld, sounds like a MUD your describing there ;)

i got one for all you maths nuts out there...

re-invent the wheel!!!!

well not quite, the challenge is quite simple, make an algorithm or function or whatever that returns the square root of any number, WITHOUT USING ANY INBUILT SQUARE ROOT FUNCTION!!!!!

so essentially, re-invent the wheel.:mrgreen:

have fun guys,
a1eio

a1eio 16 Junior Poster

not too sure what you meant mate but www.pythonware.com has a great documentation for Tkinter, here's a link to a page on the site that may or may not help you:
http://www.pythonware.com/library/tkinter/introduction/x953-menus.htm

a1eio 16 Junior Poster

yea, i knew about the popen thingy, the issue i have is that i wouldn't know the actual command that would tell a disk to eject

explanation: 'If you have a memory stick or anything like it, one way of stopping it before you pull it out is to right-click on the icon in the explorer window then select eject from the list, i basically want to know the command that does that or the way to do it without using explorer'

a1eio 16 Junior Poster

How do i access or call system commands (can't really think of a better thing to call em???)
for example on explorer you can right click on an object and select eject, or format ect ect (mainly eject is what i want to know about)
any help would be greatly appreciated
thanks,
a1eio

a1eio 16 Junior Poster

it's a game,
i run out of ideas and frequently ask my friends for things to code this time he said that there is a game site he plays (i now play it ;) ) but the layout is rubbish so he wanted me to code something that grabs the data from certain pages then put it in a tkinter gui style table so it's easier to work out numbers and how many of this you need to train and how many of that you need to buy, ect, ect
*back to the site*
the site only shows this 'end of turn' page (and other's) if it is still 'connected' to the side bar at the left hand side, if it's not, it redirects you to an error page. So... i want to know how to trick a webpage into thinking it is being viewed how it should (with it's main page and toolbar down the side), instead of being opened on it's own or by a program.
it's hard to explain.
and if you want to view the site you would have to register ect ect
unless of course your interested in text based, resource handling style web games

*EDIT: www.aarcsoft.com, then click on 'games' then click on the top game, then choose the server you want to connect to, then register and play, simple as that really

a1eio 16 Junior Poster

don't worry, it's a start, at least now i can read the sites so thanks for the help :)
goto start somewhere

a1eio 16 Junior Poster

hi,
i'd like to create something that basically grabbes information from websites, however i havn't any experience in urllib (apart from very basic page reading) and the issue is that the page i want to grab data from checks to see if another page is connected to it or perhaps to better phrase it: checks to see if it in the correct ifram in relation to an iframe next to it, hard to explain but i any help or pointers is appreciated.

a1eio 16 Junior Poster

hmm well i've little experience with pygame myself but are you sure your not missing something in your code?
i think you need to type stuff like pygame.init() and you have to flip the display stuff like that, like i said i'm not too sure but if you go on the pygame website http://www.pygame.org they might have something in the documentaion or go on their irc channel
a snippet of your code might be good?
then someone can look at it and see whats wrong

a1eio 16 Junior Poster

Wehey very nice thats solved my issue

a1eio 16 Junior Poster

Thats a very good point, i never looked at it that way, and i bet that if you use the py2exe to make a 'portable' program because it ships with the python24dll thingy then maybe thats actually a little more multi-system than a bog standard compiled exe. (then again maybe not hehe all speculation)

a1eio 16 Junior Poster

Yea but Micko has a point. it does suck when you want to take a simple short and sweet program you made with python to school or an internet cafe or any other place where you are not allowed to install stuff, i mean py2exe is good but whenever i use it i get a whole load of crap thrown in with the exe and a folder that has 5 or 6 .py files (i know they are needed but it's still anoying), ok it's good if you know where you are going but for quick and easy compilation and running python does lack...a lot

a1eio 16 Junior Poster

I'm not very certain on classes and stuff like that myself but i'm guessing and from what i've read i think if you do

class namehere(calender_name):
    stuff here

can't guarantee it will work (not on my computer so i can't get at python to try it)
but it's just an idea

a1eio 16 Junior Poster

hehe indeed,
wait we shall but when the time is right, it's right!!
hehe :D

a1eio 16 Junior Poster

hehe however py2exe might be able to do it, thanks anyway i'll look into it

a1eio 16 Junior Poster

hehe good point but you must remember those brainy guys with those phd's who have spent their lifes study on neurology still know very little at all compared to what there is to know about the brain and it's wonderfully complicated system, ooo! reverse engineering a brain must be fun indeed *wink *wink (NOT!!)
hehe
i'm from england aswell and my approuch is much less technical i wanted to write something similiar to a program called billy (i think it's on release 4.0 now)
anyway you basically talk to it and over a period of time it starts to understand things more ect ect.
All in all i'm just a very bored kid who is always looking for tasks/targets. and untill i get to actually take a 'programming' course and not this 'IT' crap they make you do at gcse level, i havn't got any tasks/targets set for me to do.

P.S have fun understanding that, hehe

a1eio 16 Junior Poster

Well I already have 3ds max, and know how to use it, but it doesn't work for what I need it for. You can only make the given shapes (Sphere, teapot, cilinder for example).

I'll check out those other programes though, thanks :)

So your telling me that when they used 3dsmax on the movie 'the day after tomorrow' they only used rectangles and teapots??
no offence mate but you obviously don't know how to use it, the whole idea is that you morph the basic shapes together:
If you want some examples on what can be done just go on some art sites and look under 3dsmax or go on google and search there.

P.S It's even used for animation aswell! it's a top-end graphics package!

P.P.S Halo 2 is a legend (a very young one perhaps but still...)

a1eio 16 Junior Poster

I wouldn't mind looking into robot design myself, that is a cool subject it's just the mechanical (physical) part i'd have trouble with. Low budget y'see ;)

a1eio 16 Junior Poster

How about this for something to do:

If you don't know what a ceaser cypher is then read this: http://library.thinkquest.org/C0126342/ceaser.htm

Make a simple program that encrypts and decrypts a simple sring into a ciphertext (my terminology is terrible, so bear with me)
example:

let's encrypt the string: 'ceaser'
using a ceaser shift of lets say...11
so to start with, the 'c' in ceaser would be shifted 11 places down the alphabet and end up as 'n':

a b (c) d e f g h i j k l m (n) o p q r s t u v w x y z
     ^ --------- 11 -------- ^

so basically you do that untill all the letters in the plaintext 'ceaser'
have been shifted 11 places along the alphabet:
'ceaser' == 'npldpc'

Note: if you reach the end of the alphabet and the count (11) is still not finished just go back to the start, ('s' and 'r' had to do that)

So once you've got that nailed, let the user input the string they want to convert and perhaps let them change the shift (number of places the letter is moved)
then simple enough if you want to decode/decrypt (whatever it's called) just stick a minus in front of the shift number (11 would = -11) so that it shifts backwards, simple as that ey?
hehehe have fun, and remember to be careful because symbols …

a1eio 16 Junior Poster

thanks for the link, i'll check it out but after what you said i think i'll go a bit easy on the subject, the months and months of testing sound rather stressfull, hehe ;)

thanks again,
a1eio

a1eio 16 Junior Poster

Hi, all you daniwebber's!!!
Simple (ish) question,
AI seems to be a really cool subject, the one problem for me is that i havn't a clue at all what it is and how it works (more to the point, how i could learn to implement it)
So i'm just wondering, if anyone has any experience or knows of a good BEGINERS guide or tutorial (paper whatever you call them) on Artificial Intelligence

thanks peeps

a1eio 16 Junior Poster

i've made a little animation using python and the pygame module,
I'm just wondering if it's possible to turn that into a screensaver?
is there a format i have to save it to?

If anyone knows i would be grateful for the solution

thanks,
a1eio

a1eio 16 Junior Poster

no probs, glad i could help :)

*edit: that smiley looks evil

a1eio 16 Junior Poster

How about this:

Make a program that can generate random passwords
For example:

password length is fixed (or the user could enter a length)
number of characters in password is random (or again the user could specify)
number of digits in password is random (or user specified)
location of numbers/characters in password is random OR you could ask the user for a word then you could use that as a base and perhaps stick things on the end or begining or perhaps replace certain letters with numbers.

All up to you, it's just an idea

a1eio 16 Junior Poster

I program for a hobby, not a job (yet)
so i have a severe hunger for ideas, this thread is great and i would like to contribute,
Here are some ideas that might give someone in my situation something to do:

This is an extract from a song by pink floyd, in my opinion (and my friend who pointed it out to me) it looks like an algorithm (set of instructions) Doesn't take long but it's interesting to see how other people do it. Simple terms:
Turn this into code

All movement is accomplished in six stages,
and the seventh brings return.
The seven is the number of the young light.
It forms when darkness is increased by one.
Change return success.
Going and coming without error.
Action brings good fortune...
Sunset.

P.S You may say there's no point, it depends on how you look at it...

a1eio 16 Junior Poster

havn't got an example, but my very rough guess is maybe you could do something along the lines of;

wrap a function around the time.sleep() function that when called it starts the sleep in another thread so that the program will only continue untill;
sleep ends,
thread gets killed (stoppped)
so the way to interrupt could be to manually shut down the thread which in turn would shut down the sleep

OR

you could make your own sleep class that allows you to kill it?

something along those lines anyway
not too experienced on threading or using classes

a1eio 16 Junior Poster

yes on two counts:
1. it looks awfuly messy ;)
2. it was a binary file and it's sorted now :)

a1eio 16 Junior Poster

yes
when i do text = f.read()
then when i print text i get a little bit then if i do it again i get a load more then if i try again i don't get anything and i am positive that there is still much much more

>>> f = file("file.txt","r")
>>> f.read()
'\x17\xa9\xaa\t\xb5\x11%$\xe9e\xcf\xaf\x1e\xee\xcf\xcb\xab\xef\xd7_r\x95\x94^ \xa8\x9e\x9b\xe4+\xcen\x9fY^\xeaI\x13\xbc\x08\xb4G\x7fiHP['
>>> f.read()
'\xa8\xca\xc9)\xde\xfa7|9l\xdc%\xe6\x17\xc5\x96F6\xc8Jx&\xf4\x0b\xb2&\x87\xbe\xe5\xeb>\x0f\xf6\xa7t\xa5"m\xfeM\xbd\x9f\x18\xbd\xf5MVT\xb2 \x13\x94S\xd0\x1c\x9b\\\xb9.g\xcb\x80\x05.-l\x87\x92&e\xd9\xf3\x9c4\xdb\xb0\x13\xee\xd8\x98vA\xf6U\xfdp/\x199\xc3A^\nC\x97\xe7\x9d`i\xf3\x1f\x89\x19\xb8:<2\x1f$\x8b\xe1\xe5K\xb4c\x03S\xbcB\x81\x92\xa9\xd0\xb4\xaaW\xcd\xf3ds\x8c\xb5\x87\xa5\x97L\xc3r0\rX\xd9\x8d(\xac=L\xfdp\x95\xf38yw\xf3e\xff\x07\x08pc=j\xac%\xad\xb7\xc9-6\xefi%\xb7\x7f\xb0\xe3H\xaf\x8f\xbf\x04k\x0b\xc5\xe4\xc9R\xa2\xc4.\xe3F\xfd\x84\x94\x01\xbeb\xaf5\x93\x95\tG+\xe5;\xfe\xe7\x92\xe6\xee8W0\x19NyEu*\xb1>\x7f\x9bc\x11q\x1d\x0c\xe9^:K\xab\xc5dt\xeb\xd4\xd7\x02\x1c\xf6\x8c\xecB\xdb\xb83\xef\xa2\xfb\x89\xd6J\xa6\x98\xaf\x126\xad\xc6\xf6\x84F\xf5\xed\xb8fL\x04|\x130\x18\x7f\xeaH?\xd2-\xed\x9b#6l\xa7W\xbd\xe1\xc4\x9d\xc8\x01\x13s\xbfwU\xa6\x80P\xf3\xdf\xe4\t\xd7\xb9\x96\xae<\xf1\xa6\xbf\x19\xb2\xc0&d\x8bt\x06\xb6\x10i\xb8\x90\xb1\xfb\xa4\xd9\xd5\x0fR\xd2\xb7\x9ax\t\r\xc0K\x92\x13\xe7\xcf\x1e\xe4\xb9\x91\x12\xcbe_\\r"w\x13\x8fF\xdc\xa1\x14\xe6\x16\x96]b7\xc1q\xbdY\xcb\xdb@q\xf3\x1d8\xa8\rHB'
>>> f.read()
' '
>>>

as you can see it does it once then it does it again
so i need some kind of method to keep doing it over and over again untill the whole file has been sucked dry

a1eio 16 Junior Poster

I want to read everything from a file using python. the one problem i am having (note: EVERYTHING from a file) is that python is returning an EOFError when i know that it's not the end of the file, is there any way to just read the damn thing till the computer crashes or at least untill the file i want to read from has been literaly sucked dry.

basically is it possible to either skip an eof key and keep reading or specify my own.

thanks
alex

a1eio 16 Junior Poster

just use clean python:

>>> a = 5
>>> b = 4
>>> a, b = b, a
>>> a
4
>>> b
5
>>> a = 'text1'
>>> b = 'text2'
>>> a, b = b, a
>>> a
'text2'
>>> b
'text1'
>>>