Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44279
| References | <09b96d6b-6db3-42a2-88d3-5fe16984fed1@googlegroups.com> |
|---|---|
| From | Chris “Kwpolska” Warrick <kwpolska@gmail.com> |
| Date | 2013-04-24 19:53 +0200 |
| Subject | Re: My gui |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1026.1366826039.3114.python-list@python.org> (permalink) |
On Wed, Apr 24, 2013 at 7:08 PM, Daniel Kersgaard
<danielkersgaard@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:
http://docs.python.org/2/library/tkinter.html#a-simple-hello-world-program
— unfortunately, I am not a fan and I am not knowledgeable about
tkinter, but I can see a lot of stuff is missing.
Please try fixing it and running it _outside of IDLE_, which is also
built in Tk. This may cause problems (but don’t worry, the code you
pasted doesn’t work anyways.)
--
Kwpolska <http://kwpolska.tk> | GPG KEY: 5EAAEA16
stop html mail | always bottom-post
http://asciiribbon.org | http://caliburn.nl/topposting.html
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
My gui Daniel Kersgaard <danielkersgaard@gmail.com> - 2013-04-24 10:08 -0700
Re: My gui Dave Angel <davea@davea.name> - 2013-04-24 13:46 -0400
Re: My gui Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-04-24 19:53 +0200
Re: My gui Ned Batchelder <ned@nedbatchelder.com> - 2013-04-24 14:08 -0400
Re: My gui Arnaud Delobelle <arnodel@gmail.com> - 2013-04-24 20:42 +0100
Re: My gui Neil Cerutti <neilc@norwich.edu> - 2013-04-24 20:26 +0000
Re: My gui Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-24 22:51 -0400
Re: My gui Chris Angelico <rosuav@gmail.com> - 2013-04-25 13:17 +1000
csiph-web