コード例 #1
0
    def __init__(self, parent=None):
        """Initialise the Calculator."""
        QW.QWidget.__init__(self, parent)

        # The display and adjusting properties
        # Using QLabel, wanted to use QLCDNumber, but can't display everything
        self.display = QW.QLabel('0')  # Initially setting the display to 0
        # Aligns in the middle, from right to left, to fit standard
        self.display.setAlignment(QC.Qt.AlignRight | QC.Qt.AlignVCenter)
        self.display_font = QG.QFont("Arial", 36)  # Sets the text
        self.display.setFont(self.display_font)
        self.display.setMinimumSize(700, 100)  # Sets the display size
        self.display.setWordWrap(True)  # Prevents extending the display

        # Initialising the logic class
        self.logic = Logic(self.display)  # Passing the display, to be updated

        # Creating all the buttons in the calculator
        self.button_0 = QW.QPushButton('0')
        self.button_1 = QW.QPushButton('1')
        self.button_2 = QW.QPushButton('2')
        self.button_3 = QW.QPushButton('3')
        self.button_4 = QW.QPushButton('4')
        self.button_5 = QW.QPushButton('5')
        self.button_7 = QW.QPushButton('7')
        self.button_6 = QW.QPushButton('6')
        self.button_8 = QW.QPushButton('8')
        self.button_9 = QW.QPushButton('9')
        self.button_negative = QW.QPushButton('+/-')
        self.button_decimal_point = QW.QPushButton('.')
        self.button_equal = QW.QPushButton('=')
        self.button_plus = QW.QPushButton('+')
        self.button_minus = QW.QPushButton('-')
        self.button_multiply = QW.QPushButton('×')
        self.button_divide = QW.QPushButton('÷')
        self.button_squared = QW.QPushButton('x²')
        self.button_squareroot = QW.QPushButton('√x')
        self.button_inverse = QW.QPushButton('1/x')
        self.button_percentile = QW.QPushButton('%')
        self.button_clear_entry = QW.QPushButton('CE')
        self.button_global_clear = QW.QPushButton('C')
        self.button_delete = QW.QPushButton('⌫')
        self.button_memory_clear = QW.QPushButton('MC')
        self.button_memory_recall = QW.QPushButton('MR')
        self.button_memory_add = QW.QPushButton('M+')
        self.button_memory_subtract = QW.QPushButton('M-')

        # Creating a group for the buttons, and connecting them to the handler
        self.group_buttons = QW.QButtonGroup()
        self.group_buttons.buttonClicked.connect(self.logic.button_press)

        # A list of all the buttons, simplifying iterating through them
        # Put into sublist based on rows, to make it clearer where buttons are
        button_list = [
            [self.button_memory_clear, self.button_memory_recall,
             self.button_memory_add, self.button_memory_subtract],
            [self.button_percentile, self.button_clear_entry,
             self.button_global_clear, self.button_delete],
            [self.button_inverse, self.button_squared, self.button_squareroot,
             self.button_divide],
            [self.button_7, self.button_8, self.button_9,
             self.button_multiply],
            [self.button_4, self.button_5, self.button_6, self.button_minus],
            [self.button_1, self.button_2, self.button_3, self.button_plus],
            [self.button_negative, self.button_0,
             self.button_decimal_point, self.button_equal]
        ]

        # Using the Grid Layout, as the calculator buttons are nicely in a grid
        grid = QW.QGridLayout()
        grid.addWidget(self.display, 1, 1, 1, -1)  # Adds the display
        self.setLayout(grid)  # Applies the layout

        # Iterates through all the buttons
        for row, sublist in enumerate(button_list, 2):
            for column, button in enumerate(sublist, 1):
                # Addding the button to the main button group
                self.group_buttons.addButton(button)
                # Adjusting properties of the buttons
                button.setMinimumSize(100, 80)
                # Puts buttons on the grid, based on positions in button_list
                grid.addWidget(button, row, column)
コード例 #2
0
    jib_parameters.add_jib_info(speed=0.5,
                                break_way=10,
                                warning_zone=40,
                                danger_zone=20)
    jib_parameters.add_jib(length=200, angle=0.0)
    jib_parameters.add_panel(
        RenderPanel(window.canvas, x=850, y=200, is_jib=True))
    jib_parameters.include_zone()

    # render cranes
    gantry_render = RenderCraneAndRail(window.canvas,
                                       gantry_parameters,
                                       color='#8170d8')
    jib_render = RenderCraneAndRail(window.canvas,
                                    jib_parameters,
                                    color='#624ad8')

    window.adjust_layers()

    # create controllers
    logic = Logic(gantry_parameters, jib_parameters, window.canvas)
    controller_gantry = CraneController(gantry_parameters, gantry_render,
                                        logic)
    controller_jib = CraneController(jib_parameters, jib_render, logic)

    # include movement
    key_control = KeyControl(controller_gantry, controller_jib)
    window.include_keyboard(key_control)

    window.root.mainloop()
