Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, multiple_selection, selection_folder, allow_file_selection, allow_folder_selection, **kwargs):
super(FileFolderNavigator, self).__init__(**kwargs)
self.set_layout_orientation(Container.LAYOUT_VERTICAL)
self.style['width'] = '100%'
self.multiple_selection = multiple_selection
self.allow_file_selection = allow_file_selection
self.allow_folder_selection = allow_folder_selection
self.selectionlist = []
self.controlsContainer = Widget()
self.controlsContainer.set_size('100%', '30px')
self.controlsContainer.style['display'] = 'flex'
self.controlsContainer.set_layout_orientation(Container.LAYOUT_HORIZONTAL)
self.controlBack = Button('Up')
self.controlBack.set_size('10%', '100%')
self.controlBack.onclick.connect(self.dir_go_back)
self.controlGo = Button('Go >>')
self.controlGo.set_size('10%', '100%')
self.controlGo.onclick.connect(self.dir_go)
self.pathEditor = TextInput()
self.pathEditor.set_size('80%', '100%')
self.pathEditor.style['resize'] = 'none'
self.pathEditor.attributes['rows'] = '1'
self.controlsContainer.append(self.controlBack)
self.controlsContainer.append(self.pathEditor)
self.controlsContainer.append(self.controlGo)
self.itemContainer = Widget(width='100%',height=300)
self.append(self.controlsContainer)
def __init__(self, button_label='epics button', epics_pv_name='', toggle=False, *args, **kwargs):
self.color_inactive = 'darkgray'
self.color_active = 'rgb(0,255,0)'
self.button = gui.Button(button_label, width="100%", height="100%", style=style_inheritance_dict)
self.led = gui.Widget(width=15, height=5, style={'position':'absolute', 'left':'2px', 'top':'2px', 'background-color':self.color_inactive})
self.led_status = False
default_style = {'position':'absolute','left':'10px','top':'10px', 'background-color':'rgb(4, 90, 188)', 'color':'white'}
default_style.update(kwargs.get('style',{}))
kwargs['style'] = default_style
kwargs['width'] = kwargs['style'].get('width', kwargs.get('width','100px'))
kwargs['height'] = kwargs['style'].get('height', kwargs.get('height','100px'))
super(EPICSBooleanButton, self).__init__(*args, **kwargs)
_style = {'position':'relative'}
_style.update(style_inheritance_dict)
self.append(gui.Container(children=[self.button, self.led], width="100%", height="100%", style=_style))
self.toggle = toggle
self.epics_pv_name = epics_pv_name
self.button.onmousedown.do(self.set_bit)
def main(self):
#creating a container GridBox type
main_container = gui.GridBox(width='100%', height='100%', style={'margin':'0px auto'})
label = gui.Label('This is a label')
label.style['background-color'] = 'lightgreen'
button = gui.Button('Change layout', height='100%')
button.onclick.do(self.redefine_grid, main_container)
text = gui.TextInput()
main_container.set_from_asciiart("""
|label |button |
|label |text |
|label |text |
|label |text |
|label |text |
""", 10, 10)
main_container.append({'label':label, 'button':button, 'text':text})
# returning the root widget
self.style['margin'] = '0px auto'
if len(title) > 0:
t = Label(title)
t.add_class('DialogTitle')
self.append(t)
if content is not None:
self.append(content)
self.container = Widget()
self.container.style['display'] = 'block'
self.container.style['overflow'] = 'auto'
self.container.style['margin'] = '5px'
self.container.set_layout_orientation(Widget.LAYOUT_VERTICAL)
self.conf = Button('Ok')
self.conf.set_size(100, 30)
self.conf.style['margin'] = '3px'
hlay = Widget(height=35)
hlay.style['display'] = 'block'
hlay.style['overflow'] = 'visible'
hlay.append(self.conf)
self.conf.style['float'] = 'right'
self.append(self.container)
self.append(hlay)
self.conf.attributes[self.EVENT_ONCLICK] = "sendCallback('%s','%s');" % (self.identifier, self.EVENT_ONCONFIRM)
self.inputs = {}
self._base_app_instance = None
def main(self):
wid = gui.VBox(width=300, height=200, margin='0px auto')
self.lbl = gui.Label('Press the button', width='80%', height='50%')
self.lbl.style['margin'] = 'auto'
self.bt = gui.Button('Press me!', width=200, height=30)
self.bt.style['margin'] = 'auto 50px'
# setting the listener for the onclick event of the button
self.bt.onclick.do(self.on_button_pressed)
# appending a widget to another, the first argument is a string key
wid.append(self.lbl)
wid.append(self.bt)
# returning the root widget
return wid
def main(self):
#margin 0px auto allows to center the app to the screen
wid = gui.VBox(width=300, height=200, margin='0px auto')
self.lbl = gui.Label('Thread result:', width='80%', height='50%')
self.lbl.style['margin'] = 'auto'
bt = gui.Button('Stop algorithm', width=200, height=30)
bt.style['margin'] = 'auto 50px'
bt.style['background-color'] = 'red'
wid.append(self.lbl)
wid.append(bt)
self.thread_alive_flag = True
self.my_thread_result = 0
#Here I start a parallel thread that executes my algorithm for a long time
t = threading.Thread(target=self.my_intensive_long_time_algorithm)
t.start()
bt.onclick.do(self.on_button_pressed)
# returning the root widget
return wid
self.txt.onchange.connect(self.on_text_area_change)
self.spin = gui.SpinBox(1, 0, 100, width=200, height=30, margin='10px')
self.spin.onchange.connect(self.on_spin_change)
self.progress = gui.Progress(1, 100, width=200, height=5)
self.check = gui.CheckBoxLabel(
'Label checkbox', True, width=200, height=30, margin='10px')
self.check.onchange.connect(self.on_check_change)
self.btInputDiag = gui.Button(
'Open InputDialog', width=200, height=30, margin='10px')
self.btInputDiag.onclick.connect(self.open_input_dialog)
self.btFileDiag = gui.Button(
'File Selection Dialog', width=200, height=30, margin='10px')
self.btFileDiag.onclick.connect(self.open_fileselection_dialog)
self.btUploadFile = gui.FileUploader(
'./', width=200, height=30, margin='10px')
self.btUploadFile.onsuccess.connect(self.fileupload_on_success)
self.btUploadFile.onfailed.connect(self.fileupload_on_failed)
items = ('Danny Young', 'Christine Holand',
'Lars Gordon', 'Roberto Robitaille')
self.listView = gui.ListView.new_from_list(
items, width=300, height=120, margin='10px')
self.listView.onselection.connect(self.list_view_on_selected)
self.link = gui.Link("http://localhost:8081", "A link to here",
width=200, height=30, margin='10px')
if cancel_name !='' or confirm_name !='':
hlay = gui.Widget(height=35)
hlay.style['display'] = 'block'
hlay.style['overflow'] = 'visible'
if confirm_name !='':
self.conf = gui.Button(confirm_name)
self.conf.set_size(100, 30)
self.conf.style['margin'] = '3px'
self.conf.style['float'] = 'right'
self.conf.attributes[self.EVENT_ONCLICK] = "sendCallback('%s','%s');" % (self.identifier, self.EVENT_ONCONFIRM)
hlay.append(self.conf)
if cancel_name != '':
self.cancel = gui.Button(cancel_name)
self.cancel.set_size(100, 30)
self.cancel.style['margin'] = '3px'
self.cancel.style['float'] = 'right'
self.cancel.attributes[self.EVENT_ONCLICK] = "sendCallback('%s','%s');" % (self.identifier, self.EVENT_ONCANCEL)
hlay.append(self.cancel)
if cancel_name !='' or confirm_name !='':
self.append(hlay)
self.inputs = {}
def main(self, name='world'):
# margin 0px auto allows to center the app to the screen
wid = gui.VBox(width=300, height=200, margin='0px auto')
bt = gui.Button('Close App', width=200, height=30)
bt.style['margin'] = 'auto 50px'
bt.style['background-color'] = 'red'
bt.onclick.do(self.on_button_pressed)
wid.append(bt)
return wid
super(FileFolderNavigator, self).__init__(**kwargs)
self.set_layout_orientation(Container.LAYOUT_VERTICAL)
self.style['width'] = '100%'
self.multiple_selection = multiple_selection
self.allow_file_selection = allow_file_selection
self.allow_folder_selection = allow_folder_selection
self.selectionlist = []
self.controlsContainer = Widget()
self.controlsContainer.set_size('100%', '30px')
self.controlsContainer.style['display'] = 'flex'
self.controlsContainer.set_layout_orientation(Container.LAYOUT_HORIZONTAL)
self.controlBack = Button('Up')
self.controlBack.set_size('10%', '100%')
self.controlBack.onclick.connect(self.dir_go_back)
self.controlGo = Button('Go >>')
self.controlGo.set_size('10%', '100%')
self.controlGo.onclick.connect(self.dir_go)
self.pathEditor = TextInput()
self.pathEditor.set_size('80%', '100%')
self.pathEditor.style['resize'] = 'none'
self.pathEditor.attributes['rows'] = '1'
self.controlsContainer.append(self.controlBack)
self.controlsContainer.append(self.pathEditor)
self.controlsContainer.append(self.controlGo)
self.itemContainer = Widget(width='100%',height=300)
self.append(self.controlsContainer)
self.append(self.itemContainer, key='items') # defined key as this is replaced later
self.folderItems = list()