4 Replies - 3340 Views - Last Post: 24 September 2009 - 12:32 AM Rate Topic: -----

#1 jaziey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-September 09

trouble creating Gui WIndow using python/Tkinter

Post icon  Posted 23 September 2009 - 04:03 PM

Attached File  lazy2Buttons.txt (849bytes)
Number of downloads: 107I am using Python for Absolute Beginners to create simple Gui windows and I am having trouble maintaining the window when there is an error. The screen quickly disappears. I am using windows XP and I am calling the .py script from the icon in start window instead of the IDE. I am using python 2.6. I have added the script to attachment and have commented out some lines to see if there are any improvements, but saw none.

thanks
jaziey

Is This A Good Question/Topic? 0
  • +

Replies To: trouble creating Gui WIndow using python/Tkinter

#2 Dogstopper  Icon User is online

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,023
  • Joined: 15-July 08

Re: trouble creating Gui WIndow using python/Tkinter

Posted 23 September 2009 - 04:27 PM

You must indent everything inside the class by one, python sees it at an emty class.. as in, your function definitions need to be indented.

This post has been edited by Dogstopper: 23 September 2009 - 04:28 PM

Was This Post Helpful? 0
  • +
  • -

#3 jaziey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-September 09

Re: trouble creating Gui WIndow using python/Tkinter

Posted 23 September 2009 - 11:21 PM

View PostDogstopper, on 23 Sep, 2009 - 03:27 PM, said:

You must indent everything inside the class by one, python sees it at an emty class.. as in, your function definitions need to be indented.


Ok, I will correct that, but is there a way to keep the gui on the screen so I can see the problem. I know if it is a regular python script I can add " raw_input("\nPress Enter to Exit")"

thanks
Jaziey
Was This Post Helpful? 0
  • +
  • -

#4 jaziey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-September 09

Re: trouble creating Gui WIndow using python/Tkinter

Posted 24 September 2009 - 12:19 AM

View Postjaziey, on 23 Sep, 2009 - 10:21 PM, said:

View PostDogstopper, on 23 Sep, 2009 - 03:27 PM, said:

You must indent everything inside the class by one, python sees it at an emty class.. as in, your function definitions need to be indented.


Ok, I will correct that, but is there a way to keep the gui on the screen so I can see the problem. I know if it is a regular python script I can add " raw_input("\nPress Enter to Exit")"

thanks
Jaziey



The gui code does not have any indentations. It does not use classes. It is a simple script:

from Tkinter import *

#create a root window

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

#create a frame in the window to hold other widgets

app = Frame(root)
app.grid()

# create a button in the frame
bttn1 = Button(app, text = "I do nothing!")
bttn1.grid()

#create a second button in the frame

bttn2 = Button(app)
bttn2.grid()

bttn2["text"] = "Me too!"

#bttn2.configure(test = "Me too!")

#create a third button in the frame

bttn3 = Button(app)
bttn3.grid()
bttn3["text"] = "Same here!"

#kick off the window's event loop

root.mainloop()
Was This Post Helpful? 0
  • +
  • -

#5 jaziey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-September 09

Re: trouble creating Gui WIndow using python/Tkinter

Posted 24 September 2009 - 12:32 AM

View PostDogstopper, on 23 Sep, 2009 - 03:27 PM, said:

You must indent everything inside the class by one, python sees it at an emty class.. as in, your function definitions need to be indented.


OK that did work, the class was indented improperly, also if I run it in IDE, I see all my errors. I thought a Tkinter script was suppose to be executed froman icon instead of the IDE.
But IDE works fine.

thanks alot. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1