コード例 #3
0
# import main Flask class and request object
from flask import Flask, request
from logic import Logic

# create the Flask app
app = Flask("SBB-backend")
log = Logic()


@app.route('/detail')
def detail():
    facility = request.args.get('facility')
    date = request.args.get('date')
    return log.detail(facility, date)


@app.route('/rafcik')
def rafcik():
    return log.rafcik()


@app.route('/home')
def home():
    return log.home()


@app.route('/form-example')
def form_example():
    return 'Form Data Example'

コード例 #4
0
ファイル: main.py プロジェクト: Pitabread8/Runaway-Trivia
from menu import Menu
from logic import Player, Logic
from lists import modes, responses
from dicts import continents, easy, medium, hard, medium_bonus, hard_bonus
import time
import random

# Creates player object
Player = Player(3)
User = Logic("Player")

# Creates and prints starting menu
begin = Menu(["Instructions", "Play"])
User.Type("Welcome to Runaway Trivia!")
begin.display()
selection = eval(input("Enter Choice Here: "))
if selection == 0:
    User.Rules()

# Creates/prints mode menu
difficulty = Menu(["Easy", "Medium", "Hard"])
print("Pick your difficulty.")
difficulty.display()
challenge = eval(input("Enter Choice Here: "))
mode_str = f"You selected {modes[challenge]} mode."
User.Type(mode_str)

# Creates menus for choosing destinations
easy_picker = Menu(continents["easy"])
medium_picker = Menu(continents["medium"])
hard_picker = Menu(continents["hard"])
コード例 #5
0
    # convert to numpy array form as list cannot do subtraction
    coord1 = np.asarray(coord1)
    coord2 = np.asarray(coord2)
    return np.linalg.norm(coord1 - coord2)


if __name__ == "__main__":
    # load file containing data
    filename = 'input.txt'
    lines = get_input(filename)

    # Retrieve data
    coordinates, num_nodes = get_input(filename)

    # initialise Graph object for constructing minimum spanning tree
    mst = Logic(num_nodes)

    # load edges to graph. Assume fully connected
    # node 0 is earth, node 1 is zearth
    for i, coord1 in enumerate(coordinates):
        for j, coord2 in enumerate(coordinates):
            if (i != j) & (i < j):
                weight = get_distance(coord1, coord2)
                mst.add_edge(i, j, weight)

    result = mst.find_MST()

    # Get best route from mst
    route = mst.find_shortest_path(0, 1, result)
    # Get max weight path in route
    max_weight = mst.get_max_weight(route)
コード例 #6
0
def magic(string1, string2):
    logic = Logic(string1, string2)
    if logic.match():
        print("Yes, '{0}' can be created".format(string2))
    else:
        print("No, '{0}' can't be created".format(string2))
