hello everyone
I am working on my application that deals with photos. well i have created my UI using Qt designer and converted it to python classes using pyuic4 but i am facing problem with the file dailoug where i can browse my directory and choose photos but i can't get them displayed on my QlistView widget.
Ihave an attachment example of my inquiry
here's my python classes converted using pyuic4
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ui.ui'
#
# Created: Sat Feb 7 16:59:29 2009
# by: PyQt4 UI code generator 4.3.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(QtCore.QSize(QtCore.QRect(0,0,908,616).size()).expandedTo(MainWindow.minimumSizeHint()))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setGeometry(QtCore.QRect(0,36,908,558))
self.centralwidget.setObjectName("centralwidget")
self.photosdisplay = QtGui.QGraphicsView(self.centralwidget)
self.photosdisplay.setWindowModality(QtCore.Qt.NonModal)
self.photosdisplay.setGeometry(QtCore.QRect(200,20,451,192))
self.photosdisplay.setObjectName("photosdisplay")
self.addphoto = QtGui.QPushButton(self.centralwidget)
self.addphoto.setWindowModality(QtCore.Qt.NonModal)
self.addphoto.setGeometry(QtCore.QRect(12,220,80,27))
self.addphoto.setObjectName("addphoto")
self.tagfield = QtGui.QLineEdit(self.centralwidget)
self.tagfield.setWindowModality(QtCore.Qt.NonModal)
self.tagfield.setGeometry(QtCore.QRect(230,220,421,27))
self.tagfield.setObjectName("tagfield")
self.options = QtGui.QComboBox(self.centralwidget)
self.options.setWindowModality(QtCore.Qt.NonModal)
self.options.setGeometry(QtCore.QRect(97,300,56,26))
self.options.setObjectName("options")
self.searchquery = QtGui.QLineEdit(self.centralwidget)
self.searchquery.setWindowModality(QtCore.Qt.NonModal)
self.searchquery.setGeometry(QtCore.QRect(159,300,501,27))
self.searchquery.setObjectName("searchquery")
self.searchphoto = QtGui.QPushButton(self.centralwidget)
self.searchphoto.setWindowModality(QtCore.Qt.NonModal)
self.searchphoto.setGeometry(QtCore.QRect(11,300,80,27))
self.searchphoto.setObjectName("searchphoto")
self.Finish = QtGui.QPushButton(self.centralwidget)
self.Finish.setWindowModality(QtCore.Qt.NonModal)
self.Finish.setGeometry(QtCore.QRect(10,520,111,31))
self.Finish.setObjectName("Finish")
self.searchresult = QtGui.QTextBrowser(self.centralwidget)
self.searchresult.setWindowModality(QtCore.Qt.NonModal)
self.searchresult.setGeometry(QtCore.QRect(200,330,461,183))
self.searchresult.setObjectName("searchresult")
self.removephoto = QtGui.QPushButton(self.centralwidget)
self.removephoto.setWindowModality(QtCore.Qt.NonModal)
self.removephoto.setGeometry(QtCore.QRect(10,260,80,27))
self.removephoto.setObjectName("removephoto")
self.cancel = QtGui.QPushButton(self.centralwidget)
self.cancel.setWindowModality(QtCore.Qt.NonModal)
self.cancel.setGeometry(QtCore.QRect(550,520,111,31))
self.cancel.setObjectName("cancel")
self.addphotoandtag = QtGui.QPushButton(self.centralwidget)
self.addphotoandtag.setWindowModality(QtCore.Qt.NonModal)
self.addphotoandtag.setGeometry(QtCore.QRect(98,220,126,27))
self.addphotoandtag.setObjectName("addphotoandtag")
self.label = QtGui.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(290,270,181,18))
self.label.setObjectName("label")
self.calendarWidget = QtGui.QCalendarWidget(self.centralwidget)
self.calendarWidget.setGeometry(QtCore.QRect(670,330,221,170))
self.calendarWidget.setObjectName("calendarWidget")
self.listView = QtGui.QListView(self.centralwidget)
self.listView.setGeometry(QtCore.QRect(10,20,181,192))
self.listView.setObjectName("listView")
self.listView_2 = QtGui.QListView(self.centralwidget)
self.listView_2.setGeometry(QtCore.QRect(10,330,181,181))
self.listView_2.setObjectName("listView_2")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setGeometry(QtCore.QRect(0,594,908,22))
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0,0,908,25))
self.menubar.setObjectName("menubar")
self.menuFile = QtGui.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
MainWindow.setMenuBar(self.menubar)
self.toolBar = QtGui.QToolBar(MainWindow)
self.toolBar.setGeometry(QtCore.QRect(0,25,11,11))
self.toolBar.setObjectName("toolBar")
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea,self.toolBar)
self.toolBar_2 = QtGui.QToolBar(MainWindow)
self.toolBar_2.setGeometry(QtCore.QRect(11,25,897,11))
self.toolBar_2.setObjectName("toolBar_2")
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea,self.toolBar_2)
self.actionImport_Photos = QtGui.QAction(MainWindow)
self.actionImport_Photos.setObjectName("actionImport_Photos")
self.actionExit = QtGui.QAction(MainWindow)
self.actionExit.setObjectName("actionExit")
self.menuFile.addSeparator()
self.menuFile.addAction(self.actionImport_Photos)
self.menuFile.addSeparator()
self.menuFile.addAction(self.actionExit)
self.menubar.addAction(self.menuFile.menuAction())
self.retranslateUi(MainWindow)
QtCore.QObject.connect(self.cancel,QtCore.SIGNAL("clicked()"),MainWindow.close)
QtCore.QObject.connect(self.Finish,QtCore.SIGNAL("clicked()"),MainWindow.update)
QtCore.QObject.connect(self.addphotoandtag,QtCore.SIGNAL("clicked()"),self.tagfield.update)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.addphoto.setText(QtGui.QApplication.translate("MainWindow", "Add Photo", None, QtGui.QApplication.UnicodeUTF8))
self.options.addItem(QtGui.QApplication.translate("MainWindow", "Date", None, QtGui.QApplication.UnicodeUTF8))
self.options.addItem(QtGui.QApplication.translate("MainWindow", "Tag", None, QtGui.QApplication.UnicodeUTF8))
self.searchphoto.setText(QtGui.QApplication.translate("MainWindow", "Search BY", None, QtGui.QApplication.UnicodeUTF8))
self.Finish.setText(QtGui.QApplication.translate("MainWindow", "Finish", None, QtGui.QApplication.UnicodeUTF8))
self.searchresult.setHtml(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.removephoto.setText(QtGui.QApplication.translate("MainWindow", "Remove", None, QtGui.QApplication.UnicodeUTF8))
self.cancel.setText(QtGui.QApplication.translate("MainWindow", "Cancel", None, QtGui.QApplication.UnicodeUTF8))
self.addphotoandtag.setText(QtGui.QApplication.translate("MainWindow", "Add Photo and give Tag", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("MainWindow", "Date search formate d-m-y", None, QtGui.QApplication.UnicodeUTF8))
self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "File", None, QtGui.QApplication.UnicodeUTF8))
self.toolBar.setWindowTitle(QtGui.QApplication.translate("MainWindow", "toolBar", None, QtGui.QApplication.UnicodeUTF8))
self.toolBar_2.setWindowTitle(QtGui.QApplication.translate("MainWindow", "toolBar_2", None, QtGui.QApplication.UnicodeUTF8))
self.actionImport_Photos.setText(QtGui.QApplication.translate("MainWindow", "Import Photos", None, QtGui.QApplication.UnicodeUTF8))
self.actionExit.setText(QtGui.QApplication.translate("MainWindow", "Exit", None, QtGui.QApplication.UnicodeUTF8))
this is my main wrapper for the above codes
import sys
from ui import Ui_MainWindow as UIMW
from PyQt4.QtCore import QObject, SIGNAL
from PyQt4 import QtCore, QtGui
import urllib2 as ulib
class MyWindow(QtGui.QMainWindow, UIMW):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setupUi(self)
self.__setupConnections()
self.listView = QtGui.QListView
def __setupConnections(self):
self.connect(self.addphoto, QtCore.SIGNAL("clicked()") ,self._addphotoClicked)
self.connect(self.addphotoandtag, QtCore.SIGNAL("clicked()") ,self._addphotoandtagClicked)
self.connect(self.removephoto, QtCore.SIGNAL("clicked()") ,self._removephotoClicked)
self.connect(self.searchphoto, QtCore.SIGNAL("clicked()" ) ,self._searchphotoClicked)
self.connect(self.cancel, QtCore.SIGNAL("clicked()"), self._cancelClicked)
self.connect(self.actionImport_Photos, QtCore.SIGNAL("triggered()") , self._actionImport_Photos)
self.connect(self.actionExit, QtCore.SIGNAL("triggered()"), self._actionExit)
def _addphotoClicked(self):
getOpenFileName = '~/Project2/copying_photos.py'
def _addphotoandtagClicked(self):
pass
def _searchphotoClicked(self):
pass
def _removephotoClicked(self):
pass
def _FinishClicked(self):
pass
def _cancelClicked(self):
pass
def _actionImport_Photos(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',
'/home/')
def _actionExit(self):
pass
def showDialog(self):
pass
if __name__=="__main__":
app=QtGui.QApplication(sys.argv)
w=MyWindow()
w.show()
sys.exit(app.exec_())
Thanks in advance