Hello. I have copied these 2 files of code from a website. main.py: from kivy.app import App from kivy.uix.label import Label from kivy.uix.boxlayout import BoxLayout from kivy.clock import Clock from kivy.properties import StringProperty import datetime class Counter_Timer(BoxLayout): def update(self, dt): delta = datetime.datetime(2015, 9, 13, 3, 5) - datetime.datetime.now() self.days = delta.days hour_string = str(delta).split(',')[1] self.hours = hours_string.split(':')[0] self.minuts = hours_string.split(':')[1] self.seconds = hours_string.split(':')[2].split('.')[0] return days, hours, minuts, seconds class Counter(App): def build(self): counter = Counter_Timer Clock.schedule_interval(counter.update, 1.0) days = StringProperty() hours = StringProperty() minutes = StringProperty() seconds = StringProperty() return if __name__ == "__main__": Counter().run() There was written: "Let's …

Member Avatar
Member Avatar
+0 forum 1

I have a block of code that i am wanting to turn into a function and i am very ocnfused on how to do it properly. If anyone could give me a lead on how to do this it would be a great help. The for statement is where i want to call the function so taht it loops through the folder its searching. for filename in glob.glob(fileFull): statinfo = os.stat(filename) for Filename in glob.glob(fileAbriv): Statinfo = os.stat(Filename) SUBJECT = 'File size of '+fileFull Subject = 'File size of '+fileAbriv BODY = 'The file size of '+fileFull+' was greater than …

Member Avatar
Member Avatar
+0 forum 3

So i am trying to take some code that i had working before and turn it into a function but every time i run my code it kicks it to line 9 in my code which is a continue statement and says the its not properly in the loop. I was wondering if someone could please explain to me where im goign wrong with this and how to fix it and if there are any other errors that would mess my code up.Any help would be greatly appriciated thank you. def convertToSor(saleDate,Amount,Fname,Lname,Email,Franchise,osg,State,Postal,OrderID,DateAdded,EmailSource): for row in cf1: nr = newrow nr[saleDate] …

Member Avatar
Member Avatar
+0 forum 6

So basically im creating this python adventure text game. And so far its good. But i have this problem with class instances(Is that the right term?) Say for example i have this class, class monster(object): def __init__(self,health,attack): self.damage = damage self.health = health So then I create a class object(again, is that the right term?) goblin = monster(5,30) skeleton = monster(10,20) so now, i have this piece of code for the fighting mechanic between the player and the monster. (I just copy past this so the indentation might be messed up) if char.location.war == True: while death == False: #check …

Member Avatar
Member Avatar
+0 forum 2

[CODE] import Tkinter as tk import Image, time, datetime def splash_screen(): root = tk.Tk() root.overrideredirect(True) width = root.winfo_screenwidth() height = root.winfo_screenheight() root.geometry('%dx%d+%d+%d' % (width*0.8, height*0.8, width*0.1, height*0.1)) image_file = "NHK.gif" image = tk.PhotoImage(file=image_file) canvas = tk.Canvas(root, height=height*0.8, width=width*0.8, bg="black") canvas.create_image(width*0.8/2, height*0.8/2, image=image) canvas.pack() root.after(10000, root.destroy) root.mainloop() return splash_screen() my_menu()# is defined at beginning of program [/CODE] When I call the definition the picture NHK.GIF shows on a black background then disappears after 10 seconds. The problem starts here; the program just stalls and nothing happens. Control is not given back to the main program ie, my menu doesn't print. When …

Member Avatar
Member Avatar
+0 forum 6

hi guys i am a beginner to python. Just now completed a few sets of lessons and i'm trying out the exercises given at the end of each chapter. I have learned till the stage of basics in defining a function. But still i am confused. [code] ##This program runs a test of knowledge true = 1 false = 0 def get_questions(): return[["What colour is the daytime sky on a clear day?","blue"],\ ["What is the answer to life, the universe and everything?","42"],\ ["What is a three letter word for mouse trap?","cat"]] def check_question(question_and_answer): question = question_and_answer[0] answer = question_and_answer[1] given_answer …

Member Avatar
Member Avatar
+0 forum 17

Hi All I am trying to learn Python and cannot get aroud this problem for the life of me. I have generated a sript as follows, called xandy.py def xandy (x,y): if x < y: print x, "is less than", y elif x > y: print x, "is greater than", y else: print x, "and", y, "are equal" I cannot get it to work in the shell? >>> x=5 >>> y=4 >>> xandy Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'xandy' is not defined >>> xandy (5,4) Traceback (most recent call last): File "<stdin>", …

Member Avatar
Member Avatar
+0 forum 3

The End.