Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
button_snap.style['margin'] = "0px"
button_snap.style['overflow'] = "auto"
button_snap.style['width'] = "30%"
button_snap.style['height'] = "15%"
hbox_snap.append(button_snap, 'button_snap')
button_close = gui.Button('close')
button_close.style['background-color'] = 'red'
button_close.style['width'] = "30%"
button_close.style['height'] = '15%'
hbox_snap.append(button_close, 'button_close')
self.main_container.append(hbox_snap, 'hbox_snap')
width = 320
height = 240
self.image_result = PILImageViewerWidget(width=width, height=height)
self.main_container.append(self.image_result, 'image_result')
self.image_label = gui.Label('', width=320, height=30, margin='5px')
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)
return self.main_container
self.table = gui.Table(width=300, height=200, margin='10px')
self.table.from_2d_matrix([['ID', 'First Name', 'Last Name'],
['101', 'Danny', 'Young'],
['102', 'Christine', 'Holand'],
['103', 'Lars', 'Gordon'],
['104', 'Roberto', 'Robitaille'],
['105', 'Maria', 'Papadopoulos']])
# the arguments are width - height - layoutOrientationOrizontal
subContainerRight = gui.Widget()
subContainerRight.style['width'] = '220px'
subContainerRight.style['display'] = 'block'
subContainerRight.style['overflow'] = 'auto'
subContainerRight.style['text-align'] = 'center'
self.count = 0
self.counter = gui.Label('', width=200, height=30, margin='10px')
self.lbl = gui.Label('This is a LABEL!', width=200, height=30, margin='10px')
self.bt = gui.Button('Press me!', width=200, height=30, margin='10px')
# setting the listener for the onclick event of the button
self.bt.set_on_click_listener(self, 'on_button_pressed')
self.txt = gui.TextInput(width=200, height=30, margin='10px')
self.txt.set_text('This is a TEXTAREA')
self.txt.set_on_change_listener(self, 'on_text_area_change')
self.spin = gui.SpinBox(100, width=200, height=30, margin='10px')
self.spin.set_on_change_listener(self, 'on_spin_change')
self.check = gui.CheckBoxLabel('Label checkbox', True, width=200, height=30, margin='10px')
self.check.set_on_change_listener(self, 'on_check_change')
self._frame=gui.VBox(width=root_width, height=400)
self.append_field(self._frame,key='frame')
self.spacer=gui.Label('\n',width=400, height=20)
self._frame.append(self.spacer,key='spacer')
self.media_list = gui.ListView(width=250, height=300)
self.media_list.set_on_selection_listener(self.on_media_selected)
self._frame.append(self.media_list,key='media_list')
self.buttons_frame= gui.HBox(width=280, height=30)
self._frame.append(self.buttons_frame,key='buttons_frame')
self.media_name=gui.Label('Selected Item: ',width=400, height=20)
self._frame.append(self.media_name,key='media_name')
self.delete_media = gui.Button('Delete',width=80, height=30)
self.delete_media.set_on_click_listener(self.on_delete_media_button_pressed)
self.buttons_frame.append(self.delete_media,key='delete_media')
self.rename_media = gui.Button('Rename',width=80, height=30)
self.rename_media.set_on_click_listener(self.on_rename_media_button_pressed)
self.buttons_frame.append(self.rename_media,key='rename_media')
self.deleteall_media = gui.Button('Delete All',width=80, height=30)
self.deleteall_media.set_on_click_listener(self.on_deleteall_media_button_pressed)
self.buttons_frame.append(self.deleteall_media,key='deleteall_media')
self.display_media()
"""
super(AdaptableDialog, self).__init__(**kwargs)
self.set_layout_orientation(gui.Widget.LAYOUT_VERTICAL)
self.style['display'] = 'block'
self.style['overflow'] = 'auto'
self.style['margin'] = '0px auto'
if len(title) > 0:
t = gui.Label(title)
t.add_class('DialogTitle')
self.append(t)
if len(message) > 0:
m = gui.Label('<br>'+message)
m.style['margin'] = '5px'
self.append(m)
# container for user widgets
if frame_height !=0:
self._container = gui.Widget(height=frame_height)
else:
self._container = gui.Widget()
self._container.style['display'] = 'block'
self._container.style['overflow'] = 'auto'
self._container.style['margin'] = '5px'
self._container.set_layout_orientation(gui.Widget.LAYOUT_VERTICAL)
self.append(self._container)
if cancel_name !='' or confirm_name !='':
hlay = gui.Widget(height=35)
def open_existing_profile(self,widget):
initial_dir=self.pp_home_dir+os.sep+"pp_profiles"+self.pp_profiles_offset
if os.path.exists(initial_dir) is False:
uc=OKDialog('Open Profile','')
uc.append_label(gui.Label("Profiles directory not found: "),bold=False)
uc.append_label(gui.Label(initial_dir),bold=False)
uc.append_label(gui.Label("Hint: Data Home option must end in pp_home"),bold=False)
uc.show(self)
return
open_existing_profile_dialog = FileSelectionDialog('Open Profile','Select profile',False, initial_dir,allow_folder_selection=True,
allow_file_selection=False,
callback=self.open_existing_profile_dialog_confirm) #width=600,height=200,
# open_existing_profile_dialog.set_on_confirm_value_listener(self.open_existing_profile_dialog_confirm)
open_existing_profile_dialog.show(self)
def on_logs_download_clicked(self,log_file,name):
self.logs_dir=self.pp_dir+os.sep+'pp_logs'
self.logs_download_dialog=AdaptableDialog(width=500,height=200,title='Download ' + name,
message='',confirm_name='Done')
self.logs_download_button = gui.FileDownloader('Click Link to Start Download',self.logs_dir+os.sep+log_file, width=200, height=80)
self.logs_download_status=gui.Label('', width=450, height=30)
self.logs_download_dialog.append_field(self.logs_download_status)
self.logs_download_status.set_text('Download: '+log_file)
self.logs_download_dialog.append_field(self.logs_download_button)
self.logs_download_dialog.show(self)
self.logs_download_dialog.set_on_confirm_dialog_listener(self.on_logs_download_dialog_confirm)
self.table = gui.Table.new_from_list([('ID', 'First Name', 'Last Name'),
('101', 'Danny', 'Young'),
('102', 'Christine', 'Holand'),
('103', 'Lars', 'Gordon'),
('104', 'Roberto', 'Robitaille'),
('105', 'Maria', 'Papadopoulos')], width=300, height=200, margin='10px')
# the arguments are width - height - layoutOrientationOrizontal
subContainerRight = gui.Widget()
subContainerRight.style['width'] = '220px'
subContainerRight.style['display'] = 'block'
subContainerRight.style['overflow'] = 'auto'
subContainerRight.style['text-align'] = 'center'
self.count = 0
self.counter = gui.Label('', width=200, height=30, margin='10px')
self.lbl = gui.Label('This is a LABEL!', width=200, height=90, margin='10px')
self.bt = gui.Button('Press me!', width=200, height=30, margin='10px')
# setting the listener for the onclick event of the button
self.bt.set_on_click_listener(self.on_button_pressed)
self.txt = gui.TextInput(width=200, height=30, margin='10px')
self.txt.set_text('This is a TEXTAREA')
self.txt.set_on_change_listener(self.on_text_area_change)
self.spin = gui.SpinBox(100, width=200, height=30, margin='10px')
self.spin.set_on_change_listener(self.on_spin_change)
self.check = gui.CheckBoxLabel('Label checkbox', True, width=200, height=30, margin='10px')
self.check.set_on_change_listener(self.on_check_change)
pi_reboot_menu.set_on_click_listener(self.pi_reboot_menu_clicked)
pi_shutdown_menu=gui.MenuItem('Shutdown Pi',width=miw+30,height=30)
pi_shutdown_menu.set_on_click_listener(self.pi_shutdown_menu_clicked)
pi_close_manager_menu=gui.MenuItem('Exit PPManager',width=miw+30,height=30)
pi_close_manager_menu.set_on_click_listener(self.pi_close_manager_menu_clicked)
# list of profiles
self.profile_list = gui.ListView(width=250, height=300)
self.profile_list.set_on_selection_listener(self.on_profile_selected)
#status and buttons
self.profile_name = gui.Label('Selected Profile: ',width=400, height=20)
self.pp_state_display = gui.Label('',width=400, height=20)
self.pp_state_display.css_font_weight='bold'
self.run_pp = gui.Button('Run',width=80, height=30)
self.run_pp.set_on_click_listener(self.on_run_button_pressed)
self.exit_pp = gui.Button('Exit',width=80, height=30)
self.exit_pp.set_on_click_listener(self.on_exit_button_pressed)
self.refresh = gui.Button('Refresh List',width=120, height=30)
self.refresh.set_on_click_listener(self.on_refresh_profiles_pressed)
# Build the layout
# buttons
button_frame.append(self.run_pp)
button_frame.append(self.exit_pp)
title (str): The title of the dialog.
message (str): The message description.
kwargs: See Container.__init__()
"""
super(AdaptableDialog, self).__init__(*args, **kwargs)
self.set_layout_orientation(gui.Container.LAYOUT_VERTICAL)
self.style.update({'display':'block', 'overflow':'auto', 'margin':'0px auto'})
if len(title) > 0:
t = gui.Label(title)
t.add_class('DialogTitle')
#t.css_font_weight='bold'
self.append(t, "title") ###
if len(message) > 0:
m = gui.Label(message)
m.css_margin = '5px'
self.append(m, "message") ###
# container for user widgets
if frame_height !=0:
self._container = gui.Container(height=frame_height)
else:
self._container = gui.Container()
self._container.style.update({'display':'block', 'overflow':'auto', 'margin':'5px'})
self._container.set_layout_orientation(gui.Container.LAYOUT_VERTICAL)
self.append(self._container, "central_container") #moved
if cancel_name !='' or confirm_name !='':
hlay = gui.Container(height=35)
hlay.css_display = 'block'
hlay.style['overflow'] = 'visible'
self.lblLeftNum = gui.Label(str(self.LeftNum), width='100%', height='130px', style={'margin':'0px 0px 10px', 'font-size':'140px', 'line-height':'130px', 'text-align':'center'})
self.btLeftPlus = gui.Button('', width='80px', height='80px', style={'margin':'0px 10px 20px', 'font-size':'50px', 'line-height':'50px', 'text-align':'center'})
self.btLeftPlus.attributes['class']='up80'
self.btLeftMinus = gui.Button('', width='80px', height='80px', style={'margin':'0px 10px 20px', 'font-size':'50px', 'line-height':'50px', 'text-align':'center'})
self.btLeftMinus.attributes['class']='dn80'
lblLeftMatch = gui.Label('MATCHES WON:', width=150, height='30px', style={'margin':'0px 5px', 'font-size':'20px', 'line-height':'30px', 'text-align':'left', 'display':'inline'})
self.lblLeftMatches = gui.Label(str(self.LeftMatchNum), width=30, height='30px', style={'margin':'0px 5px', 'font-size':'20px', 'line-height':'30px', 'text-align':'left', 'display':'inline'})
# Right side interface
self.lblRightName = gui.Label(self.Name2, width='95%', height='60px', style={'margin':'20px 2px 0px', 'font-size':'40px', 'line-height':'60px', 'text-align':'center', 'overflow':'hidden'})
self.lblRightNum = gui.Label(str(self.LeftNum), width='100%', height='130px', style={'margin':'0px 0px 10px', 'font-size':'140px', 'line-height':'130px', 'text-align':'center'})
self.btRightPlus = gui.Button('', width='80px', height='80px', style={'margin':'0px 10px 20px', 'font-size':'50px', 'line-height':'50px', 'text-align':'center'})
self.btRightPlus.attributes['class']='up80'
self.btRightMinus = gui.Button('', width='80px', height='80px', style={'margin':'0px 10px 20px', 'font-size':'50px', 'line-height':'50px', 'text-align':'center'})
self.btRightMinus.attributes['class']='dn80'
lblRightMatch = gui.Label('MATCHES WON:', width=150, height='30px', style={'margin':'0px 5px', 'font-size':'20px', 'line-height':'30px', 'text-align':'left', 'display':'inline'})
self.lblRightMatches = gui.Label(str(self.RightMatchNum), width=30, height='30px', style={'margin':'0px 5px', 'font-size':'20px', 'line-height':'30px', 'text-align':'left', 'display':'inline'})
# Appends all the widgets to create the interface
self.wid2.append([self.lblLeftName, self.lblLeftNum, self.btLeftPlus, self.btLeftMinus, lblLeftMatch, self.lblLeftMatches])
self.wid3.append([self.lblRightName, self.lblRightNum, self.btRightPlus, self.btRightMinus, lblRightMatch, self.lblRightMatches])
wid1.append(self.wid2)
wid1.append(self.wid3)
# Extra labels and button to manage:
# The number of games to win, to win a match
lblMatch = gui.Label('GAMES FOR MATCH:', width='50%', height='50px', style={'margin':'15px 2px 0px 10px', 'font-size':'25px', 'line-height':'35px', 'text-align':'center'})
self.lblMatches = gui.Label(str(self.MatchNum), width='8%', height='50px', style={'margin':'15px 2px 0px', 'font-size':'25px', 'line-height':'35px', 'text-align':'center'})
btMatchPlus = gui.Button('', width='50px', height='50px', style={'margin':'5px 2px 0px 20px', 'font-size':'30px', 'line-height':'30px', 'text-align':'center'})
btMatchPlus.attributes['class']='up50'
btMatchMinus = gui.Button('', width='50px', height='50px', style={'margin':'5px 2px', 'font-size':'30px', 'line-height':'30px', 'text-align':'center'})
btMatchMinus.attributes['class']='dn50'
wid1.append([lblMatch, btMatchPlus, self.lblMatches, btMatchMinus])
# Reset buttons for Score and Matches won
btReset = gui.Button('RESET SCORE', width='50%', height='35px', style={'margin':'10px 25% 10px', 'font-size':'25px', 'line-height':'30px', 'text-align':'center'})