By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

how to attach execute commands to button?

P: 1
Hi,

Sorry if this is an obvious question but I am new to python and can't seem to find an easy example for what I want to to.

I would like to define a button with tinker and then have that execute a scriptable shell binary file with options.

In TCL/TK, this would be a simple example ;

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/wish -f
  2. frame .rc -borderwidth 2
  3. wm title . "Resources"
  4. pack .rc
  5. button .rc.b -text "Press Me to process"  -command {exec shake -x test.sk}
  6. pack .rc.b
  7.  
Where shake is an executable defined in the environment and test.shk is one of its ascii text process input files.

So, I have looked as os.system and subprocess but I can't see an easy method to do this, like the above, simple 'hello world' type thing.

So in summary, if I went to a shell and typed shake -x test.sk, the shake binary would process its input file test.shk with the argument x and everything is ok. Calling {exec shake -x test.sk} from a tcl/tk script would do the same thing. I just can't seem to find a way to rewrite my example above using python.

Thanks for any help.
Nov 19 '08 #1
Share this Question
Share on Google+
1 Reply


Curtis Rutland
Expert 2.5K+
P: 3,256
Please enclose your posted code in [CODE] [/CODE] tags (See How to Ask a Question). Code tags preserve indention and uses a monospaced font.

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [CODE] [/CODE] tags in future.

MODERATOR
Nov 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.