Exemplo n.º 1
0
    def __init__(self, main_window):
        # Initialize screen
        super().__init__()
        self.ui = Ui_Problem()
        self.ui.setupUi(self)

        # Set a variable for the main window so that we can access it later
        self.main_window = main_window

        # Connect the buttons to their functions
        self.ui.button_home.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_back.clicked.connect(
            lambda: self.main_window.change_screen('ProblemSelection'))
        self.ui.button_help.clicked.connect(lambda: display_help('Problem'))

        # Buttons for new problem and checking answer
        self.ui.button_new.clicked.connect(self.new_problem)
        self.ui.button_check.clicked.connect(self.check)
        # Pressing enter in the text box is the same as pressing the check button
        self.ui.text_entry.returnPressed.connect(self.check)

        # Connect the input box to a function that updates the image
        self.ui.text_entry.textChanged.connect(self.update_text)

        # Variables for the problem parameters
        self.parameters = None
        self.complexity = None
        self.problem = None
        self.answer = None
        self.problem_type = None
Exemplo n.º 2
0
    def __init__(self, main_window):
        # Initialize screen
        super().__init__()
        self.ui = Ui_FlashcardSelection()
        self.ui.setupUi(self)

        # Set a variable for the main window so that we can access it later
        self.main_window = main_window

        # Connect the buttons to their functions
        self.ui.button_home.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_back.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_help.clicked.connect(
            lambda: display_help('FlashcardSelection'))

        # Display the available flashcard sets
        self.setup_flashcards()

        # Buttons for new sets
        self.ui.derivatives_new_button.clicked.connect(
            lambda: self.new_set('Derivatives'))
        self.ui.integrals_new_button.clicked.connect(
            lambda: self.new_set('Integrals'))
        self.ui.series_new_button.clicked.connect(
            lambda: self.new_set('Series'))
Exemplo n.º 3
0
    def __init__(self, main_window):
        # Initialize screen
        super().__init__()
        self.ui = Ui_ProblemSeries()
        self.ui.setupUi(self)

        # Set a variable for the main window so that we can access it later
        self.main_window = main_window

        # Connect the buttons to their functions
        self.ui.button_home.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_back.clicked.connect(
            lambda: self.main_window.change_screen('ProblemSelection'))
        self.ui.button_help.clicked.connect(
            lambda: display_help('ProblemSeries'))

        # Set the buttons for a new problem and checking answer
        self.ui.button_new.clicked.connect(self.new_problem)
        self.ui.button_check.clicked.connect(self.check)

        # Variables for problem parameters
        self.parameters = None
        self.problem = None
        self.answer = None
Exemplo n.º 4
0
    def __init__(self, main_window):
        # Initialize screen
        super().__init__()
        self.ui = Ui_ProblemSelection()
        self.ui.setupUi(self)

        # Set a variable for the main window so that we can access it later
        self.main_window = main_window

        # Connect the buttons to their functions
        self.ui.button_home.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_back.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_help.clicked.connect(
            lambda: display_help('ProblemSelection'))

        # Connect the buttons to go to the problem screen
        self.ui.button_d.clicked.connect(lambda: self.go('d'))
        self.ui.button_i.clicked.connect(lambda: self.go('i'))
        self.ui.button_s.clicked.connect(lambda: self.go('s'))

        # Connect every check box to a function that checks if the button selection is valid
        for layout in (self.ui.d_buttons.layout(), self.ui.i_buttons.layout(),
                       self.ui.s_buttons.layout()):
            # Skip the last item; it's a spacer
            for i in range(layout.count() - 1):
                # Connect the button
                layout.itemAt(i).widget().clicked.connect(self.check_buttons)
