Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main(self):
#creating a container VBox type, vertical (you can use also HBox or Widget)
main_container = gui.Widget(width=300, style={'margin':'0px auto'}, layout_orientation=gui.Widget.LAYOUT_VERTICAL)
m11 = gui.MenuItem('Save', [gui.MenuItem('Save'), gui.MenuItem('Save as')], width=100, height=30)
m1 = gui.MenuItem('File', [m11, gui.MenuItem('Open')], width=100, height=30)
menu = gui.Menu([m1, gui.MenuItem('View', width=100, height=30), gui.MenuItem('Dialog', width=100, height=30)], width='100%', height='30px')
menubar = gui.MenuBar(width='100%', height='30px')
menubar.append(menu)
listview = gui.ListView(children={'0': gui.ListItem('zero'), 'n': 'n'})
print( listview.append({'1': gui.ListItem('uno'), '2': gui.ListItem('due')}) )
print( listview.append([gui.ListItem('tre'), gui.ListItem('quattro')]) )
dropdown = gui.DropDown({'0': gui.DropDownItem('zero'), 'n': gui.DropDownItem('n')})
print( dropdown.append({'1': gui.DropDownItem('uno'), '2': gui.DropDownItem('due')}) )
print( dropdown.append(['tre', 'quattro']) )
table = gui.Table({'0': gui.TableRow(['zero','zeroo','zerooo']), 'n':gui.TableRow(['n','nn','nnn'])})
print( table.append({'1': gui.TableRow(['uno','unoo','unooo']), '2':gui.TableRow(['due','duee','dueee'])}) )
row3 = gui.TableRow()
row3.append(['tre','tree','treee'])
def main(self):
#creating a container VBox type, vertical (you can use also HBox or Widget)
main_container = gui.Widget(width=300, style={'margin':'0px auto'}, layout_orientation=gui.Widget.LAYOUT_VERTICAL)
m11 = gui.MenuItem('Save', [gui.MenuItem('Save'), gui.MenuItem('Save as')], width=100, height=30)
m1 = gui.MenuItem('File', [m11, gui.MenuItem('Open')], width=100, height=30)
menu = gui.Menu([m1, gui.MenuItem('View', width=100, height=30), gui.MenuItem('Dialog', width=100, height=30)], width='100%', height='30px')
menubar = gui.MenuBar(width='100%', height='30px')
menubar.append(menu)
listview = gui.ListView(children={'0': gui.ListItem('zero'), 'n': 'n'})
print( listview.append({'1': gui.ListItem('uno'), '2': gui.ListItem('due')}) )
print( listview.append([gui.ListItem('tre'), gui.ListItem('quattro')]) )
dropdown = gui.DropDown({'0': gui.DropDownItem('zero'), 'n': gui.DropDownItem('n')})
print( dropdown.append({'1': gui.DropDownItem('uno'), '2': gui.DropDownItem('due')}) )
print( dropdown.append(['tre', 'quattro']) )
table = gui.Table({'0': gui.TableRow(['zero','zeroo','zerooo']), 'n':gui.TableRow(['n','nn','nnn'])})
print( table.append({'1': gui.TableRow(['uno','unoo','unooo']), '2':gui.TableRow(['due','duee','dueee'])}) )
row3 = gui.TableRow()
row3.append(['tre','tree','treee'])
row4 = gui.TableRow()
row4.append(['quattro','quattroo','quattrooo'])
print( table.append({'3':row3 , '4':row4}) )
print( table.append({'5':gui.TableRow(['5','55','555']) , '6':gui.TableRow(['6','66','666'])}) )
print( table.append(gui.TableRow(['sette','settee','setteee']) ) )
main_container.append([menubar, listview, dropdown, table])
def main(self):
#creating a container VBox type, vertical (you can use also HBox or Widget)
main_container = gui.Widget(width=300, style={'margin':'0px auto'}, layout_orientation=gui.Widget.LAYOUT_VERTICAL)
m11 = gui.MenuItem('Save', [gui.MenuItem('Save'), gui.MenuItem('Save as')], width=100, height=30)
m1 = gui.MenuItem('File', [m11, gui.MenuItem('Open')], width=100, height=30)
menu = gui.Menu([m1, gui.MenuItem('View', width=100, height=30), gui.MenuItem('Dialog', width=100, height=30)], width='100%', height='30px')
menubar = gui.MenuBar(width='100%', height='30px')
menubar.append(menu)
listview = gui.ListView(children={'0': gui.ListItem('zero'), 'n': 'n'})
print( listview.append({'1': gui.ListItem('uno'), '2': gui.ListItem('due')}) )
print( listview.append([gui.ListItem('tre'), gui.ListItem('quattro')]) )
dropdown = gui.DropDown({'0': gui.DropDownItem('zero'), 'n': gui.DropDownItem('n')})
print( dropdown.append({'1': gui.DropDownItem('uno'), '2': gui.DropDownItem('due')}) )
print( dropdown.append(['tre', 'quattro']) )
table = gui.Table({'0': gui.TableRow(['zero','zeroo','zerooo']), 'n':gui.TableRow(['n','nn','nnn'])})
print( table.append({'1': gui.TableRow(['uno','unoo','unooo']), '2':gui.TableRow(['due','duee','dueee'])}) )
row3 = gui.TableRow()
row3.append(['tre','tree','treee'])
row4 = gui.TableRow()
row4.append(['quattro','quattroo','quattrooo'])
print( table.append({'3':row3 , '4':row4}) )
print( table.append({'5':gui.TableRow(['5','55','555']) , '6':gui.TableRow(['6','66','666'])}) )
print( table.append(gui.TableRow(['sette','settee','setteee']) ) )
#creating a container VBox type, vertical (you can use also HBox or Widget)
main_container = gui.Widget(width=300, style={'margin':'0px auto'}, layout_orientation=gui.Widget.LAYOUT_VERTICAL)
m11 = gui.MenuItem('Save', [gui.MenuItem('Save'), gui.MenuItem('Save as')], width=100, height=30)
m1 = gui.MenuItem('File', [m11, gui.MenuItem('Open')], width=100, height=30)
menu = gui.Menu([m1, gui.MenuItem('View', width=100, height=30), gui.MenuItem('Dialog', width=100, height=30)], width='100%', height='30px')
menubar = gui.MenuBar(width='100%', height='30px')
menubar.append(menu)
listview = gui.ListView(children={'0': gui.ListItem('zero'), 'n': 'n'})
print( listview.append({'1': gui.ListItem('uno'), '2': gui.ListItem('due')}) )
print( listview.append([gui.ListItem('tre'), gui.ListItem('quattro')]) )
dropdown = gui.DropDown({'0': gui.DropDownItem('zero'), 'n': gui.DropDownItem('n')})
print( dropdown.append({'1': gui.DropDownItem('uno'), '2': gui.DropDownItem('due')}) )
print( dropdown.append(['tre', 'quattro']) )
table = gui.Table({'0': gui.TableRow(['zero','zeroo','zerooo']), 'n':gui.TableRow(['n','nn','nnn'])})
print( table.append({'1': gui.TableRow(['uno','unoo','unooo']), '2':gui.TableRow(['due','duee','dueee'])}) )
row3 = gui.TableRow()
row3.append(['tre','tree','treee'])
row4 = gui.TableRow()
row4.append(['quattro','quattroo','quattrooo'])
print( table.append({'3':row3 , '4':row4}) )
print( table.append({'5':gui.TableRow(['5','55','555']) , '6':gui.TableRow(['6','66','666'])}) )
print( table.append(gui.TableRow(['sette','settee','setteee']) ) )
main_container.append([menubar, listview, dropdown, table])
# returning the root widget
return main_container
# Initialise an instance of the Pi Presents and Web Editor driver classes
self.pp=PiPresents()
self.ed = WebEditor()
self.ed.init(self.manager_dir)
mww=550
# root and frames
root = gui.VBox(width=mww, margin='0px auto') #the margin 0px auto centers the main container
root.style['display'] = 'block'
root.style['overflow'] = 'hidden'
# root = gui.VBox(width=mww,height=600) #10
top_frame=gui.VBox(width=mww,height=40) #1
middle_frame=gui.VBox(width=mww,height=500) #5
# middle_frame.style['background-color'] = 'LightGray'
button_frame=gui.HBox(width=280,height=30) #10
menubar=gui.MenuBar(width='100%', height='30px')
# menu
# menu = gui.Menu(width=mww-20, height=30)
menu=gui.Menu(width='100%', height='30px')
miw=70
# media menu
media_menu = gui.MenuItem('Media',width=miw, height=30)
media_import_menu = gui.MenuItem('Import',width=miw, height=30)
media_upload_menu = gui.MenuItem('Upload',width=miw, height=30)
media_manage_menu = gui.MenuItem('Manage',width=miw, height=30)
ColourMap().init()
# initialise editor options OSC config class, and OSC editors
self.eo=Options()
self.eo.init_options(self.editor_dir)
self.osc_config=OSCConfig()
# initialise variables
self.init()
# BUILD THE GUI
# frames
root = gui.Container(width=770,height=500, margin='0px auto') #the margin 0px auto centers the main container
bottom_frame=gui.Container(width=770,height=400)#1
bottom_frame.set_layout_orientation(gui.Container.LAYOUT_HORIZONTAL)
# bottom_frame.style['display'] = 'block'
# bottom_frame.style['overflow'] = 'auto'
left_frame=gui.Container(width=300,height=400)#1
# left_frame.set_layout_orientation(gui.Container.LAYOUT_VERTICAL)
left_frame.style['margin']='10px'
middle_frame=gui.VBox(width=50,height=250)#1
middle_frame.style['margin']='10px'
right_frame=gui.Container(width=300,height=400)#1
updown_frame=gui.VBox(width=50,height=400)#1
# get interface and IP details of preferred interface
interface,ip = network.get_preferred_ip()
print 'Network details ' + network.unit + ' ' + interface + ' ' + ip
start_browser=False
if mode =='local':
ip= '127.0.0.1'
start_browser=True
if mode == 'native':
start(PPWebEditor, standalone=True)
exit()
else:
# start the web server to serve the Web Editor App
start(PPWebEditor,address=ip, port=network.editor_port,username=network.editor_username,password=network.editor_password,
multiple_instance=True,enable_file_cache=True, debug=False,
update_interval=0.3, start_browser=start_browser)
exit()
def run(camera, gui, raspi_headless, batch_process, raspi_gpio):
if gui:
print('starting gui...')
start(WebGui, address='0.0.0.0', websocket_port=8082, port=8081, host_name='raspberrypi.local', start_browser=True)
else:
try:
if camera or raspi_headless:
picam = importlib.import_module('picamera')
cam = picam.PiCamera()
cam.rotation=90
else:
cam = None
app = Workflow(dataset, imageprocessor, cam)
app.setup(setup_gpio=raspi_gpio)
except ImportError as e:
print('picamera module missing, please install using:\n sudo apt-get update \n'
' sudo apt-get install python-picamera')
logging.exception(e)
sys.exit()
while True:
checkbox_display_tagged.style['height'] = "30px"
vbox_settings.append(checkbox_display_tagged, 'checkbox_display_tagged')
hbox_snap.append(vbox_settings, 'vbox_settings')
button_close = gui.Button('close')
button_close.style['background-color'] = 'red'
button_close.style['width'] = "200px"
button_close.style['height'] = '30px'
hbox_snap.append(button_close, 'button_close')
self.main_container.append(hbox_snap, 'hbox_snap')
width = 200
height = 200
self.image_original = PILImageViewerWidget(width=width, height=height)
self.main_container.append(self.image_original, 'image_original')
self.image_result = PILImageViewerWidget(width=width, height=height)
self.main_container.append(self.image_result, 'image_result')
self.image_label = gui.Label('', width=400, height=30, margin='10px')
self.image_label.style['align-items'] = "center"
self.main_container.append(self.image_label, 'image_label')
button_close.set_on_click_listener(self.on_close_pressed)
button_snap.set_on_click_listener(self.on_snap_pressed)
button_open.set_on_click_listener(self.on_open_pressed)
return self.main_container
def display_media(self):
self.media_list.empty()
self.current_media_name=''
items=sorted(os.listdir(self.current_media))
i=0
for item in items:
if (self.is_profile is False and os.path.isdir(self.current_media+ os.sep+item) is False) or (self.is_profile is True and os.path.isdir(self.current_media+ os.sep+item) is True and os.path.exists(self.current_media+ os.sep + item + os.sep + 'pp_showlist.json') is True):
obj= gui.ListItem(item,width=200, height=20)
self.media_list.append(obj,key=i)
i+=1
return