Connecting Tech Pros Worldwide Help | Site Map

how to attach execute commands to button?

Newbie
 
Join Date: Nov 2008
Posts: 1
#1: Nov 19 '08
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.
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,603
#2: Nov 21 '08

re: how to attach execute commands to button?


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
Reply