woooee 814 Nearly a Posting Maven

"ans" is never changed under the "while ans" loop so it loops continuously. A function Click Here would make things easier and cleaner

def get_numbers(number_to_get):
    return_list = []
    lits = ["first", "second", "third", "fourth", "fifth"]
    for num in range(number_to_get):
        input_num = raw_input("enter your %s number " %(lits[num] ))
        return_list.append(input_num)
    return return_list

ans=raw_input("""
Thanks for choosing addition mode!  
How many numbers would you like to add? """)
numbers_list = get_numbers(int(ans))
print numbers_list
woooee 814 Nearly a Posting Maven

no idea why my program is not reading the text file correctly

I have no idea what that means.

Print the entire string you are checking and it will show the problem with the upper/lower/digit statements. The upper and lower may work but the digit will not because the input can not be converted to an integer.

infile = open("text.txt", "r")
for character in infile.readlines():
    print repr(character)

    if character.isupper() == True:
         print "Upper"

    elif character.islower() == True:
       print "Lower"

    elif character.isdigit() == True:
       print "Digit"

    else:
        print "None of the above"
woooee 814 Nearly a Posting Maven

I think most programmers will tell you that the Graphics module is more trouble that it is worth. Here is similar with Tkinter and using "after" for the timing. You can easily get events, like mouse clicks, in Tkinter also Click Here

import tkinter as tk
import random

class App():
    def __init__(self):
        self.root = tk.Tk()
        self.cv = tk.Canvas(self.root, width=600, height=300) 
        self.cv.grid()

        self.start_y=30
        self.num_runs = 1
        self.flash()

        self.root.mainloop()

    def flash(self,):
        start_y = self.start_y
        start_x = 50
        color = random.choice(["blue", "yellow", "orange", "green", "white"])
        for ctr in range(random.randint(1,9)):
            self.cv.create_oval(start_x, start_y, start_x+30, start_y+30,
                                fill=color)            
            start_x += 50
        self.start_y += 50

        if self.num_runs < 5:
            self.root.after(1000, self.flash)
            self.num_runs += 1
            print self.num_runs

if __name__ == "__main__":
    app = App()
woooee 814 Nearly a Posting Maven

A simple Google turned up pyQtGraph Click Here and there have to be many other examples out there. Matplotlib is an excellent tool, though not Qt.

woooee 814 Nearly a Posting Maven

You have check_button() declared twice in the code above. One of them should be deleted. A proof of concept to show that the code is working as programmed (although possibly not as you want). Add a print statement to show the values for GPIO.input(13) and GPIO.LOW. Possibly the else statement is hit every time so it looks like nothing is happening.

from Tkinter import *

##import time

def say_ALLON():
    print "ALL LIGHTS ON"

def say_ALLOFF():
    print "ALL LIGHTS OFF"


def say_FSON():
    print "FRONT LIGHTS ON"

def say_FSOFF():
    print "FRONT LIGHTS OFF"

def check_button():
    print "check_button"
    if labelText.on_off:
        labelText.set("REAR LIGHTS ON")
    else:
        labelText.set("LIGHTS OFF")
    labelText.on_off = not labelText.on_off
    root.after(500, check_button)


def say_RSON():
    print "REAR LIGHTS ON"

def say_RSOFF():
    print "REAR LIGHTS OFF"



root = Tk()

button = Button(root, text="Quit.", fg="red", command=quit)
button.grid(row=5, column=3)

FSON_there = Button(root, text="FRONT LIGHTS ON!", command=say_FSON, height = 8, width = 25)
FSON_there.grid(row=2, column=2)

FSOFF_there = Button(root, text="FRONT LIGHTS OFF!", command=say_FSOFF, height = 8, width = 25)
FSOFF_there.grid(row=2, column=3)

RSON_there = Button(root, text="REAR LIGHTS ON!", command=say_RSON, height = 8, width = 25)
RSON_there.grid(row=3, column=2)

RSOFF_there = Button(root, text="REAR LIGHTS OFF!", command=say_RSOFF, height = 8, width = 25)
RSOFF_there.grid(row=3, column=3)

ALLON_there = Button(root, text="ALL ON!", command=say_ALLON, height = 8, width = 25)
ALLON_there.grid(row=4, column=2)

ALLOFF_there = Button(root, text="ALL OFF!", command=say_ALLOFF, height = 8, width = 25)
ALLOFF_there.grid(row=4, column=3)

labelText = StringVar()
labelText.set("REAR LIGHTS ON")
button1 = Label(root, textvariable=labelText, height=4)
button1.grid(row=3, column=4)

root.title("CONTROL SYSTEM")
root.geometry('700x500+200+200')

labelText.on_off=True
root.after(10,check_button)
root.mainloop()
woooee 814 Nearly a Posting Maven

There is more than one way to skin that cat. I use a tkinter variable and update it. Note that you have to call updater() to get the whole thing started.

try:
    import Tkinter as tk     ## Python 2.x
except ImportError:
    import tkinter as tk     ## Python 3.x

class UpdateLabel():
    def __init__(self):
        self.win = tk.Tk()
        self.win.title("Ausgangsposition")
        self.win.minsize(800, 600)
        self.ctr = 0
        self.tk_var = tk.StringVar()
        self.tk_var.set("0")
        lab=tk.Label(self.win, textvariable=self.tk_var,
                       bg='#40E0D0', fg='#FF0000')
        lab.place(x=20, y=30)
        self.updater()
        self.win.mainloop()

    def updater(self):
        self.ctr += 1
        self.tk_var.set(str(self.ctr))
        if self.ctr < 10:
            self.win.after(1000, self.updater)
        else:
            self.win.quit()

UL=UpdateLabel()
woooee 814 Nearly a Posting Maven

You can tell if a file has been changed by the size of the file and date. Check the os.stat module. st_size will give you the size. And one of the getxxtime in os.path will give you the time there is more than one

woooee 814 Nearly a Posting Maven

Keeping track of everything is going to become a pain without a class structure. Note the use of partial to pass the window id to the next function. You can do this but how are you going to keep track of the responses? I would suggest you consider a generic function that receives the questions or whatever and updates a dictionary with the answers. It then returns to a common window with a "Next" button, which destroys the previous window and calls the function again with the next question, etc.

from Tkinter import *
import tkMessageBox
from functools import partial

def init(win):
   win.title("Ausgangsposition")
   win.minsize(800, 600)
   win.configure(background='#40E0D0')
   win.resizable(width=FALSE, height=FALSE)
   lab=Label(win, text="Aktueller Kurs:  Euro/BTC", bg='#40E0D0', fg='#FF0000')
   lab2=Label(win,text="Aktuell verf\xfcgbare Coins: BTCs", bg='#40E0D0', fg='#FF0000')
   lab.place(x=20, y=30)
   lab2.place(x=20, y=70)

def messageWindow():
    root.withdraw()
    windz = Toplevel()
    message = "This is the child window"
    Label(windz, text=message).pack()
    Button(windz, text='Next', command=partial(next_message, windz)).pack()

def next_message(tk_id):
    tk_id.destroy()
    root. deiconify()
    Button(root, text='Quit', command=root.quit, bg="red").pack()

root = Tk()

## eliminate things not necessary for this example
#root.withdraw()
#root.overrideredirect(1)
#root.update()
#root.deiconify()

btn = Button(root, text="Hello", command=messageWindow)
btn.pack()
#init(root)
root.mainloop()
woooee 814 Nearly a Posting Maven

The response was to your first error message.

win" is closed but cmd shows error logs every 5 seconds because of the label in "getcurrentrateandcurrentbalance()".
Any idea how to fix this? The methode seems to be called again although "win" is closed.

It was still running because Tk was still running. Your function calls itself repeatedly

