[python]got A Problem In My Little Program - No reaction when button was pressed

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > Python

[python]got A Problem In My Little Program - No reaction when button was pressed

jedipi
I am a newbie in Python.

After read some parts of 《OReilly - ProgrammingPython2ndEd.chm》,
I try to write a small problem as following.
But it is no reaction when I press the button.
Does anyone can tell me why?

CODE

from Tkinter import * # get widget classes
class Inputer(Frame): # subclass our GUI
def __init__(self, parent=None): # constructor method
 Frame.__init__(self, parent)
 self.pack()
 ent = Entry(self)
 ent.insert(0, 'Type words here') # set text
 ent.pack(side=LEFT) # grow horiz
 ent.focus() # save a click
 ent.bind('<Return>', (lambda event: self.input(ent.get()))) # on enter key
 widget = Button(self, text='Query', command=self.input(ent.get()))
 widget.pack(side=RIGHT)
def input(self,text):

print text

if __name__ == '__main__': Inputer().mainloop()

 

 

 


Reply

gentoo
QUOTE(jedipi @ Mar 28 2005, 09:29 AM)
I am a newbie in Python.

After read some parts of 《OReilly - ProgrammingPython2ndEd.chm》,
I try to write a small problem as following.
But it is no reaction when I press the button.
Does anyone can tell me why?

CODE

from Tkinter import * # get widget classes
class Inputer(Frame): # subclass our GUI
def __init__(self, parent=None): # constructor method
 Frame.__init__(self, parent)
 self.pack()
 ent = Entry(self)
 ent.insert(0, 'Type words here') # set text
 ent.pack(side=LEFT) # grow horiz
 ent.focus() # save a click
 ent.bind('<Return>', (lambda event: self.input(ent.get()))) # on enter key
 widget = Button(self, text='Query', command=self.input(ent.get()))
 widget.pack(side=RIGHT)
def input(self,text):

print text

if __name__ == '__main__': Inputer().mainloop()

*



Python is sensitive to indent. I am not sure whether it is the reason. But , at least , these
run well on my gentoo box:
CODE

#!/usr/bin/env python
from Tkinter import * # get widget classes
class Inputer(Frame): # subclass our GUI
 def __init__(self, parent=None): # constructor method
   Frame.__init__(self, parent)
   self.pack()
   ent = Entry(self)
   ent.insert(0, 'Type words here') # set text
   ent.pack(side=LEFT) # grow horiz
   ent.focus() # save a click
   ent.bind('<Return>', (lambda event: self.input(ent.get()))) # on enter key
   widget = Button(self, text='Query', command=self.input(ent.get()))
   widget.pack(side=RIGHT)
 def input(self,text):
   print text
if __name__ == '__main__': Inputer().mainloop()

