Package nukescripts :: Package pyQtExamples :: Module webBrowser
[hide private]
[frames] | no frames]

Source Code for Module nukescripts.pyQtExamples.webBrowser

 1  ## example PyQt panel that implements a simple web browser in Nuke 
 2   
 3  import nuke 
 4  import nukescripts 
 5  import sip 
 6   
 7  from PyQt4.QtGui import * 
 8  from PyQt4.QtCore import * 
 9  from PyQt4.QtWebKit import * 
10   
11   
12 -class WebBrowserWidget(QWidget):
13 - def changeLocation(self):
14 self.webView.load( QUrl(self.locationEdit.text()) )
15
16 - def __init__(self):
17 super( QWidget, self).__init__() 18 self.webView = QWebView(); 19 20 self.setLayout( QVBoxLayout() ) 21 22 self.locationEdit = QLineEdit( 'http://www.google.com' ) 23 self.locationEdit.setSizePolicy( QSizePolicy.Expanding, self.locationEdit.sizePolicy().verticalPolicy() ) 24 25 QObject.connect( self.locationEdit, SIGNAL('returnPressed()'), self.changeLocation ) 26 27 self.layout().addWidget( self.locationEdit ) 28 29 bar = QToolBar() 30 bar.addAction( self.webView.pageAction(QWebPage.Back)) 31 bar.addAction( self.webView.pageAction(QWebPage.Forward)) 32 bar.addAction( self.webView.pageAction(QWebPage.Stop)) 33 bar.addAction( self.webView.pageAction(QWebPage.Reload)) 34 bar.addSeparator() 35 36 37 self.layout().addWidget( bar ) 38 self.layout().addWidget( self.webView ) 39 40 self.webView.load( QUrl( 'http://www.google.com' ) )
41
42 -class WebBrowserKnob():
43
44 - def makeUI(self):
45 self.webWidget = WebBrowserWidget() 46 return self.webWidget
47
48 -class WebBrowserPanel(nukescripts.PythonPanel):
49
50 - def __init__(self):
51 super(WebBrowserPanel, self).__init__("Web Browser", "uk.co.thefoundry.WebBrowserPanel") 52 self.webBrowserKnob = nuke.PyCustom_Knob( "web", "", "nukescripts.pyQtExamples.webBrowser.WebBrowserKnob()" ) 53 self.addKnob( self.webBrowserKnob )
54 55
56 -def addPanel():
57 return WebBrowserPanel().addToPane()
58 59 menu = nuke.menu('Pane') 60 menu.addCommand('Web Browser',addPanel) 61 nukescripts.registerPanel('uk.co.thefoundry.WebBrowserPanel', addPanel) 62