Exemplo n.º 5
0
    def __init__(self, main_window):
        # Initialize screen
        super().__init__()
        self.ui = Ui_Graph()
        self.ui.setupUi(self)

        # Set a variable for the main window so that we can access it later
        self.main_window = main_window

        # Variable for window size
        self.window_size = [-10, 10, -10, 10]

        # Connect the buttons to their functions
        self.ui.button_home.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_back.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_help.clicked.connect(lambda: display_help('Graph'))

        # Text box
        self.ui.function_entry.textChanged.connect(self.update_graph)
        # Check boxes
        self.ui.check_zeroes.clicked.connect(self.update_graph)
        self.ui.check_extrema.clicked.connect(self.update_graph)
        self.ui.check_inflection.clicked.connect(self.update_graph)
        self.ui.check_derivative.clicked.connect(self.update_graph)
        self.ui.check_integral.clicked.connect(self.update_graph)
        # Window box
        self.ui.button_window.clicked.connect(self.change_window)
Exemplo n.º 6
0
    def __init__(self, main_window):
        # Initialize screen
        super().__init__()
        self.ui = Ui_FlashcardSetEdit()
        self.ui.setupUi(self)

        # Variables for the specific set
        self.type = None
        self.set = None

        # Set a variable for the main window so that we can access it later
        self.main_window = main_window

        # Connect the buttons to their functions
        # Back button is not connected here because it depends on the parameters
        self.ui.button_home.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_help.clicked.connect(
            lambda: display_help('FlashcardSetEdit'))

        # Connect delete set and new card buttons
        self.ui.delete_button.clicked.connect(self.delete)
        self.ui.new_button.clicked.connect(self.new)
Exemplo n.º 7
0
    def __init__(self, main_window):
        # Initialize screen
        super().__init__()
        self.ui = Ui_Flashcards()
        self.ui.setupUi(self)

        # Set main window
        self.main_window = main_window
        # Index in set
        self.index = 0
        # Set of cards
        self.set = []
        # Set of cards in order
        self.set_inorder = None

        # Type of set and specific set
        self.card_type = None
        self.card_set = None

        # Connect buttons
        self.ui.button_home.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_back.clicked.connect(
            lambda: self.main_window.change_screen('FlashcardSelection'))
        self.ui.button_help.clicked.connect(lambda: display_help('Flashcards'))
        # Flip - either by button or by clicking the card
        self.ui.button_flip.clicked.connect(self.flip)
        self.ui.flashcard.mouseReleaseEvent = lambda event: self.flip()
        # Previous and next
        self.ui.button_previous.clicked.connect(self.previous)
        self.ui.button_next.clicked.connect(self.next)
        # Edit card
        self.ui.button_edit.clicked.connect(
            lambda: self.main_window.change_screen('FlashcardSetEdit', (
                self.card_type, self.card_set)))
        # Randomize order
        self.ui.check_random.clicked.connect(self.randomize)
Exemplo n.º 8
0
    def __init__(self, main_window):
        # Initialize screen
        super().__init__()
        self.ui = Ui_Calculator()
        self.ui.setupUi(self)

        # Set a variable for the main window so that we can access it later
        self.main_window = main_window

        # Set base mode
        self.mode = 'Derivative'
        self.ui.radio_d.setChecked(True)

        # Connect the buttons to their functions
        self.ui.button_home.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_back.clicked.connect(
            lambda: self.main_window.change_screen('Home'))
        self.ui.button_help.clicked.connect(lambda: display_help('Calculator'))
        # Radio buttons
        self.ui.radio_d.clicked.connect(self.change_mode)
        self.ui.radio_i.clicked.connect(self.change_mode)
        self.ui.radio_s.clicked.connect(self.change_mode)
        self.ui.button_convergence.clicked.connect(self.change_mode)
        self.ui.button_value.clicked.connect(self.change_mode)
        # Text boxes
        self.ui.text_entry_d.textChanged.connect(self.update_text)
        self.ui.text_entry_i.textChanged.connect(self.update_text)
        self.ui.text_entry_s.textChanged.connect(self.update_text)
        self.ui.lower_bound.textChanged.connect(self.update_text)
        self.ui.upper_bound.textChanged.connect(self.update_text)
        # Variable buttons
        self.ui.variable_d.currentTextChanged.connect(self.update_text)
        self.ui.variable_i.currentTextChanged.connect(self.update_text)
        self.ui.variable_s.currentTextChanged.connect(self.update_text)
        self.ui.value_s.textChanged.connect(self.update_text)
