ProPresenter-Stage-Display-Python
ProPresenter-Stage-Display-Python copied to clipboard
Connection Status
Had an idea about putting a connection status in the top right of the display, so if the app disconnects from the ProPresenter service or cannot reach it, you get an error instead of a blank screen. Then when the connection is good again, the message disappears. Check it out - not much modification was needed.
` def connected(self, data):
print "ProPresenter Connected"
self.updateStatus("")
def connectFailed(self, error):
self.tryReconnect = True
if self.disconnectTime == 0:
self.disconnectTime = time.time()
print "ProPresenter Connect Failed", error
self.updateStatus("NO CONNECTION")
def disconnected(self, error):
self.tryReconnect = True
if self.disconnectTime == 0:
self.disconnectTime = time.time()
print "ProPresenter Disconnected", error
self.updateStatus("DISCONNECTED")`
and then the object:
self.labelStatus = tk.Label( self, text = "", font = (self.fontName, self.fontSizeClock, self.fontStyle), background = self.backgroundColour, foreground = self.errorColour, wraplength = self.wordWrapLength, anchor = tk.SE, justify = tk.LEFT ) self.labelStatus.grid( column = 1, row = 0, sticky = tk.E+tk.N+tk.S, padx = self.padX, pady = self.padY )
and the function: ` def updateStatus(self, data): if self.labelStatus is None: return False
self.labelTimer.config(text = "")
self.labelStatus.config(text = data)`
It doesn't need a new column or row since it shares it with the Timer status. Just needs a parameter in the JSON file like so:
"TextColourError": "#FF0000",
Actually took this a little further and added the ability to show the server IP address and the machine's local IP address if can't connect to the ProPresenter host.
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) print "Stage display:", s.getsockname()[0] self.IP_Addr=s.getsockname()[0] s.close()
and show it in the connectFailed() definition-
self.nextText="DISPLAY: "+self.IP_Addr+"\nSERVER: "+self.ProP_IPAddress