Permalink
Browse files

added imdb support, slot has some problem...

  • Loading branch information...
1 parent 7b92464 commit 4afd4965b8a4d7682bf37eb7ebbd88778ccc9ee3 @sandeepraju committed Feb 18, 2012
Showing with 21 additions and 6 deletions.
  1. +21 −6 myapplication.py
  2. BIN myapplication.pyc
View
@@ -1,4 +1,4 @@
-import sys
+import sys, urllib2
from PyQt4.QtGui import *
from PyQt4.QtCore import *
@@ -11,22 +11,37 @@ def __init__(self):
self.layout = QVBoxLayout(self)
#creating widgets & adding them to the layout created
- self.label = QLabel("Qt",self)
+ self.label = QLabel("IMDB Fetcher",self)
self.layout.addWidget(self.label)
- self.edit = QLineEdit("KDE",self)
+ self.edit = QLineEdit("",self)
+ self.edit.setPlaceholderText("Enter a movie name")
self.layout.addWidget(self.edit)
#a single line like this can create and any widget to the
#layout provided we no more need the reference to it
- self.layout.addWidget(QPushButton("hello",self))
-
+ self.fetch = QPushButton("Fetch!",self)
+ self.layout.addWidget(self.fetch)
+ self.connect(self.fetch, SIGNAL("clicked()"),\
+ self, SLOT(self.slotFetchData()))
+
#set the geometry if required
#self.setGeometry(300, 300, 250, 500)
#setting window title
#self.setWindowTitle('Icon')
-
#setting window icon
#self.setWindowIcon(QIcon('web.png'))
+
+ def slotFetchData(self):
+ qDebug("hello...?")
+ response = urllib2.urlopen("http://www.imdbapi.com?t=avatar" + str(self.edit.text()))
+ response = eval(response.read())
+ tempHLayout = QHBoxLayout(self)
+ #if response == Parse Error -> display error
+ #if response ==
+ #QWebKit()
+ tempHLayout.addWidget(QLabel("Title: ", self))
+ tempHLayout.addWidget(QLabel(response["Title"],self))
+ self.layout.addItem(tempHLayout)
View
Binary file not shown.

0 comments on commit 4afd496

Please sign in to comment.