Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52074 > unrolled thread
| Started by | snakeinmyboot <mikelhamer@gmail.com> |
|---|---|
| First post | 2013-08-06 15:28 -0700 |
| Last post | 2013-08-09 15:02 +1000 |
| Articles | 9 — 4 participants |
Back to article view | Back to comp.lang.python
[tkinter] trouble running imported modules in main program snakeinmyboot <mikelhamer@gmail.com> - 2013-08-06 15:28 -0700
Re: [tkinter] trouble running imported modules in main program Terry Reedy <tjreedy@udel.edu> - 2013-08-06 19:38 -0400
Re: [tkinter] trouble running imported modules in main program snakeinmyboot <mikelhamer@gmail.com> - 2013-08-06 21:25 -0700
Re: [tkinter] trouble running imported modules in main program snakeinmyboot <mikelhamer@gmail.com> - 2013-08-06 21:26 -0700
Re: [tkinter] trouble running imported modules in main program Cousin Stanley <cousinstanley@gmail.com> - 2013-08-07 20:08 +0000
Re: [tkinter] trouble running imported modules in main program snakeinmyboot <mikelhamer@gmail.com> - 2013-08-07 21:06 -0700
Re: [tkinter] trouble running imported modules in main program David <bouncingcats@gmail.com> - 2013-08-08 15:13 +1000
Re: [tkinter] trouble running imported modules in main program snakeinmyboot <mikelhamer@gmail.com> - 2013-08-08 21:28 -0700
Re: [tkinter] trouble running imported modules in main program David <bouncingcats@gmail.com> - 2013-08-09 15:02 +1000
| From | snakeinmyboot <mikelhamer@gmail.com> |
|---|---|
| Date | 2013-08-06 15:28 -0700 |
| Subject | [tkinter] trouble running imported modules in main program |
| Message-ID | <6f47e052-ec39-4894-a527-0d68653d5375@googlegroups.com> |
Hello, I am currently just starting to learn the basics of the tkinter module and ive run into a problem. To teach myself I am messing around by creating separate modules containing basic GUI apps like a tip calculator and kilometer converter, then creating a main program that displays buttons you can click that will create instances of the modules (tip calculator, kilometer converter). So far ive managed to successfully make the basic GUI apps works just fine, and have been able to import them into my main program and get them to launch in a new window when i click the buttons and everything, but heres my problem. Everything displays ok, like the labels, entry boxes, and buttons, but when I actually click the buttons (which are supposed to trigger a method within the module and display a label containing the calculated data).. nothing happens. When I run the modules by themselves everything works just fine (testing by making the module create an instance of itself but i # them out before running the main program). I have posted all my code to this forum if you need to look at it http://python-forum.org/viewtopic.php?f=12&t=5620 Any idea what im doing wrong here?
[toc] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-08-06 19:38 -0400 |
| Message-ID | <mailman.283.1375832351.1251.python-list@python.org> |
| In reply to | #52074 |
On 8/6/2013 6:28 PM, snakeinmyboot wrote:
> Hello,
>
> I am currently just starting to learn the basics of the tkinter module and ive run into a problem. To teach myself I am messing around by creating separate modules containing basic GUI apps like a tip calculator and kilometer converter, then creating a main program that displays buttons you can click that will create instances of the modules (tip calculator, kilometer converter). So far ive managed to successfully make the basic GUI apps works just fine, and have been able to import them into my main program and get them to launch in a new window when i click the buttons and everything, but heres my problem.
>
> Everything displays ok, like the labels, entry boxes, and buttons, but when I actually click the buttons (which are supposed to trigger a method within the module and display a label containing the calculated data).. nothing happens. When I run the modules by themselves everything works just fine (testing by making the module create an instance of itself but i # them out before running the main program)
Make the boilerplate test code conditional, something like
if __name__ == '__main__':
root = tkinter.Tk()
app = MainClass(root) # 'MainClass' depends on the module.
root.mainloop
root.destroy
and you do not need to comment it out as it will be ignored when the
module is imported.
> I have posted all my code to this forum if you need to look at it
>
> http://python-forum.org/viewtopic.php?f=12&t=5620
Code comments: double and triple spacing code make it painful to read,
especiallly in a 10 line box.
self.miles_button = tkinter.Button(self.frame3, \
text = 'Miles', \
command = self.conv_miles)
Leave off the unneeded \s.
> Any idea what im doing wrong here?
You got the answer there -- only one mainloop. Revising the code as
suggested above will do that.
Note: I am a tkinter beginner too, so I would also have to experiment
with details to get importable custom widgets, built from tk widgets, right.
--
Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | snakeinmyboot <mikelhamer@gmail.com> |
|---|---|
| Date | 2013-08-06 21:25 -0700 |
| Message-ID | <b8701561-63c2-48b7-9ac5-aa958c75ce75@googlegroups.com> |
| In reply to | #52086 |
On Tuesday, August 6, 2013 7:38:55 PM UTC-4, Terry Reedy wrote: > On 8/6/2013 6:28 PM, snakeinmyboot wrote: > > > Hello, > > > > > > I am currently just starting to learn the basics of the tkinter module and ive run into a problem. To teach myself I am messing around by creating separate modules containing basic GUI apps like a tip calculator and kilometer converter, then creating a main program that displays buttons you can click that will create instances of the modules (tip calculator, kilometer converter). So far ive managed to successfully make the basic GUI apps works just fine, and have been able to import them into my main program and get them to launch in a new window when i click the buttons and everything, but heres my problem. > > > > > > Everything displays ok, like the labels, entry boxes, and buttons, but when I actually click the buttons (which are supposed to trigger a method within the module and display a label containing the calculated data).. nothing happens. When I run the modules by themselves everything works just fine (testing by making the module create an instance of itself but i # them out before running the main program) > > > > Make the boilerplate test code conditional, something like > > > > if __name__ == '__main__': > > root = tkinter.Tk() > > app = MainClass(root) # 'MainClass' depends on the module. > > root.mainloop > > root.destroy > > > Could you elaborate on this a little bit? Never even heard the term "boilerplate test code". Also, I have removed the mainloops from the other modules, but this didnt seem to affect anything. Thanks for the reply!
[toc] | [prev] | [next] | [standalone]
| From | snakeinmyboot <mikelhamer@gmail.com> |
|---|---|
| Date | 2013-08-06 21:26 -0700 |
| Message-ID | <66fbaae1-0097-4073-8643-524cef4ffbce@googlegroups.com> |
| In reply to | #52086 |
> Make the boilerplate test code conditional, something like > > > > if __name__ == '__main__': > > root = tkinter.Tk() > > app = MainClass(root) # 'MainClass' depends on the module. > > root.mainloop > > root.destroy > > > Could you elaborate on this a little bit? Never even heard the term "boilerplate test code". Also, I have removed the mainloops from the other modules, but this didnt seem to affect anything. Thanks for the reply! (the message I sent you was supposed to be this reply, my bad)
[toc] | [prev] | [next] | [standalone]
| From | Cousin Stanley <cousinstanley@gmail.com> |
|---|---|
| Date | 2013-08-07 20:08 +0000 |
| Message-ID | <ktu9gj$n73$1@dont-email.me> |
| In reply to | #52086 |
Terry Reedy wrote:
> Code comments :
>
> double and triple spacing code
> make it painful to read,
Not for everyone :-)
I prefer mostly double-spaced code
in any language
> especially in a 10 line box.
Agree, but the 10 line box
would not be used for routine
code editing and viewing
and could be made larger
to accomodate viewing code
posted online ....
--
Stanley C. Kitching
Human Being
Phoenix, Arizona
[toc] | [prev] | [next] | [standalone]
| From | snakeinmyboot <mikelhamer@gmail.com> |
|---|---|
| Date | 2013-08-07 21:06 -0700 |
| Message-ID | <5d739907-50ec-4691-a4a3-5c10f2b7cfe2@googlegroups.com> |
| In reply to | #52147 |
>if __name__ == '__main__': > root = tkinter.Tk() > app = MainClass(root) # 'MainClass' depends on the module. > root.mainloop > root.destroy for REAL you guys...wtf does this even mean lol. what is a boilerplate test code?
[toc] | [prev] | [next] | [standalone]
| From | David <bouncingcats@gmail.com> |
|---|---|
| Date | 2013-08-08 15:13 +1000 |
| Message-ID | <mailman.338.1375940811.1251.python-list@python.org> |
| In reply to | #52164 |
On 8 August 2013 14:06, snakeinmyboot <mikelhamer@gmail.com> wrote: > > for REAL you guys...wtf does this even mean lol. what is a boilerplate test code? Did you try at all to find the answer to this yourself? I ask because it took me only a few seconds to go to wikipedia and search for "boilerplate" find this for you: http://en.wikipedia.org/wiki/Boilerplate_code Tip: To successfully use forums like this one (where a lot of very smart people read), the more care/effort/thought you demonstrate that you tried to solve your issue before asking, the more likely you are to receive a response.
[toc] | [prev] | [next] | [standalone]
| From | snakeinmyboot <mikelhamer@gmail.com> |
|---|---|
| Date | 2013-08-08 21:28 -0700 |
| Message-ID | <8039efc1-5fa1-46be-a834-46bd7981f7f5@googlegroups.com> |
| In reply to | #52167 |
On Thursday, August 8, 2013 1:13:48 AM UTC-4, David wrote: > On 8 August 2013 14:06, snakeinmyboot <mikelhamer@gmail.com> wrote: > > > > > > for REAL you guys...wtf does this even mean lol. what is a boilerplate test code? > > > > Did you try at all to find the answer to this yourself? > > > > I ask because it took me only a few seconds to go to wikipedia and > > search for "boilerplate" find this for you: > > http://en.wikipedia.org/wiki/Boilerplate_code > > > > Tip: To successfully use forums like this one (where a lot of very > > smart people read), the more care/effort/thought you demonstrate that > > you tried to solve your issue before asking, the more likely you are > > to receive a response. I did read that article but I couldnt really figure out how to apply it to the code he was giving as an example of making it "conditional".
[toc] | [prev] | [next] | [standalone]
| From | David <bouncingcats@gmail.com> |
|---|---|
| Date | 2013-08-09 15:02 +1000 |
| Message-ID | <mailman.385.1376024580.1251.python-list@python.org> |
| In reply to | #52241 |
On 9 August 2013 14:28, snakeinmyboot <mikelhamer@gmail.com> wrote: > On Thursday, August 8, 2013 1:13:48 AM UTC-4, David wrote: >> On 8 August 2013 14:06, snakeinmyboot <mikelhamer@gmail.com> wrote: >> >> Did you try at all to find the answer to this yourself? >> >> I ask because it took me only a few seconds to go to wikipedia and >> search for "boilerplate" find this for you: >> >> http://en.wikipedia.org/wiki/Boilerplate_code >> >> Tip: To successfully use forums like this one (where a lot of very >> smart people read), the more care/effort/thought you demonstrate that >> you tried to solve your issue before asking, the more likely you are >> to receive a response. > > I did read that article but I couldnt really figure out how to apply it to the code he was giving as an example of making it "conditional". Did you try the research method I gave you in my previous answer?
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web