5 Replies - 591 Views - Last Post: 28 December 2012 - 09:28 AM Rate Topic: -----

#1 merlin'sbeard  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 20
  • Joined: 27-December 12

GUI programming

Posted 27 December 2012 - 08:34 AM

Hi i'm new to python and i just statred learning gui programming with Tkinter and i've stumbled upon a little problem. I'm learnning from an ebook i downloaded and i am trying to replicate a program in that ebook but the program doesn't run i've checked it lots of times but still do not know what is wrong.
from Tkinter import *

class Application(Frame):
    def __init__(self, master):       
        Frame.__init__(self, master):
        self.grid()
        self.create_widgets()

    def create_widgets(self):
        self.bttn1 = Button(self, text="I do nothing")
        self.bttn1.grid()

        self.bttn2 = Button(self)
        self.bttn2.grid()
        self.bttn2.configure(text="Me too!")

        self.bttn3 = Button(self)
        self.bttn3.grid()
        self.bttn3["text"] = "Me also!"

#main        
root = Tk()
root.title("Lazy Buttons Again")
root.geometry("200x85")

app = Application(root)
root.mainloop()






Is This A Good Question/Topic? 0
  • +

Replies To: GUI programming

#2 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7996
  • View blog
  • Posts: 13,694
  • Joined: 19-March 11

Re: GUI programming

Posted 27 December 2012 - 08:37 AM

Just to make everyone's life easier, could you please provide a little more information about the exact problem you're having?

Are you seeing error messages from the interpreter? If so, what are they? (just copy the output, don't summarize it!)
If the program doesn't report an error, what does it do, and how is that different from what you expect?
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3806
  • View blog
  • Posts: 13,488
  • Joined: 12-December 12

Re: GUI programming

Posted 27 December 2012 - 08:46 AM

You haven't told us what error message(s) you receive?

Correct this line - without the colon at the end:
Frame.__init__(self, master)

The Tkinter library is renamed tkinter in Python 3. Identifiers are case-sensitive in Python.

This post has been edited by andrewsw: 27 December 2012 - 08:50 AM

Was This Post Helpful? 2
  • +
  • -

#4 merlin'sbeard  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 20
  • Joined: 27-December 12

Re: GUI programming

Posted 27 December 2012 - 08:47 AM

i get no errors when i double clik on the file it simply does not run.(That normally happens when there is an error in my code and it probably will not run till i fill the error). I use IDLE.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3806
  • View blog
  • Posts: 13,488
  • Joined: 12-December 12

Re: GUI programming

Posted 27 December 2012 - 03:49 PM

It worked for me - that is, the form displayed - when I removed the colon mentioned in my previous post.
Was This Post Helpful? 1
  • +
  • -

#6 merlin'sbeard  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 20
  • Joined: 27-December 12

Re: GUI programming

Posted 28 December 2012 - 09:28 AM

thanks alot it works now :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1