Object-oriented GUI development in python

Posted by ptabatt on Stack Overflow See other posts from Stack Overflow or by ptabatt
Published on 2010-05-22T04:18:03Z Indexed on 2010/05/22 4:20 UTC
Read the original article Hit count: 281

Filed under:
|
|

Hey guys, new programmer here. I have an assignment for class and I'm stuck... What I need to do is a create a GUI that gives someone a basic arithmetic problem in one box, asks the person to answer it, evaluates it, and tells you if you're right or wrong...

Basically, what I have is this: [code] class Lesson(Frame): def init (self, parent=None): Frame.init(self, parent) self.pack() Lesson.make_widgets(self)

def make_widgets(self):
    Label(self, text="").pack(side=TOP)

    ent = Entry(self)
    self.a = randrange(1,10)
    self.b = randrange(1,10)
    self.expr = choice(["+","-"])

    ent.insert(END, str(self.a) + str(self.expr) + str(self.a))

[/code]

I've broken this down into many little steps and basically, what I'm trying to do right now is insert a default random expression into the first entry widget. When I run this code, I just get a blank Label. Why is that? How can I put a something like "7+7" into the box? If you absolutely need background to the problem, it's question #3 on this link.

http://reed.cs.depaul.edu/lperkovic/csc242/homeworks/Homework8.html

-Thanks for all help in advance.

© Stack Overflow or respective owner

Related posts about gui

Related posts about python