Exemplo n.º 9
0
def on_turn(player):
	key = libtcod.console_wait_for_keypress(True)
	
	# exit the game
	if key.vk == libtcod.KEY_ESCAPE:
		if config.QUICK_START:
			raise game.SetState('quit')
		
		elif ask_confirmation(player, 'Are you sure you want to quit?'):
			if ask_confirmation(player, 'Save the game?  Your old save will be lost.'):
				raise game.SetState(game.save_game)
			
			else:
				raise game.SetState('quit')
		
		else:
			return False
	
	# Move, attack, or interact with a feature
	elif key.vk in DIRECTION_KEYS:
		dx, dy = DIRECTION_KEYS[key.vk]
		i, j = player.x + dx, player.y + dy
		
		feature = player.map.feature_at(i, j)
		actor = player.map.actor_at(i, j)
		
		if player.map.can_place_actor(i, j):
			player.move_to(i, j)
			
			return True
		
		elif actor and actor.faction in ['enemy', 'neutral']:
			return player.melee_attack(actor)
		
		else:
			return feature.interact(player)
	
	# Do nothing for a turn
	elif key.c == ord('.') or key.vk == libtcod.KEY_KP5:
		
		player.energy = min(player.energy + 1, player.max_energy)
		
		return True
	
	# Pick up an item
	elif key.c == ord('g'):
		item = player.map.item_at(player.x, player.y)
		if item is None:
			messages.Basic('There is nothing to pick up here.', '?')
			
			return False
		
		elif len(player.inventory) >= player.inventory_size:
			messages.Basic("You can't pick up the {:s}; your inventory is full.".format(item.name), '?', item)
			
			return False
		
		else:
			player.inventory.add(item)
			player.map.items.remove(item)
			
			item.x, item.y, item.map = None, None, None
			
			# if/when npcs can pick up items, generalize this message
			messages.Basic('You pick up the {:s}.'.format(item.name), player, item)
			
			return True
	
	# Open the inventory
	elif key.c == ord('i'):
		return display_inventory(player)
	
	# Close a door
	elif key.c == ord('c'):
		can_close = []
		
		for (dx, dy) in ADJACENT:
			feature = player.map.feature_at(player.x + dx, player.y + dy)
			
			if feature.is_door and feature.open:
				can_close.append((dx, dy))
		
		if len(can_close) == 0:
			messages.Basic('There is nothing to close here.', '?')
			
			return False
		
		else:
			choice = ask_which_direction(player, 'Close in what direction?', can_close)
			
			if choice is not None:
				return player.map.feature_at(player.x + choice[0], player.y + choice[1]).interact(player)
	
	elif key.c == ord('>'):
		feature = player.map.feature_at(player.x, player.y)
		
		if feature.is_stairs:
			raise game.SetState(game.change_level)
		
		else:
			messages.Basic("There are no stairs here.", '?')
			return False
	
	# Look at the map
	elif key.c == ord('l'):
		look(player)
		
		return False
	
	# Show the help menu
	elif key.c == ord('?'):
		display_help()
		
		return False
	
	# Show the message log
	elif key.c == ord('m'):
		display_message_log(player)
		
		return False
	
	# Save a screenshot
	elif key.c == ord('P'):
		pic = libtcod.image_from_console(0)
		libtcod.image_save(pic, 'screenshots/{}.bmp'.format(time_as_string(file_safe = True)))
		
		messages.Basic('Screenshot saved.', '?')
		
		return False
	
	elif key.c == ord('D') and config.DEBUG_KEYS:
		debug(player)
		
		return False