0

I have a problem with opening a small dialog window when I press a button from my MainWindow. I know how to make a window that I need to open (let's call it EDIT WINDOW), but calling (opening) it from Main form, and another module is a different story.

Main window is showing, and working. All the imports are fine, with sqlite connection working. Basically, program is finished, only this dialog remains... It should have QMainWindow as it parent.

#!/usr/bin/python
#encoding=utf8
import sys
from PyQt4 import QtCore, QtGui
from gui import Ui_glavni
from dialog import Ui_Dialog
import snimanje #imported modules
import clear
import pretraga
import izmena #this should represent module with custom made dialog.


class Prozor(snimanje.Snimi, clear.Brisanje, pretraga.Pretraga,QtGui.QMainWindow):
    def __init__(self,parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.ui=Ui_glavni()
        self.ui.setupUi(self)
        QtCore.QObject.connect(self.ui.dugmeSnimi, QtCore.SIGNAL("clicked()"), self.snimi)
        QtCore.QObject.connect(self.ui.dugmeOtkazi, QtCore.SIGNAL("clicked()"), self.brisanjeUnos)
        QtCore.QObject.connect(self.ui.dugmeOtkazi2, QtCore.SIGNAL("clicked()"), self.brisanjeListanje)
        QtCore.QObject.connect(self.ui.dugmeTrazi, QtCore.SIGNAL("clicked()"), self.pretraga)
        QtCore.QObject.connect(self.ui.checkJedinica, QtCore.SIGNAL("stateChanged(int)"), self.aktivJedinica)
        QtCore.QObject.connect(self.ui.checkVrednost, QtCore.SIGNAL("stateChanged(int)"), self.aktivVrednost)
        QtCore.QObject.connect(self.ui.menjaIme, QtCore.SIGNAL("clicked()"), izmena.dijalog)
        QtCore.QObject.connect(self.ui.dugmeBrisi, QtCore.SIGNAL("clicked()"), self.brisanjeIzBaze)
#SREDI IZMENU. SREDI PROVERU UNETIH U BAZU PO BROJU PREDMETA


        def startup():
            self.brisanjeUnos()
            self.brisanjeListanje()
            self.provera()

        startup()

    def aktivJedinica(self):
        self.ui.lineJedinica.setEnabled(False)
        self.ui.lineJedinica.setText("")
        self.ui.checkJedinica.checkStateSet()
        if self.ui.checkJedinica.isChecked():
            self.ui.lineJedinica.setEnabled(True)
            #self.ui.checkJedinica.setEnabled(False)

    def aktivVrednost(self):
        self.ui.vrednost.setEnabled(False)
        self.ui.vrednost.setText("")
        if self.ui.checkVrednost.isChecked():
            self.ui.vrednost.setEnabled(True)

    def pretraga(self):
        if self.ui.radioIme.isChecked():
            self.pretragaIme()
        elif self.ui.radioBrPr.isChecked():
            self.pretragaBrPr()
        else:
            self.pretragaSudski()



if __name__=="__main__":
    program = QtGui.QApplication(sys.argv)
    mojprogram = Prozor()
    mojprogram.show()
    sys.exit(program.exec_())
tshepang
  • 12,111
  • 21
  • 91
  • 136
ivica
  • 1,388
  • 1
  • 22
  • 38
  • I would like to open a custom made dialog (nothing fancy, one lineEdit and two buttons) named dialog. My idea was to import the module, and a button click would display the child dialog. I have been reading Rapid GUI programming ebook, which addresses a similar issue, but am unable to do the same in my example. – ivica Jun 28 '12 at 12:28
  • Ooooook, Dialog is opening right now, but I can't use any signals in it. Will update the thread with the right code when i clean it up. – ivica Jun 28 '12 at 12:43
  • http://stackoverflow.com/questions/9074195/displaying-pop-up-windows-in-python-pyqt4 This is the answer. I was wrong the whole time. – ivica Jun 28 '12 at 13:17

0 Answers0