Thursday, January 26, 2012

Dental Work

So I had some dental work done this afternoon, and what with working a job in the morning to early afternoon, I didn't get much work done on the project. Not to worry though, I've got a chunk of free time set aside this weekend to make up the time lost having someone take a drill to my teeth. I did make one significant piece of progress though. I figured out exactly what was going wrong with the error I was having trouble with the last couple of days. When I called the setText function on a set die, I was calling it as self.die1.setText("1"). The error said that I was trying to pass the function two arguments, which I didn't think I was doing. Well, apparently I was passing it two arguments without realizing it. When a function is called with the dot operator, the object the function is called on is passed to the function as an argument. So when I called self.die1.setText("1"), what this actually translated to was die1.setText(self, "1"), which is two arguments. I haven't been able to fix this problem yet, because taking out the self doesn't work since I'm calling the function in a separate function from the function in which I declared the objects. So the interpreter doesn't know what die1 is unless I tell it is a member of self. So I may end up having to declare the die buttons to be globals that can be accessed from any function in the program. I tried implementing it that way, but since I have little experience in globals, I was doing something wrong and it wasn't working. Globals tend to be pretty dangerous, since you could easily change the value accidentally in a function that shouldn't have access to the variables, so they tend not to get taught much in programming classes and I never learned how to implement them before. Another thing on my to-do list for this project is to get to work finishing up my final paper. I'll finish up work on that over the weekend, also in that free time I've got planned out.

No comments:

Post a Comment