how to attach execute commands to button?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frankvw
    New Member
    • Nov 2008
    • 1

    how to attach execute commands to button?

    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 ;

    Code:
    #!/usr/bin/wish -f
    frame .rc -borderwidth 2
    wm title . "Resources"
    pack .rc
    button .rc.b -text "Press Me to process"  -command {exec shake -x test.sk}
    pack .rc.b
    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.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    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

    Comment

    Working...