Exemplo n.º 1
0
def saveImg():
    x = master.winfo_rootx() + w.winfo_x() + 60
    y = master.winfo_rooty() + w.winfo_y() + 50
    x1 = x + w.winfo_width()
    y1 = y + w.winfo_height()
    ImageGrab.grab().crop((x, y, x1, y1)).save("tel.png")
    number = checking.check('tel.png')
    messagebox.showinfo("Number found!!",
                        f"{number} is the number you drew. if not Sorry :'(")
    w.delete(ALL)
Exemplo n.º 2
0
def main1():

    word = get_word()
    guesses = []
    guessed = False
    print()
    print("The word contains", len(word), "letters.")
    print("_ " * len(word))

    while not guessed:

        print()
        text = "Please enter one letter or a word of " + str(len(word)) + " letters : "

        guess = input(text).upper()

        if guess.isalpha() == True:
            if guess in guesses:
                print('''
You have already guessed "''' + guess + '".')

            elif len(guess) == len(word):
                guesses.append(guess)
                if guess == word:
                    guessed = True
                else:
                    print('''
Sorry,that is incorrect word.''')
            elif len(guess) == 1:
                guesses.append(guess)
                result = check(word, guesses, guess)
                if result == word:
                    guessed = True
                else:
                    print(result)
            else:
                print("Invalid Entry.")
            
            print()
            print('''You had guessed following letters : ''', guesses[0:len(guesses)])
            
        else:
            print("Please enter only alphabets, not numbers or any other special characters !!!")
             
    print('''
Yes,the word is''', word + "! You got it in", len(guesses), "tries.")
Exemplo n.º 3
0
def update_charts(btn_node, btn_edge, btn_confirm, btn_cancel, node_data,
                  edge_data, e_name, e_src, e_tgt, e_event, e_condition,
                  e_action, n_label, n_name):
    global first_time
    if first_time:
        data = read_txt("./2020-result.txt")
    else:
        data = read_txt('./result.txt')
    if int(btn_confirm) > int(btn_cancel):
        div_children = [
            html.P(children='执行成功', style={'color': 'green'}),
            html.Button(id='confirm',
                        n_clicks=0,
                        children='确认',
                        style={
                            'color': 'blue',
                            'visibility': "hidden"
                        }),
            html.Button(id='cancel',
                        n_clicks=0,
                        children='取消',
                        style={
                            'color': 'blue',
                            'visibility': "hidden"
                        }),
        ]
        new_data = read_txt("./check.txt")
        create_txt(new_data, checking=False)
        first_time = False
        return new_data, div_children
    elif int(btn_cancel) > int(btn_confirm):
        div_children = [
            html.P(children='已取消执行', style={'color': 'green'}),
            html.Button(id='confirm',
                        n_clicks=0,
                        children='确认',
                        style={
                            'color': 'blue',
                            'visibility': "hidden"
                        }),
            html.Button(id='cancel',
                        n_clicks=0,
                        children='取消',
                        style={
                            'color': 'blue',
                            'visibility': "hidden"
                        }),
        ]
        return data, div_children
    else:
        new_data = copy.deepcopy(data)
        if int(btn_edge) > int(
                btn_node
        ) and e_name and e_src and e_tgt and e_event and e_condition and e_action:
            e_edge = {
                "id": e_src + e_tgt,
                "source": e_src,
                "target": e_tgt,
                "name": e_name,
                "event": e_event,
                "cond": e_condition,
                "action": e_action,
                "color": "black"
            }
            new_data.append({"data": e_edge})
        elif int(btn_node) > int(btn_edge) and n_label and n_name:
            new_data.append({
                "data": {
                    "id": n_label,
                    "label": n_label,
                    'name': n_name,
                    "color": "gray"
                }
            })
        elif node_data:
            dict_node_data = {"data": node_data}
            new_data.remove(dict_node_data)
        elif edge_data:
            edge_node_data = {"data": edge_data}
            new_data.remove(edge_node_data)

        create_txt(new_data, checking=True)  # 创建check文件
        check_success = check()  # 检查是否可以执行

        if check_success == 'Yes':
            div_children = [
                html.P(children='执行成功', style={'color': 'green'}),
                html.Button(id='confirm',
                            n_clicks=0,
                            children='确认',
                            style={
                                'color': 'blue',
                                'visibility': "hidden"
                            }),
                html.Button(id='cancel',
                            n_clicks=0,
                            children='取消',
                            style={
                                'color': 'blue',
                                'visibility': "hidden"
                            }),
            ]
            create_txt(new_data, checking=False)
            first_time = False
            return new_data, div_children
        elif check_success == 'No':
            div_children = [
                html.P(children='执行失败', style={'color': 'red'}),
                html.Button(id='confirm',
                            n_clicks=0,
                            children='确认',
                            style={
                                'color': 'blue',
                                'visibility': "hidden"
                            }),
                html.Button(id='cancel',
                            n_clicks=0,
                            children='取消',
                            style={
                                'color': 'blue',
                                'visibility': "hidden"
                            }),
            ]
            return data, div_children
        else:
            div_children = [
                html.P(children='存在风险,确认执行吗?', style={'color': 'red'}),
                html.Button(id='confirm',
                            n_clicks=0,
                            children='确认',
                            style={
                                'color': 'blue',
                                'visibility': "visible"
                            }),
                html.Button(id='cancel',
                            n_clicks=0,
                            children='取消',
                            style={
                                'color': 'blue',
                                'visibility': "visible"
                            }),
            ]
            return data, div_children