def getcurrentrateandcurrentbalance():
    threading.Timer(5.0, getcurrentrateandcurrentbalance).start()

What is it you are trying to do? And why does creating a label require Threading and Timer? It is better to use Tkinter's after() and update() if necessary to call a funcion every x seconds. Click Here

Your next error will be because of an undeclared variable (at least in the code you posted).

print "Hello, World!" + result

"result" if not declared or updated in the function.

woooee 814 Nearly a Posting Maven

You have to destroy/quit the Tk() instance. You can not do that because "win" now points to a Toplevel. Give the Toplevel another, unique name.

win = Tk()
win = Toplevel()
woooee 814 Nearly a Posting Maven

The button's command parameter http://effbot.org/tkinterbook/button.htm would call a funtion that would open a new Toplevel Gui http://effbot.org/tkinterbook/toplevel.htm

woooee 814 Nearly a Posting Maven
IndexError: list index out of range

means that at least one of the items in "x" has less than 3 elements. Before the sort, run some code to print anything with less than 3 elements and decide what you want to do with those records.

Note also that this while loop will never exit because d[2] and field do not change, (and you can not write to read only file).

    while d[2]==field: 
        fid.write(d+'\n')
woooee 814 Nearly a Posting Maven

I don't see the error line in the code you posted either, but in any case in the line

im = Image.open(resizelist[val])

resizelist is used to to store images throughout the code and not the file names which are necessary for Image.open(). A simple print statement should help you understand the problem, so if you print val, type(resizelist[val]), and resizelist[val] if you want, it will show that it is not a file name, based on the error message provided.

woooee 814 Nearly a Posting Maven

A guess would be that "newSentence" is used in both loops so contains only the value from the last loop. Or in
number = len(sentence)
"sentence" is not initialized and still has a length of zero.
Convert this code to a function and pass each player's correct-letters-guessed list and the to be guessed word to the function, returning the new list. Note that "in enteredLetters" should not be necessary as "in newSentence" will give the same result. For further assistance be more specific about what "it doesn't work" means.

woooee 814 Nearly a Posting Maven

You use the variable name "blue" in two different places.

woooee 814 Nearly a Posting Maven

Or put it in a Toplevel which can be positioned and sized.

woooee 814 Nearly a Posting Maven

This gets the directory name and has nothing to do with file name. TKinter has an askopenfilename method to get the file names.

woooee 814 Nearly a Posting Maven

but how do I make it more of an arbitrary path (rather than the C:\Users etc) since I need it so that anyone can run that program and write to that file.

Tkinter has an askdirectory Click Here

woooee 814 Nearly a Posting Maven

Do you want to include numbers and everything else not in string.punctuation

s_nopunct = "".join(c for c in s if c not in string.punctuation).lower()

Generally it is better to include what you want instead of excluding a certain set as above, as anything you forgot about is automatically included.

s_nopunct = "".join(c for c in s if c in string.letters).lower()

A set intersection of string.letters and "s" can also be used.

Note also that list_unique is only one name as you have it in the code above so the

for x in list_unique:

is not necessary.

kxjakkk commented: I only want to include words that are 2 or more letters. Words such as "error-free" would need to be separated to form just two words. +0
woooee 814 Nearly a Posting Maven

Which is worse in movies/shows from the 80s: the teased hair or the synthesizer music.

woooee 814 Nearly a Posting Maven

Use a function http://www.tutorialspoint.com/python/python_functions.htm and call it as many times as you like

import time

def print_something(ctr):
    choices = ["zero", "one", "two", "three", "four",
               "five", "six"]
    if ctr < len(choices):
        print(" This is page", choices[ctr])
    else:
        print("Sorry, but what you have typed in is invalid,\nPlease try again.")

ctr=1
print_something(ctr)
time.sleep(1.0)
ctr = 6
print_something(ctr)
time.sleep(1.0)
ctr = 10
print_something(ctr)
woooee 814 Nearly a Posting Maven

