F:/KPlato/koffice/libs/kross/test/testguiform.py

Aller à la documentation de ce fichier.
00001 #!/usr/bin/env kross
00002 
00003 import Kross, os
00004 
00005 #window = Kross.activeWindow()
00006 #if window == None:
00007 #    print "Creating new dialog"
00008 #    window = Kross.createDialog("TestGuiFormDialog")
00009 #else:
00010 #    print "Using active window"
00011 
00012 print "1................"
00013 forms = Kross.module("forms")
00014 print "2................"
00015 print "===================================> %s" % forms
00016 print dir(forms)
00017 
00018 dialog = forms.createDialog("TestGuiFormDialog")
00019 dialog.setButtons("Ok|Cancel")
00020 dialog.setFaceType("List") #Auto Plain List Tree Tabbed
00021 
00022 #print "===> dialog %s %s" % (dialog,dir(dialog))
00023 
00024 #page0 = dialog.addPage("Welcome","Welcome","about_kde")
00025 ##widget0 = Kross.forms().createWidget(page0, 'QWidget', 'MyForm1', {})
00026 ##widget0label = Kross.forms().createWidget(page0, 'QLabel', 'label', {'text':'Testlabel'})
00027 #widget0 = Kross.forms().createWidgetFromUI(page0,
00028     #'<ui version="4.0" >'
00029     #' <class>Form</class>'
00030     #' <widget class="QWidget" name="Form" >'
00031     #'  <layout class="QHBoxLayout" >'
00032     #'   <property name="margin" >'
00033     #'    <number>9</number>'
00034     #'   </property>'
00035     #'   <property name="spacing" >'
00036     #'    <number>6</number>'
00037     #'   </property>'
00038     #'   <item>'
00039     #'    <widget class="QLabel" name="label" >'
00040     #'     <property name="text" >'
00041     #'      <string>Testlabel</string>'
00042     #'     </property>'
00043     #'     <property name="alignment" >'
00044     #'      <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>'
00045     #'     </property>'
00046     #'    </widget>'
00047     #'   </item>'
00048     #'  </layout>'
00049     #' </widget>'
00050     #'</ui>')
00051 
00052 page3 = dialog.addPage("Options","Options","configure")
00053 uifile = os.path.join( self.currentPath(), "testguiform.ui" )
00054 widget3 = forms.createWidgetFromUIFile(page3, uifile)
00055 
00056 page1 = dialog.addPage("File","Import From Image File","fileopen")
00057 widget1 = forms.createFileWidget(page1, "kfiledialog:///mytestthingy1")
00058 #widget1.setMode("Saving")
00059 widget1.setMode("Opening")
00060 widget1.setFilter("*.cpp|C++ Source Files\n*.h|Header files")
00061 
00062 #optionspage = dialog.addPage("Options","Import Options","configure")
00063 #optionswidget = Kross.forms().createWidgetFromUIFile(optionspage, "/home/kde4/koffice/krita/plugins/viewplugins/scripting/scripts/pilimport.ui")
00064 
00065 #w = widget #widget["KFileDialog::mainWidget"]
00066 #print dir(w)
00067 #for idx in range( len(w) ):
00068 #    obj = w[ idx:idx ][0]
00069 #    print "...... idx=%s obj=%s name=%s class=%s" % ( idx , obj , obj.__name__ , obj.__class__ )
00070 
00071 ##combo = dialog["QWidget"]["QWidget"]["QGroupBox"]["QComboBox"]
00072 #combo = widget["QGroupBox"]["QComboBox"]
00073 #combo.setEditText("Hello World")
00074 
00075 print "######################################## self.currentPath=\"%s\"" % self.currentPath()
00076 
00077 result = dialog.exec_loop()
00078 if result:
00079     print "===> result=%s" % dialog.result()
00080 
00081     def getOption(widget, optionname, optionlist):
00082         try:
00083             childwidget = widget[ optionname ]
00084             for option in optionlist:
00085                 radiobutton = childwidget[ option ]
00086                 if radiobutton.checked:
00087                     return option
00088         except:
00089             import sys, traceback
00090             raise "\n".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) )
00091         raise "No such option \"%s\"" % optionname
00092 
00093     colorspace = getOption(optionswidget, "Colorspace", ["RGB","CMYK"])
00094     destination = getOption(optionswidget, "Destination", ["NewLayer","ActiveLayer"])
00095     size = getOption(optionswidget, "Size", ["Resize","Scale","Ignore"])
00096 
00097     print "===> colorspace=%s destination=%s size=%s" % (colorspace,destination,size)
00098 
00099     #destinationwidget = optionswidget["Destination"]
00100     #if destinationwidget["NewLayer"].checked:
00101     #elif destinationwidget["ActiveLayer"].checked:
00102     #else:
00103 
00104     #sizebox = optionswidget["Size"]
00105     #if sizebox["Resize"].checked:
00106     #elif sizebox["Scale"].checked:
00107     #elif sizebox["Ignore"].checked:
00108     #else:
00109 
00110     #w = csbox
00111     #for idx in range( len(w) ):
00112     #    obj = w[ idx:idx ][0]
00113     #    print "...... idx=%s obj=%s name=%s class=%s" % ( idx , obj , obj.__name__ , obj.__class__ )
00114 
00115 print dir(dialog)
00116 dialog.delayedDestruct();

Généré le Wed Nov 22 23:41:12 2006 pour KPlato par  doxygen 1.5.1-p1