def UiComponents(self, cols=45, rows=47): # Рисуем поле self.field = [] for col in range(cols): self.field.append([]) for row in range(rows): cell = Cell(self, row, col) cell.move(1 + 14 * row, 40 + 14 * col) cell.clicked.connect(cell.click) self.field[-1].append(cell) # # Кнопка вызова справки self.helpGroundButton.clicked.connect(self.groundHelp) # Кнопка вызова полного отчета self.outputButton.clicked.connect(self.fullReport) # Кнопка расчета критического пути self.actionButton.clicked.connect(self.findPath) # Кнопка очистки нарисованых путей self.clearButton.clicked.connect(self.clearPath) # Кнопка сохранения self.saveButton.clicked.connect(lambda: saving.save(self, self.field)) self.saveButton.setIcon(QIcon('pictures/save.png')) # Кнопка загрузки self.loadButton.clicked.connect(lambda: saving.load(self)) self.loadButton.setIcon(QIcon('pictures/open.png')) # Кнопка технических средств нарушителя self.intruder_tech_button.clicked.connect(self.changeTech) # Скрыть кнопки настроек нарушителя self.intruder_add_tech_list.setVisible(False) # Привязка функций на кнопки тех средств нарушителя self.intruder_add_tech_list.itemDoubleClicked.connect(self.addTech) # Удаление элемента по двойному щелчку self.intruder_tech_list.itemDoubleClicked.connect(self.removeTech)
def openingmenu(): references.config.defaults() references.config.screen.blit(references.config.logo, (0,0)) pygame.display.update() print(''' ██╗░░██╗███████╗░█████╗░██████╗░████████╗██╗░░░░░██╗███████╗███████╗ ██║░░██║██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██║░░░░░██║██╔════╝██╔════╝ ███████║█████╗░░███████║██████╔╝░░░██║░░░██║░░░░░██║█████╗░░█████╗░░ ██╔══██║██╔══╝░░██╔══██║██╔══██╗░░░██║░░░██║░░░░░██║██╔══╝░░██╔══╝░░ ██║░░██║███████╗██║░░██║██║░░██║░░░██║░░░███████╗██║██║░░░░░███████╗ ╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░╚══════╝╚═╝╚═╝░░░░░╚══════╝ ____________________________________________________________________ ''') print('Is this your first time playing? (y/n)') x = input(Fore.WHITE + '>> ') if x == 'y': references.config.newbie = True print(Fore.WHITE + 'Ahh! Then we should explain the game to you!') references.config.screen.fill(references.config.black) pygame.display.update() cutscenes.explain() cutscenes.newgame() return if x == 'n': references.config.newbie = False print(Fore.WHITE + 'Very Nice, thanks for playing again, do you want to start a new game? (y/n)') x = input(Fore.WHITE + '>> ') print('____________________________________________________________________') if x == 'y': references.config.screen.fill(references.config.black) pygame.display.update() cutscenes.newgame() return if x == 'n': print('Copy and paste your save data bellow:') x = input('>> ') saving.load()
def load_game(_surface, _username, is_origin): doc = None if is_origin: doc = saving.load('origin') # 进入开篇剧情,提问出身 choice = start_ask(_surface) if choice == 0: doc.warrior.bag.armor.append(internal.armor(database.get_armor('sword-4'))) # 达官显贵 elif choice == 1: doc.warrior.bag.money += 100 # 巨商大贾 doc.warrior.bag.armor.append(internal.armor(database.get_armor('book-4'))) elif choice == 2: doc.warrior.bag.armor.append(internal.armor(database.get_armor('book-1'))) # 知识分子 elif choice == 3: doc.POLICE_PROB = 0.001 # 平头百姓 doc.choice = choice doc.save(_username) else: doc = saving.load(_username) import ui ui.ID = _username ui.parse_doc(doc) database.commit() ui.main(_username, is_origin)
def eventLoad( self ): filename = self.consoleInput('Load Workspace >> ') if filename and saving.load( self, filename ): self.invalidate()
def __init__( self, caption ): Window.__init__( self, caption ) dirChilds = Vector2( (-1,0) ) self.items = [] # Load default workspace filename = config.get( 'workspace', 'default.xml' ) if filename: if not saving.load( self, filename ): print "Can't open default workspace" self.expandMatrix = TransformMatrix() self.expandMatrix.setExpand( Figure.expandCoef ) self.viewMatrix = None self.viewMatrix = self.defaultView( self.size, 35 ) self.selection = Selection( None ) self.highlight = Selection( None ) # Dragging Figure over another Figure self.dragPos = None # Start drag position self.mode = let.Mode() # Mode of reduction self.quick = False # Quick Reduction self.cursors = ( cursors.arrow, cursors.finger ) self.setCursor( self.cursors[ int( self.quick ) ] ) self.nonstop = False # Nonstop reduction mode self.showInfo = True # Drawing self.boldLambda = int( config.get( 'bold_lambda', 0 ) ) self.eventProcs = { K_i: self.eventInputItem, K_d: self.eventDeleteItem, K_c: self.eventCopyItem, K_RETURN: { KMOD_CTRL: self.eventNonstop, None: self.eventReduce }, K_BACKSPACE: self.eventUndo, K_z: { KMOD_CTRL: self.eventUndo }, K_y: { KMOD_CTRL: self.eventRedo }, K_LEFT: { KMOD_ALT: self.eventUndo }, K_RIGHT: { KMOD_ALT: self.eventRedo }, K_SPACE: self.eventExpandSelection, K_DELETE: self.eventDeleteNode, K_INSERT: { KMOD_ALT: self.eventAddLambda, KMOD_CTRL: self.eventAddApplicationAfter, None: self.eventAddApplicationBefore }, K_s: { KMOD_CTRL: self.eventSave, KMOD_ALT: self.eventModeBySelection }, K_o: { KMOD_CTRL: self.eventLoad }, K_q: self.eventModeQuick, K_a: { KMOD_ALT: self.eventModeStrategy, KMOD_CTRL: self.eventAddApplicationAfter, None: self.eventAddApplicationBefore }, K_l: { KMOD_ALT: self.eventModeLazy, None: self.eventAddLambda }, K_v: self.eventAddVariable, K_p: { KMOD_ALT: self.eventModeLazy }, K_e: { KMOD_ALT: self.eventExportMode }, K_F1: self.eventViewHelp, K_F5: self.eventRefreshView, K_F12: self.eventSaveScreen } #----------------------------------------------------- # Prepare toolbars self.toolbars = [] ims = toolbar.ImageSet( 'icons.bmp', (48,48) ) # Create font for Menus fontsize = int( config.get( 'fontsize' ) ) or 11 toolbar.ToolbarItem.fontsize = fontsize toolbar.ToolbarItem.font = pygame.font.SysFont( 'lucidaconsole', fontsize ) left = toolbar.Toolbar( toolbar.LEFT ) left.add( self.eventInputItem, 'Input Item from console (I)', 'Input Item' ) left.add( None, None, '' ) left.add( None, None, 'Reduction' ) left.add( self.eventModeStrategy, 'Toggle reduction strategy (Alt+A)', ' Normal order', ' Applicative', lambda:self.mode.applicative ) left.add( self.eventModeLazy, 'Toggle calculus (Alt+L, Alt+P)', ' Pure Lambda', ' Lazy', lambda:self.mode.lazy ) left.add( self.eventModeBySelection, 'Reduction inside selection only or the whole expression (Alt+S)', ' whole expression', ' in selection', lambda:self.mode.redex ) left.add( None, None, '' ) left.add( self.eventSave, 'Save Workspace. Input file name from console. (Ctrl+S)', 'Save' ) left.add( self.eventLoad, 'Load Workspace. Input file name from console. (Ctrl+O)', 'Load' ) self.toolbars.append( left ) right = toolbar.Toolbar( toolbar.RIGHT ) right.add( self.eventModeQuick, 'Quick mode: Pick for reduction. (Q)', (ims,2,1), (ims,2,2), lambda:self.quick ) right.add( self.eventAddVariable, 'Add a free variable to workspace (V)', (ims,0,0) ) right.add( self.eventAddApplicationBefore, 'Add application before selection (Insert, A)', (ims,0,1) ) right.add( self.eventAddApplicationAfter, 'Add application after selection (Ctrl+Insert, Ctrl+A)', (ims,0,2) ) right.add( self.eventAddLambda, 'Add lambda bubble (Alt+Insert, L)', (ims,1,2) ) right.add( self.eventDeleteNode, 'Delete selected bubbles (Delete)', (ims,1,1) ) right.add( self.eventDeleteItem, 'Delete selected item (D)', (ims,1,0) ) right.add( self.eventCopyItem, 'Copy selected item (C)', (ims,2,0) ) self.toolbars.append( right ) bottom = toolbar.Toolbar( toolbar.BOTTOM ) bottom.add( self.eventUndo, 'Undo (Ctrl+Z, Alt+Left, Backspace)', (ims,3,1) ) bottom.add( self.eventReduce, 'Reduce selected figure (Enter)', (ims,3,0) ) bottom.add( self.eventRedo, 'Redo (Ctrl+Y, Alt+Right)', (ims,3,2) ) self.toolbars.append( bottom ) self.invalidate()
def from_file(cls,filename): return cls.from_pickle(saving.load(filename))
def __init__(self, stuff): if saving.exists(stuff): self = saving.load(stuff)
def main(_id, is_origin): global surface, IS_SHOPPING, newbie, FRAME, POLICE_PROB, police_defeated, now_map, CHOICE, ID, police_served, _now_floor ID = _id surface.fill(Color('black')) frame() go_stairs() show_warrior(newbie) if is_origin: plot.starter(surface) show_map(now_map) framerate = pygame.time.Clock() while True: framerate.tick(FRAME) ticks = pygame.time.get_ticks() if not IS_SHOPPING: now_map.active_container.update(ticks, pic_dic["empty"], FRAME) now_map.active_container.draw(surface) for event in pygame.event.get(): if event.type == QUIT: if newbie.life > 0: doc = saving.document(newbie, _now_floor, floors.floors, POLICE_PROB, police_defeated, CHOICE, police_served) doc.save(_id) exit() elif event.type == MOUSEMOTION: # 显示装备信息/怪物信息 now_map.mousemove_show_monster() mousemove_show_armor(newbie) elif event.type == MOUSEBUTTONDOWN: mouse_pos = pygame.mouse.get_pos() # 注意点到”出售装备“”佩戴装备“时,不能将clicked清除! if IS_SHOPPING: empty(surface, (208, 293, 385, 25)) # 清除提示语 p = check_mouse_pos(mouse_pos, newbie.bag) if p[0] == 7: # 拆卸 drop_armor(newbie) clear_clicked(newbie) elif p[0] == 5: # 佩戴装备 for i in range(0, len(newbie.bag.armor)): if newbie.bag.armor[i].clicked: if newbie.armor[ newbie.bag.armor[i].kind] is not None: newbie.armor[ newbie.bag.armor[i].kind].clicked = True drop_armor(newbie) newbie.bag.armor[i].clicked = False newbie.armor_wear(newbie.bag.armor[i]) del newbie.bag.armor[i] show_warrior(newbie) show_shop(newbie) break else: hint_txt = text("请先在背包中选中装备!", 210, 295, font_20) hint_txt.show(surface) elif p[0] == 6: # 出售装备 sell_armor(newbie) empty(surface, (208, 293, 385, 25)) # 清除提示语 elif p[0] == 3: # 使用黑石 for i in range(0, 4): if use_black_gem(newbie, i) < 0: empty(surface, (208, 293, 385, 25)) # 清除提示语 break elif p[0] == 4: # 购买物品 for i in range(0, 6): if buy(newbie, i) < 0: empty(surface, (208, 293, 385, 25)) # 清除提示语 break elif p[0] == 1: # 选中包里的装备 clear_clicked(newbie) if newbie.bag.armor[p[1]] is not None: newbie.bag.armor[p[1]].clicked = True pygame.draw.rect(surface, Color('gold'), (210 + 50 * (p[1] % 8), 85 + 50 * (p[1] // 8), 32, 32), 2) elif p[0] == 2: # 选中穿上的装备 clear_clicked(newbie) if newbie.armor[p[1]] is not None: newbie.armor[p[1]].clicked = True pygame.draw.rect(surface, Color('gold'), (5 + 37 * p[1], 181, 32, 32), 2) elif p[0] == 8: # 查看上一次战斗记录 startfile('last_battle.log') else: # 按了其他地方 clear_clicked(newbie) pygame.display.update() elif event.type == KEYDOWN: if event.key == K_p: if IS_SHOPPING: empty(surface, (190, 15, 420, 420)) IS_SHOPPING = False show_map(now_map) else: show_shop(newbie) IS_SHOPPING = True elif event.key == K_s: if newbie.life > 0: doc = saving.document(newbie, _now_floor, floors.floors, POLICE_PROB, police_defeated, CHOICE, police_served) doc.save(_id) plot.save_success(surface) show_map(now_map) elif event.key == K_r: surface.fill(Color('black')) frame() parse_doc(saving.load(_id)) go_stairs() elif not IS_SHOPPING: if event.key == K_LEFT: now_map.walk(1, FRAME) elif event.key == K_RIGHT: now_map.walk(2, FRAME) elif event.key == K_UP: now_map.walk(3, FRAME) elif event.key == K_DOWN: now_map.walk(0, FRAME) elif event.key == K_u and newbie.experience >= 100: Upgrade(newbie) show_map(now_map) elif event.key == K_PAGEUP: if _now_floor > 0 and _now_floor != 6 and _now_floor < 16: _now_floor -= 1 if not go_stairs(True): _now_floor += 1 now_floor = "{}{}".format( newbie.occupation, _now_floor) elif event.key == K_PAGEDOWN: if _now_floor < 18: _now_floor += 1 if not go_stairs(True): _now_floor -= 1 now_floor = "{}{}".format( newbie.occupation, _now_floor) show_warrior(newbie) pygame.display.update()
def walk(self, _dir, _frame): global newbie, surface, police_defeated, police_served, _now_floor, ID, life_left, CHOICE old_posit = tuple(self.warrior_posit) self.warrior_posit[0] += walk_dir[_dir][0] self.warrior_posit[1] += walk_dir[_dir][1] newbie.face = _dir walkable = True upstairs = downstairs = False framerate = pygame.time.Clock() if self.warrior_posit[0] < 0 or self.warrior_posit[ 0] > 12 or self.warrior_posit[1] < 0 or self.warrior_posit[ 1] > 12: walkable = False elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "mons": if self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "29" and _now_floor < 16: # 是城管,触发plot if _now_floor != 8 or CHOICE == 3: plot_end = plot.ChengGuan(surface, newbie.bag) if plot_end[0]: res = fight_wrap( newbie, monster( database.get_monster( self.data[self.warrior_posit[0]][ self.warrior_posit[1]]))) with open('last_battle.log', "w") as f: f.write(res[1]) if res[0] == "???": # 被城管揍了,东西抢走,留一滴血 newbie.life = 1 if plot_end[1] == 3: newbie.bag.money = 0 else: newbie.bag.keys[plot_end[1]] = 0 plot.ChengGuan_end_1(surface) else: # 打赢了城管 police_defeated += 1 plot.ChengGuan_end_2(surface) else: # 乖乖地交了东西 police_served += 1 else: plot.floor8_1(surface) sleep(1) res = fight_wrap( newbie, monster( database.get_monster( self.data[self.warrior_posit[0]][ self.warrior_posit[1]]))) with open('last_battle.log', "w") as f: f.write(res[1]) if res[0] == "???": # 败于城管 newbie.life = 1 if plot.floor8_fail_ask(surface, CHOICE): # 回答正确 plot.floor8_answer_right(surface) newbie.bag.gem += 1 else: plot.floor8_answer_wrong(surface, CHOICE) # 回答错误,死亡 walkable = False life_left -= 1 update_life(ID, life_left) to_exit = (life_left <= 0) k = plot.death(surface, to_exit, life_left) if k == 1: surface.fill(Color('black')) frame() parse_doc(saving.load(ID)) go_stairs() elif k == 2: exit() else: plot.floor8_success(surface) else: res = fight_wrap( newbie, monster( database.get_monster(self.data[self.warrior_posit[0]][ self.warrior_posit[1]]))) with open('last_battle.log', "w") as f: f.write(res[1]) if res[0] == "???": # 死了,触发plot walkable = False life_left -= 1 update_life(ID, life_left) to_exit = (life_left <= 0) k = plot.death(surface, to_exit, life_left) if k == 1: surface.fill(Color('black')) frame() parse_doc(saving.load(ID)) go_stairs() elif k == 2: exit() elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "empt" and _now_floor < 16: if random() < POLICE_PROB: self.data[self.warrior_posit[0]][ self.warrior_posit[1]] = "mons-29" walkable = False elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "barr": walkable = False elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "lava": newbie.life = round(newbie.life * 0.8) # 每一步踏上熔岩,生命值损失20% elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "door": if int(self.data[self.warrior_posit[0]][self.warrior_posit[1]] [5]) < 3: if newbie.bag.keys[int(self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5])] > 0: newbie.bag.keys[int(self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5])] -= 1 else: if newbie.bag.keys[3] > 0: if hint_bomb(self) == -1: walkable = False else: newbie.bag.keys[3] -= 1 else: walkable = False else: # 花型门 num = int(self.data[self.warrior_posit[0]][ self.warrior_posit[1]][6:]) # 06层选择职业的花型门 if num < 7 and num > 2: newbie.occupation = chr(num - 3 + ord('A')) walkable = plot.flower_gates[num](surface, self.data, CHOICE) if walkable: self.door_open(framerate) elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "stai": if self.data[self.warrior_posit[0]][ self.warrior_posit[1]][7] == 'd': downstairs = True else: upstairs = True elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "item": if self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "black_gem": newbie.bag.gem += 1 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "bomb": newbie.bag.keys[3] += 1 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "money": newbie.bag.money += 50 # 暂定一个金块=50金 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "yellow_key": newbie.bag.keys[0] += 1 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "blue_key": newbie.bag.keys[1] += 1 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "red_key": newbie.bag.keys[2] += 1 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "key_box": newbie.bag.keys[0] += 1 newbie.bag.keys[1] += 1 newbie.bag.keys[2] += 1 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "food": if self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "red_gem": newbie.properties["p_attack"] += 2 newbie.update_properties() elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "blue_gem": newbie.properties["p_defense"] += 2 newbie.update_properties() elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "yellow_gem": newbie.properties["m_attack"] += 2 newbie.update_properties() elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "green_gem": newbie.properties["m_defense"] += 2 newbie.update_properties() elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "feather": newbie.upgrade() if self.warrior_posit == [1, 8]: # 02层的羽毛,触发隐藏怪物 plot.hide_monster(surface, self.data) elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "small_blood": newbie.life += 100 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "big_blood": newbie.life += 250 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][5:] == "special_blood": newbie.life *= 2 elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:3] == "npc": # TODO: 触发相应剧情或提示 walkable = False plot.npcs[int( self.data[self.warrior_posit[0]][self.warrior_posit[1]][4:])]( surface, self.data, old_posit) elif self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "hint": walkable = False plot.hints[int( self.data[self.warrior_posit[0]][self.warrior_posit[1]][5:])]( surface, self.data) else: arm = armor( database.get_armor( self.data[self.warrior_posit[0]][self.warrior_posit[1]])) newbie.bag.armor.append(arm) # 播放动画 play_animation(self.warrior_sprite, framerate) if walkable: # 更改新位 if upstairs: _now_floor -= 1 elif downstairs: _now_floor += 1 else: if self.data[self.warrior_posit[0]][ self.warrior_posit[1]][0:4] == "lava": self.data[self.warrior_posit[0]][ self.warrior_posit[1]] = "lava-warrior" else: self.data[self.warrior_posit[0]][ self.warrior_posit[1]] = "warrior" # 更改原位 if self.data[old_posit[0]][old_posit[1]][0:4] == "lava": self.data[old_posit[0]][old_posit[1]] = "lava" else: self.data[old_posit[0]][old_posit[1]] = "empty" # TODO: 注意更新显示! self.reload(newbie) go_stairs()
def eventLoad(self): filename = self.consoleInput('Load Workspace >> ') if filename and saving.load(self, filename): self.invalidate()
def __init__(self, caption): Window.__init__(self, caption) dirChilds = Vector2((-1, 0)) self.items = [] # Load default workspace filename = config.get('workspace', 'default.xml') if filename: if not saving.load(self, filename): print "Can't open default workspace" self.expandMatrix = TransformMatrix() self.expandMatrix.setExpand(Figure.expandCoef) self.viewMatrix = None self.viewMatrix = self.defaultView(self.size, 35) self.selection = Selection(None) self.highlight = Selection(None) # Dragging Figure over another Figure self.dragPos = None # Start drag position self.mode = let.Mode() # Mode of reduction self.quick = False # Quick Reduction self.cursors = (cursors.arrow, cursors.finger) self.setCursor(self.cursors[int(self.quick)]) self.nonstop = False # Nonstop reduction mode self.showInfo = True # Drawing self.boldLambda = int(config.get('bold_lambda', 0)) self.eventProcs = { K_i: self.eventInputItem, K_d: self.eventDeleteItem, K_c: self.eventCopyItem, K_RETURN: { KMOD_CTRL: self.eventNonstop, None: self.eventReduce }, K_BACKSPACE: self.eventUndo, K_z: { KMOD_CTRL: self.eventUndo }, K_y: { KMOD_CTRL: self.eventRedo }, K_LEFT: { KMOD_ALT: self.eventUndo }, K_RIGHT: { KMOD_ALT: self.eventRedo }, K_SPACE: self.eventExpandSelection, K_DELETE: self.eventDeleteNode, K_INSERT: { KMOD_ALT: self.eventAddLambda, KMOD_CTRL: self.eventAddApplicationAfter, None: self.eventAddApplicationBefore }, K_s: { KMOD_CTRL: self.eventSave, KMOD_ALT: self.eventModeBySelection }, K_o: { KMOD_CTRL: self.eventLoad }, K_q: self.eventModeQuick, K_a: { KMOD_ALT: self.eventModeStrategy, KMOD_CTRL: self.eventAddApplicationAfter, None: self.eventAddApplicationBefore }, K_l: { KMOD_ALT: self.eventModeLazy, None: self.eventAddLambda }, K_v: self.eventAddVariable, K_p: { KMOD_ALT: self.eventModeLazy }, K_e: { KMOD_ALT: self.eventExportMode }, K_F1: self.eventViewHelp, K_F5: self.eventRefreshView, K_F12: self.eventSaveScreen } #----------------------------------------------------- # Prepare toolbars self.toolbars = [] ims = toolbar.ImageSet('icons.bmp', (48, 48)) # Create font for Menus fontsize = int(config.get('fontsize')) or 11 toolbar.ToolbarItem.fontsize = fontsize toolbar.ToolbarItem.font = pygame.font.SysFont('lucidaconsole', fontsize) left = toolbar.Toolbar(toolbar.LEFT) left.add(self.eventInputItem, 'Input Item from console (I)', 'Input Item') left.add(None, None, '') left.add(None, None, 'Reduction') left.add(self.eventModeStrategy, 'Toggle reduction strategy (Alt+A)', ' Normal order', ' Applicative', lambda: self.mode.applicative) left.add(self.eventModeLazy, 'Toggle calculus (Alt+L, Alt+P)', ' Pure Lambda', ' Lazy', lambda: self.mode.lazy) left.add( self.eventModeBySelection, 'Reduction inside selection only or the whole expression (Alt+S)', ' whole expression', ' in selection', lambda: self.mode.redex) left.add(None, None, '') left.add(self.eventSave, 'Save Workspace. Input file name from console. (Ctrl+S)', 'Save') left.add(self.eventLoad, 'Load Workspace. Input file name from console. (Ctrl+O)', 'Load') self.toolbars.append(left) right = toolbar.Toolbar(toolbar.RIGHT) right.add(self.eventModeQuick, 'Quick mode: Pick for reduction. (Q)', (ims, 2, 1), (ims, 2, 2), lambda: self.quick) right.add(self.eventAddVariable, 'Add a free variable to workspace (V)', (ims, 0, 0)) right.add(self.eventAddApplicationBefore, 'Add application before selection (Insert, A)', (ims, 0, 1)) right.add(self.eventAddApplicationAfter, 'Add application after selection (Ctrl+Insert, Ctrl+A)', (ims, 0, 2)) right.add(self.eventAddLambda, 'Add lambda bubble (Alt+Insert, L)', (ims, 1, 2)) right.add(self.eventDeleteNode, 'Delete selected bubbles (Delete)', (ims, 1, 1)) right.add(self.eventDeleteItem, 'Delete selected item (D)', (ims, 1, 0)) right.add(self.eventCopyItem, 'Copy selected item (C)', (ims, 2, 0)) self.toolbars.append(right) bottom = toolbar.Toolbar(toolbar.BOTTOM) bottom.add(self.eventUndo, 'Undo (Ctrl+Z, Alt+Left, Backspace)', (ims, 3, 1)) bottom.add(self.eventReduce, 'Reduce selected figure (Enter)', (ims, 3, 0)) bottom.add(self.eventRedo, 'Redo (Ctrl+Y, Alt+Right)', (ims, 3, 2)) self.toolbars.append(bottom) self.invalidate()