Newbie question: PyQt & Form::init() SOLVED
Sven Ehret
sation at web.de
Mon Sep 25 11:45:22 EDT 2006
Diez B. Roggisch wrote:
> Sven Ehret wrote:
>
>> Diez B. Roggisch wrote:
>>
>>> Sven Ehret wrote:
>>>
>>>> Hello List,
>>>>
>>>> I am trying to learn Python and followed the tutorial at
>>>> http://www.cs.usfca.edu/~afedosov/qttut/. Being happy that it works, I
>>>> am now trying to do my own project, but I am having problems with
>>>> initialization of my form.
>>>>
>>>> I want to automatically fill a couple of comboboxes upon starting the
>>>> program. I read on the net that I simply have to add a function
>>>> called »Form1.Init()« with the content I wish to have executed at start
>>>> time. However, it never gets executed, so it seems. When I re-write the
>>>> application to have the code executed at the press of a button, it
>>>> works. What am I doing wrong?
>>>
>>> Show us more code, and we show you the problem. At least we can try
>>> then, until someone finally implements
>>>
>>> from __future__ import mindreading
>>>
>>> Diez
>>
>> Oh, sorry. *blush*
>> here is my code (two files):
>>
>> form1.py:
>> # -*- coding: utf-8 -*-
>>
>> # Form implementation generated from reading ui file 'form1.ui'
>> #
>> # Created: Mo Sep 25 15:38:56 2006
>> # by: The PyQt User Interface Compiler (pyuic) 3.14.1
>> #
>> # WARNING! All changes made in this file will be lost!
>>
>>
>> from qt import *
>>
>>
>> class Form1(QDialog):
>> def __init__(self,parent = None,name = None,modal = 0,fl = 0):
>> QDialog.__init__(self,parent,name,modal,fl)
>>
>> if not name:
>> self.setName("Form1")
>>
>>
>>
>> self.pushButton1 = QPushButton(self,"pushButton1")
>> self.pushButton1.setGeometry(QRect(410,340,80,30))
>>
>> self.comboBox1 = QComboBox(0,self,"comboBox1")
>> self.comboBox1.setGeometry(QRect(310,10,120,31))
>> self.comboBox1.setSizeLimit(12)
>> self.comboBox1.setMaxCount(12)
>>
>> self.comboBox2 = QComboBox(0,self,"comboBox2")
>> self.comboBox2.setGeometry(QRect(431,10,60,31))
>>
>> self.buttonGroup1 = QButtonGroup(self,"buttonGroup1")
>> self.buttonGroup1.setGeometry(QRect(10,50,480,200))
>>
>> self.pushButton3 = QPushButton(self,"pushButton3")
>> self.pushButton3.setGeometry(QRect(200,320,101,24))
>>
>> self.textLabel1 = QLabel(self,"textLabel1")
>> self.textLabel1.setGeometry(QRect(71,10,160,30))
>>
>> self.languageChange()
>>
>> self.resize(QSize(504,380).expandedTo(self.minimumSizeHint()))
>> self.clearWState(Qt.WState_Polished)
>>
>> self.connect(self.pushButton1,SIGNAL("clicked()"),self.close)
>> self.connect(self.comboBox1,SIGNAL("activated(const
>> QString&)"),self.AddMonthsToCombo)
>
> When you just invoke
>
>
> self.AddMonthsToCombo()
>
> here, things should work.
>
> Diez
thank you, but,
I think I was able to sort it out for myself. I had to add the function
using the QtDesigner GUI (Add Slot). Then it gets recognised as
initialization module.
More information about the Python-list
mailing list