Reminds me of the Yoda condition I see occasionally in code.
If 5 = x Then

That should yield an error in most of today's compiliers. There was a time when
if x=5
could result in True in some languages, so
if 5=x
was used since the 5 can't be reassigned and would result in an error message.

woooee 814 Nearly a Posting Maven

Conundrum = Trying to fiqure out what Pneumonoultramicroscopicsilicovolcanoconiosis means

woooee 814 Nearly a Posting Maven

An incidental character is just shot, while the hero is put into some kind of elaborate will-blow-up-at-some-tme-in-the-future position to kill them. Of course they escape in the nick of time.

Just bad writing = the villian or criminal is the person who was introduced once in the beginning of the show and you never see them again, but they had some hidden or unknown reason to commit the crime/murder. It's too boring to watch when you know that they have to be the criminal, and know there is no way to figure out who did it because you won't know the details until right before the end. Just lazy writing.

woooee 814 Nearly a Posting Maven

It gives me an errorwhere the # is below
print "\ncb_handler"#, cb_number

"It gives me an error" is not nearly enough info. Are you using Python 3.x? There is a difference between print statements for 2.x vs. 3.x, so convert to a 3.X print statement if you are.

woooee 814 Nearly a Posting Maven

Your program has many issues. The main problem is that you have many instances of the Tk() class, which leads to unknown results. Use Toplevel to open a new GUI. This is code I have lying around that shows how to use grid_forget. The buttons are stored in a dictionary, but for one button that is not necessary. You could also use grid_remove or destroy to remove/delete the button.

from Tkinter import *
from functools import partial

class ButtonsTest:
   def __init__(self):
      self.top = Tk()
      self.top.title('Buttons Test')
      self.top_frame = Frame(self.top, width =400, height=400)
      self.button_dic = {}
      self.buttons()
      self.top_frame.grid(row=0, column=1)

      Button(self.top_frame, text='Exit', 
             command=self.top.quit).grid(row=10,column=1, columnspan=5)

      self.top.mainloop()

   ##-------------------------------------------------------------------         
   def buttons(self):
      b_row=1
      b_col=0
      for but_num in range(1, 11):
         b = Button(self.top_frame, text = str(but_num), 
                    command=partial(self.cb_handler, but_num))
         b.grid(row=b_row, column=b_col)
         self.button_dic[but_num] = b

         b_col += 1
         if b_col > 4:
            b_col = 0
            b_row += 1

   ##----------------------------------------------------------------
   def cb_handler( self, cb_number ):
      print "\ncb_handler", cb_number
      self.button_dic[cb_number].grid_forget()

##===================================================================
BT=ButtonsTest()
woooee 814 Nearly a Posting Maven

but has the value of mytik = .16801968

That is a tkinter ID number.

mytik = Entry(aApp,textvariable=tik)
woooee 814 Nearly a Posting Maven

Yes, and I wonder how many answer wrong on purpose, thinking that's a dumb question.

woooee 814 Nearly a Posting Maven

1 In 4 Americans Thinks The Sun Goes Around The Earth, Survey Says

A quarter of Americans surveyed could not correctly answer that the Earth revolves around the sun and not the other way around, according to a report out Friday from the National Science Foundation.

To the question "Does the Earth go around the Sun, or does the Sun go around the Earth," 26 percent of those surveyed answered incorrectly.

woooee 814 Nearly a Posting Maven

Biblical scholars have long been aware [that] many of the stories and accounts in the sacred book were not written by eyewitnesses, and according to new research, further evidence of that historical distance has appeared in the form of a hump-backed camel.

New research using radioactive-carbon dating techniques shows the animals weren't domesticated until hundreds of years after the events documented in the Book of Genesis. The research was published by Erez Ben-Yosef and Lidar Sapir-Hen, archaeologists from Tel Aviv University in Israel. They believe camels were not domesticated in the eastern Mediterranean until the 10th century B.C.

