View Full Version : Gui for a command line plugin with flags... help?
DRadford 10-31-2009, 07:21 PM Ok, so I'm totally a n00b at programming but I understand the basic concepts (more in python than mel). I'm trying to create a simple gui for the command line plugin m2mdd. However, there are several flags that are needed for the plugin to work in a way that's actually helpful. Some of those flags being -fps, (self explanatory), -sclm (scale) and -edirp (output dir).
What I'm trying to do is create a simple gui that allows me to type in the desired fps, output dir and scale and have it plug those values into the right flags.
I'm having 2 notable problems (Here's where the noobness comes in).
1) How do I grab the text that's typed into a textField and assign it to a variable?
2) How do I use that variable within the button -command function?
syntax aside, I THINK it would work something like this:
textField: "scale"
[typed value]: ".01"
textField: "OutputDir"
[desired folder]: "C:/..."
$scale = scale.value
$outdir = OutputDir.value
button -command "m2mdd -edirp$outdir -sclm$scale"
resulting in the equivilent of typing "m2mdd-edirp C:/... -sclm .01" into the mel command line.
Clearly my syntax is all off but that's basically what I'm trying to get at.
Help please?
-David
|
|
DRadford
11-03-2009, 04:40 PM
*Bump*
Nothing? This has to be one of the most basic functions of using a text field, SOMEBODY has to know how to get that data out??
arkangel-fx
11-03-2009, 05:09 PM
string $window = `window`;
rowColumnLayout -numberOfColumns 2 -columnAttach 1 "right" 0
-columnWidth 1 100 -columnWidth 2 250;
text -label "Scale";
string $scale = `textField`;
text -label "OutputDir";
string $outDir = `textField`;
textField -edit -enterCommand ("setFocus " + $outDir) $scale;
string $myScale = textField("-q", "-text", $scale);
string $myOutDir = textField("-q", "-text", $outDir);
string $myCmd = "m2mdd -edirp $myOutDir -sclm $myScale";
button -command $myCmd;
showWindow $window;
DRadford
11-05-2009, 05:33 PM
Ok, so I tried that bit of code and it ALMOST works perfectly. I made a couple changes to get it to work a LITTLE better but its still not working right.
if (`window -exists m2mddWindow`) deleteUI m2mddWindow;
string $window = `window -title "M2MDD" -widthHeight 200 100 m2mddWindow`;
rowColumnLayout -numberOfColumns 2 -columnAttach 1 "right" 0
-columnWidth 1 100 -columnWidth 2 250;
text -label "Scale";
string $scale = `textField`;
text -label "OutputDir";
string $outDir = `textField`;
textField -edit -enterCommand ("setFocus " + $outDir) $scale;
string $junk = "C:/Documents and Settings/dradford/Desktop/Amanda";
string $myScale = textField("-q", "-text", $scale);
string $myOutDir = textField("-q", "-text", $outDir);
string $myCmd = ("m2mdd -edirp " + "$myOutDir" + " -sclm " + "$myScale");
button -label "Export" -command $myCmd;
showWindow $window;
I was using the $junk variable to test the $myCmd function, that's how I figured out I needed quotes around the variables in $myCmd. Anyway, its like the variables are being assigned based on what's in the textField when its created and not changing when I type something in. Do I need to do something to update the variable value once the textField is edited?
arkangel-fx
11-05-2009, 05:49 PM
Well, you should move the queries of the textboxes to a proc and call that proc from a button.
global proc doGUI() {
if (`window -exists m2mddWindow`) deleteUI m2mddWindow;
string $window = `window -title "M2MDD" -widthHeight 200 100 m2mddWindow`;
rowColumnLayout -numberOfColumns 2 -columnAttach 1 "right" 0
-columnWidth 1 100 -columnWidth 2 250;
text -label "Scale";
string $scale = `textField`;
text -label "OutputDir";
string $outDir = `textField`;
textField -edit -enterCommand ("setFocus " + $outDir) $scale;
string $junk = "C:/Documents and Settings/dradford/Desktop/Amanda";
button -label "Export" -command doExport($scale, $outDir);
showWindow $window;
}
global proc doExport(string $guiHscale, string $guiHoutDir) {
string $myScale = textField("-q", "-text", $guiHscale);
string $myOutDir = textField("-q", "-text", $guiHoutDir);
string $myCmd = ("m2mdd -edirp " + "$myOutDir" + " -sclm " + "$myScale");
eval($myCmd)
}
doGUI;
That should work now, didnt test it, but it should.
CGTalk Moderation
11-05-2009, 05:49 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.