class __Touch(Script): def __init__(self): Script.__init__(self, "touch") self.vfs = vfs.vfs() self.shm = SHM().create() def start(self, arg): fname = arg["filename"].value() if self.touch(fname): val = Variant("SHM create file " + fname) val.thisown = False self.res["result"] = val else: err = Variant("Can't find path") err.thisown = False self.res["error"] = err def touch(self, fname): plist = fname.split("/") snode = "" for path in plist: if path != "": snode += "/" node = self.vfs.getnode(snode) if not self.vfs.getnode(snode + path): node = self.shm.addnode(node, path) snode += path return node
class __Touch(Script): def __init__(self): Script.__init__(self, "touch") self.vfs = vfs.vfs() self.shm = SHM().create() def start(self, arg): fname = arg["filename"].value() if self.touch(fname): self.res["result"] = Variant("SHM create file " + fname) else: self.res["error"] = Variant("Can't find path") def touch(self, fname): plist = fname.split('/') snode = '' for path in plist: if path != '': snode += '/' node = self.vfs.getnode(snode) if not self.vfs.getnode(snode + path): node = self.shm.addnode(node, path) snode += path return node
def __init__(self): Script.__init__(self, "touch") self.vfs = vfs.vfs() self.shm = SHM().create()
def main(): pygame.init() projectile = pygame.image.load('Picture/Projectile.png') wave = pygame.image.load('Picture/Wave.png') pendulum = pygame.image.load('Picture/SHM.png') collision = pygame.image.load('Picture/Collision.png') projection = pygame.image.load('Picture/Circular.png') title = display_title('PHYSICS SIMULATOR', [0, 255, 255], (366, 60), screen, 54) topic1 = display_title('1. Supepostion of Wave', [255, 255, 0], (120, 140), screen, 35) topic2 = display_title('2. Simple Pendulum', [255, 255, 0], (120, 185), screen, 35) topic3 = display_title('3. Projectile Motion', [255, 255, 0], (120, 230), screen, 35) topic4 = display_title('4. Collision', [255, 255, 0], (120, 275), screen, 35) topic5 = display_title('5. Projection of Particle', [255, 255, 0], (120, 320), screen, 35) topic6 = display_title(' in Circular Motion', [255, 255, 0], (120, 365), screen, 35) boxes() pygame.display.flip() while True: #screen.fill([47, 52, 64], rect=[705, 145, 460, 410]) boxes() topic6.display() topic5.display() topic4.display() topic3.display() topic2.display() topic1.display() title.display() pygame.display.update() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: sys.exit() if event.type == pygame.MOUSEMOTION: posx, posy = pygame.mouse.get_pos() while (110 <= posx <= 680) and (140 <= posy <= 175): screen.fill([91, 96, 95], rect=[705, 145, 460, 410]) screen.blit(wave, (710, 150)) pygame.display.update() posx, posy = pygame.mouse.get_pos() for sub_event in pygame.event.get(): if sub_event.type == pygame.MOUSEBUTTONDOWN: import wave wave.run_wave() while (110 <= posx <= 680) and (185 <= posy <= 225): screen.fill([91, 96, 95], rect=[705, 145, 460, 410]) screen.blit(pendulum, (710, 150)) pygame.display.update() posx, posy = pygame.mouse.get_pos() for sub_event in pygame.event.get(): if sub_event.type == pygame.MOUSEBUTTONDOWN: import main main.program() while (110 <= posx <= 680) and (230 <= posy <= 270): screen.fill([91, 96, 95], rect=[705, 145, 460, 410]) screen.blit(projectile, (710, 150)) pygame.display.update() posx, posy = pygame.mouse.get_pos() for sub_event in pygame.event.get(): if sub_event.type == pygame.MOUSEBUTTONDOWN: import Projectile Projectile.mainPro() while (110 <= posx <= 680) and (275 <= posy <= 315): screen.fill([91, 96, 95], rect=[705, 145, 460, 410]) screen.blit(collision, (710, 150)) pygame.display.update() posx, posy = pygame.mouse.get_pos() for sub_event in pygame.event.get(): if sub_event.type == pygame.MOUSEBUTTONDOWN: import ElasticCollision ElasticCollision.main_program() while (110 <= posx <= 680) and (320 <= posy <= 360): screen.fill([91, 96, 95], rect=[705, 145, 460, 410]) screen.blit(projection, (710, 150)) pygame.display.update() posx, posy = pygame.mouse.get_pos() for sub_event in pygame.event.get(): if sub_event.type == pygame.MOUSEBUTTONDOWN: import SHM SHM.run_shm()