http://news.yahoo.com/blogs/sideshow/camels-in-the-bible-182042100.html

woooee 814 Nearly a Posting Maven

This code writes every row to the output file if "cat" is found anywhere in the file.

for row in reader:
    if "cat" in reader:
        writer.writerow(row)

For three different strings, you would use something like

for row in reader:
    found = False
    for col in row:    
        if col in [string_1, string_2, string_3] and not found:
            writer.writerow(row)
            found = True
woooee 814 Nearly a Posting Maven

Gentlemen You can't fight in here, this a war room

Dr. Strangelove...or How I Learned to Stop Worrying and Love the Bomb.

woooee 814 Nearly a Posting Maven

"Refurbished" is a crap shoot. I've had good luck where they last as long as a new machine and one that died after a few months. As a general rule the warranty is 90 days so consider a new machine with less than "decent" specs as well.

woooee 814 Nearly a Posting Maven

Also, functions Click Here make it easy to test each module individually, and to see things that may be burried in a larger body of code like the duplicate similarity == 100 test here

                if similarity == 100:
                    name3 = ' '.join(name2[-1:])               
                    for item in name3:
                        if similarity == 100:
woooee 814 Nearly a Posting Maven

Using the royal "we" when one is referring to oneself is even worse, especially when one works with one who actually does this. And no, the one who does this is not a sports star.

woooee 814 Nearly a Posting Maven

You should add the "\r\n" each time and test for size

def create_file_numbers(filename, size):
    output_list = list()
    count = 0
    total_output = 0
    while total_output < size:
        output = "%d\r\n" % (count)
        output_list.append(output)
        total_output += len(output)
        count += 1

    with open(filename,'wb') as f:
        f.write(''.join(output_list))
woooee 814 Nearly a Posting Maven

Add the directory to your path then use import program_name. To add it permanently add
export PYTHONPATH=$PYTHONPATH:/new/directory/name
to your .bash.rc file. To add it for this program

sys.path.append("/add/this/directory")

See this tutorial Click Here

woooee 814 Nearly a Posting Maven

Use Idle to start, as it comes with Python. Later you can move to something else once you know more. Getting started with Idle (although your version of Python is hopefully newer than the one used in the link). Next start with a tutorial like this one There are more tutorials on the Python Wiki

woooee 814 Nearly a Posting Maven

That question was already asked here with more than enough hints to solve the problem.

woooee 814 Nearly a Posting Maven

The problem is here

while os.stat(filename).st_size < size:

Both input and output are buffered on computers. First create a list of what you want to write and check the size each time. Then use .join() to write the file. Writing each number to the file is inefficient and slower anyway, so keep the data in memory where you have more control.

Also, Python has universal newline support so you can just use "\n".

woooee 814 Nearly a Posting Maven

Append the count + word to the new list.

words = ["engine","ant","aeiou"]
count = 0
vow_count = []
for chars in words:
    for letter in chars.lower():
        if letter in 'aeiou':
            count += 1
    vow_count.append([count, chars])
    count = 0
vow_count.sort()
print vow_count
print [word for count, word in vow_count]
woooee 814 Nearly a Posting Maven

Sleep showers away cellular grime that builds up while the brain is awake. The brain pushes fluid in between its cells to flush out buildup products, such as protein pieces that form plaque in people with Alzheimer's disease.
Science News Magazine

woooee 814 Nearly a Posting Maven

Your code is not anything that can really be corrected. Start with the "Defining Classes" and "Using Classes" Click Here and go on from there Post back once you have the basics down with any further questions.

woooee 814 Nearly a Posting Maven

How come you can travel north in a straight line until you go south, but when you go west you are always going west.

woooee 814 Nearly a Posting Maven

I don't know what an ibookG4 is but if it is an Apple product, previous versions should be available in their repos and it would be as simple as telling the software manager to install a particular version. Also, the software manager may have a "revert back to the previous version" option, but search on Apple's repos and/or the appropriate sub-forum at Apple's forums, not Adobe's. If you just want flash in a browser, check for flash plugins for whatever browser you use.

