Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Espresso Controller
GUI & Web Server
"""
import threading
import time
from remi import start, gui, App
from systemcontrol.heaterPWM import SoftwarePWM
from systemcontrol.max31855 import SoftwareSPI
from systemcontrol.pid import PID
class Espresso(App):
def __init__(self, *args):
super(Espresso, self).__init__(*args)
def main(self):
self.setTemp = 105
self.calibrationOffset = 0 # Added to thermocouple output.
self.boilerTemp = 0
self.tempStarted = False
self.heaterPIDStarted = False
self.tempProbe = SoftwareSPI()
self.pid = PID(5,1,0.04)
self.pid.setSetPoint(self.setTemp)
mainContainer = gui.Widget(width=320)
verticalContainer = gui.Widget(width='100%', layout_orientation=gui.Widget.LAYOUT_VERTICAL)
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import remi.gui as gui
from remi import start, App
from threading import Timer
class MyApp(App):
def __init__(self, *args):
super(MyApp, self).__init__(*args)
def idle(self):
self.counter.set_text('Running Time: ' + str(self.count))
self.progress.set_value(self.count%100)
def main(self):
# the margin 0px auto centers the main container
verticalContainer = gui.Container(width=540, margin='0px auto', style={'display': 'block', 'overflow': 'hidden'})
horizontalContainer = gui.Container(width='100%', layout_orientation=gui.Container.LAYOUT_HORIZONTAL, margin='0px', style={'display': 'block', 'overflow': 'auto'})
subContainerLeft = gui.Container(width=320, style={'display': 'block', 'overflow': 'auto', 'text-align': 'center'})
self.img = gui.Image('/res:logo.png', height=100, margin='10px')
self.img.onclick.do(self.on_img_clicked)
from remi import start, App
from remi_plus import OKDialog,LinkDialog, OKCancelDialog, AdaptableDialog, append_with_label,FileSelectionDialog
import time
import subprocess
import sys, os, shutil
import configparser
import zipfile
from threading import Timer
from time import sleep
from pp_network import Mailer, Network
class PPManager(App):
def __init__(self, *args):
super(PPManager, self).__init__(*args)
def read_options(self,manager_options_file_path):
self.options=Options()
self.options.read_options(manager_options_file_path)
self.pp_home_dir=self.options.pp_home_dir
self.pp_profiles_offset=self.options.pp_profiles_offset
self.pp_profiles_dir=self.options.pp_profiles_dir
self.top_dir=self.options.top_dir
self.media_dir=self.options.media_dir
self.media_offset=self.options.media_offset
def startGrab(self, device_id='default', use_flash="false"):
self.app.execute_javascript('startGrab("%s", %s);'%(device_id, use_flash))
def nextFrame(self):
self.app.execute_javascript('snapshot();')
def new_blob(self, img_data):
img_data = base64.b64decode(img_data)
f = open("./img.png",'wb')
f.write(img_data)
f.close()
class MyApp(App):
ON_LOG = "onlog"
def __init__(self, *args):
super(MyApp, self).__init__(*args, static_file_path='./res/')
def onlog(self, msg):
print("LOG LOG LOG")
print("CONSOLE LOG: " + msg)
def main(self):
wid = gui.VBox(width='100%', margin='0px auto')
width = '300' #'2048'
height = '300' #'1152'
self.video = gui.Widget(width=300, height=300, _type='video')
self.video.attributes['autoplay'] = 'true'
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import remi.gui as gui
from remi import start, App
import os
class MyApp(App):
def __init__(self, *args):
res_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res')
#static_file_path can be an array of strings allowing to define
# multiple resource path in where the resources will be placed
super(MyApp, self).__init__(*args, static_file_path=res_path)
def idle(self):
#idle loop, you can place here custom code
# avoid to use infinite iterations, it would stop gui update
pass
def main(self):
#custom additional html head tags
my_html_head = """<title>Bootstrap Test</title>"""
#Load Boostrap Ressources from Online Source
code_classes += main_code_class
compiled_code = prototypes.proto_code_program % {'imports': '\n'.join(["from " + modulename + " import *" for modulename in modules_to_import]),
'code_classes': code_classes,
'classname': configuration.configDict[configuration.KEY_PRJ_NAME],
'configuration': configuration.configDict
}
print(compiled_code)
if save_path_filename != None:
f = open(save_path_filename, "w")
f.write(compiled_code)
f.close()
class Editor(App):
EVENT_ONDROPPPED = "on_dropped"
selectedWidget = None
def __init__(self, *args):
editor_res_path = os.path.join(os.path.dirname(__file__), 'res')
super(Editor, self).__init__(
*args, static_file_path={'editor_resources': editor_res_path})
def idle(self):
for drag_helper in self.drag_helpers:
drag_helper.update_position()
def main(self):
self.mainContainer = gui.Container(width='100%', height='100%', layout_orientation=gui.Container.LAYOUT_VERTICAL, style={
'background-color': 'white', 'border': 'none', 'overflow': 'hidden'})
from remi import start, App
from remi_plus import OKDialog, OKCancelDialog, AdaptableDialog, append_with_label,FileSelectionDialog
import time
import subprocess
import sys, os, shutil
import ConfigParser
import zipfile
from threading import Timer
from time import sleep
from pp_network import Mailer, Network
class PPManager(App):
def __init__(self, *args):
super(PPManager, self).__init__(*args)
def read_options(self,options_file_path):
self.options=Options()
self.options.read_options(options_file_path)
self.pp_home_dir=self.options.pp_home_dir
self.pp_profiles_offset=self.options.pp_profiles_offset
self.pp_profiles_dir=self.options.pp_profiles_dir
self.top_dir=self.options.top_dir
self.media_dir=self.options.media_dir
self.media_offset=self.options.media_offset
self.livetracks_dir=self.options.livetracks_dir
import remi.gui as gui
from remi import App
from .common import PILImageViewerWidget
from pathlib import Path
from app.workflow import Workflow
from app.drawing_dataset import DrawingDataset
from app.image_processor import ImageProcessor, tensorflow_model_name, model_path
import importlib
import logging
class RaspiLocalGui(App):
"""
gui for the app
"""
def __init__(self, *args):
super(RaspiLocalGui, self).__init__(*args)
self._cam = None
def idle(self):
# idle function called every update cycle
pass
def main(self):
try:
picam = importlib.import_module('picamera')
self._cam = picam.PiCamera()
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
""" Here is an "Hello World" application showing a simple interaction
with the user.
"""
import remi.gui as gui
from remi import start, App
class MyApp(App):
def __init__(self, *args):
super(MyApp, self).__init__(*args)
def main(self):
#creating a container VBox type, vertical
wid = gui.VBox(width=300, height=200)
#creating a text label, "white-space":"pre" preserves newline
self.lbl = gui.Label('Hello\n test', width='80%', height='50%', style={"white-space":"pre"})
#a button for simple interaction
bt = gui.Button('Press me!', width=200, height=30)
#setting up the listener for the click event
bt.onclick.do(self.on_button_pressed)
else:
if self.nearest_mine > 0:
self.set_text(str(self.nearest_mine))
else:
self.style['background-color'] = 'rgb(200,255,100)'
return
if self.state == 2:
self.style['background-image'] = "url('/my_resources:doubt.png')"
if self.state == 1:
self.style['background-image'] = "url('/my_resources:flag.png')"
def add_nearest_mine(self):
self.nearest_mine += 1
class MyApp(App):
def __init__(self, *args):
res_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res')
super(MyApp, self).__init__(*args, static_file_path={'my_resources':res_path})
def display_time(self):
self.lblTime.set_text('Play time: ' + str(self.time_count))
self.time_count += 1
if not self.stop_flag:
threading.Timer(1, self.display_time).start()
def main(self):
# the arguments are width - height - layoutOrientationOrizontal
self.main_container = gui.Container(margin='0px auto')
self.main_container.set_size(1020, 600)
self.main_container.set_layout_orientation(gui.Container.LAYOUT_VERTICAL)