-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathResolvePageSwitcher.py
executable file
·133 lines (117 loc) · 4.83 KB
/
ResolvePageSwitcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# DaVinci Resolve scripting proof of concept. Resolve page external switcher.
# Local or TCP/IP control mode.
# Refer to Resolve V15 public beta 2 scripting API documentation for host setup.
# Copyright 2018 Igor Riđanović, www.hdhead.com
from PyQt4 import QtCore, QtGui
import sys
import socket
# If API module not found assume we're working as a remote control
try:
import DaVinciResolveScript
#Instantiate Resolve object
resolve = DaVinciResolveScript.scriptapp('Resolve')
checkboxState = False
except ImportError:
print 'Resolve API not found.'
checkboxState = True
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8('Resolve Page Switcher'))
Form.resize(561, 88)
Form.setStyleSheet(_fromUtf8('background-color: #282828;\
border-color: #555555;\
color: #929292;\
font-size: 13px;'\
))
self.horizontalLayout = QtGui.QHBoxLayout(Form)
self.horizontalLayout.setObjectName(_fromUtf8('horizontalLayout'))
self.mediaButton = QtGui.QPushButton(Form)
self.mediaButton.setObjectName(_fromUtf8('mediaButton'))
self.horizontalLayout.addWidget(self.mediaButton)
self.editButton = QtGui.QPushButton(Form)
self.editButton.setObjectName(_fromUtf8('editButton'))
self.horizontalLayout.addWidget(self.editButton)
self.fusionButton = QtGui.QPushButton(Form)
self.fusionButton.setObjectName(_fromUtf8('fusionButton'))
self.horizontalLayout.addWidget(self.fusionButton)
self.colorButton = QtGui.QPushButton(Form)
self.colorButton.setObjectName(_fromUtf8('colorButton'))
self.horizontalLayout.addWidget(self.colorButton)
self.fairlightButton = QtGui.QPushButton(Form)
self.fairlightButton.setObjectName(_fromUtf8('fairlightButton'))
self.horizontalLayout.addWidget(self.fairlightButton)
self.deliverButton = QtGui.QPushButton(Form)
self.deliverButton.setObjectName(_fromUtf8('deliverButton'))
self.horizontalLayout.addWidget(self.deliverButton)
self.tcpipcheckBox = QtGui.QCheckBox(Form)
self.tcpipcheckBox.setObjectName(_fromUtf8('tcpipcheckBox'))
self.tcpipcheckBox.setChecked(checkboxState)
self.horizontalLayout.addWidget(self.tcpipcheckBox)
self.mediaButton.clicked.connect(lambda: self.pageswitch('media'))
self.editButton.clicked.connect(lambda: self.pageswitch('edit'))
self.fusionButton.clicked.connect(lambda: self.pageswitch('fusion'))
self.colorButton.clicked.connect(lambda: self.pageswitch('color'))
self.fairlightButton.clicked.connect(lambda: self.pageswitch('fairlight'))
self.deliverButton.clicked.connect(lambda: self.pageswitch('deliver'))
self.mediaButton.setStyleSheet(_fromUtf8('background-color: #181818;'))
self.editButton.setStyleSheet(_fromUtf8('background-color: #181818;'))
self.fusionButton.setStyleSheet(_fromUtf8('background-color: #181818;'))
self.colorButton.setStyleSheet(_fromUtf8('background-color: #181818;'))
self.fairlightButton.setStyleSheet(_fromUtf8('background-color: #181818;'))
self.deliverButton.setStyleSheet(_fromUtf8('background-color: #181818;'))
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate('Resolve Page Switcher',\
'Resolve Page Switcher', None))
self.mediaButton.setText(_translate('Form', 'Media', None))
self.editButton.setText(_translate('Form', 'Edit', None))
self.fusionButton.setText(_translate('Form', 'Fusion', None))
self.colorButton.setText(_translate('Form', 'Color', None))
self.fairlightButton.setText(_translate('Form', 'Fairlight', None))
self.deliverButton.setText(_translate('Form', 'Deliver', None))
self.tcpipcheckBox.setText(_translate("Form", "TCP/IP remote", None))
def send(self, message):
s = socket.socket()
try:
s.connect((server, port))
except socket.error:
print 'Server unavailable. Exiting.'
s.send(message)
return s.recv(32)
def pageswitch(self, page):
# Send page name to server to switch remote Resolve's page
if self.tcpipcheckBox.isChecked():
response = self.send(page)
print 'Server echo:', response
# Switch local Resolve's page if API is available
else:
try:
resolve.OpenPage(page)
print 'Switched to', page
except NameError:
print 'Resolve API not found. Run in remote mode instead?'
if __name__ == '__main__':
# Assign server parameters
server = '192.168.1.1'
port = 7779
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())