-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenCmdWrapper_win.py
670 lines (568 loc) · 27.5 KB
/
genCmdWrapper_win.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
import sys
from PyQt4 import QtCore,QtGui
from PyQt4.QtCore import QTimeLine
from genCmdWrapper import *
from functools import partial
from extraDialogs import *
class ExtendedQLabel( QtGui.QLabel ):
"""
A class of QLabel with added custom signal slots
"""
def __init( self,parent ):
QtGui.QLabel.__init__( self,parent )
def mouseReleaseEvent( self,ev ):
"""
Setups the mouseRelease signal
Connect to this Using
QtCore.SIGNAL( 'clicked()' ), func)
"""
self.emit( QtCore.SIGNAL( 'clicked()' ) )
class FaderWidget( QtGui.QWidget ):
"""A dict that keeps keys in
insertion order"""
def __init__( self,old_widget,new_widget ):
"""A dict that keeps keys in insertion order"""
QtGui.QWidget.__init__( self,new_widget )
self.old_pixmap = QtGui.QPixmap( new_widget.size() )
old_widget.render( self.old_pixmap )
self.pixmap_opacity = 1.0
self.timeline = QTimeLine()
self.timeline.valueChanged.connect( self.animate )
self.timeline.finished.connect( self.close )
self.timeline.setDuration( 333 )
self.timeline.start()
self.resize( new_widget.size() )
self.show()
def paintEvent( self,event ):
painter = QtGui.QPainter()
painter.begin( self )
painter.setOpacity( self.pixmap_opacity )
painter.drawPixmap( 0,0,self.old_pixmap )
painter.end()
def animate( self,value ):
self.pixmap_opacity = 1.0 - value
self.repaint()
class StackedWidget( QtGui.QStackedWidget ):
def __init__( self,parent = None ):
"""
StackedWidget class to manage fade in/out when changing widget display
"""
QtGui.QStackedWidget.__init__( self,parent )
def setCurrentIndex( self,index ):
self.fader_widget = FaderWidget( self.currentWidget(),self.widget( index ) )
QtGui.QStackedWidget.setCurrentIndex( self,index )
def setIndex1( self ):
self.setCurrentIndex( 0 )
def setIndex2( self ):
self.setCurrentIndex( 1 )
def setIndex3( self ):
self.setCurrentIndex( 2 )
class Dialog( QtGui.QDialog ):
def __init__( self,parent = None,commands = {} ):
super( Dialog,self ).__init__( parent )
self.commandList = []
for command in commands:
self.commandList.append( command.cmdName )
self.commandSelected = self.commandList.index( self.setCommand() )
self.command = commands[self.commandSelected]
cmdName = self.command.cmdName
self.resize( 1150,350 )
#LAYOUTS!
#top horizontal row
layout_root = QtGui.QVBoxLayout()
layout_top = QtGui.QHBoxLayout()
layout_root.addLayout( layout_top )
#first vertical column from the left, on horizontal top row
#command Configs
layout_top_vert1 = QtGui.QVBoxLayout()
#Horizontal rows inside
layout_top_vert1_boolAsString = QtGui.QHBoxLayout()
layout_top_vert1_threads = QtGui.QHBoxLayout()
layout_top_vert1_extension = QtGui.QHBoxLayout()
layout_top_vert1_threads.setContentsMargins ( 0,5,0,0 )
layout_top_vert1_extension.setContentsMargins ( 0,5,0,0 )
layout_top.addLayout( layout_top_vert1 )
#second vertical column from the left, on horizontal top row
#file list view
layout_top_Horizontal_vert2 = QtGui.QVBoxLayout()
layout_top_Horizontal_vert2_Top = QtGui.QHBoxLayout()
layout_top.addLayout( layout_top_Horizontal_vert2 )
#middle layout, vertical to hold the 3 column options row
self.layout_middle = QtGui.QVBoxLayout()
layout_root.addLayout( self.layout_middle )
#fileView
self.excelWidget = QtGui.QTableWidget()
self.excelWidget.setShowGrid( True )
self.excelWidget.setColumnCount( 2 )
self.excelWidget.setColumnWidth( 0,495 )
self.excelWidget.setColumnWidth( 1,495 )
self.excelWidget.setRowCount( 0 )
self.excelWidget.verticalHeader().setDefaultSectionSize( 17 )
self.excelWidget.setSortingEnabled( 1 )
self.excelWidget.setHorizontalHeaderLabels( ["inputFiles","outputFiles"] )
#CMD Config controls
configButtonSize = 18
if self.command.inputFile:
#if self.command.multipleinputFiles:
files_inputFilesButton = QtGui.QPushButton( self.tr( "Select Input Files" ) )
files_inputFilesButton.clicked.connect( self.setOpenFileNames )
files_inputFilesButton.setFixedHeight ( configButtonSize )
else:
files_inputFilesButton = QtGui.QPushButton( self.tr( "Select output FileName" ) )
files_inputFilesButton.setFixedHeight ( configButtonSize )
files_inputFilesButton.clicked.connect( self.setOutputFileName )
files_outputDirectoryButton = QtGui.QPushButton( self.tr( "Select Output Directory" ) )
files_previewCmdButton = QtGui.QPushButton( self.tr( "preview Commands" ) )
files_saveScriptButton = QtGui.QPushButton( self.tr( "save Script" ) )
files_scheduleCmdButton = QtGui.QPushButton( self.tr( "schedule Command" ) )
uncheckAllButton = QtGui.QPushButton( self.tr( "uncheck all" ) )
files_processButton = QtGui.QPushButton( self.tr( "START!" ) )
files_outputDirectoryButton.setFixedHeight ( configButtonSize )
files_previewCmdButton.setFixedHeight ( configButtonSize )
files_saveScriptButton.setFixedHeight ( configButtonSize )
files_scheduleCmdButton.setFixedHeight ( configButtonSize )
files_processButton.setFixedHeight ( 30 )
files_threadsLabel = QtGui.QLabel( "threads" )
files_threadsN = QtGui.QSpinBox()
files_threadsN.setValue( 1 )
files_extensionLabel = QtGui.QLabel( "fileExt" )
files_extensionQComboBox = QtGui.QComboBox()
files_extensionQComboBox.setFixedWidth( 50 )
files_extensionQComboBox.setEditable( 1 )
files_extensionQComboBox.addItems( [self.command.files_outputExtension] )
#signaling
files_processButton.clicked.connect( self.process )
files_outputDirectoryButton.clicked.connect( self.setExistingDirectory )
files_previewCmdButton.clicked.connect( self.reviewCmd )
uncheckAllButton.clicked.connect( self.uncheckAll )
#add stretchiness and stuff
layout_top_vert1.setStretch( 1,1 )
layout_top_vert1.setSpacing( 0 )
layout_top_vert1.addWidget( files_inputFilesButton )
layout_top_vert1.addWidget( files_outputDirectoryButton )
layout_top_vert1.addWidget( files_previewCmdButton )
layout_top_vert1.addWidget( uncheckAllButton )
layout_top_vert1.addWidget( files_saveScriptButton )
layout_top_vert1.addWidget( files_scheduleCmdButton )
layout_top_vert1.addStretch( 1 )
layout_top_vert1.addLayout( layout_top_vert1_boolAsString )
layout_top_vert1_threads.addWidget( files_threadsLabel )
layout_top_vert1_threads.addWidget( files_threadsN )
layout_top_vert1_extension.addWidget( files_extensionLabel )
layout_top_vert1_extension.addWidget( files_extensionQComboBox )
layout_top_vert1.addLayout( layout_top_vert1_extension )
layout_top_vert1.addStretch( 1 )
layout_top_vert1.addLayout( layout_top_vert1_threads )
layout_top_vert1.addStretch( 1 )
layout_top_vert1.addStretch( 1 )
layout_top_vert1.addWidget( files_processButton )
self.boolAsStringQCheckBox = QtGui.QCheckBox()
boolAsStringQLabel = QtGui.QLabel( "bool as strings" )
self.boolAsStringQCheckBox.toggled.connect( self.setBoolAsString )
layout_top_vert1_boolAsString.addWidget( boolAsStringQLabel )
layout_top_vert1_boolAsString.addWidget( self.boolAsStringQCheckBox )
layout_top_Horizontal_vert2.addLayout( layout_top_Horizontal_vert2_Top )
viewFileListButton = QtGui.QPushButton( "viewFileList" )
viewMiscButton = QtGui.QPushButton( "viewMisc" )
workersStdoutButton = QtGui.QPushButton( "workersStdout" )
layout_top_Horizontal_vert2_Top.addWidget( viewFileListButton )
layout_top_Horizontal_vert2_Top.addWidget( viewMiscButton )
layout_top_Horizontal_vert2_Top.addWidget( workersStdoutButton )
self.viewMiscButtonQPlainTextEdit = QtGui.QPlainTextEdit()
self.progressBar = QtGui.QProgressBar()
self.progressBar.setValue( 0 )
self.progressBar.valueChanged.connect( self.processFinishedWindow )
self.stack = StackedWidget()
layout_top_Horizontal_vert2.addWidget( self.stack )
self.columnNQSlider = QtGui.QSlider()
self.columnNQSlider.setOrientation( 0x1 )
self.columnNQSlider.setMinimum( 3 )
self.columnNQSlider.setMaximum( 12 )
self.columnNQSlider.setValue( 8 )
self.columnNQSlider.setTickInterval( 1 )
self.columnNQSlider.setTickPosition( 2 )
self.columnNQSlider.valueChanged.connect( self.rearrangeOptions )
layout_top_Horizontal_vert2.addWidget( self.columnNQSlider )
self.stack.addWidget( self.excelWidget )
self.stack.addWidget( self.viewMiscButtonQPlainTextEdit )
self.stack.addWidget( self.progressBar )
viewFileListButton.clicked.connect( self.stack.setIndex1 )
viewMiscButton.clicked.connect( self.reviewCmd )
workersStdoutButton.clicked.connect( self.stack.setIndex3 )
#CMD! OPTIONS
self.optionsNames = self.command.options.keys()
self.optionNumber = len( self.command.options.keys() )
maxColumn = 8
if self.optionNumber % maxColumn == 0:
rowNumber = self.optionNumber / maxColumn
else:
rowNumber = ( self.optionNumber / maxColumn ) + 1
i = 0
self.optionQGroupBox = []
optionCharQLabel=[]
optionQLabel = []
self.layout_middle_Hor = []
frameStyle = QtGui.QFrame.Sunken | QtGui.QFrame.Panel
for row in range( 0,rowNumber ):
self.layout_middle_Hor.append( QtGui.QHBoxLayout() )
self.layout_middle.addLayout( self.layout_middle_Hor[row] )
for column in range( 0,maxColumn ):
currentOptionName = self.optionsNames[i]
self.optionQGroupBox.append( QtGui.QGroupBox() )
optionCharQLabel.append( ExtendedQLabel() )
optionQLabel.append( ExtendedQLabel() )
optionCharQLabel[i].setParent( self.optionQGroupBox[i] )
optionCharQLabel[i].setParent( self.optionQGroupBox[i] )
optionQLabel[i].setParent( self.optionQGroupBox[i] )
self.optionQGroupBox[i].setTitle( currentOptionName )
self.optionQGroupBox[i].setCheckable( 1 )
self.optionQGroupBox[i].setChecked( self.command.options[currentOptionName].state )
self.optionQGroupBox[i].setFixedHeight( 51 )
#self.optionQGroupBox[i].setFlat(1)
self.optionQGroupBox[i].setAlignment(0)
optionCharQLabel[i].move( 8,25 )
optionQLabel[i].move( 29,25 )
#TODO:add - -- / as option prefixs
optionCharQLabel[i].setText( str(self.command.options[currentOptionName].optionPrefix) )
optionQLabel[i].setText( str( self.command.options[currentOptionName].param.value[0] ) )
#optionQLabel[i].setFrameStyle( frameStyle )
optionCharQLabel[i].setFixedWidth( 20 )
optionQLabel[i].setFixedWidth( 90 )
self.layout_middle_Hor[row].addWidget( self.optionQGroupBox[i] )
#signals
self.connectCheckbox( self.optionQGroupBox[i],self.optionsNames[i] )
currentParamType = self.command.options[currentOptionName].paramTypeString
#connects option QLabel to custom dialog for user input
self.connectButton( currentParamType,
optionQLabel[i],
optionQLabel[i],
i,
currentOptionName )
#connects option prefix QLabel to custom dialog for user input
self.connectQLabelOptionChar( optionCharQLabel[i],
i,
currentOptionName )
if i == self.optionNumber - 1:
break
i += 1
#bottom layout
self.setLayout( layout_root )
self.setWindowTitle( self.tr( cmdName ) )
def setOutputFileName(self):
"""
asks the user to select an item from a list, also editable for custom string parameters
"""
items = QtCore.QStringList("")
itemCurrentIndex = 0
item,ok = QtGui.QInputDialog.getItem( self,
self.tr( "QInputDialog.getItem()" ),
self.tr( "fileName:" ),
items,
itemCurrentIndex,
True )
if ok and not item.isEmpty():
#set the currentIndex based on the "string" passed
self.command.files_outputFile=[str(item)]
def connectQLabelOptionChar(self,optionCharQLabel,index,currentOptionName):
self.connect ( optionCharQLabel,
QtCore.SIGNAL( 'clicked()' ),
partial( self.setOptionPrefix,
optionCharQLabel,
index,
currentOptionName
) )
def setOptionPrefix(self,nameQLabel,index,currentOptionName ):
"""
asks the user to select an item from a list, also editable for custom string parameters
"""
itemList = [self.command.options[currentOptionName].optionPrefix]
items = QtCore.QStringList()
itemCurrentIndex = 0
for item in itemList:
items << self.tr( str( item ) )
item,ok = QtGui.QInputDialog.getItem( self,
self.tr( "QInputDialog.getItem()" ),
self.tr( "itemList:" ),
items,
itemCurrentIndex,
True )
if ok and not item.isEmpty():
self.command.options[currentOptionName].optionPrefix=( str( item ) )
nameQLabel.setText( self.tr( item ) )
def rearrangeOptions( self ):
"""rearrange the middle middle_hotLayout
depending on the column n"""
maxColumn = self.columnNQSlider.value()
if self.optionNumber % maxColumn == 0:
rowNumber = self.optionNumber / maxColumn
else:
rowNumber = ( self.optionNumber / maxColumn ) + 1
i = 0
for rowLayout in self.layout_middle_Hor:
rowLayout.setParent( None )
del rowLayout
self.layout_middle_Hor = []
for QGroupBox in self.optionQGroupBox:
QGroupBox.setParent( None )
for row in range( 0,rowNumber ):
self.layout_middle_Hor.append( QtGui.QHBoxLayout() )
self.layout_middle.addLayout( self.layout_middle_Hor[row] )
for column in range( 0,maxColumn ):
self.layout_middle_Hor[row].addWidget( self.optionQGroupBox[i] )
if i == self.optionNumber - 1:
break
i += 1
self.resize( 1150,250 )
def setBoolAsString( self,boolAsStringQCheckBox ):
"""Sets the bool value to pass the boolean args to the cmd as a
string value or equivalent value."""
newValue = self.boolAsStringQCheckBox.isChecked()
for option in self.command.options.keys():
if self.command.options[option].paramTypeString == "Boolean":
self.command.options[option].param.boolAsString = newValue
def updateFileTable( self ):
"""updates the interface file input output spreadsheet"""
n = len( self.command.files_inputFiles )
self.excelWidget.setRowCount( 0 )
self.excelWidget.setRowCount( n + 1 )
if self.command.inputFile:
self.excelWidget.setItem( 0,0,QtGui.QTableWidgetItem( self.command.files_inputDirectory ) )
else:
self.excelWidget.setItem( 0,0,QtGui.QTableWidgetItem( "no input files" ) )
self.excelWidget.setItem( 0,1,QtGui.QTableWidgetItem( self.command.files_outputDirectory ) )
# for i in range( 0,n ):
# self.excelWidget.setItem( 0,2 + ( i * 2 ),QtGui.QTableWidgetItem( self.command.files_inputFiles[i] ) )
## if not self.command.multipleOutputFiles:
# self.excelWidget.setItem( 0,3 + ( i * 2 ),QtGui.QTableWidgetItem( self.command.files_outputFile[0] ) )
# #else:self.excelWidget.setItem( 0,3 + ( i * 2 ),QtGui.QTableWidgetItem( self.command.files_outputFile[i] ) )
def reviewCmd ( self ):
"""sets the top middle stacked widget value to view mode"""
self.command.debug()
self.viewMiscButtonQPlainTextEdit.clear()
for cmd in self.command.fullCmdCommand:
for arg in cmd:
self.viewMiscButtonQPlainTextEdit.insertPlainText(str(" " + str(arg)))
self.viewMiscButtonQPlainTextEdit.insertPlainText( str( "\n" ) )
self.stack.setIndex2()
def process( self ):
"""updates the commands to run and send the commands[] to sleepProgress to
run as a background pr"""
print "Running!"
self.command.debug()
self.progressBar.setValue( 0 )
self.stack.setIndex3()
self.thread = SleepProgress( cmdLines = self.command.fullCmdCommand )
self.thread.partDone.connect( self.updatePBar )
#self.thread.procDone.connect( self.fin )
self.thread.start()
def processFinishedWindow( self ):
"""
if progressBarValue is 100 pop up window saying is done
"""
if self.progressBar.value() == 100:
QtGui.QMessageBox.about( None,"Notice","done!" )
def updatePBar( self,val ):
"""
updates the progressBar value
"""
self.progressBar.setValue( val )
def uncheckAll( self ):
"""
sets False to all argument options state on optionObjects
"""
for checkBox in self.optionQGroupBox:
checkBox.setChecked( 0 )
def setCommand( self ):
"""
lists the commands found in the xml and makes the user pick one
to work with
"""
itemList = self.commandList
items = QtCore.QStringList()
for item in itemList:
items << self.tr( str( item ) )
item,ok = QtGui.QInputDialog.getItem( self,
self.tr( "QInputDialog.getItem()" ),
self.tr( "itemList:" ),
items,
0,
True )
if ok and not item.isEmpty():
#set the currentIndex based on the "string" passed
return item
def setExistingDirectory( self ):
"""
asks the user for a directory
"""
options = QtGui.QFileDialog.DontResolveSymlinks | QtGui.QFileDialog.ShowDirsOnly
directory = QtGui.QFileDialog.getExistingDirectory( self,
self.tr( "QFileDialog.getExistingDirectory()" ),
"",options )
if not directory.isEmpty():
self.command.files_outputDirectory = directory + "\\"
self.updateFileTable()
def setOpenFileName( self ):
"""
asks the user for a file
"""
options = QtGui.QFileDialog.Options()
if True:
options |= QtGui.QFileDialog.DontUseNativeDialog
selectedFilter = QtCore.QString()
fileName = QtGui.QFileDialog.getOpenFileName( self,
self.tr( "QFileDialog.getOpenFileName()" ),
"",
self.tr( "All Files (*)" ),selectedFilter,
options )
if not fileName.isEmpty():
self.command.files_inputFiles = [ str( fileName ) ]
self.command.setInputFilesFromAbsolutePaths( [ str( fileName ) ] )
self.updateFileTable()
def setOpenFileNames( self ):
"""
asks the user for files
"""
options = QtGui.QFileDialog.Options()
if True:
options |= QtGui.QFileDialog.DontUseNativeDialog
selectedFilter = QtCore.QString()
fileNames = QtGui.QFileDialog.getOpenFileNames( self,
self.tr( "QFileDialog.getOpenFileNames()" ),"",
self.tr( "All Files (*)" ),selectedFilter,
options )
if fileNames.count():
files = []
for index in range( 0,fileNames.count() ):
files.append( str( fileNames[index] ) )
self.command.files_inputFiles = files
self.command.setInputFilesFromAbsolutePaths( files )
# self.updateFileTable()
def setItem( self,nameQLabel,index,currentOptionName ):
"""
asks the user to select an item from a list, also editable for custom string parameters
"""
itemList = self.command.options[currentOptionName].param.list
items = QtCore.QStringList()
itemCurrentIndex = self.command.options[currentOptionName].param.index
for item in itemList:
items << self.tr( str( item ) )
item,ok = QtGui.QInputDialog.getItem( self,
self.tr( "QInputDialog.getItem()" ),
self.tr( "itemList:" ),
items,
itemCurrentIndex,
True )
if ok and not item.isEmpty():
#set the currentIndex based on the "string" passed
self.command.options[currentOptionName].param.set_valueFromString( str( item ) )
nameQLabel.setText( self.tr( item ) )
def connectButton( self,currentParamType,button,nameQLabel,index,currentOptionName ):
"""
connects the interface control passed as an argument to the corresponding askUser dialog data Type
"""
if currentParamType == "float":
self.connect ( nameQLabel,
QtCore.SIGNAL( 'clicked()' ),
partial( self.setfloat,
nameQLabel,
index,
#getLabelText QString object and cast to int
currentOptionName
) )
if currentParamType == "Integer":
self.connect ( nameQLabel,
QtCore.SIGNAL( 'clicked()' ),
partial( self.setInteger,
nameQLabel,
index,
#getLabelText QString object and cast to int
currentOptionName
) )
if currentParamType == "fixedString" or currentParamType == "string":
self.connect ( nameQLabel,
QtCore.SIGNAL( 'clicked()' ),
partial( self.setItem,
nameQLabel,
index,
#getLabelText QString object and cast to int
currentOptionName
) )
if currentParamType == "Boolean":
self.connect ( nameQLabel,
QtCore.SIGNAL( 'clicked()' ),
partial( self.setItem,
nameQLabel,
index,
#getLabelText QString object and cast to int
currentOptionName
) )
if currentParamType == "float3":
self.connect ( nameQLabel,
QtCore.SIGNAL( 'clicked()' ),
partial( self.setfloat3,
nameQLabel,
#getLabelText QString object and cast to int
currentOptionName
) )
def setfloat3( self,nameQLabel,currentOptionName ):
"""
asks the user for 3 floats
"""
x = float( self.command.options[currentOptionName].param.value[0][0] )
y = float( self.command.options[currentOptionName].param.value[0][1] )
z = float( self.command.options[currentOptionName].param.value[0][2] )
dialog = float3Input( x = x,y = y,z = z,decimals = 8 )
returnValue = dialog.exec_()
self.command.options[currentOptionName].param.set_value( returnValue )
nameQLabel.setText( self.tr( str( returnValue ) ) )
def connectCheckbox( self,checkbox,currentOptionName ):
"""
connects the toggled emitted signal from a checkbox to the change state parameter function
"""
checkbox.toggled.connect( partial( self.changeParamActiveState,
checkbox,
currentOptionName
) )
def changeParamActiveState( self,checkbox,currentOptionName ):
"""
changes the active state of an option object passed as the argument to the corresponding
interface checkbox object
"""
if checkbox.isChecked() == True:
value = True
else: value = False
#setsActiveState
self.command.options[currentOptionName].state = value
def setfloat( self,nameQLabel,index,currentOptionName ):
"""
asks the user for a float value
"""
#cast the activeParamValue to float
value = self.command.options[currentOptionName].param.value[0]
d,ok = QtGui.QInputDialog.getDouble( self,
self.tr( "QInputDialog.getDouble()" ),self.tr( "Float:" ),
value,
- 650,650,15 )
if ok:
#update interface label
nameQLabel.setText( self.tr( "%5" ).arg( d ) )
#sets the activeParam[0] to value in input
self.command.options[currentOptionName].param.set_value( d )
def setInteger( self,nameQLabel,index,currentOptionName ):
"""
asks the user for a integer
"""
value = self.command.options[currentOptionName].param.value[0]
i,ok = QtGui.QInputDialog.getInteger( self,
self.tr( "QInputDialog.getInteger()" ),self.tr( "Integer:" ),
value,
- 65000,65000,1 )
if ok:
#update interface label
nameQLabel.setText( self.tr( "%1" ).arg( i ) )
#sets the activeParam[0] to value in input
self.command.options[currentOptionName].param.set_value( i )
xml_cmds = init_xmlCmd_rev1( 'cmds.xml',verbose = False )
commands = []
for cmd in xml_cmds.getCmds():
commands.append( commandWrapper( cmd ) )