On 24 April 2013 18:53, Chris “Kwpolska” Warrick <kwpol...@gmail.com> wrote: > On Wed, Apr 24, 2013 at 7:08 PM, Daniel Kersgaard > <danielkersga...@gmail.com> wrote: >> Today, being the last day of lectures at school, my instructor ran briefly >> through Tkninter and GUIs. I'd been looking forward to this particular >> lesson all semester, but when I got home and copied a sample program from my >> textbook verbatim, IDLE does nothing. No error, no nothing. Any ideas? Here >> is the code from my program. I'm not sure if this is appropriate, but >> suggestions are helpful. >> >> import tkinter >> import tkinter.messagebox >> >> class MyGui: >> def _init_(self): >> self.main_window = tkinter.Tk() >> >> self.top_frame = tkinter.Frame(self.main_window) >> self.bottom_frame = tkinter.Frame(self.main_window) >> >> self.prompt_label = tkinter.Label(self.top_frame, text = 'Enter a >> distance in Kilometers: ') >> self.kilo_entry = tkinter.Entry(self.top_frame, width = 10) >> >> self.prompt_label.pack(side = 'left') >> self.kilo_entry.pack(side = 'left') >> >> self.calc_button = tkinter.Button(self.bottom_frame, text = >> 'Convert', command = self.convert) >> >> self.quit_button = tkinter.Button(self.bottom_frame, text = 'Quit', >> command = self.main_window.destroy) >> >> self.calc_button.pack(side = 'left') >> self.quit_button.pack(side = 'left') >> >> self.top_frame.pack() >> self.bottom_frame.pack() >> >> tkinter.mainloop() >> >> def convert(self): >> kilo = float(self.kilo_entry.get()) >> >> miles = kilo * 0.6214 >> >> tkinter.messagebox.showinfo('Result', str(kilo) + ' kilometers is >> equal to ' + str(miles) + 'miles.') >> >> poop = MyGui() >> >> -- >> http://mail.python.org/mailman/listinfo/python-list > > poop? Seriously? You aren’t serious about that copying, right? > > Your code seems to be missing a lot of important stuff. You don’t > inherit from tkinter.Frame. Compare your program to the sample “Hello > world!” program:
His class is not a frame, it's just a container for the tkinter code. It's a bit unusual but it looks correct to me (apart from the single underscores in __init__() as spotted by Ned Batchelder). -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list