<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19019"></HEAD>
<BODY>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=543222207-05042011>Hi I
am a beginner with python , QGIS and pyQT.</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=543222207-05042011>I am
working on a python plug-in and would like to populate dynamically a pyQT based
QDialog form with combo boxes at runtime (the elements to be added are input via
a config txt file that is read). Thus I would like to get hints how I can do
this .</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=543222207-05042011>I have
a a py file with the dialog form
(streameditcustomformdialog.py):</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=543222207-05042011>from
PyQt4 import QtCore, QtGui<BR>from ui_streameditcustomform import
Ui_StreamEditCustomForm<BR># create the dialog for zoom to point<BR>class
StreamEditCustomFormDialog(QtGui.QDialog):<BR> def
__init__(self, parent = None):<BR>
QtGui.QDialog.__init__(self)<BR> # Set
up the user interface from
Designer.<BR> self.ui =
Ui_StreamEditCustomForm()<BR>
self.ui.setupUi(self)<BR></SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=543222207-05042011>and a
routine that reads the config file and should populate the form with new
comboxes:</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=543222207-05042011>def
inputConfig(self):<BR>
<BR> # QgisMainWindow =
qgis.utils.iface.mainWindow()
<BR> filename =
QFileDialog.getOpenFileName(None, 'Open File', "C:/",
\<BR> "Text
Files (*.txt
*.csv)");
<BR> if
filename:<BR>
formconfig_input = open(filename, 'r') # input species info id ,
name for batch
processing<BR>
while
1:<BR>
formconfig_line =
formconfig_input.readline() #
read csv text file line
<BR>
if not formconfig_line:
break<BR>
formconfig_splitline =
formconfig_line.split(',')<BR>
if len(formconfig_splitline) <
3:<BR>
QMessageBox.information(None,"A problem occured with your input file.",
\<BR>
"The file you choose did not have the proper \n syntax or number of comma
separated
fields.")<BR>
return<BR>
else:<BR>
fieldname1 =
formconfig_splitline[0]<BR>
fieldtype1 =
formconfig_splitline[1]<BR>
fieldlength1 =
formconfig_splitline[2]<BR>
QMessageBox.information(None,"Form Info:",
\<BR>
fieldname1 + '\n' + fieldtype1 + '\n' +
fieldlength1)<BR>
self.dlg =
StreamEditCustomFormDialog()<BR>
#show the
dialog<BR>
self.dlg.comboBoxNew =
QtGui.QComboBox()<BR>
self.dlg.comboBoxNew.setObjectName("comboBox")<BR>
self.dlg.comboBoxNew.setItemText(1, QtGui.QApplication.translate("Form", "bw",
None,
QtGui.QApplication.UnicodeUTF8))<BR>
self.dlg.show()<BR>
return<BR>
formconfig_input.close</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011>However I tried it above - the combo box does not
appear on the form which is showing ok if I run the plugin, no error message
...but no combo box ...</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=543222207-05042011>What
am I doing wrong?</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=543222207-05042011>Will
this take care of layout management or how could I have the layout (e.g. size of
form handled if many combo boxes are added ?</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011>Thanks</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN
class=543222207-05042011>Karsten</SPAN></FONT></DIV>
<P class=MsoNormal align=left><FONT size=2><SPAN
style="FONT-FAMILY: Verdana; FONT-SIZE: 11pt">Karsten
Vennemann<BR></SPAN></FONT><FONT size=1><SPAN
style="FONT-FAMILY: Verdana; FONT-SIZE: 9pt"><BR></SPAN></FONT><FONT
color=#003264><FONT size=1><SPAN
style="FONT-FAMILY: Verdana; FONT-SIZE: 9pt">Terra GIS
LTD<BR></SPAN></FONT></FONT><FONT color=#003264 size=1><SPAN
style="FONT-FAMILY: Verdana; FONT-SIZE: 9pt"><A
href="http://www.terragis.net">www.terragis.net</A></SPAN></FONT></P></BODY></HTML>