コード例 #7
0
def intentRouter(event, context):
    intent = event['request']['intent']['name']
    logic = Logic()
    # Custom Intents
    if intent == 'FormulaIntent':
        text = 'Let\'s learn maths formula...\n'
        for i in logic.formula.keys():
            # text = text + logic.formula[i] + '<break time="1s">'
            text = text + logic.formula[i]
            text = text + '<break time="2s"/>'
        return sayWithoutCards(text)
    elif intent == 'SineIntent':
        value = event['request']['intent']['slots']['value']['value']
        value = float(value)
        text = 'The sine of ' + str(value) + ' is ' + str(logic.sine(value))
        return say('Answer', text)
    elif intent == 'CosineIntent':
        value = event['request']['intent']['slots']['value']['value']
        value = float(value)
        text = 'The cosine of ' + str(value) + ' is ' + str(
            logic.cosine(value))
        return say('Answer', text)
    elif intent == 'TangentIntent':
        value = event['request']['intent']['slots']['value']['value']
        value = float(value)
        text = 'The tangent of ' + str(value) + ' is ' + str(
            logic.tangent(value))
        return say('Answer', text)
    elif intent == 'CosecIntent':
        value = event['request']['intent']['slots']['value']['value']
        value = float(value)
        text = 'The cosec of ' + str(value) + ' is ' + str(
            1 / logic.sine(value))
        return say('Answer', text)
    elif intent == 'SecantIntent':
        value = event['request']['intent']['slots']['value']['value']
        value = float(value)
        text = 'The secant of ' + str(value) + ' is ' + str(
            1 / logic.cosine(value))
        return say('Answer', text)
    elif intent == 'CotIntent':
        value = event['request']['intent']['slots']['value']['value']
        value = float(value)
        text = 'The cot of ' + str(value) + ' is ' + str(
            1 / logic.tangent(value))
        return say('Answer', text)
    elif intent == 'FactorialIntent':
        value = event['request']['intent']['slots']['value']['value']
        value = int(value)
        text = 'The factorial of ' + str(value) + ' is ' + str(
            logic.factorial(value))
        return say('Answer', text)
    elif intent == 'PowerIntent':
        ''' Here a is the base and b is the exponent'''
        a = event['request']['intent']['slots']['a']['value']
        b = event['request']['intent']['slots']['b']['value']
        a = int(a)
        b = int(b)
        text = 'The value of ' + str(a) + ' to the power ' + str(
            b) + ' is ' + str(a**b)
        return say('Answer', text)
    elif intent == 'NaturalNumbersIntent':
        n = event['request']['intent']['slots']['n']['value']
        n = int(n)
        text = 'The Sum of the first ' + str(n) + ' Natural Numbers is ' + str(
            logic.sumOfNaturalNumbers(n))
        return say('Answer', text)
    elif intent == 'nPrIntent':
        n = event['request']['intent']['slots']['n']['value']
        r = event['request']['intent']['slots']['r']['value']
        n = int(n)
        r = int(r)
        text = 'The value of ' + str(n) + ' P ' + str(r) + ' is ' + str(
            logic.factorial(n) // (logic.factorial(n - r)))
        return say('Answer', text)
    elif intent == 'nCrIntent':
        n = event['request']['intent']['slots']['n']['value']
        r = event['request']['intent']['slots']['r']['value']
        n = int(n)
        r = int(r)
        text = 'The value of ' + str(n) + ' C ' + str(r) + ' is ' + str(
            logic.factorial(n) //
            (logic.factorial(n - r) * logic.factorial(r)))
        return say('Answer', text)
    elif intent == 'AboutIntent':
        text = 'I was created by Rajdeep Roy Chowdhury. '
        return say('Developer', text)
    # Required Intents
    elif intent == "AMAZON.CancelIntent":
        return sayWithoutCards("Ok! Cancelling...")
    elif intent == "AMAZON.HelpIntent":
        text = (
            'You can ask me to calculate trigonometric functions, Factorials,'
            'Exponents, Permutations and combinations. I would learn more functions as soon as possible.'
        )
        return sayAndListen('Help', text)
    elif intent == "AMAZON.StopIntent":
        return sayWithoutCards("Ok! Stopping...")
    else:
        return say(
            'Oops',
            'Oops! This option is invalid right now, it might be available in the next version.'
        )
コード例 #8
0
ファイル: GUI.py プロジェクト: rozhinst/Simple-Calculator
import tkinter as tk
from logic import Logic
# creating the main frame of the calculator
frame = tk.Tk()
frame.title("Calculator")
frame.geometry("354x460")
frameLabel = tk.Label(frame, text="CALCULATOR", bg='Black', font=("Lucida Calligraphy", 25, 'bold'), fg='White').pack(side=tk.TOP)
frame.config(background='Black')

# creating the entry field for user input
text_in = tk.StringVar()
text_in.set(" ")
e1 = tk.Entry(frame, textvar=text_in, width=40).pack()

#  connecting gui to logic
logic = Logic(text_in)

# creating buttons
but1 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(1), text="1", font=("Courier New", 16, 'bold'))
but1.place(x=10, y=100)

but2 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(2), text="2", font=("Courier New", 16, 'bold'))
but2.place(x=10, y=170)

but3 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(3), text="3", font=("Courier New", 16, 'bold'))
but3.place(x=10, y=240)

but4 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(4), text="4", font=("Courier New", 16, 'bold'))
but4.place(x=75, y=100)

but5 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(5), text="5", font=("Courier New", 16, 'bold'))
コード例 #9
0
    def __init__(self):
        self.logic = Logic()
        self.patch_list = self.logic.get_patch_list()

        # Set up GUI
        self.window = tk.Tk()
        self.window.title("AoE2DE Patch Reverter")
        self.window.minsize(width=750, height=500)
        self.window.resizable(0, 0)

        def on_closing():
            self.logic.on_closing()
            self.window.destroy()

        self.window.protocol("WM_DELETE_WINDOW", on_closing)

        self.upper_frame = tk.Frame(master=self.window)
        self.upper_frame.pack(side="top",
                              expand=True,
                              fill="both",
                              padx=10,
                              pady=(10, 5))
        self.upper_frame.columnconfigure(0, weight=1)
        self.upper_frame.columnconfigure(1, weight=1)
        self.upper_frame.columnconfigure(2, weight=1)
        self.upper_frame.columnconfigure(3, weight=1)
        self.upper_frame.columnconfigure(4, weight=1)
        self.upper_frame.columnconfigure(5, weight=1)
        self.upper_frame.rowconfigure(0, weight=1)
        self.upper_frame.rowconfigure(1, weight=1)
        self.upper_frame.rowconfigure(2, weight=1)

        self.lower_frame = tk.Frame(master=self.window)
        self.lower_frame.pack(side="bottom",
                              expand=True,
                              fill="both",
                              padx=10,
                              pady=(5, 10))

        self.selected_patch_title = tk.StringVar()

        patch_titles = [
            f"{p['version']} - {time.strftime('%d/%m/%Y', p['date'])}"
            for p in self.patch_list
        ]

        self.lbl_select_patch = ttk.Label(master=self.upper_frame,
                                          text="Version")
        self.lbl_select_patch.grid(row=0, column=0, sticky="e")
        self.opt_select_patch = ttk.OptionMenu(self.upper_frame,
                                               self.selected_patch_title,
                                               patch_titles[0],
                                               *[p for p in patch_titles])
        self.opt_select_patch.grid(row=0, column=1, sticky="w")

        self.selected_language_name = tk.StringVar()
        self.lbl_select_language = ttk.Label(master=self.upper_frame,
                                             text="Language")
        self.lbl_select_language.grid(row=1, column=0, sticky="e")
        self.opt_select_language = ttk.OptionMenu(self.upper_frame,
                                                  self.selected_language_name,
                                                  Languages.EN.name,
                                                  *[l.name for l in Languages])
        self.opt_select_language.grid(row=1, column=1, sticky="w")

        self.btn_patch = ttk.Button(master=self.upper_frame,
                                    text="Patch",
                                    command=self.__patch)
        self.btn_patch.grid(row=0, column=5, sticky="nesw")

        self.btn_restore = ttk.Button(master=self.upper_frame,
                                      text="Restore",
                                      command=self.__restore)
        self.btn_restore.grid(row=1, column=5, sticky="nesw")

        self.btn_game_dir = ttk.Button(master=self.upper_frame,
                                       text="Set Game directory",
                                       command=self.__select_game_dir)
        self.btn_game_dir.grid(row=2, column=5, sticky="nesw")

        self.lbl_username = ttk.Label(master=self.upper_frame, text="Username")
        self.lbl_username.grid(row=2, column=0, sticky="e")
        self.ent_username = ttk.Entry(master=self.upper_frame)
        self.ent_username.grid(row=2, column=1, sticky="nesw")

        self.lbl_password = ttk.Label(master=self.upper_frame, text="Password")
        self.lbl_password.grid(row=2, column=2, sticky="e")
        self.ent_password = ttk.Entry(master=self.upper_frame, show="*")
        self.ent_password.grid(row=2, column=3, sticky="nesw")

        self.text_box = tk.Text(master=self.lower_frame, state="disabled")
        self.text_box.pack(expand=True, fill="both")

        # Redirect stdout to the text box
        sys.stdout = redirector.StdoutRedirector(self.text_box)
コード例 #10
0
# Creating menu buttons using class "Button"
buttonStart = Button(399, 178, 534, 90)
buttonTutorial = Button(399, 320, 530, 90)
buttonOptions = Button(399, 462, 530, 90)
buttonCredits = Button(399, 605, 530, 90)

# Creating start buttons using class "Button"
buttonSomar = Button(1177, 316, 113, 89)
buttonSubtrair = Button(1177, 423, 113, 89)
buttonMultiplicar = Button(1177, 520, 113, 89)
buttonDividir = Button(1177, 618, 113, 89)
buttonLevelUpOn = Button(50, 508, 155, 46)
buttonLevelUpOff = Button(50, 554, 155, 46)

# Cria objeto para ser usado na lógica do jogo
logicNow = Logic()

#FSMControl
running = 1
menu = 1
start = 0
tutorial = 0
options = 0
credits = 0

#Lógica adicional para o start
gerar = True
a = 0
b = 0
userString = ""
showAnswer = 0
コード例 #11
0
    def __init__(self):
        super().__init__()

        self.initUI()

        self.logic = Logic()
コード例 #12
0
ファイル: gui.py プロジェクト: Anichelli/PRG
    def __init__(self,master=None):
        #root (Tk) - główne okno aplikacji
        self.root = Tk()

        #ustawienie parametrów dla głównego okna
        self.root.title("Projekt Grupowy - 19@KISI'2018")
        self.root.geometry("1035x770")
        self.root.configure(background="aliceblue")

        #klasa do wykonywania logiki
        self.logic = Logic(self)

        #definiowanie niestandardowych czcionek
        buttonFont = Font(slant=ITALIC,family="Helvetica",size=10)
        labelFont = Font(weight=BOLD,size=10)
        outputLabelFont = Font(weight=BOLD,size=18,family="Arial")

        #zmienna typu boolean mówiąca, czy trwa przetwarzanie
        self.isProcessing = False;

        #definiowanie ramek na elementy
        self.loadingFrame = Frame(self.root,height=310,width=510,bd=5,relief=GROOVE,background="gainsboro")
        self.loadingFrame.place(relx=0.01,rely=0.01)

        self.loadingFrame2 = Frame(self.root,height=310,width=510,bd=5,relief=GROOVE,background="gainsboro")
        self.loadingFrame2.place(relx=0.01,rely=0.4136)

        self.outputFrame = Frame(self.root,height=620,width=505,bd=5,relief=GROOVE,background="gainsboro")
        self.outputFrame.place(relx=0.505,rely=0.01)

        self.optionsFrame = Frame(self.root,height=130,width=1018,bd=5,relief=GROOVE,background="gainsboro")
        self.optionsFrame.place(relx=0.01,rely=0.83)

        #Label zawierający napis "source image" i znajdujący się nad obrazem z treścią
        self.infoLabel1 = Label(self.loadingFrame,text="Source image",background="gainsboro",font=labelFont)
        self.infoLabel1.place(relx=0.0, rely=-0.005, height=40, width=120)

        #Label zawierający napis "style image" i znajdujący się nad obrazem z stylem
        self.infoLabel2 = Label(self.loadingFrame2,text="Style image",background="gainsboro",font=labelFont)
        self.infoLabel2.place(relx=0.0, rely=-0.005, height=40, width=110)

        #Label zawierający napis "output image" i znajdujący się nad obrazem wynikowym
        self.infoLabel3 = Label(self.outputFrame,text="Output image",background="gainsboro",font=outputLabelFont)
        self.infoLabel3.place(relx=0.35, rely=0.1,height=40,width=160)

        #Label zawierający napis "Layer selection" i będący obok wyboru warstw
        self.infoLabel4 = Label(self.optionsFrame,text="Layer selection",background="gainsboro", font=outputLabelFont)
        self.infoLabel4.place(relx=0.015,rely=0.01,height=30,width=200)

        #Label zawierający napis "Progress:" i będący obok paska postępu
        self.infoLabel5 = Label(self.optionsFrame,text="Progress:",background="gainsboro", font=labelFont)
        self.infoLabel5.place(relx=0.6,rely=0.01,height=30,width=110)

        #Labele do wyświetlania obrazów (obrazy wyświetlane są jako ich treść)
        self.srcImgLabel = Label(self.loadingFrame,text="",background="aliceblue",borderwidth=2,relief=SOLID)
        self.srcImgLabel.place(relx=0.22, rely=0.13, height=256, width=272)

        self.styleImgLabel = Label(self.loadingFrame2,text="",background="aliceblue",borderwidt=2,relief=SOLID)
        self.styleImgLabel.place(relx=0.22, rely=0.13, height=256, width=272)

        self.outputImgLabel = Label(self.outputFrame,text="",background="lightskyblue",borderwidth=2,relief=SOLID)
        self.outputImgLabel.place(relx=0.225, rely=0.2, height=256, width=272)

        #pasek postępu przetwarzania
        self.progress = ttk.Progressbar(self.optionsFrame,orient="horizontal",length=290,mode="determinate")
        self.progress.place(relx=0.7,rely=0.05)

        #przyciski używane w interfejsie
        self.srcLoadButton = Button(self.loadingFrame,text="Load image",command=self.logic.srcLoadClick)
        self.srcLoadButton.place(relx=0.78, rely=0.017, height=33,width=100)
        self.srcLoadButton.configure(background="powderblue",font=buttonFont)

        self.styleLoadButton = Button(self.loadingFrame2,text="Load image",command=self.logic.styleLoadClick)
        self.styleLoadButton.place(relx=0.78,rely=0.017,height=33,width=100)
        self.styleLoadButton.configure(background="powderblue",font=buttonFont)

        self.startButton = Button(self.outputFrame,text="Startuj",command=self.logic.startProcessing)
        self.startButton.place(relx=0.4,rely=0.65,height=50,width=100)
        self.startButton.configure(backgroun="powderblue",font=buttonFont)

        self.saveButton = Button(self.outputFrame,text="Save",command=self.logic.saveClick)
        self.saveButton.place(relx=0.77,rely=0.925,height=33,width=100)
        self.saveButton.configure(background="powderblue",font=buttonFont)

        #przyciski odpowiadające za wybór warstw sieci
        self.layerButton64 = Button(self.optionsFrame,text="3x3 conv, 64")
        self.layerButton64.place(relx=0.01,rely=0.28,height=25,width=100)
        self.layerButton64.configure(background="aliceblue")

        self.layerButton64_2 = Button(self.optionsFrame,text="3x3 conv, 64")
        self.layerButton64_2.place(relx=0.01,rely=0.51,height=25,width=100)
        self.layerButton64_2.configure(background="aliceblue")

        self.layerButton128 = Button(self.optionsFrame,text="3x3 conv, 128")
        self.layerButton128.place(relx=0.12, rely=0.28,height=25,width=100)
        self.layerButton128.configure(background="blanchedalmond")

        self.layerButton128_2 = Button(self.optionsFrame,text="3x3 conv, 128")
        self.layerButton128_2.place(relx=0.12,rely=0.51,height=25,width=100)
        self.layerButton128_2.configure(background="blanchedalmond")

        self.layerButton256 = Button(self.optionsFrame,text="3x3 conv, 256")
        self.layerButton256.place(relx=0.23, rely=0.05,height=25,width=100)
        self.layerButton256.configure(background="lavender")

        self.layerButton256_2 = Button(self.optionsFrame,text="3x3 conv, 256")
        self.layerButton256_2.place(relx=0.23, rely=0.28,height=25,width=100)
        self.layerButton256_2.configure(background="lavender")

        self.layerButton256_3 = Button(self.optionsFrame, text="3x3 conv, 256")
        self.layerButton256_3.place(relx=0.23, rely=0.51, height=25, width=100)
        self.layerButton256_3.configure(background="lavender")

        self.layerButton256_4 = Button(self.optionsFrame, text="3x3 conv, 256")
        self.layerButton256_4.place(relx=0.23, rely=0.74, height=25, width=100)
        self.layerButton256_4.configure(background="lavender")

        self.layerButton512 = Button(self.optionsFrame,text="3x3 conv, 512")
        self.layerButton512.place(relx=0.34, rely=0.05,height=25,width=100)
        self.layerButton512.configure(background="mintcream")

        self.layerButton512_2 = Button(self.optionsFrame, text="3x3 conv, 512")
        self.layerButton512_2.place(relx=0.34, rely=0.28, height=25, width=100)
        self.layerButton512_2.configure(background="mintcream")

        self.layerButton512_3 = Button(self.optionsFrame, text="3x3 conv, 512")
        self.layerButton512_3.place(relx=0.34, rely=0.51, height=25, width=100)
        self.layerButton512_3.configure(background="mintcream")

        self.layerButton512_4 = Button(self.optionsFrame, text="3x3 conv, 512")
        self.layerButton512_4.place(relx=0.34, rely=0.74, height=25, width=100)
        self.layerButton512_4.configure(background="mintcream")

        self.layerButton512_5 = Button(self.optionsFrame, text="3x3 conv, 512")
        self.layerButton512_5.place(relx=0.45, rely=0.05, height=25, width=100)
        self.layerButton512_5.configure(background="mistyrose")

        self.layerButton512_6 = Button(self.optionsFrame, text="3x3 conv, 512")
        self.layerButton512_6.place(relx=0.45, rely=0.28, height=25, width=100)
        self.layerButton512_6.configure(background="mistyrose")

        self.layerButton512_7 = Button(self.optionsFrame, text="3x3 conv, 512")
        self.layerButton512_7.place(relx=0.45, rely=0.51, height=25, width=100)
        self.layerButton512_7.configure(background="mistyrose")

        self.layerButton512_8 = Button(self.optionsFrame, text="3x3 conv, 512")
        self.layerButton512_8.place(relx=0.45, rely=0.74, height=25, width=100)
        self.layerButton512_8.configure(background="mistyrose")

        #centrowanie okna
        self.logic.center()
        #główna pętla okna
        self.root.mainloop()
コード例 #13
0
 def __init__(self):
     self.bodylist = []
     self.locallistpos = []
     self.system_logic = Logic()
     self.sumHelper = 0
コード例 #14
0
ファイル: game.py プロジェクト: pguz/PyTicTac
 def __init__(self, config, inputs, output):
     self._inputs = inputs
     self._output = output
     self._logic = Logic(config.get_board_size())
コード例 #15
0
import cv2
import time
import threading
from detector import Detector
from mainboard_controller import MainboardController
from referee_controller import RefereeController
from logic import Logic

camera = cv2.VideoCapture(0)
detect = Detector()
mainboard = MainboardController()
logic = Logic(mainboard)
referee_controller = RefereeController()

# Define the states
STATE_BALL_NOT_FOUND = 'ballnotfound'
STATE_BALL_FOUND = 'ballfound'
STATE_GRAB_BALL = 'grabball'
STATE_BALL_GRABBED = 'ballgrabbed'
STATE_MOVE_TO_BALL = 'movetoball'
STATE_FIND_BALL = 'findball'
STATE_FIND_GOAL = 'findgoal'
STATE_GOAL_SCORED = 'goalscored'
STATE_BALL_LOST = 'balllost'

state = STATE_FIND_BALL
balldetails = ""
goaldetails = ""
seeingaball = False
ballindribler = False
ballclose = False
コード例 #16
0
    def post(self, registry_obj):
        try:
            _op = Logic()
            _infos = dict()
            if registry_obj == "school":
                _infos = self._get_school_argument()
                _op = SchoolLogic()

            if registry_obj == "grade":
                _infos = self._get_grade_argument()
                _op = GradeLogic()

            if registry_obj == "class":
                _infos = self._get_class_argument()
                _op = ClassLogic()

            if registry_obj == "teacher":
                _infos = self._get_teacher_argument()
                _op = TeacherLogic()
            if registry_obj == "teacher_history":
                _infos = self._get_teacher_history_argument()
                _op = Teacher_HistoryLogic()

            if registry_obj == "student":
                _infos = self._get_student_argument()
                _op = StudentLogic()
            if registry_obj == "student_history":
                _infos = self._get_student_history_argument()
                _op = Student_HistoryLogic()

            if registry_obj == "relative":
                _infos = self._get_relative_argument()
                _op = RelativeLogic()

            if registry_obj == "relation":
                _infos = self._get_relation_argument()
                _op = RelationLogic()

            if registry_obj == "user":
                user_level = int(self.get_secure_cookie('user_level'))
                level = int(self.get_argument('level', 1))
                if user_level >= level:
                    self.finish(
                        json.dumps({
                            'state': 4,
                            'message': 'Permissions cannot operate'
                        }))
                    return
                _infos = self._get_user_argument()
                _op = UserLogic()

            _ = _op.input(**_infos)
            if _:
                self.finish(
                    json.dumps({
                        'state': 0,
                        'message': 'input info success.'
                    }))
            else:
                self.finish(
                    json.dumps({
                        'state': 1,
                        'message': 'action %s error' % registry_obj
                    }))
        except NotFound as ex:
            LOG.error("Input %s param not data:%s" % (registry_obj, ex))
            self.finish(json.dumps({'state': 2, 'message': 'param not data'}))
        except ParamExist as ex:
            LOG.error("Input %s param exit:%s" % (registry_obj, ex))
            self.finish(json.dumps({'state': 5, 'message': 'param exit'}))
        except ParamNone as ex:
            LOG.error("Input %s param exit:%s" % (registry_obj, ex))
            self.finish(json.dumps({'state': 6, 'message': 'param exit'}))
        except Exception as ex:
            LOG.error("Input %s error:%s" % (registry_obj, ex))
            self.finish(json.dumps({'state': 3, 'message': 'input error'}))
コード例 #17
0
def main():
    argument_parser = get_argument_parser()
    arguments = argument_parser.parse_args()
    lnd = Lnd(arguments.lnddir, arguments.grpc)
    first_hop_channel_id = fmt.parse_channel_id(vars(arguments)['from'])
    to_channel = fmt.parse_channel_id(arguments.to)

    if arguments.ratio < 1 or arguments.ratio > 50:
        print("--ratio must be between 1 and 50")
        sys.exit(1)
    channel_ratio = float(arguments.ratio) / 100

    if arguments.incoming is not None and not arguments.list_candidates:
        print(
            "--outgoing and --incoming only work in conjunction with --list-candidates"
        )
        sys.exit(1)

    if arguments.list_candidates:
        incoming = arguments.incoming is None or arguments.incoming
        if incoming:
            list_incoming_candidates(lnd, channel_ratio)
        else:
            list_outgoing_candidates(lnd, channel_ratio)
        sys.exit(0)

    if to_channel is None and first_hop_channel_id is None and arguments.path is None:
        argument_parser.print_help()
        sys.exit(1)

    percentage = arguments.percentage
    if percentage:
        if percentage < 1 or percentage > 100:
            print("--percentage must be between 1 and 100")
            argument_parser.print_help()
            sys.exit(1)

    # the 'to' argument might be an index, or a channel ID
    if to_channel and to_channel < 10000:
        # here we are in the "channel index" case
        index = int(to_channel) - 1
        candidates = get_incoming_rebalance_candidates(lnd, channel_ratio)
        candidate = candidates[index]
        last_hop_channel = candidate
    else:
        # else the channel argument should be the channel ID
        last_hop_channel = get_channel_for_channel_id(lnd, to_channel)

    first_hop_channel = get_channel_for_channel_id(lnd, first_hop_channel_id)

    if first_hop_channel_id != None and first_hop_channel == None:
        debug(
            "Ⓔ from channel not usable (unknown channel, or channel not active)"
        )
        sys.exit(1)

    # build hops array from CSV expanded arguments
    hops = []
    if arguments.path:
        for path in arguments.path:
            for subpath in path.split(","):
                hops.append(subpath)

        # ensure I am last hop
        me = lnd.get_info().identity_pubkey
        if not hops[-1] == me:
            hops.append(me)

        # first hop when using --path
        if first_hop_channel_id == None:
            for channel in lnd.get_channels():
                if channel.remote_pubkey == hops[0]:
                    local_sats_available = channel.local_balance - channel.local_chan_reserve_sat
                    if local_sats_available > int(arguments.amount):
                        debug('Ⓘ Selecting outgoing channel %s' %
                              fmt.col_lo(fmt.print_chanid(channel.chan_id)))
                        first_hop_channel = channel
                        break
            if first_hop_channel == None:
                debug('Ⓔ Could not find a suitable channel to first hop')
                sys.exit(1)

    amount = get_amount(arguments, first_hop_channel, last_hop_channel)

    if amount == 0:
        debug("Ⓘ Amount is 0, nothing to do")
        sys.exit(0)

    max_fee_factor = arguments.max_fee_factor

    excluded = []
    if arguments.exclude:
        for exclude in arguments.exclude:
            excluded.append(fmt.parse_channel_id(exclude))

    result = Logic(lnd, first_hop_channel, last_hop_channel, amount,
                   channel_ratio, excluded, max_fee_factor, arguments.deep,
                   hops).rebalance()

    if not result:
        sys.exit(2)
    sys.exit(0)
