def switch_to_da_form(self, *args):
self.manager.transition.direction = 'right'
self.manager.current = 'da_form'
# Input Screen for Deadlock Detection algorithm
python类Screen()的实例源码
def switch_to_page_form(self, *args):
self.manager.transition.direction = 'right'
self.manager.current = 'page_form'
# Input Screen for Disk Scheduling Algorithms
def save(self, usb = False, *args,**kwargs):
if self.meta != None:
self.save_meta()
save_dir = roboprinter.robo_screen()
Logger.info(save_dir)
save_dir = save_dir.replace("ROBOSAVE", "")
Logger.info(save_dir)
filename = os.path.basename(self.temp_file_path)
if save_dir == 'local':
save_dir = FILES_DIR + "/"+ filename
final_dir = save_dir
counter = 0
#don't overwrite an already saved file
while os.path.isfile(final_dir):
counter += 1
final_dir = save_dir.replace(".gcode", "_" + str(counter) + ".gcode")
short_dir = 'local/'
else:
short_dir = save_dir + "/"
save_dir = FILES_DIR + "/" + save_dir + "/"+ filename
final_dir = save_dir
counter = 0
#dont overwrite an already saved file
while os.path.isfile(final_dir):
counter += 1
final_dir = save_dir.replace(".gcode", "_" + str(counter) + ".gcode")
if os.path.isfile(self.temp_file_path):
#copy the file
shutil.copyfile(self.temp_file_path, final_dir)
#remove the temporary file if it is not from a USB drive
if not usb:
os.remove(self.temp_file_path)
fit_filename = filename.replace(".gcode", "_" + str(counter))
if len(fit_filename) > 24:
fit_filename = "..." + fit_filename[len(fit_filename) - 24:]
layout = Confirmation_Screen(roboprinter.lang.pack['Files']['Save_File']['Sub_Title'], fit_filename + roboprinter.lang.pack['Files']['Save_File']['Body'], "Icons/Slicer wizard icons/check_icon.png", roboprinter.robosm.go_back_to_main)
sc = Screen(name = 'confirmation')
sc.add_widget(layout)
roboprinter.robosm.add_widget(sc)
roboprinter.robosm.current = sc.name
Logger.info('File Saved/Removed')
#add a 2 second delay for updating files
Clock.schedule_once(self.update_files, 2)
def HotKey1(channel):
global hotkey1string
global screenon
global windowuptime
global windowdowntime
global WINDOWSUPON
global WINDOWSDOWNON
if hotkey1string == "Seek Up":
Clock.schedule_once(seekup_callback)
Clock.schedule_once(seekup_callback,.1)
if hotkey1string == "Seek Down":
Clock.schedule_once(seekdown_callback)
Clock.schedule_once(seekdown_callback,.1)
if hotkey1string == "Garage":
Clock.schedule_once(garage_callback)
Clock.schedule_once(garage_callback,.1)
if hotkey1string == "Radar":
Clock.schedule_once(radar_callback)
if hotkey1string == "Cup Lights":
Clock.schedule_once(leds_callback)
if hotkey1string == "Windows Up":
if WINDOWSDOWNON == 0: #only works when windows down isnt running
Clock.schedule_once(windowsup_callback)
Clock.schedule_once(windowsupOFF_callback, windowuptime)
return
if WINDOWSUPON == 1:
Clock.schedule_once(windowsupOFF_callback) #if windows going up while pushed, will cancel and stop windows
if hotkey1string == "Windows Down":
if WINDOWSUPON == 0: #only works when windows up isnt running
Clock.schedule_once(windowsdown_callback)
Clock.schedule_once(windowsdownOFF_callback, windowdowntime)
return
if WINDOWSDOWNON == 1:
Clock.schedule_once(windowsdownOFF_callback) #if windows going down while pushed, will cancel and stop windows
if hotkey1string == "Screen Toggle":
if screenon == 1:
os.system("sudo echo 1 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen off
screenon = 0
return
if screenon == 0:
os.system("sudo echo 0 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen on
screenon = 1
return
if hotkey1string == "None":
return
def HotKey2(channel):
global hotkey2string
global screenon
global windowuptime
global windowdowntime
global WINDOWSUPON
global WINDOWSDOWNON
if hotkey2string == "Seek Up":
Clock.schedule_once(seekup_callback)
Clock.schedule_once(seekup_callback,.1)
if hotkey2string == "Seek Down":
Clock.schedule_once(seekdown_callback)
Clock.schedule_once(seekdown_callback,.1)
if hotkey2string == "Garage":
Clock.schedule_once(garage_callback)
Clock.schedule_once(garage_callback,.1)
if hotkey2string == "Radar":
Clock.schedule_once(radar_callback)
if hotkey2string == "Cup Lights":
Clock.schedule_once(leds_callback)
if hotkey2string == "Windows Up":
if WINDOWSDOWNON == 0: #only works when windows down isnt running
Clock.schedule_once(windowsup_callback)
Clock.schedule_once(windowsupOFF_callback, windowuptime)
return
if WINDOWSUPON == 1:
Clock.schedule_once(windowsupOFF_callback) #if windows going up while pushed, will cancel and stop windows
if hotkey2string == "Windows Down":
if WINDOWSUPON == 0: #only works when windows up isnt running
Clock.schedule_once(windowsdown_callback)
Clock.schedule_once(windowsdownOFF_callback, windowdowntime)
return
if WINDOWSDOWNON == 1:
Clock.schedule_once(windowsdownOFF_callback) #if windows going down while pushed, will cancel and stop windows
if hotkey2string == "Screen Toggle":
if screenon == 1:
os.system("sudo echo 1 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen off
screenon = 0
return
if screenon == 0:
os.system("sudo echo 0 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen on
screenon = 1
return
if hotkey2string == "None":
return