SunQuest
           Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old September 11th, 2003, 07:10 PM
bmelton bmelton is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 bmelton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Multiple commands to a button?

Does anyone know if there's a way to string multiple commands to a button?

I have a small app that has a menu command to pull up a search entry in a new frame, with a close button... when You click on the search menu option, it deletes the search option (to keep from opening multiple frames), so I want to know if there's a way to get the close button (in the frame) to run multiple commands when clicked. I want it to insert the menu option for search again, and frame.destroy as well.

I tried creating a function that would just do both, and tie the button to that, but for some reason (and I'm a serious newbie; about one week's worth of experience), I can't close the frame from within another function.

Relevant code is below:
Code:
def insert():
    menu.delete(3) #deletes the menu option that called this function
    cframe = Frame(main)
    def search(event):
        ENTRY = entry.get()
        """Bunch of search stuff"""

    entry = Entry(cframe)
    entry.pack(side=TOP)
    entry.bind("<Return>", search)
    searchButton = Button(cframe, text='Search')
    searchButton.bind("<Button>", search)
    searchButton.pack(side=TOP)

    b1 = Button(cframe,text='Close',command=menu.insert_command(3, label="Search", command=insert),command=cframe.destroy).pack(side=TOP)
    cframe.pack(side=TOP)


If you look, it's not hard to see how I'm trying to string multiple commands to the "b1" button, but I just don't know how to pull it off. Like I said, I tried to define another function, but in that function, cframe.destroy does absolutely nothing whatsoever. I don't get it. Any ideas?

Reply With Quote
  #2  
Old September 12th, 2003, 03:11 PM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
Two things:

a) What toolkit are you using?
b) I think a better general feel for what you are trying to do with the whole app would be better

Reply With Quote
  #3  
Old September 13th, 2003, 02:26 PM
bmelton bmelton is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 bmelton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry, I'm using Tkinter for the GUI.

As for what it does, long story short, it opens a comma delimited text file, parses out each field into parts, and returns the relevant ones to the user, with field 1 being searchable.

It's not incredibly complicated, just my limited knowledge of the language won't allow me to progress beyond the stuck spot I'm in.

-9mm-

Reply With Quote
  #4  
Old September 13th, 2003, 05:21 PM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
I think basically what you need to do is simply create a function that calls both of those other functions and then hook that one in as the callback function (command=).

Reply With Quote
  #5  
Old September 13th, 2003, 05:36 PM
bmelton bmelton is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 bmelton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I tried that, but for some reason, I can't destroy a frame from any function other than the one that I called it in, and I don't know why. I would think that cframe.destroy would destroy it no matter where it was called from, but apparently, that isn't the case.

Is there something I'm missing in regards to that? Because frankly, that does seem the way to work it, it just won't allow me to close a frame outside of where I created it. :'(

-9mm-

Reply With Quote
  #6  
Old September 14th, 2003, 02:03 AM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
Well, unless you pass a reference to cframe into the other function, there's no way it can know what it is... it's a scope issue.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Multiple commands to a button?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway