Ejemplo n.º 1
0
def init():
    manager.load_components()

    # Setup components
    render.window = window
    keyboard.keystate = keystate
    collider.set_world("player", 32, 0, 192, 240)
    collider.set_world("projectiles", 32, -100, 192, 440)
    collider.set_world("kamikaze", -150, -150, 192 + 300, 240 + 300)

    # Create gui
    gui.create()

    # Create player ship
    player.spawn_new()

    global wave_iter
    wave_iter = wave.wave_01()
Ejemplo n.º 2
0
def main(*argv):
	global interface
	debug = False
	b, s, ui = None, None, None
	try:
		options = 'Dngtd:as:b:'
		opts, args = getopt.getopt(argv, options)

		for opt, val in opts:
			if opt == '-D':
				debug = True
			elif opt == '-n':
				interface = None
			elif opt == '-g':
				import gui as interface
			elif opt == '-t':
				import text as interface
			elif opt == '-d':
				interface.delay = float(val)
			elif opt == '-a':
				solver.findall = True
			elif opt == '-s':
				interface.size = int(val)
			elif opt == '-b':
				board.size = int(val)
	
		if len(args) == 0:
			raise ValueError("No starting square specified")
			
		elif len(args) == 1:
			try:
				col = 'abcdefgh'.index(args[0][0])
				row = '12345678'.index(args[0][1])
			except ValueError:
				raise ValueError('Not a chess coordinate')
				
		elif len(args) == 2:
			row, col = map(int, args)
		
		# start the show
		ui = interface and interface.create()
		s = solver.Solver(ui)
		b = s.board

		if debug:
			solve = lambda: s.solve(row, col)
			threading.Thread(None, solve, 'SolverThread').start()
		else:
			s.solve(row, col)

	except ValueError, e:
		ex(e, usage=True)
def main(args):
    output_folder = os.path.expanduser(args.output_folder)
    books = helper.get_table(output_folder, force=args.force)
    if args.gui:
        app = gui.create()
        app.set_output_folder(output_folder)
        app.populate_genres(helper.get_genres(books))
        app._helper = helper
        app._books = books
        threading.Thread(app.mainloop()).start()
        return 0

    if args.list_genres:
        print("\nAvailable genre options:")
        genres = helper.get_genres(books)
        for key in sorted(genres):
            print("  '{}': {} books".format(key, genres[key]))
        print()
        return 0

    if args.list_books is not None:
        print("\nList of available books:")
        count = 0
        books = helper.get_books_in_genres(books, args.list_books)
        for book in sorted(books):
            count += 1
            print("  {}. {}".format(count, book))
        print()
        return 0

    if not args.genre and not args.title and not args.all:
        print("\nNo books selected to download!")
        print("  Please select books by title (--title) or genre (--genre)")
        print("  If you want to download everything use --all\n")
        return 1

    helper.download_books(
        books,
        args.output_folder,
        force=args.force,
        selected_genre=args.genre,
        selected_title=args.title,
        pdf=(not args.only_epub),
        epub=(not args.only_pdf),
        confirm_download=args.confirm_before_download,
        verbose=args.verbose,
    )

    print("\nFinish downloading.")
    return 0
button_pin = 20
motor_pin_1 = 13
motor_pin_2 = 14
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(motor_pin_1, GPIO.OUT)
GPIO.setup(motor_pin_2, GPIO.OUT)

closed = False
def on_close():
    global closed
    closed = True
    GPIO.output(motor_pin_1, False)
    GPIO.output(motor_pin_2, False)

window = gui.create("motor_control2.ui", on_close)
window.show()

toggled = False
previous_state = False
while not closed:
    state = GPIO.input(button_pin)
    #...
    if (previous_state == False and state == True):
        toggled = not toggled
        if toggled:  # Display current direction on GUI
            window.directionLabel.setText("Clockwise")
        else:
            window.directionLabel.setText("Counter-Clockwise")
    if window.powerButton.isChecked():
        #...
Ejemplo n.º 5
0
    2: effect_decorators.to_1d(visualize_energy.effect),
    3: effect_decorators.to_1d(visualize_spectrum.effect),
    4: effect_decorators.to_2d(visualize_scroll.effect),
    5: effect_decorators.to_2d(visualize_energy.effect),
    6: effect_decorators.to_2d(visualize_spectrum.effect),
    7: original_visualize_spectrum.effect
}

default_effect = 5
"""Visualization effect to display on the LED strip"""

# Main program logic follows:
if __name__ == '__main__':
    print('Press Ctrl-C to quit.')
    led.start()
    if config.USE_GUI:
        gui.create()
    # Initialize LEDs
    led.update()
    effect_index = default_effect
    try:
        effect_index = int(sys.argv[1])
    except TypeError:
        print('Not valid effect index', sys.argv[1])
        effect_index = default_effect
    if effect_index > len(effects):
        effect_index = default_effect
    # Start listening to live audio stream
    microphone.start_stream(
        visualization.microphone_callback(effects[effect_index]))
Ejemplo n.º 6
0
import gui
import RPi.GPIO as GPIO
#...
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

button_pin = 20
motor_pin_1 = 13
motor_pin_2 = 14
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(motor_pin_1, GPIO.OUT)
#...
GPIO.setup(motor_pin_2, GPIO.OUT)

window = gui.create("motor_control1.ui")  # Load custom GUI from file
window.show()  # Show custom GUI as an application

toggled = False
previous_state = False
while True:
    #...
    state = GPIO.input(button_pin)
    if (previous_state == False and state == True):
        toggled = not toggled
        GPIO.output(motor_pin_1, False)
        GPIO.output(motor_pin_2, toggled)
    #...
    previous_state = state
    window.update()  # Refresh widgets and process events
    time.sleep(0.01)
Ejemplo n.º 7
0
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(motor_pin_1, GPIO.OUT)
#...
GPIO.setup(motor_pin_2, GPIO.OUT)

closed = False


def on_close():
    global closed  # We are changing "closed" value in here, so it must be global
    closed = True  # Indicate that the window is closing
    GPIO.output(motor_pin_1, False)  # Turn the motor off
    GPIO.output(motor_pin_2, False)  # Turn the motor off


window = gui.create("motor_control1.ui",
                    on_close)  # Pass function to run when window is closed
window.show()

toggled = False
previous_state = False
while not closed:  # Stop looping when window is closed
    state = GPIO.input(button_pin)
    #...
    if (previous_state == False and state == True):
        toggled = not toggled
        GPIO.output(motor_pin_1, False)
        GPIO.output(motor_pin_2, toggled)
    previous_state = state
    window.update()
    time.sleep(0.01)