yvonne.lundeandreassen.9 commented: What is a 'software manager'? and - have you ever tried apple's forum ? you'll need 2 hours just to get into it ! +0
woooee 814 Nearly a Posting Maven

"I love it when a plan comes together." - John "Hannibal" Smith (The A-Team)

+1

I am, therefore I think. Descartes has it backwards.

woooee 814 Nearly a Posting Maven

Your allowed to split infinities now and I do it the odd time. If the reader doesn't understand, he still won't understand if you switch the words around

But you are not allowed to subsitute "your" for the contraction of you are=you're

Your cat ran away
You're looking for it

woooee 814 Nearly a Posting Maven

The easiest to understand is to use two loops, the first going up to the halfway point and the second going down. You have to first decide how to find the halfway point for an even or odd number for the size of the mountain (note the use of two different values below). You can also use one loop, incrementing a counter by adding to it going up and subtracting from it going down but you then have to allow for two numbers in the middle that could be equal.

My preference would be to use list slicing. The following is not meant to be ready to hand in code but a rough example.

too_many_nums = [1, 3, 5, 7, 9, 11]

for length in (3, 4, 5, 6, 10):
    middle, remain = divmod(length, 2)
    if remain:
        middle += 1
    list_of_odds = too_many_nums[:middle]
    ## length-middle because if an odd length, the back half 
    ## has one less value than the front, i.e. they are not equal
    junk_list = too_many_nums[:length-middle]
    junk_list.reverse()
    list_of_odds.extend(junk_list)
    print length, list_of_odds
woooee 814 Nearly a Posting Maven

You can do this with list comprehension. A hint

x=3
print range(x, 0, -1)
woooee 814 Nearly a Posting Maven

You have to explicitly call the init method in child classes. Also, I am guessing that the widgets are not showing because they are not explicitly placed in the root widget. Finally, there is no reason to assign the return of place() to a variable as it is always "None", and you do not call mainloop() anywhere.

from tkinter import * #Allows GUIs to be created
from random import randint #allows random integers to be generated

class StudentSkeleton:  #This class contains the basic layout for the student part of the application

    def __init__(self):
        ##-----------------------------------------
        ##"self." = visible throughout the class, including parent
        self.StudentGui = Tk()
        ##-----------------------------------------
        self.StudentGui.title('Thomas Hardye Sixth Form Application Program')
        self.StudentGui.geometry('800x640+200+200') #sets the size of the window
        self.StudentGui.resizable(width = FALSE, height = FALSE) #stops resizing of window
        #StudentSchoolLogo = PhotoImage(file='N:\Computing\A2 Computing\F454\part 3 Development\crest1-edited.gif')#brings in file of school Logo*
        #StudentSchoolImage = Label(self,image = StudentSchoolLogo).place(x=630,y=0)#places school image on screen    
        print "__init__ called"


class MainMenu(StudentSkeleton):#inheriting the student skeleton for the main menu GUI
    def __init__(self):
        ##-----------------------------------------
        ## call init method of child class
        StudentSkeleton.__init__(self)
        ##-----------------------------------------
        Label(self.StudentGui, text = 'Welcome to the Thomas Hardye Sixth Form Application Program',font=('TkDefaultFont',14)).place(x=80,y=30) #setting up welcome message to users
        Label(self.StudentGui, text = 'Are you a student or member of staff?',font = ('TkDefaultFont',14)).place(x=200,y=80)
        Button(self.StudentGui, text = 'Student',height = 3, width = 15, 
               font = ('TkDefaultFont',14)).place(x=100,y=300) #button to select student side of program
        Button(self.StudentGui, text = 'Staff', height = 3, width = 15, font = ('TkDefaultFont',14)).place(x=540,y=300) #button to select staff side of program
        Label(self.StudentGui, text = 'This lets …