def submit_button(self): options = {'disable': False, 'colour': False, 'sharing': False} disable_group = ToggleButton.get_widgets('disable') colour_group = ToggleButton.get_widgets('colour') sharing_group = ToggleButton.get_widgets('sharing') # In what format to send the options to the main program???? for x in disable_group: if x.text == 'Yes' and x.state == 'down': options['disable'] = True print x.text + " " + x.state for x in colour_group: if x.text == 'Yes' and x.state == 'down': options['colour'] = True print x.text + " " + x.state for x in sharing_group: if x.text == '(1)' and x.state == 'down': options['sharing'] = True print x.text + " " + x.state app = App.get_running_app().root app.call_stage1(options, self.stage_duration)
def save_settings(self): """Saves the settings of the config file. """ # Reference: # https://stackoverflow.com/questions/31763187/is-there-builtin-way-to-get-a-togglebutton-groups-current-selection current = [ t for t in ToggleButton.get_widgets('orientation') if t.state == 'down' ][0].text.lower() global FRAME_ORIENTATION FRAME_ORIENTATION = current CONFIG['SLIDESHOW']['frame_orientation'] = current # Image Directory global IMG_DIR IMG_DIR = self.ids.img_dir_text.text CONFIG['SLIDESHOW']['img_dir'] = self.ids.img_dir_text.text # Time Delay # Reference: # https://stackoverflow.com/questions/30202801/how-to-access-id-widget-of-different-class-from-a-kivy-file-kv global TIME_DELAY TIME_DELAY = self.ids.td_spin.output.text CONFIG['SLIDESHOW']['time_delay'] = self.ids.td_spin.output.text # Save all values to file with open(CONFIGFILE, 'w') as configfile: CONFIG.write(configfile)
def get_current(self): universal_menu_section_button_list = ToggleButton.get_widgets( 'menu_section') universal_down_list = [ button for button in universal_menu_section_button_list if button.state == 'down' and button.config_type == self.config_type ] button = universal_down_list[0] return button.uid
def which_instrument_set(self): """ Returns the instrument set that is currently selected on the toggle buttons. This is ugly because kivy doesn't have a built in method for figuring out which button is toggled """ from kivy.uix.togglebutton import ToggleButton as TB button_text = next( (t.id for t in TB.get_widgets('inst_sets') if t.state == 'down'), None) return button_text
def on_touch_down(self, touch): # nacisniecie przyciksu w obszarze rysowania tworzy kropke z dzwiekiem # jest jakis przycisk radio jest zaznaczony with self.canvas: buttons = ToggleButton.get_widgets('sounds') for button in buttons: if button.state == 'down': pos = (touch.x - self.SIZE / 2, touch.y - self.SIZE / 2) self.create_dot(pos, button.color, button.player) del buttons
def dot(self): if self.dotting: return self.dotting = True ciph_tb = next( (t for t in ToggleButton.get_widgets('ciph') if t.state == 'down'), None) if ciph_tb == None: self.dotlabel.text = 'Please select a cipher' self.dotting = False return len_tb = next( (t for t in ToggleButton.get_widgets('len') if t.state == 'down'), None) if len_tb == None: self.dotlabel.text = 'Please select a ciphertext length' self.dotting = False return length = int(len_tb.id) lang_tb = next( (t for t in ToggleButton.get_widgets('lang') if t.state == 'down'), None) if lang_tb == None: self.dotlabel.text = 'Please select a language' self.dotting = False return lang = lang_tb.id if ciph_tb.id != 'caesar': self.dotlabel.text = 'Frequency analysis currently only available for caesar cipher.' self.dotting = False return import train results = train.test_all(length, lang) self.dotlabel.text = 'Frequency analysis accuracy: ' + str(results) self.dotting = False
def file_button_clicked(self,btn): exp_data.clear_object() button_selected=[t for t in ToggleButton.get_widgets('experiment') if t.state=='down'] if len(button_selected) != 0: #deal with exception here of not selecting a single experiment current = button_selected[0] exp_data.update_filename(current.text,App.get_running_app().user_data_dir+'/'+current.text) self.select_exp.dismiss() self.parent.current = 'StartExperiment' else: error_popup=Popup(title='Error',content=Label(text="Please select a experiment before\nproceeding.")\ ,size_hint=(.80,.40),auto_dismiss=True) error_popup.open() Clock.schedule_interval(error_popup.dismiss, 3)
def reset(self): """Return to initial values.""" self.purse.cash = self.INITIAL_AMOUNT self.root.ids.result_status.text = str(self.bets.ZERO) self.root.ids.cur_balance.text = str(self.purse.balance) self.root.ids.min_bet.text = f"{self.GREEN_SECTOR_AMOUNT:.1f}" self.bet_sector = self.GREEN_SECTOR for toggle in ToggleButton.get_widgets("zero"): toggle.state = "normal" self.show_bets()
def build(self): controller = Controller() # przypisuje odtwarzacze do przycisku zeby potem mozne je bylo latwo odnalezc buttons = ToggleButton.get_widgets('sounds') for i, button in enumerate(buttons): if len(self.players) > i: button.player = self.players[i] else: button.player = self.players[-1] # z jakiegos powodu w kivy trzeba to usunac explicite del buttons return controller
def submit_button(self): name = 'colour' option = False group = ToggleButton.get_widgets('colour') # In what format to send the options to the main program???? for x in group: if x.text == 'Yes' and x.state == 'down': option = True app = App.get_running_app().root app.set_options(name, option)
def plotTr(self): aa = [ t for t in ToggleButton.get_widgets('tires') if t.state == 'down' ][0].text bb = [t for t in ToggleButton.get_widgets('opt') if t.state == 'down'][0].text checkDic = { 'Left Front': 0, 'Right Front': 1, 'Left Rear': 2, 'Right Rear': 3, 'Ftire long': 13, 'Ftire lat': 9, 'Slip ratio': 17, 'Slip angle': 21 } a = 0 b = checkDic.get(bb) + checkDic.get(aa) f = open("./plotdata.txt") xl = [] yl = [] a = int(a) b = int(b) for line in f: line = line[:-1] ld = line.split(',') xl.append(float(ld[a])) yl.append(float(ld[b])) plt.plot(xl, yl) plt.xlabel(aa) plt.ylabel(bb) plt.show()
def choose_button(self): app = App.get_running_app().root #app.add_widget(SelectionTransferWidget(pos = (0, 0), id = '1')) name = 'scripting' option = False group = ToggleButton.get_widgets('scripting') # In what format to send the options to the main program???? for x in group: if x.text == 'Yes' and x.state == 'down': option = True user_study = 1 group = ToggleButton.get_widgets('user_study') # In what format to send the options to the main program???? for x in group: if x.text == '2' and x.state == 'down': user_study = 2 app.start(self.numberOfUsers, option, user_study)
def book_activity(self): user = loginscreen.LoginScreenLayout.body.user activity_images = ToggleButton.get_widgets('activities') for each in activity_images: if each.state == 'down': user.book_activity(str(ActivityScreenLayout.body.chosen_day), each.source) ActivityScreenLayout.body.booked_activity = each.source break else: user.book_activity(str(ActivityScreenLayout.body.chosen_day), '') ActivityScreenLayout.body.booked_activity = '' # disable booking button until a different activity is chosen self.disabled = True
def submit_button(self): print "I'm in SelectionTransferWidget" name = 'sharing' option = False sharing_group = ToggleButton.get_widgets('sharing') # In what format to send the options to the main program???? for x in sharing_group: if x.text == '(1)' and x.state == 'down': option = True print option app = App.get_running_app().root app.set_options(name, option) print "I'm going to set_option"
def on_release(self): user = loginscreen.LoginScreenLayout.body.user # check if user has special needs if user.special_notes in physically_challenged: for each in ToggleButton.get_widgets('activities'): if each.state == 'down': # if physically challenging activity is selected popup a warning if activity_names[each.source][1] == 'Physical challenge': content = WarningLayout( text='The activity may be physically challenging\n' 'Do you wish to proceed?') popup = Popup( size_hint=(.45, .55), separator_color=(.1, .1, 1, .775), content=content, title='Warning', auto_dismiss=False, title_size=30, title_color=(0, 0, 0, 1), pos_hint={ 'x': .375, 'y': .2125 }, background='res/system/white_background.jpg') content.proceed_btn.bind(on_release=popup.dismiss) content.stop_btn.bind(on_release=popup.dismiss) content.proceed_btn.bind(on_release=self.proceed) content.stop_btn.bind( on_release=(lambda dt: self.stop(each))) popup.open() return else: self.book_activity() self.book_activity() else: self.book_activity()
def train(self): # don't start training again with one currently active if self.training: return self.training = True # get cipher choice ciph_tb = next( (t for t in ToggleButton.get_widgets('ciph') if t.state == 'down'), None) if ciph_tb == None: self.aistatus.text = 'Please select a cipher' self.training = False return ciph = ciph_tb.id ## if cipher == 'affine': ## self.aistatus.text = 'Affine not yet implemented with the GUI.' ## self.training = False ## return # get length choice len_tb = next( (t for t in ToggleButton.get_widgets('len') if t.state == 'down'), None) if len_tb == None: self.aistatus.text = 'Please select a ciphertext length' self.training = False return length = int(len_tb.id) lang_tb = next( (t for t in ToggleButton.get_widgets('lang') if t.state == 'down'), None) if lang_tb == None: self.aistatus.text = 'Please select a language' self.training = False return lang = lang_tb.id self.aistatus.text = 'Checking necessary files...' files = self.file_checker(ciph, length, lang) if files: self.aistatus.text = 'Files exist. Moving directly to training...' else: self.aistatus.text = 'Files do not exist. Generating necessary files...' sleep(1) if ciph == 'evan': for msg in cgtrain(): self.aistatus.text = msg self.training = False return import generator import train # actual work begins here languages = {'eng': 'English', 'span': 'Spanish', 'fren': 'French'} self.aistatus.text = 'Creating snippets in ' + languages[lang] + '...' generator.generate(length, lang) self.aistatus.text = 'Snippets created. Encrypting snippets for testing...' generator.encrypt(length, lang, ciph) self.aistatus.text = 'Encryption complete. Advancing to neural network.' for msg in train.train(length, lang, ciph): self.aistatus.text = msg self.training = False
def check_activity(): for each in ToggleButton.get_widgets('activities'): if each.source == ActivityScreenLayout.body.booked_activity: return each return ''
self.ids.off.disabled = True if not self.button_set: Clock.schedule_once(initialize_buttons) self.button_set = True scheduler = BackgroundScheduler() scheduler.add_job(self.scheduled_reboot, 'cron', day_of_week='mon-sun', hour=2, minute=0, misfire_grace_time=1000) scheduler.start() Window.clearcolor = OFF_WHITE for group in ('source', 'power'): for widget in ToggleButton.get_widgets(group): widget.allow_no_selection = False def update_clock(self): self.ids.header_date.text = get_timedate() def disable_buttons(self): self.ids.dvd.disabled = True self.ids.cable.disabled = True self.ids.pc.disabled = True self.ids.doccam.disabled = True self.ids.wificollab.disabled = True self.ids.laptop.disabled = True self.parent.parent.ids.shared_screen.vol_slider_p.disabled = True self.parent.parent.ids.shared_screen.audio_mute_p.disabled = True self.parent.parent.ids.shared_screen.video_mute_p.disabled = True
def switch_screen(self, name: str): """Switch application screen manager to a given screen.""" if name: self.ids.screen_manager.current = name for button in ToggleButton.get_widgets("screen"): button.state = "down" if button.screen == name else "normal"
def dwell(self): if self.parent is not None and getattr(self.parent, "typename", None)=="VerticalScroller": # todo: do I need the following next line? if getattr(self, "typename", None)=="Picture": if self.parent.parent.parent.make_duplicate_on_dwell is False: parent = self.parent.parent.parent # todo: properly convert between the co-ordinate systems parent.items.remove_widget(self) root = App.get_running_app().root root.add_widget(self) self.do_translation = True self.do_translation_x = True self.do_translation_y = True self.do_scale = True self.do_rotation = True self.auto_bring_to_front = True self.accept_touch_even_if_all_transforms_are_false = True # Todo: should really figure out why, when de-attaching this # the touches linger on the object # this hack seems to work for now self._touches = [] else: # Figure out if we have colour code on/off group = ToggleButton.get_widgets('colour') # In what format to send the options to the main program???? colour_code_on = False for x in group: if x.text == 'Yes' and x.state == 'down': colour_code_on = True if colour_code_on: p = Picture(source = self.source, description = self.description, draw_description = self.draw_description, border_colour = self.border_colour) # Not sure why being ignored when in the constructor, but # if set from the outside, appears to force it on :) p.description_background_colour = self.description_background_colour else: anonymous_color = json.loads(Config.get('options', 'anonymous_color')) p = Picture(source = self.source, description = self.description, draw_description = self.draw_description, border_colour = anonymous_color) # Not sure why being ignored when in the constructor, but # if set from the outside, appears to force it on :) p.description_background_colour = anonymous_color # get the center of x and top of y t_x, t_y = self.to_window(self.center[0], self.top) # get the center of x and bottom of y b_x, b_y = self.to_window(self.center[0], 0) # get the center of x and y c_x, c_y = self.to_window(self.center[0], self.center[1]) top = Vector(t_x, t_y) bottom = Vector(b_x, b_y) up_vector = top-bottom try: rotation = self.parent.parent.parent.rotation except: rotation = 0 up_vector = up_vector.normalize() # place a constant 150 pixels up from the center # todo: should incoporate the size of the vertical scroller box center_position = top+up_vector*150 # make sure the new position isn't outside of the screen final_center_position = Utilities.clamp(*center_position) root = App.get_running_app().root p.center = (c_x, c_y) p.apply_transform(Matrix().rotate(radians(rotation), 0, 0, 1), anchor=Vector(p.center)) p.scale = 0.0001 root.add_widget(p) anim = Animation(center = final_center_position, duration = 0.5, t="in_out_cubic") &\ Animation(scale = 1, duration = 0.5, t="in_out_cubic") anim.start(p)
def perform_action(self, action): global basics_present, ds, current_ds, ds_in_background, ds_present # clear the input section everytime a menu button is pressed action_widget.oprtn_input.clear_widgets() # if the basics content is displayed clear it. if basics_present == True: action_widget.disp_sec.clear_widgets() basics_present = False # if current_ds == 'Arrays': # if basics menu is selected if action == 'basics': #clear everything before displaying the content action_widget.disp_sec.clear_widgets() # show the basics action_widget.disp_sec.add_widget(Label( text=insert_data.ds_data.get( action_widget.ds_widget.text)[action], color=[0,0,0,1])) # the basics section is on display and the ds is in background if present basics_present = True if ds_present: ds_in_background = True # if create menu is selected elif action == 'create': # clear the display action_widget.disp_sec.clear_widgets() # the ds has not been created yet and if previously it was created it has been deleted ds_present = False # there is no ds present in background ds_in_background = False # basics section is not on display basics_present = False if current_ds == 'Arrays': action_widget.oprtn_input.add_widget(ArrayCreationWidget()) elif current_ds == 'Linked List': action_widget.oprtn_input.add_widget(LLCreationWidget()) elif current_ds == 'Queue': action_widget.oprtn_input.add_widget(QueueCreationWidget()) elif current_ds == 'Stack': action_widget.oprtn_input.add_widget(StackCreationWidget()) elif current_ds == 'Heap': action_widget.oprtn_input.add_widget(HeapCreationWidget()) elif current_ds == 'Tree': action_widget.oprtn_input.add_widget(TreeCreationWidget()) elif current_ds == 'Graph': action_widget.oprtn_input.add_widget(GraphCreationWidget()) else: # if ds is present and in the background if ds_present == True and ds_in_background == True: # display the ds for d in range (ds): action_widget.disp_sec.add_widget(d) # the ds is no longer in the background ds_in_background = False basics_present = False if action == 'insert': if current_ds == 'Arrays': action_widget.oprtn_input.add_widget( ArrayInsertionWidget()) elif current_ds == 'Linked List': action_widget.oprtn_input.add_widget( LLInsertionWidget()) elif current_ds == 'Queue': action_widget.oprtn_input.add_widget( QueueInsertionWidget()) elif current_ds == 'Stack': action_widget.oprtn_input.add_widget( StackInsertionWidget()) elif current_ds == 'Heap': action_widget.oprtn_input.add_widget( HeapInsertionWidget()) elif current_ds == 'Tree': action_widget.oprtn_input.add_widget( TreeInsertionWidget()) elif current_ds == 'Graph': action_widget.oprtn_input.add_widget( GraphInsertionWidget()) elif action == 'delete': if current_ds == 'Arrays': arr_del_w = ArrayDeletionWidget() action_widget.oprtn_input.add_widget(arr_del_w) selected_opt =[option for option in ToggleButton.get_widgets( 'oprtn_type') if option.state == 'down'][0] arr_del_w.delete_button.bind( on_press = arr_del_w.delete_data) elif current_ds == 'Linked List': action_widget.oprtn_input.add_widget(LLDeletionWidget()) elif current_ds == 'Queue': action_widget.oprtn_input.add_widget(QueueDeletionWidget()) elif current_ds == 'Stack': action_widget.oprtn_input.add_widget(StackDeletionWidget()) elif current_ds == 'Heap': action_widget.oprtn_input.add_widget(HeapDeletionWidget()) elif current_ds == 'Tree': action_widget.oprtn_input.add_widget(TreeDeletionWidget()) elif current_ds == 'Graph': action_widget.oprtn_input.add_widget(GraphDeletionWidget()) elif action == 'replace': if current_ds == 'Arrays': arr_repl_w = ArrayReplacementWidget() action_widget.oprtn_input.add_widget(arr_repl_w) arr_repl_w.repl_btn.bind( on_press = partial( arr_repl_w.replace_data, [option for option in ToggleButton.get_widgets( 'oprtn_type_repl') if option.state == 'down'][0]. text)) elif current_ds == 'Linked List': action_widget.oprtn_input.add_widget( LLReplacementWidget()) elif current_ds == 'Queue': action_widget.oprtn_input.add_widget( QueueReplacementWidget()) elif current_ds == 'Stack': action_widget.oprtn_input.add_widget( StackReplacementWidget()) elif current_ds == 'Heap': action_widget.oprtn_input.add_widget( HeapReplacementWidget()) elif current_ds == 'Tree': action_widget.oprtn_input.add_widget( TreeReplacementWidget()) elif current_ds == 'Graph': action_widget.oprtn_input.add_widget( GraphReplacementWidget())
def auth(self, instance): #Obtenemos fecha para el nombre de la imagen timestr = time.strftime("%Y%m%d-%H%M%S") #Obtenemos el color currentColor = [ t for t in ToggleButton.get_widgets('color') if t.state == 'down' ][0] currentFormat = [ f for f in ToggleButton.get_widgets('format') if f.state == 'down' ][0] currentSize = [ s for s in ToggleButton.get_widgets('size') if s.state == 'down' ][0] imageFinalName = '' print(currentColor.text) ret, foto = self.capture.read() if currentColor.text == 'B/N': foto = cv2.cvtColor(foto, cv2.COLOR_RGB2GRAY) elif currentColor.text == 'Binarizada': foto = cv2.cvtColor(foto, cv2.COLOR_RGB2GRAY) #NORMAL thresholding (global) #ret,foto = cv2.threshold(foto,127,255,cv2.THRESH_BINARY) #Adaptive MEAN Thresholding #foto = cv2.adaptiveThreshold(foto,255,cv2.ADAPTIVE_THRESH_MEAN_C,\ #cv2.THRESH_BINARY,11,2) #Adaptive Gaussian Thresholding foto = cv2.adaptiveThreshold(foto,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\ cv2.THRESH_BINARY, 11, 2) #Format to save. if currentFormat.text == 'PNG': compression_params = [cv2.IMWRITE_PNG_COMPRESSION, 9] cv2.imwrite(timestr + '.png', foto, compression_params) imageFinalName = timestr + '.png' im = imaag.open(timestr + ".png") width, height = im.size for x in range(width): for y in range(height): r, g, b = im.getpixel((x, y)) if (r > g and r > b): r1, g1, b1 = 255, 0, 0 if (g > r and g > b): r1, g1, b1 = 0, 255, 0 if (b > r and b > g): r1, g1, b1 = 0, 0, 255 newpixel = r1, g1, b1 im.putpixel((x, y), newpixel) im.save('colorC.png') elif currentFormat.text == 'JPG': cv2.imwrite(timestr + '.jpg', foto, [int(cv2.IMWRITE_JPEG_QUALITY), 90]) imageFinalName = timestr + '.jpg' elif currentFormat.text == 'GIF': compression_params = [cv2.IMWRITE_PNG_COMPRESSION, 9] cv2.imwrite(timestr + '.png', foto, compression_params) im = imaag.open(timestr + ".png") im = im.convert('RGB').convert('P', palette=imaag.ADAPTIVE) os.remove(timestr + ".png") im.save(timestr + '.gif') imageFinalName = timestr + '.gif' elif currentFormat.text == 'BMP': print('La pidio BMP el prro') compression_params = [cv2.IMWRITE_PNG_COMPRESSION, 9] cv2.imwrite(timestr + '.png', foto, compression_params) img = imaag.open(timestr + ".png") file_out = timestr + '.bmp' if len(img.split()) == 4: # prevent IOError: cannot write mode RGBA as BMP r, g, b, a = img.split() img = imaag.merge("RGB", (r, g, b)) img.save(file_out) imageFinalName = file_out else: img.save(file_out) imageFinalName = file_out os.remove(timestr + ".png") else: cv2.imwrite(timestr + '.png', foto) #Resize if necesary if currentSize.text == '800x600': print('Entro 360') width = 800 height = 600 im = imaag.open(imageFinalName) im2 = im.resize((width, height), imaag.ANTIALIAS) im2.save('800600' + imageFinalName) elif currentSize.text == '640x360': print('Entro 360') width = 30 height = 30 im = imaag.open(imageFinalName) im2 = im.resize((width, height), imaag.ANTIALIAS) im2.save('640360' + imageFinalName)
def auth(self, instance): #Obtenemos fecha para el nombre de la imagen timestr = time.strftime("%Y%m%d-%H%M%S") #Obtenemos el color currentColor=[t for t in ToggleButton.get_widgets('color') if t.state=='down'][0] currentFormat=[f for f in ToggleButton.get_widgets('format') if f.state=='down'][0] currentSize=[s for s in ToggleButton.get_widgets('size') if s.state=='down'][0] imageFinalName = '' print(currentColor.text) ret,foto = self.capture.read() if currentColor.text == 'B/N': foto = cv2.cvtColor(foto, cv2.COLOR_RGB2GRAY) elif currentColor.text == 'Binarizada': foto = cv2.cvtColor(foto, cv2.COLOR_RGB2GRAY) #NORMAL thresholding (global) ret,foto = cv2.threshold(foto,127,255,cv2.THRESH_BINARY) #Adaptive MEAN Thresholding #foto = cv2.adaptiveThreshold(foto,255,cv2.ADAPTIVE_THRESH_MEAN_C,\ #cv2.THRESH_BINARY,11,2) #Adaptive Gaussian Thresholding #foto = cv2.adaptiveThreshold(foto,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\ #cv2.THRESH_BINARY, 11, 2) #Format to save. if currentFormat.text == 'PNG': compression_params = [cv2.IMWRITE_PNG_COMPRESSION, 9] cv2.imwrite(timestr+'.png', foto, compression_params) imageFinalName = timestr+'.png' elif currentFormat.text == 'JPG': cv2.imwrite(timestr+'.jpg', foto, [int(cv2.IMWRITE_JPEG_QUALITY), 90]) imageFinalName = timestr+'.jpg' elif currentFormat.text == 'GIF': compression_params = [cv2.IMWRITE_PNG_COMPRESSION, 9] cv2.imwrite(timestr+'.png', foto, compression_params) im = imaag.open(timestr+".png") im = im.convert('RGB').convert('P', palette=imaag.ADAPTIVE) os.remove(timestr+".png") im.save(timestr+'.gif') imageFinalName = timestr+'.gif' elif currentFormat.text == 'BMP': print('La pidio BMP el prro') compression_params = [cv2.IMWRITE_PNG_COMPRESSION, 9] cv2.imwrite(timestr+'.png', foto, compression_params) img = imaag.open(timestr+".png") file_out = timestr+'.bmp' if len(img.split()) == 4: # prevent IOError: cannot write mode RGBA as BMP r, g, b, a = img.split() img = imaag.merge("RGB", (r, g, b)) img.save(file_out) imageFinalName = file_out else: img.save(file_out) imageFinalName = file_out os.remove(timestr+".png") else: cv2.imwrite(timestr+'.png', foto) #Resize if necesary if currentSize.text == '800x600': print('Entro 360') width = 800 height = 600 im = imaag.open(imageFinalName) im2 = im.resize((width, height), imaag.ANTIALIAS) im2.save('800600'+imageFinalName) elif currentSize.text == '640x360': print('Entro 360') width = 32 height = 32 im = imaag.open(imageFinalName) im2 = im.resize((width, height), imaag.ANTIALIAS) im2.save('640360'+imageFinalName) im3 = imaag.open('640360'+imageFinalName) F=[-1, -1, 0, 1, 1, 1, 0, -1]; C=[0, 1, 1, 1, 0, -1, -1, -1]; width, height = im3.size sumatoria = 0 for x in range(1, width, 3): for y in range(1, height, 3): #if(((x+1)%3) == 0 and ((y+1)%3) == 0): print ('('+str(x)+', '+str(y)+')') r0 = im3.getpixel((x,y)) sumatoria+=r0 print('Valores dentro del subfor, vuelta en 8') for i in range(0, 8): m = x+F[i] n = y+C[i] print ('('+str(m)+', '+str(n)+')') if ((((m >= 0) and (m <= width)) and ((n >= 0) and (n <= height))) and ((n != width) and (m != height))): r = im3.getpixel((m,n)) sumatoria+=r sumatoria/=9 im3.putpixel((x, y), int(sumatoria)) for i in range(0, 8): m = x+F[i] n = y+C[i] if ((((m >= 0) and (m <= width)) and ((n >= 0) and (n <= height))) and ((n != width) and (m != height))): r = im3.getpixel((m,n)) im3.putpixel((m, n), int(sumatoria)) im3.save('EJERCICIO'+imageFinalName)