コード例 #18
0
def run_logic(constraints):
    logic = Logic(logic_constraints)
    csp = CSP()
    csp.solve(logic)
    csp.print_solution()
コード例 #19
0
        return sayWithoutCards("Ok! Cancelling...")
    elif intent == "AMAZON.HelpIntent":
        text = (
            'You can ask me to calculate trigonometric functions, Factorials,'
            'Exponents, Permutations and combinations. I would learn more functions as soon as possible.'
        )
        return sayAndListen('Help', text)
    elif intent == "AMAZON.StopIntent":
        return sayWithoutCards("Ok! Stopping...")
    else:
        return say(
            'Oops',
            'Oops! This option is invalid right now, it might be available in the next version.'
        )


def lambda_handler(event, context):
    if event['request']['type'] == "LaunchRequest":
        return onLaunch(event, context)
    elif event['request']['type'] == "IntentRequest":
        return intentRouter(event, context)


# For local debugging purposes only
if __name__ == '__main__':
    print('The json object that is returned is...')
    print(Logic().formula['sin2X'])
    # json_request=dict()
    # context=dict()
    # print(lambda_handler(json_request,context))
    # This is only for debugging locally
コード例 #20
0
ファイル: update.py プロジェクト: imzihuang/edu_project
    def post(self, update_obj):
        try:
            _id = ""
            _value = {}
            _op = Logic()
            if update_obj == "school":
                _id, _value = self._get_school_argument()
                _op = SchoolLogic()

            if update_obj == "grade":
                _id, _value = self._get_grade_argument()
                _op = GradeLogic()

            if update_obj == "class":
                _id, _value = self._get_class_argument()
                _op = ClassLogic()

            if update_obj == "teacher":
                _id, _value = self._get_teacher_argument()
                _op = TeacherLogic()

            if update_obj == "student":
                _id, _value = self._get_student_argument()
                _op = StudentLogic()

            if update_obj == "relative":
                _id, _value = self._get_relative_argument()
                _op = RelativeLogic()

            if update_obj == "relation":
                _id, _value = self._get_relation_argument()
                _op = RelationLogic()

            if update_obj == "user":
                _id, _value = self._get_user_argument()
                _op = UserLogic()

            if not _value or not _id:
                LOG.error("update info, %s params is None: %s, %r" %
                          (update_obj, _id, _value))
                self.finish(
                    json.dumps({
                        'state': 1,
                        'message': 'params %s is None' % update_obj
                    }))
                return
            _ = _op.update(_id, **_value)
            if _:
                self.finish(
                    json.dumps({
                        'state': 0,
                        'message': 'update info success.'
                    }))
            else:
                self.finish(
                    json.dumps({
                        'state': 4,
                        'message': 'update info faild.'
                    }))
        except NotFound as ex:
            LOG.error("Update %s param not data:%s" % (update_obj, ex))
            self.finish(json.dumps({'state': 2, 'message': 'param not data'}))
        except ParamExist as ex:
            LOG.error("Update %s param exit:%s" % (update_obj, ex))
            self.finish(json.dumps({'state': 5, 'message': 'param exit'}))
        except Exception as ex:
            LOG.error("Update %s error:%s" % (update_obj, ex))
            self.finish(
                json.dumps({
                    'state': 3,
                    'message': 'update action error'
                }))
コード例 #21
0
from logic import Logic
import asyncio
from fastapi import FastAPI, Request
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from models import BanlistLongPolling, BanlistGetRaw

logic = Logic()

app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")


@app.get("/banlist/web/{server_id}/{count}")
async def getWeb228(request: Request, server_id: int, count: int):
    return templates.TemplateResponse(
        "main.html", {
            'request': request,
            "server_id": server_id,
            "count": count,
            'bans': await logic.getWeb(server_id, count)
        })


@app.post("/banlist/longpoll")
async def longPoll228(*, longpoll: BanlistLongPolling):
    return await logic.longPoll(longpoll.server, longpoll.ban)


@app.post("/banlist/get")
コード例 #22
0
ファイル: requests.py プロジェクト: jordan-carl/scorclaw
Created on 26/04/2013

@author: José M. Camacho - camachososa@josemazocom
@author: Gabriel E. Muñoz - [email protected]
'''
'''
The Requests class will handle HTTP requests.
'''

import SimpleHTTPServer
import re

from variables import SERIAL_PORT
from logic import Logic

logic = Logic(SERIAL_PORT)
logic.initialize()


class Requests(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(self):
        path = self.path
        pathSplitted = re.split('/', path)

        good_path = True
        response = ''

        if len(pathSplitted) == 2 and pathSplitted[1] != '':
            verb = pathSplitted[1]

            if verb == 'more_x':