<!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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;&nbsp;&nbsp; def 
__init__(self, parent = None):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
QtGui.QDialog.__init__(self)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Set 
up the user interface from 
Designer.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ui = 
Ui_StreamEditCustomForm()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.ui.setupUi(self)<BR></SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN 
class=543222207-05042011></SPAN></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=543222207-05042011>def 
inputConfig(self):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # QgisMainWindow = 
qgis.utils.iface.mainWindow()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filename = 
QFileDialog.getOpenFileName(None, 'Open File', "C:/", 
\<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Text 
Files (*.txt 
*.csv)");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
filename:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
formconfig_input = open(filename, 'r')&nbsp;&nbsp; # input species info id , 
name for batch 
processing<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
while 
1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
formconfig_line&nbsp; = 
formconfig_input.readline()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # 
read&nbsp; csv text file line 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if not formconfig_line: 
break<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
formconfig_splitline = 
formconfig_line.split(',')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if len(formconfig_splitline) &lt; 
3:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
QMessageBox.information(None,"A problem occured with your input file.", 
\<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
"The file you choose did not have the proper \n syntax or number of comma 
separated 
fields.")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
return<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
fieldname1&nbsp;&nbsp; = 
formconfig_splitline[0]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
fieldtype1&nbsp;&nbsp; = 
formconfig_splitline[1]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
fieldlength1 = 
formconfig_splitline[2]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
QMessageBox.information(None,"Form Info:", 
\<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
fieldname1 + '\n' + fieldtype1 + '\n' + 
fieldlength1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.dlg = 
StreamEditCustomFormDialog()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
#show the 
dialog<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.dlg.comboBoxNew = 
QtGui.QComboBox()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.dlg.comboBoxNew.setObjectName("comboBox")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.dlg.comboBoxNew.setItemText(1, QtGui.QApplication.translate("Form", "bw", 
None, 
QtGui.QApplication.UnicodeUTF8))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.dlg.show()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
return<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
formconfig_input.close</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN 
class=543222207-05042011></SPAN></FONT>&nbsp;</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>&nbsp;</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>&nbsp;</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>