QUOTE
chmod u+x test.py
./test.py

 

 

 


Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : python, problem, program, reaction, button, pressed

  1. Tuning Car Studio
    The perfect program to tune your car! (2)
  2. Python Mysqldb Threading
    (0)
    I have a small application that spawns several threads which produce output that I insert into the
    database. The output from one thread is an array and I use CODE cursor.executemany . In the
    beginning I was always getting the mysql error QUOTE lock time exceeded try to restart the
    transaction ...I managed to resolve this issue - partially it was coming from IDLE editor and the
    open python shell - seems they were not unlocking the tables while open - so in order for my code to
    run I use to run it from the shell ... The next step to handle this was to lock ....
  3. Best Program To Tune Up An Old Computer?
    (9)
    Alright, the computer I'm on now runs well, however, the laptop, which I received from my
    Grandpa is a bit slow, in fact, it is very, very slow. I'm pretty sure at some point, though, it
    was a bit faster. Could anyone recommend me a program that could boost the speed by optimizing the
    computer, or by deleting some clutter, or repairing the registry. I remember I've tried before
    with some optimization programs on this computer, but since I used free programs (I don't want
    to pay for a program for the slow Laptop, either) I could only use half of the optimi....
  4. Problem With Move_uploaded_file()
    Permission denied? (5)
    CODE Warning: move_uploaded_file(images/profile/Mordent.jpg)
    [function.move-uploaded-file]: failed to open stream: Permission denied in
    /home/mordent/public_html/withvalour/edit_image.php on line 42 Warning:
    move_uploaded_file() [function.move-uploaded-file]: Unable to move
    '/tmp/phpOWVz7o' to 'images/profile/Mordent.jpg' in
    /home/mordent/public_html/withvalour/edit_image.php on line 42 Any ideas? The code seems fine,
    as it works a treat when I run it locally (on WAMPServer), but as soon as I tr....
  5. Administrator Account Problem In Microsoft Xp [solved]
    I have lost "my documents" (20)
    I have problem with administrator account ... I created new administrator account with this way:
    start /control panel /account users/new account and than I created a new one ; after this I turned
    off computer . I wanted to have two skypes turned on and my friend suggested me to do so... when I
    turned it on the second day , I coudn't enter with the first administrator ,and I entered with
    the administrator that I had created . I have lost my document folder.. please help me . how can I
    enter or can I enter with that first administrator account?? Can my documents be ....
  6. Best Free Anti-virus Program
    NID UR ADVISE! PLS. HELP (16)
    NID UR ADVISE! PLS. HELP....
  7. A Gaiaonline Problem
    A problem i want to stop (9)
    I have a problem getting on Gaiaonline. When I go it always says "SLOW DOWN Slow down,
    hotshot! You've been loading pages too fast, and our system doesn't like it. Take a
    break for a few minutes so we can catch up! This is not a ban. Come back in a littlw while,
    ok?" and I want it to stop! So can anyone please help me out here?....
  8. Trojan / Virus Problem ,please Help
    might be (hoon) (18)
    I have been infected with atrojan but i can detect it. and i have detected Hoon trojan and deleted
    it ,but the symptoms of the trojan is still on my pcs network " all driver have an autoplay (right
    click by mouse) and it gives my this message by d-click on any driver ************** SYS.EXE
    QUOTE windows cannot find 'sys.exe',make sure you typed the name correctly and then try
    again.to search for a file ,clicl the start botton then clicl search the virus was detected and
    deleted from all drivers: C:\sys.exe D:\sys.exe E:\sys.exe F:\sys....
  9. Fedora Core 6 Install Problem
    (6)
    I have tried three times to get Fedora Core 6 to install but I keep getting the same error message:
    “there was an error running your transaction, for the following reason(s): file conflicts”. I am
    using all of the default settings except changing the time zone and basically installing all
    packages. The error always happens near the end of the fifth disk. I have run sha hash checking on
    all media and everything checks out. Has anyone had this problem or a possible solution?....
  10. Internet Explorer 7 Problem
    Works fine in Firefox! (Shocker) (8)
    Hey, I'm helping my mom with one of her web projects for class and I've noticed a pretty
    big problem (no thanks to IE7) that cost her a few points. It won't load an image of an email
    icon, however, Firefox will load and display it properly. Here's the line for the image: CODE
    <img src="nationalparks/images/email.gif" width="99" height="100"
    border="0" alt="Email" /> Also, IE7 complains about some ActiveX content,
    but this is just a basic page and NO JavaScript, NO Java applets, NO ActiveX of any ki....
  11. Win Rar Password Problem
    (7)
    i have some trouble with some winrar files password the files is for an ISO and iam trying to remove
    the password because some files has a different password i have tried to change the password but no
    luck ...i used set default password and no luck too if any1 have any idea please post it thanks in
    advance -joe....
  12. Problem With Drag And Drop (or So It Seems).
    (11)
    I'm running on Windows XP with Service Pack 1. The last few days, all of a sudden, the drag and
    drop functionality of explorer (or anything on the operating system that uses system calls in order
    to perform it) screws up completely. I attempt to drag it, and it just flickers a bit to the
    direciton I'm moving it and then fails. It doesn't seem to be the mouse as I can still drag
    a rectangle selection to select multiple files etc, just no drag and drop. However, it isn't
    always like that, it works generally (as far as I know) and stop working out of now....
  13. Frustrating Problem With XP On Laptop
    (19)
    I have my Dualcore AMD Acer laptop, 5102Wlmi, with a 120GB hd, 2 GB ram, etc. I had a friend buy it
    in the states and bring it over just 2 months ago. All of a sudden, the other day when i went to
    turn it on, it would bring up the xp boot screen, and then just hang there. I tried a different hard
    drive. no luck. I tired installing XP, but after booting from cd and loading all the drivers, right
    after the FAT and NTFS drivers, it says "Setup is loading Windows" and then it hangs there. I've
    left it overnight and in the morning it's still in the same place. I can&#....
  14. Spam Problem On My Forums
    (25)
    I’m starting to have a real problem in my forums. Apparently “midget anal porn” is the hottest new
    thing. I didn’t think midgets were into that kind of thing but apparently I’m wrong (apologies to
    any midgets out there). I knew that spam may be a problem on my board but I didn’t think that I
    would be a target just yet. I only have 16 registered users (including the spam bots). How in the
    world did they find me? Just like junk mail I figure this problem is only going to get worst since
    I am now apparently on the list. Does anyone have a solution to this problem? I....
  15. Gba Game Program
    (5)
    Just woundering if anyone appart from me has even tried to create games for the gba
    And if so... were you... A: successful or any good at it... B: what type
    of scripting did you use... I use HAM and VHAM (Click here to go to the Home page)
    (sorry about the colour just had to try it... /tongue.gif" style="vertical-align:middle" emoid=":P"
    border="0" alt="tongue.gif" />)....
  16. Need To Hack An Admin Account On Xp... No Problem!
    It's so easy to hack an account you'll be amazed (61)
    Well recently one of my good girl that is a friend got a laptop from her dad. Her dad does websites
    so the laptop was new and worked fine, but needed to be defraged. The one problem, her nor her dad
    knew the admin password. I told her to post her question on Trap 17 and it got answered with in
    minutes. All you have to do is these few steps: 1. Reboot 2. Before the windows logo comes up press
    F11 (Just start clicking it over and over again until the windows logo comes up.) 3. Just sit and
    let it do it's thing and when the login screen comes up click on the Admin icon....
  17. OnMouseOver Button
    (10)
    Hi, this little code is perfect for adding short instructions on a submit button, simply add your
    text to the mouseover event of the button, for example: regards,....
  18. The Mentos And Diet Coke Reaction
    (54)
    I heard that if you placed mentos into a bottle of diet coke it would create a fountain effect. When
    I tried this I got covered in coke because of the speed of the reaction. Luckily no sugar means it
    does attract as many bugs. After this I wondered for a while what exactly is the chemical reaction
    that takes place between a mentos mint and diet coke. If anyone knows please post. It would be
    interesting if this only worked with diet coke. One more thing, I have also heard that a group of
    people created a video with several hundred of these "fountains" going off in a spe....
  19. Photoshop Cropping Problem
    (6)
    All right. For most of my Photoshop work, I use Photoshop 6.0. Yes, I know it's old, but it
    gets the job done, not to mention I just don't have the money of Photoshop CS or Photoshop CS2
    right now. But I'm getting off topic. Anyways, a few months ago, when I went to crop a
    picture, it wouldn't crop all the way. It would crop to a certain point and then just stop and
    refused to go any further with the cropping box. It seems to only form squares and sometimes
    horizontal rectangles, but only to a certain extent. However, when I opened Adobe Photosho....
  20. XP Problem: Clicking On Folder Opens Search
    (4)
    I have no idea why, but for some reason whenever I click on a folder now it opens it as a search
    instead of just showing me the contents. Whenever I right click it, search is at the top of the tab
    in bold instead of open. Is there any way I can fix this? I have no idea what I did wrong. Sorry,
    I fixxed it.....
  21. A Free Graphic Design Program That Could Equal Photoshop?
    (35)
    The past few years of my designing experience have been accomplished mainly by using a copy of my
    friend's father's Adobe Photoshop CS 8.0 CD. But my computer had been bugging me lately and
    i had no choice but to reformat it, at the same time wiping away any trace of the program.
    Unfortunately for me, i hadn't made a copy of the CD myself and i feel so much regret and
    remorse over that incident. Still, i have to look towards the future. I've went to the Adobe
    website and in no way am i going to pay 600 bucks for one program that i use once every week. A....
  22. Which Virus-protection Program Is The Best?
    (18)
    I personally have only ever used McAffee so i cant really judge, I was just wondering the numbers of
    people who prefer one over the other or can't choose.....
  23. Problem: I Need Urgent Help. Can't Boot.
    (9)
    Hi all. Thanks for reading this, and helping me... /unsure.gif' border='0'
    style='vertical-align:middle' alt='unsure.gif' /> I have a big problem - I must fix one computer
    for one of my important clients, but, everything seems to be fine, until you turn it on (really
    /rolleyes.gif' border='0' style='vertical-align:middle' alt='rolleyes.gif' /> ) ehm, anyway, when
    computer is turned ON, it boots and when it comes to login screen just blocks, and freezes, and
    there's nothing to do there. Sometimes I can manage to click on user to login, but then freezes
    again. .....
  24. Favorite Graphics Program?
    What program do you guys use for graphic (64)
    What is the graphics program you guys use the most? I use the Gimp, it's not only just as good
    (if not better in some ways) as photoshop but it's free.....
  25. Wuts A Good Game Maker Program?
    (12)
    whats a good game maker program where i can add them to my site?....
  26. Do You Program/code Your Own Games
    What games have you made? (11)
    Hey all! I was wondering what kinds of games you all have made or are working on right now.
    I'm also interested in what languages/software you used to make them. The most recent game
    I've made is Cannon Wars. It is a 3-D artillery game, similar to Scorched 3D . You control
    the angle and power of your gun and try to blow the other players up. After a lot of work I was
    able to add network support so you can play with people over a LAN. It also has a primitive Ai so
    that you can play against computer players. I wrote it in C++ and used Directx for the g....
  27. Clicksor
    Pay Per Click (CPC) Program Review (7)
    Clicksor Also known as : Clicksor :: PROGRAM TYPE :: PAY PER CLICK ( CPC ) :: PAY PER
    CLICK PROGRAM COMMENTS :: They are just like BiDclix. Ads are not relevant but you have to select
    categories. Thie feature might be useful to some.. but may not be for others. The Pay per click
    prices are not so good as Google. They claim to pay 70% of the revenue. :: COMPANY BACKGROUND ::
    Clicksor.com Inc is a division of YesUp Ecommerce Solutions Inc. YesUp was founded in 1999 and
    incorporated in 2001 under the name YesUp Ecommerce Solutions Inc. Headquartered in the ....
  28. Google Adsense
    Pay Per Click (CPC) Program Review (24)
    Google Adsense Also known as : Google Adsense ( program used by publishers ) and the ads
    created by advertisers are called Google Adwords. :: PROGRAM TYPE :: PAY PER CLICK ( CPC ) ::
    PAY PER CLICK PROGRAM COMMENTS :: They are the biggest pay per click network. With a very huge
    amount of advertisers bidding for clicks. Some sources claim that they give about 70% of the revenue
    to the publishers. The main key factor of this network is their keyword relavant ads i.e. Contextual
    Advertising. Because of this, the ads delivered on your website would be relevant to ....
  29. Error 406 - Problem In My Phpbb Forum
    Actually a problem with Apache (8)
    When I post the message in my forum contant the word "system" it can't work and said the HTTP
    error 406. I add three Mod : attach mod 2.3.11 , cash mod 2.2.2 , pay money mod 1.0.7 phpBB
    verison 2.0.12 my forum http://siuwing.astahost.com/testmod and then I also setup a model forum
    by cPanel , the error of posting also occur -> http://www.siuwing.astahost.com/testmod2/ the
    model forum havent adding any mod what is the problem ...? /sad.gif' border='0'
    style='vertical-align:middle' alt='sad.gif' /> ....
  30. Python (win32)
    Anyone Experienced? (1)
    So of late I've become increasingly interested in the whole bitTorrent trend, and I was possibly
    looking into dabbling in a release of my own... I was wondering if anyone has any experience with
    Python, and if so, which IDE should I use... I have Emacs (of course), but it's more hackerish
    than userfriendly, and I'm so noob with python i need to use a p*ssy prog that spoils you with
    dropdowns and context-sensitive help... Maybe I'm a dreamer, but oh well... Thx in advance...
    Oh yeah, this is for win32 development, as the people I would distribute my....

    1. Looking for python, problem, program, reaction, button, pressed

Searching Video's for python, problem, program, reaction, button, pressed
advertisement




[python]got A Problem In My Little Program - No reaction when button was pressed



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE