Commit 0e647da1 authored by unknown's avatar unknown

Updates for web itnerface, add actions, and custom styling using css/style.css

parent c2e68056
#title
{
text-align:center;
color:red;
}
#mainmenu
{
margin: 0;
padding: 0 0 20px 10px;
border-bottom: 1px solid #000;
}
#mainmenu ul, #mainmenu li
{
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
}
#mainmenu a:link, #mainmenu a:visited
{
float: left;
line-height: 14px;
font-weight: bold;
margin: 0 10px 4px 10px;
text-decoration: none;
color: #999;
}
#mainmenu a:link#current, #mainmenu a:visited#current, #mainmenu a:hover
{
border-bottom: 4px solid #000;
padding-bottom: 2px;
background: transparent;
color: #000;
}
#mainmenu a:hover { color: #000; }
#controls
{
}
#controls ul
{
list-style: none;
margin: 0px;
padding: 0px;
border: none;
}
#controls ul li
{
margin: 0px;
padding: 0px;
}
#controls ul li a
{
font-size: 80%;
display: block;
border-bottom: 1px dashed #C39C4E;
padding: 5px 0px 2px 4px;
text-decoration: none;
color: #666666;
width:160px;
}
#controls ul li a:hover, #controls ul li a:focus
{
color: #000000;
background-color: #eeeeee;
}
#settings
{
margin: 0px;
padding-top: 50px;
border: none;
}
#settings table
{
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
}
#settings table th {
background-color:#c3dde0;
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
#settings table tr {
background-color:#d4e3e5;
}
#settings table td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
\ No newline at end of file
[global] [global]
server.socket_host: "localhost" server.socket_host: "localhost"
server.socket_port: 8080 server.socket_port: 8080
[/css/style.css]
tools.staticfile.on = True
tools.staticfile.filename = "C:\Printrun-web\Printrun\css\style.css"
#!/usr/bin/python #!/usr/bin/python
import cherrypy, pronterface import cherrypy, pronterface, re
import os.path
def PrintHeader(): def PrintHeader():
return "<html><head></head><body><h3><a href='/'>main</a> | <a href='/settings'>settings</a> </h3>" return '<html>\n<head>\n<title>Pronterface-Web</title>\n<link rel="stylesheet" type="text/css" href="/css/style.css" type="text/css"></link>\n</head>\n<body>\n'
def PrintMenu():
return '<div id="mainmenu"><ul><li><a href="/">home</a></li><li><a href="/settings">settings</a></li><li><a href="/console">console</a></li></ul></div>'
def PrintFooter(): def PrintFooter():
return "</body></html>" return "</body></html>"
pronterPtr = 0 def ReloadPage(action):
return "<html><head><meta http-equiv='refresh' content='0;url=/'></head><body>"+action+"</body></html>"
gPronterPtr = 0
gWeblog = ""
gLogRefresh =5
class SettingsPage(object): class SettingsPage(object):
def __init__(self): def __init__(self):
self.name="<h1>Pronterface Settings</h1>" self.name="<div id='title'>Pronterface Settings</div>"
def SetPface(self, pface):
self.pface = pface def index(self):
pageText=PrintHeader()+self.name+PrintMenu()
pageText=pageText+"<div id='settings'><table>\n<tr><th>setting</th><th>value</th>"
pageText=pageText+"<tr>\n <td><b>Build Dimenstions</b></td><td>"+str(gPronterPtr.settings.build_dimensions)+"</td>\n</tr>"
pageText=pageText+" <tr>\n <td><b>Last Bed Temp</b></td><td>"+str(gPronterPtr.settings.last_bed_temperature)+"</td>\n</tr>"
pageText=pageText+" <tr>\n <td><b>Last File Path</b></td><td>"+gPronterPtr.settings.last_file_path+"</td>\n</tr>"
pageText=pageText+" <tr>\n <td><b>Last Temperature</b></td><td>"+str(gPronterPtr.settings.last_temperature)+"</td>\n</tr>"
pageText=pageText+" <tr>\n <td><b>Preview Extrusion Width</b></td><td>"+str(gPronterPtr.settings.preview_extrusion_width)+"</td>\n</tr>"
pageText=pageText+" <tr>\n <td><b>Filename</b></td><td>"+str(gPronterPtr.filename)+"</td></tr></div>"
pageText=pageText+PrintFooter()
return pageText
index.exposed = True
class LogPage(object):
def __init__(self):
self.name="<div id='title'>Pronterface Console</div>"
def index(self):
pageText="<html><head><meta http-equiv='refresh' content='"+str(gLogRefresh)+"'></head><body>"
pageText+="<div id='status'>"
pageText+=gPronterPtr.status.GetStatusText()
pageText+="</div>"
pageText=pageText+"<div id='console'>"+gWeblog+"</div>"
pageText=pageText+"</body></html>"
return pageText
index.exposed = True
class ConsolePage(object):
def __init__(self):
self.name="<div id='title'>Pronterface Settings</div>"
def index(self): def index(self):
pageText=self.name+PrintHeader() pageText=PrintHeader()+self.name+PrintMenu()
pageText=pageText+"<table><tr><td><b>Build Dimenstions</b></td><td>"+str(pronterPtr.settings.build_dimensions)+"</td></tr>" pageText+="<div id='logframe'><iframe src='/logpage' width='100%' height='100%'>iFraming Not Supported?? No log for you.</iframe></div>"
pageText=pageText+"<tr><td><b>Last Bed Temp</b></td><td>"+str(pronterPtr.settings.last_bed_temperature)+"</td></tr>" pageText+=PrintFooter()
pageText=pageText+"<tr><td><b>Last File Path</b></td><td>"+pronterPtr.settings.last_file_path+"</td></tr>"
pageText=pageText+"<tr><td><b>Last Temperature</b></td><td>"+str(pronterPtr.settings.last_temperature)+"</td></tr>"
pageText=pageText+"<tr><td><b>Preview Extrusion Width</b></td><td>"+str(pronterPtr.settings.preview_extrusion_width)+"</td></tr>"
pageText=pageText+"<tr><td><b>Filename</b></td><td>"+str(pronterPtr.filename)+"</td></tr>"
return pageText return pageText
index.exposed = True index.exposed = True
class ConnectButton(object):
def index(self):
#handle connect push, then reload page
gPronterPtr.connect(0)
return ReloadPage("Connect...")
index.exposed = True
class DisconnectButton(object):
def index(self):
#handle connect push, then reload page
gPronterPtr.disconnect(0)
return ReloadPage("Disconnect...")
index.exposed = True
class ResetButton(object):
def index(self):
#handle connect push, then reload page
gPronterPtr.reset(0)
return ReloadPage("Reset...")
index.exposed = True
class PrintButton(object):
def index(self):
#handle connect push, then reload page
gPronterPtr.printfile(0)
return ReloadPage("Print...")
index.exposed = True
class PauseButton(object):
def index(self):
#handle connect push, then reload page
gPronterPtr.pause(0)
return ReloadPage("Pause...")
index.exposed = True
class WebInterface(object): class WebInterface(object):
def __init__(self, pface): def __init__(self, pface):
self.pface = pface self.pface = pface
self.weblog="Connecting web interface to pronterface..." global gPronterPtr
self.name="<h1>Pronterface Settings</h1>" global gWeblog
global pronterPtr self.name="<div id='title'>Pronterface Web-Interface</div>"
pronterPtr = self.pface gWeblog = "Connecting web interface to pronterface..."
gPronterPtr = self.pface
settings = SettingsPage() settings = SettingsPage()
logpage = LogPage()
console = ConsolePage()
#actions
connect = ConnectButton()
disconnect = DisconnectButton()
reset = ResetButton()
printbutton = PrintButton()
pausebutton = PrintButton()
def index(self): def index(self):
pageText=self.name+PrintHeader() pageText=PrintHeader()+self.name+PrintMenu()
pageText=pageText+"<textarea rows='30' cols='100'>"+self.weblog+"</textarea>" pageText+="<div id='controls'>"
pageText=pageText+PrintFooter() pageText+="<ul><li><a href='/connect'>Connect</a></li>"
pageText+="<li><a href='/disconnect'>Disconnect</a></li>"
pageText+="<li><a href='/reset'>Reset</a></li>"
pageText+="<li><a href='/printbutton'>Print</a></li>"
pageText+="<li><a href='/pausebutton'>Pause</a></li></ul>"
pageText+="</div>"
pageText=pageText+"<div id='file'>File Loaded: <i>"+str(gPronterPtr.filename)+"</i></div>"
pageText+="<div id='logframe'><iframe src='/logpage' width='100%' height='100%'>iFraming Not Supported?? No log for you.</iframe></div>"
pageText+=PrintFooter()
return pageText return pageText
def AddLog(self, log): def AddLog(self, log):
self.weblog=self.weblog+"\n"+log global gWeblog
gWeblog=gWeblog+"</br>"+log
def AppendLog(self, log): def AppendLog(self, log):
self.weblog=self.weblog+log global gWeblog
gWeblog=re.sub("\n", "</br>", gWeblog)+log
index.exposed = True index.exposed = True
class WebInterfaceStub(object): class WebInterfaceStub(object):
...@@ -52,9 +143,14 @@ class WebInterfaceStub(object): ...@@ -52,9 +143,14 @@ class WebInterfaceStub(object):
index.exposed = True index.exposed = True
def StartWebInterfaceThread(webInterface): def StartWebInterfaceThread(webInterface):
current_dir = os.path.dirname(os.path.abspath(__file__))
cherrypy.config.update({'engine.autoreload_on':False}) cherrypy.config.update({'engine.autoreload_on':False})
cherrypy.config.update("http.config") cherrypy.config.update("http.config")
cherrypy.quickstart(webInterface) conf = {'/css/style.css': {'tools.staticfile.on': True,
'tools.staticfile.filename': os.path.join(current_dir, 'css/style.css'),
}}
cherrypy.config.update("http.config")
cherrypy.quickstart(webInterface, '/', config=conf)
if __name__ == '__main__': if __name__ == '__main__':
cherrypy.config.update("http.config") cherrypy.config.update("http.config")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment