Exemplo n.º 1
0
    apps.append(filename)
    print(filename)
    for app in apps:
        label = tk.Label(frame, text=app, bg="grey")
        label.pack()


def runApps():
    for app in apps:
        os.startfile(app)


canvas = tk.Canvas(root, height=700, width=700, bg="#263D42")
canvas.pack()

frame = tk.Frame(root, bg="white")
frame.place(relwidth=0.8, relheight=0.8, relx=0.1, rely=0.1)

openFile = tk.Button(root, text="Add Apps", padx=10,
                     pady=5, fg="white", bg="#263D42", command=addApp)
openFile.pack()

runApps = tk.Button(root, text="Run Apps", padx=10,
                    pady=5, fg="white", bg="#263D42", command=runApps)
runApps.pack()

for app in apps:
    label = tk.Label(frame, text=app)
    label.pack()

root.mainloop()
Exemplo n.º 2
0
        detail = "" if optiondetail.get() == "No" else "-detail"
        out = "" if len(entry.get()) == 0 else "-o %s" %entry.get()

        if f2 is None:
            subprocess.call('python fingeRNAt.py -r %s -f %s %s %s %s %s %s %s' % (f1, option.get(), dha, wrapper, addH, out, h2o, detail), shell = True)
        else:
            subprocess.call('python fingeRNAt.py -r %s -l %s -f %s %s %s %s %s %s %s' % (f1, f2, option.get(), dha, wrapper, addH, out, h2o, detail), shell = True)

root = tk.Tk()
root.title("fingeRNAt")
root.geometry("575x880")
root.resizable(width = False, height = False)

# Intro

app_intro = tk.Frame(root,bd=16, relief='sunken')
app_intro.grid(row = 0, column = 0)

intro =  tk.Label(app_intro, text = "Welcome to fingeRNAt program!")
intro.grid(row = 0, column = 0, sticky = tk.W + tk.E, pady = 5, columnspan = 2)

intro2 = tk.Label(app_intro, text = "Choose your inputs and parametres to calculate Structural Interaction Fingerprint (SIFt)")
intro2.grid(row = 1, column = 0, sticky = tk.W + tk.E, columnspan = 2)

# Input files choice

app1 = tk.Frame(root)
app1.grid(row = 1, column=  0, pady = 10)

lbl1 = tk.Label(app1, text = "Choose path to RNA/DNA file")
lbl1.grid(row = 0, column = 0, sticky = tk.W )
Exemplo n.º 3
0
# to rename the title of the window
window.title("Teleop")
window.minsize(800,500)
# pack is used to show the object in the window

# You will create two text labels namely 'username' and 'password' and and two input labels for them
tk.Label(window, text = "Controls", font=("", 24)).grid(row = 0, column = 0, sticky = '', pady = 10) #'username' is placed on position 00 (row - 0 and column - 0)
tk.Label(window, text = "Parameters", font=("", 24)).grid(row = 0, column = 2, sticky = '', pady = 10)

window.columnconfigure(0,weight=1)
window.columnconfigure(2,weight=4)
window.rowconfigure(0, weight = 0)
window.rowconfigure(2, weight = 1)
window.rowconfigure(3, weight = 4)

controls_frame = tk.Frame(window,name="controls_frame")
controls_frame.grid(row = 1, column = 0, sticky = 'NSEW')
params_frame = tk.Frame(window,name="params_frame")
params_frame.grid(row = 1, column = 2, sticky = 'NSEW')
wp_frame = tk.Frame(window,name="wp_frame")
wp_frame.grid(row = 3, column = 2, sticky = 'NSEW')

ttk.Separator(window, orient='vertical').grid(column=1, row=0, rowspan=2, sticky='NS')
ttk.Separator(window, orient='horizontal').grid(column=0, row=2, columnspan=4, sticky='NSEW')

# 'Entry' class is used to display the input-field for 'username' text label
btn_w = tk.Button(controls_frame, text = "W", width = 1, height = 2, name = 'btn_w')
btn_w.grid(row = 0, column = 1, sticky = 'S')

btn_a = tk.Button(controls_frame, text = "A", width = 1, height = 2, name = 'btn_a')
btn_a.grid(row = 1, column = 0, sticky = 'E')
Exemplo n.º 4
0
def open_win():
    ''' Opens Main Window '''
    global application, WinStat
    con = sqlite.connect("aquatech.sqlite")
    cur = con.cursor()

    WinStat = 'application'
    application = Tk()
    #application.wm_iconbitmap('favicon.ico')

    application.title("MP AquaTech PVT. LMT.")
    application.geometry("800x400")
    application.configure(background="white")
    application.state("zoomed")

    main_frame = tk.Frame(application, background="white")

    left_bottle = tk.Frame(main_frame, background="white")
    b_img = ImageTk.PhotoImage(Image.open('bottle.png'))
    panel = Label(left_bottle, image=b_img).pack(fill=BOTH, expand=1)
    left_bottle.grid(row=0, column=0, sticky="N")

    app_frame = tk.Frame(main_frame, background="white")
    ''' Main Window Picture '''
    img = ImageTk.PhotoImage(Image.open('collage.jpg'))
    panel = Label(app_frame, image=img).grid(row=0, column=0, columnspan=8)

    menu_bar = Menu(app_frame)
    bottle = Menu(menu_bar, tearoff=0)
    labour = Menu(menu_bar, tearoff=0)
    manage_clients = Menu(menu_bar, tearoff=0)
    expenses = Menu(menu_bar, tearoff=0)
    report = Menu(menu_bar, tearoff=0)
    '''Stock Maintainance'''
    bottle.add_command(label="Future Choice", command=future_choice)
    bottle.add_command(label="Payas", command=payas)
    bottle.add_command(label="Oras", command=oras)
    bottle.add_command(label="34 Grams", command=gram_34)
    '''Expiry Check'''
    labour.add_command(label="Labour Details", command=labour_details)
    labour.add_command(label="Attendance", command=attendance)
    labour.add_command(label="Over Time", command=ot)
    labour.add_command(label="Salary", command=labour_payment)
    '''Billing'''
    expenses.add_command(label="Enter Expenses", command=edit_expenses)
    expenses.add_command(label="View Expenses", command=view_expenses)
    '''Billing'''
    manage_clients.add_command(label="Add Clients", command=add_clients)
    manage_clients.add_command(label="View Clients", command=view_clients)

    menu_bar.add_cascade(label="Bottle", menu=bottle)
    menu_bar.add_cascade(label="Labour", menu=labour)
    menu_bar.add_cascade(label="Expenses", menu=expenses)
    menu_bar.add_cascade(label="Manage Clients", menu=manage_clients)
    menu_bar.add_cascade(label="Report", command=freport)
    menu_bar.add_cascade(label="Logout", command=again)
    application.config(menu=menu_bar)

    last_expenses = tk.Frame(app_frame, bg="white")
    tk.Label(last_expenses,
             background="white",
             font=("Belwe Bd BT", 20),
             text="Last Day Expenses",
             fg="blue").grid(row=1, column=1, columnspan=2)
    sql = "select * from expenses where adate='%s'" % (y)
    print(sql)
    cur.execute(sql)
    i = 3
    total = 0
    for result in cur:

        Label(last_expenses,
              background="white",
              font=("Belwe lt BT", 15),
              text=result[2]).grid(row=i, column=1)
        Label(last_expenses,
              background="white",
              font=("Belwe lt BT", 15),
              text=result[3]).grid(row=i, column=2)
        i += 1
        total += result[3]
    Label(last_expenses,
          background="white",
          font=("Belwe Bd BT", 15),
          text="-" * 40).grid(row=i, column=1, columnspan=2)
    Label(last_expenses,
          background="white",
          font=("Belwe Bd BT", 15),
          text="Total =  ").grid(row=i + 1, column=1)
    Label(last_expenses,
          background="white",
          font=("Belwe Bd BT", 15),
          text=total).grid(row=i + 1, column=2)
    last_expenses.grid(row=1, column=0, columnspan=2, sticky="N")

    last_sell = tk.Frame(app_frame, bg="white")
    tk.Label(last_sell,
             text="Last Day Sell",
             font=("Belwe Bd BT", 20),
             background="white",
             fg="blue").grid(row=0, column=0, columnspan=3)
    sql = "select * from sell where adate='%s'" % (y)
    print(sql)
    cur.execute(sql)
    i = 3
    total = 0
    for result in cur:

        Label(last_sell,
              text=result[2],
              font=("Belwe lt BT", 15),
              background="white").grid(row=i, column=0)
        Label(last_sell,
              text=result[6],
              font=("Belwe lt BT", 15),
              background="white").grid(row=i, column=1)
        Label(last_sell,
              text=result[7],
              font=("Belwe lt BT", 15),
              background="white").grid(row=i, column=2)
        i += 1
        total += result[6]
    Label(last_sell,
          text="-" * 40,
          font=("Belwe Bd BT", 15),
          background="white").grid(row=i, column=0, columnspan=3)
    Label(last_sell,
          text="Total",
          font=("Belwe Bd BT", 15),
          background="white").grid(row=i + 1, column=0)
    Label(last_sell, text=" = ", font=("Belwe Bd BT", 15),
          background="white").grid(row=i + 1, column=1)
    Label(last_sell, text=total, font=("Belwe Bd BT", 15),
          background="white").grid(row=i + 1, column=2)
    last_sell.grid(row=1, column=2, columnspan=3, sticky="N")

    not_paid = tk.Frame(app_frame, background="white")
    tk.Label(not_paid,
             text="Payment Pending",
             font=("Belwe Bd BT", 20),
             background="white",
             fg="blue").grid(row=1, column=0, columnspan=3)
    sql = "select * from sell where date(adate)<=date('%s') and paid='not paid' order by adate" % (
        f)
    print(sql)
    cur.execute(sql)
    i = 3
    total = 0
    for result in cur:

        Label(not_paid,
              text=result[1],
              font=("Belwe lt BT", 15),
              background="white").grid(row=i, column=0)
        Label(not_paid,
              text=result[2],
              font=("Belwe lt BT", 15),
              background="white").grid(row=i, column=1)
        Label(not_paid,
              text=result[6],
              font=("Belwe lt BT", 15),
              background="white").grid(row=i, column=2)
        i += 1
    Label(not_paid,
          text="-" * 40,
          font=("Belwe Bd BT", 15),
          background="white").grid(row=i, column=0, columnspan=3)
    not_paid.grid(row=1, column=5, columnspan=3, sticky="N")

    app_frame.grid(row=0, column=1, sticky="N")

    right_bottle = tk.Frame(main_frame, background="white")
    r_img = ImageTk.PhotoImage(Image.open('bottle.png'))
    panel = Label(right_bottle, image=r_img, relief=FLAT).pack(fill=BOTH,
                                                               expand=1)
    right_bottle.grid(row=0, column=2, sticky="N")

    main_frame.pack(anchor=CENTER)

    application.mainloop()
Exemplo n.º 5
0
    def __init__(self):
        self.window = tk.Tk()
        self.window.title("linked_list_insertionsort")
        self.window.protocol("WM_DELETE_WINDOW", self.kill_callback)
        self.window.geometry("430x350")

        frame = tk.Frame(self.window)
        frame.pack(padx=0, pady=5, fill=tk.BOTH, expand=True)
        frame.rowconfigure(1, weight=1)
        frame.columnconfigure(0, weight=1)
        frame.columnconfigure(1, weight=1)
        frame.columnconfigure(2, weight=1)

        button = tk.Button(frame,
                           text="Randomize",
                           width=10,
                           command=self.randomize)
        button.grid(row=0, column=0, padx=5, pady=2)
        button = tk.Button(frame,
                           text="Insertionsort",
                           width=10,
                           command=self.insertionsort)
        button.grid(row=0, column=1, padx=5, pady=2)
        button = tk.Button(frame,
                           text="Selectionsort",
                           width=10,
                           command=self.selectionsort)
        button.grid(row=0, column=2, padx=5, pady=2)

        frame2 = tk.Frame(frame)
        frame2.grid(row=1, column=0, sticky=tk.W + tk.E + tk.N + tk.S)
        scrollbar = tk.Scrollbar(frame2)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        self.unsorted_listbox = tk.Listbox(frame2)
        self.unsorted_listbox.pack(padx=5,
                                   pady=2,
                                   side=tk.TOP,
                                   fill=tk.BOTH,
                                   expand=True)
        self.unsorted_listbox.config(yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.unsorted_listbox.yview)

        frame2 = tk.Frame(frame)
        frame2.grid(row=1, column=1, sticky=tk.W + tk.E + tk.N + tk.S)
        scrollbar = tk.Scrollbar(frame2)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        self.insertionsort_listbox = tk.Listbox(frame2)
        self.insertionsort_listbox.pack(padx=5,
                                        pady=2,
                                        side=tk.TOP,
                                        fill=tk.BOTH,
                                        expand=True)
        self.insertionsort_listbox.config(yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.insertionsort_listbox.yview)

        frame2 = tk.Frame(frame)
        frame2.grid(row=1, column=2, sticky=tk.W + tk.E + tk.N + tk.S)
        scrollbar = tk.Scrollbar(frame2)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        self.selectionsort_listbox = tk.Listbox(frame2)
        self.selectionsort_listbox.pack(padx=5,
                                        pady=2,
                                        side=tk.TOP,
                                        fill=tk.BOTH,
                                        expand=True)
        self.selectionsort_listbox.config(yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.selectionsort_listbox.yview)

        # Force focus so Alt+F4 closes this window and not the Python shell.
        self.window.focus_force()
        self.window.mainloop()

def first():
    tkinter.Label(frame1, text="Enter number of rounds").grid(row=0, column=0)
    number_of_rounds = tkinter.Entry(frame1)
    number_of_rounds.grid(row=0, column=1)
    tkinter.Label(frame1, text="Enter number of players").grid(row=1, column=0)
    number_of_players = tkinter.Entry(frame1)
    number_of_players.grid(row=1, column=1)
    tkinter.Button(frame1, text="next",
                   command=lambda players=number_of_players, rounds=number_of_rounds: second(number_of_players,
                                                                                             number_of_rounds)).grid(
        row=3, column=1)


players = []
position = {}
i = 0
starting_time = 0
number_to_find = 0
number_of_rounds = 0
number_of_players = 0
t = tkinter.Tk()
t.title("Finding Numbers")
frame1 = tkinter.Frame(t)
frame2 = tkinter.Frame(t)
first()
frame1.grid(row=0, column=0)
frame2.grid(row=1, column=0)
t.mainloop()
Exemplo n.º 7
0
def forgot_pass():
    root.destroy()
    ''' Opens Create Window '''
    global forgot_window, WinStat, un, question_var, ans
    WinStat = 'forgot_window'
    forgot_window = Tk()
    forgot_window.configure(background="white")
    forgot_window.state("zoomed")

    #forgot_window.wm_iconbitmap('favicon.ico')

    forgot_main_frame = tk.Frame(forgot_window, background="white")

    img = ImageTk.PhotoImage(Image.open('front.png'))
    panel = Label(forgot_main_frame, image=img).grid(row=0,
                                                     column=0,
                                                     columnspan=5)

    Label(forgot_main_frame,
          text='Enter Details to Get Your Password',
          font=("Belwe lt BT", 15),
          background="white").grid(row=1, column=0, columnspan=5)
    Label(
        forgot_main_frame,
        text='--------------------------------------------------------------',
        font=("Belwe lt BT", 15),
        background="white").grid(row=3, column=0, columnspan=5)
    Label(forgot_main_frame,
          text='Username',
          font=("Belwe lt BT", 15),
          background="white").grid(row=4, column=1)
    un = Entry(forgot_main_frame, font=("Belwe lt BT", 15), width=15)
    un.grid(row=4, column=2)

    question_var = StringVar()
    choices = [
        'Who is your fav. teacher ?', ' What is your childhod name?',
        'What is your Birth Place ?', 'What is your fav. Dish ?'
    ]
    question_var.set(choices[1])  # set the default option
    question = OptionMenu(forgot_main_frame, question_var, *choices)
    Label(forgot_main_frame,
          text="Choose a dish",
          font=("Belwe lt BT", 15),
          background="white").grid(row=6, column=1)
    question.grid(row=6, column=2)

    Label(forgot_main_frame,
          text='Answer',
          font=("Belwe lt BT", 15),
          background="white").grid(row=8, column=1)
    ans = Entry(forgot_main_frame, font=("Belwe lt BT", 15), width=15)
    ans.grid(row=8, column=2)
    Label(forgot_main_frame,
          text='',
          font=("Belwe lt BT", 15),
          background="white").grid(row=9, column=0, columnspan=5)
    tk.Button(forgot_main_frame,
              text='Recover Password',
              font=("Belwe lt BT", 15),
              command=get_pass).grid(row=10, column=1)
    tk.Button(forgot_main_frame,
              width=6,
              text='Close',
              font=("Belwe lt BT", 15),
              command=forgot_main_frame.destroy).grid(row=10, column=2)
    Label(
        forgot_main_frame,
        text='--------------------------------------------------------------',
        font=("Belwe lt BT", 15),
        background="white").grid(row=11, column=0, columnspan=5)
    Label(forgot_main_frame,
          text='Have Account',
          font=("Belwe lt BT", 15),
          background="white").grid(row=12, column=0, columnspan=2)
    tk.Button(forgot_main_frame,
              text=' Login Here',
              font=("Belwe lt BT", 15),
              command=again).grid(row=12, column=2)
    Label(
        forgot_main_frame,
        text='--------------------------------------------------------------',
        font=("Belwe lt BT", 15),
        background="white").grid(row=13, column=0, columnspan=5)

    forgot_main_frame.pack(anchor=CENTER)
    forgot_window.mainloop()
Exemplo n.º 8
0
hourSpinner = tkinter.Spinbox(timeFrame, width=2, value=tuple(range(0,24)))
minuteSpinner = tkinter.Spinbox(timeFrame, width=2, from_=0, to=59)
secondSpinner = tkinter.Spinbox(timeFrame, width=2, from_=0, to=59)
hourSpinner.grid(row=0, column=1)
tkinter.Label(timeFrame, text=':').grid(row=0, column=1)
minuteSpinner.grid(row=0, column=2)
tkinter.Label(timeFrame, text=':').grid(row=0, column=1)
secondSpinner.grid(row=0, column=4)
tkinter.Label(timeFrame, text=':').grid(row=0, column=1)

timeFrame['padx'] = 36

#frame for the date spinners

dateFrame = tkinter.Frame(mainWindow)
dateFrame.grid(row=4, column=0, sticky="new")

#Date labels

dayLabel = tkinter.Label(dateFrame, text="day")
montLabel = tkinter.Label(dateFrame, text="month")
yearLabel = tkinter.Label(dateFrame, text="year")
dayLabel.grid(row=0, column=0, sticky='w')
montLabel.grid(row=0, column=1, sticky='w')
yearLabel.grid(row=0, column=2, sticky='w')

#date spinners

daySpin = tkinter.Spinbox(dateFrame, width=5, from_=1, to=31)
monthSpin = tkinter.Spinbox(dateFrame, width=5, values = ("Jan", "feb", "mar", "apr", "may", "jun", "aug", "wrze", "paz", "list", "grud" ))
Exemplo n.º 9
0
    def __init__(self, window_manager, **kw):
        super().__init__(**kw)
        self.window_manager = window_manager
        self.database: DataBase = window_manager.database

        # Frame
        input_frame = tkinter.Frame(self)
        label_frame = tkinter.Frame(input_frame)
        entry_frame = tkinter.Frame(input_frame)
        input_frame.pack()
        label_frame.pack(side='left')
        entry_frame.pack(side='right')

        # Input
        number_label = tkinter.Label(label_frame, text='运单号')
        number_label.pack()
        self.number_entry = tkinter.Entry(entry_frame)
        self.number_entry.bind('<Return>', self.take)
        self.number_entry.focus_set()
        self.number_entry.pack()

        # Button
        button_frame = tkinter.Frame(self)
        button_frame.pack()
        self.not_taken_mode = True

        def switch():
            if self.not_taken_mode:
                self.not_taken_mode = False
            else:
                self.not_taken_mode = True
            self.set_table()

        take_button = tkinter.Button(button_frame,
                                     text='领取',
                                     command=self.take)
        display_button = tkinter.Button(button_frame,
                                        text='显示/隐藏已领取',
                                        command=switch)
        take_button.pack(side='left')
        display_button.pack(side='right')

        # Data Frame
        data_frame = tkinter.Frame(self)
        data_frame.pack()

        # Table
        self.table = ttk.Treeview(data_frame,
                                  show='headings',
                                  selectmode='browse',
                                  columns=('时间', '快递公司', '收件人', '运单号', '状态'))
        self.table.column('时间', width=100, anchor='center')
        self.table.column('快递公司', width=100, anchor='center')
        self.table.column('收件人', width=100, anchor='center')
        self.table.column('运单号', width=100, anchor='center')
        self.table.column('状态', width=100, anchor='center')
        self.table.heading('时间', text='时间')
        self.table.heading('快递公司', text='快递公司')
        self.table.heading('收件人', text='收件人')
        self.table.heading('运单号', text='运单号')
        self.table.heading('状态', text='状态')
        self.table.bind('<Return>', self.take)
        self.table.pack(side='left')
        self.set_table()

        # Scrollbar
        scrollbar = tkinter.Scrollbar(data_frame,
                                      orient='vertical',
                                      command=self.table.yview)
        scrollbar.pack(side='right', fill='y')
        self.table.configure(yscrollcommand=scrollbar.set)

        tkinter.Label(self, text=constant.SEARCH_HELP, font=('宋体', 24)).pack()
Exemplo n.º 10
0
def main(argv):
    display = Display()
    # Xinput
    extension_info = display.query_extension("XInputExtension")
    xinput_major = extension_info.major_opcode

    typing_tracker = TypingTracker(None)

    aliasing_map = AliasMap(open("halfquerty-v2.bin", "rb").read())

    version_info = display.xinput_query_version()
    print("Found XInput version %u.%u" % (
        version_info.major_version,
        version_info.minor_version,
    ))

    xscreen = display.screen()
    xscreen.root.xinput_select_events([
        (
            xinput.AllDevices,
            xinput.KeyPressMask
            | xinput.KeyReleaseMask
            | xinput.ButtonPressMask
            | xinput.RawButtonPressMask,
        ),
    ])

    # Window
    win = tk.Tk()
    win.geometry("+100+100")

    win.wm_attributes("-topmost", 1)
    win.attributes("-alpha", 0.5)
    win.config(bg=BG_NOHL)
    win.overrideredirect(True)

    container = tk.Frame(win, cnf={"bg": BG_NOHL})
    container.pack()

    before_txt_var = tk.StringVar()
    before_txt_var.set("")
    before_label = tk.Label(
        container,
        textvariable=before_txt_var,
        cnf={
            "font": "monospace 12",
            "fg": FG_NOHL,
            "bg": BG_NOHL,
            "height": 1
        },
    )

    sel_txt_var = tk.StringVar()
    sel_txt_var.set("")
    sel_label = tk.Label(
        container,
        textvariable=sel_txt_var,
        cnf={
            "font": "monospace 12",
            "fg": FG_SEL,
            "bg": BG_SEL,
            "height": 1
        },
    )

    after_txt_var = tk.StringVar()
    after_txt_var.set("")
    after_label = tk.Label(
        container,
        textvariable=after_txt_var,
        cnf={
            "font": "monospace 12",
            "fg": FG_NOHL,
            "bg": BG_NOHL,
            "height": 1
        },
    )

    suggestion_container = tk.Frame(win, cnf={"bg": BG_NOHL})
    suggestion_labels = []
    suggestion_idx = 0

    before_label.pack(side=tk.LEFT)
    sel_label.pack(side=tk.LEFT)
    after_label.pack(side=tk.LEFT)
    suggestion_container.pack(side=tk.BOTTOM)

    vocab = Vocab.loads(open("vocab.json", "r").read())
    ui = UInput()

    suggester = Suggester(vocab, edit_sequence_config=EditSequencesConfig())

    try:
        while True:
            i = 0
            while display.pending_events() > 0 and i < 20:
                i += 1
                event = display.next_event()

                # print(event)
                if not event or event.type != 35:
                    continue

                if event.evtype == xinput.KeyPress:
                    keycode = event.data.detail
                    keysym = display.keycode_to_keysym(keycode, 0)
                    if keycode == STEP_NEXT:
                        suggestion_idx = min(suggestion_idx + 1,
                                             len(suggestion_labels) - 1)
                    elif keycode == STEP_PREV:
                        suggestion_idx = max(suggestion_idx - 1, 0)
                    elif keycode == SELECT_ACTIVE:
                        # correct the word to the suggestion
                        before_text, after_text = typing_tracker.get_text()
                        last_word = get_last_word(before_text)

                        suggestions = suggester.get_prefix_suggestions(
                            lastword)

                        if suggestion_idx < len(suggestions):
                            correct_typing_buffer(display, ui, last_word,
                                                  suggestions[suggestion_idx])

                    else:
                        typing_tracker.handle_keypress_sym(keysym)
                        suggestion_idx = 0

                elif event.evtype == xinput.KeyRelease:
                    keycode = event.data.detail
                    keysym = display.keycode_to_keysym(keycode, 0)
                    typing_tracker.handle_keyrelease_sym(keysym)
                elif (event.evtype == xinput.ButtonPress
                      or event.evtype == xinput.RawButtonPress):
                    typing_tracker.reset_buff()
            if i >= 1:
                before_text, after_text = typing_tracker.get_text()
                before_txt_var.set(before_text)
                h = 1 + before_text.count("\r")
                before_label.configure({"height": h})
                after_txt_var.set(after_text)

                lastword = get_last_word(before_text)
                suggestions = suggester.get_prefix_suggestions(lastword)
                while len(suggestions) > len(suggestion_labels):
                    l = SuggestionLabel(suggestion_container, )
                    suggestion_labels.append(l)

                while len(suggestions) < len(suggestion_labels):
                    l = suggestion_labels.pop()
                    l.dispose()

                for i, (sugg,
                        label) in enumerate(zip(suggestions,
                                                suggestion_labels)):
                    label.update(sugg, i == suggestion_idx)
            win.update_idletasks()
            win.update()
    except KeyboardInterrupt as e:
        return 0
    except Exception as e:
        print(e)
        print(full_stack())
    finally:
        win.destroy()
        return 1
Exemplo n.º 11
0
 def __init__(self, root):
     frame = tk.Frame(root)
     # frame.pack()
     frame.pack(side = tk.LEFT, padx = 30, pady = 60)
     self.hi_there = tk.Button(frame, text="hello python", fg = "blue", bg = "red", command = self.say_hi)
     self.hi_there.pack()
Exemplo n.º 12
0
def turn_interface(root):

	main_frame = tk.Frame(root, bg=bg_color, bd=0)
	main_frame.place(relx = 0, rely = 0, relwidth=1, relheight=1)

	"""HEADER"""

	subframe_name = tk.Frame(main_frame, bg=second_color, bd=0)
	subframe_name.place(relx=0, rely=0, relwidth=1, relheight=0.06)

	name_label = tk.Label(subframe_name, text='Maxwell pendulum modeling', font=(headers_font, 30), bg=second_color)
	name_label.place(relx = 0.05, rely = 0.5, anchor='w')

	author_label = tk.Label(subframe_name, text='designed by Timofey Antipov', font=(headers_font, 10), bg=second_color)
	author_label.place(relx=0.9, rely=0.95, anchor='se')

	"""END OF HEADER"""


	"""PARAMETERS FRAME"""

	parameters_frame = MyFrame()
	parameters_frame.set_frame(main_frame, 0.02, 0.075, 0.45, 0.12)
	parameters_frame.set_label("Model\nparameters", 0.25)

	# Radius area

	r_ax = Param_block(parameters_frame.frame, "Axle radius (cm):", 1, 0.25, 0, 0.25)
	r_disk = Param_block(parameters_frame.frame, "Disk radius (cm):", 1, 0.25, 0.5, 0.75)

	# Mass area

	m_ax = Param_block(parameters_frame.frame, "Axle mass (g):", 1, 0.5, 0, 0.25)
	m_disk = Param_block(parameters_frame.frame, "Disk mass (g):", 1, 0.5, 0.5, 0.75)

	# Length area

	l_cyl = Param_block(parameters_frame.frame, "Cylinder length (cm):", 1, 0.75, 0, 0.25)
	l_thread = Param_block(parameters_frame.frame, "Thread length (cm):", 1, 0.75, 0.5, 0.75)

	"""END OF PARAMETERS FRAME"""


	"""INITIAL CONDITIONS"""

	conditions_frame = MyFrame()
	conditions_frame.set_frame(main_frame, 0.02, 0.215, 0.45, 0.06)
	conditions_frame.set_label("Initial conditions", 0.25)

	z_0 = Param_block(conditions_frame.frame, "Coordinate:", 0, 0.25, 0, 0.5, 0.5)
	v_0 = Param_block(conditions_frame.frame, "Velocity:", 0, 0.5, 0, 0.5, 0.5)

	direct_label = tk.Label(conditions_frame.frame, text="Direction:", font=(general_font, 16), bg=bg_color, fg=second_color)
	direct_label.place(relx=0.75, rely=0, relwidth=0.25, relheight=0.5)

	dir_var = tk.StringVar()

	direct_radio_up = tk.Radiobutton(conditions_frame.frame, text="Up", font=(general_font, 14), variable=dir_var, value='up')
	direct_radio_up.place(relx=0.75, rely=0.5, relwidth=0.125, relheight=0.5)
	direct_radio_down = tk.Radiobutton(conditions_frame.frame, text='Down', font=(general_font, 14), variable=dir_var, value='down')
	direct_radio_down.place(relx=0.875, rely=0.5, relwidth=0.125, relheight=0.5)


	"""END OF INITIAL CONDITIONS"""

	"""CONTROL PANEL"""

	control_frame = MyFrame()
	control_frame.set_frame(main_frame, 0.02, 0.295, 0.45, 0.06)
	control_frame.set_label("Controls", 0.25)

	entries = [m_disk.field, m_ax.field, r_disk.field,
	r_ax.field, l_cyl.field, l_thread.field, z_0.field, v_0.field, direct_radio_up, direct_radio_down]

	start_command = lambda: controls.start(start_button.button, stop_button.button, [m_disk.field.get(), m_ax.field.get(), r_disk.field.get(),
	r_ax.field.get(), l_cyl.field.get(), l_thread.field.get(), z_0.field.get(), v_0.field.get(), str(dir_var.get())], entries)
	stop_command = lambda: controls.stop(start_button.button, stop_button.button)

	start_button = Control_button(control_frame.frame, "Start", start_command, 0.3, 0.1)
	stop_button = Control_button(control_frame.frame, "Stop", stop_command, 0.65, 0.1)

	"""END OF CONTROL PANEL"""


	"""GRAPH 1"""

	graph1_frame = MyFrame()
	graph1_frame.set_frame(main_frame, 0.02, 0.41, 0.45, 0.55)
	graph1_frame.set_label("Time dependence", Width=1, Height=0.1)

	pic1 = tk.Frame(graph1_frame.frame, bg='white')
	pic1.place(relx=0,rely=0.1, relwidth=1, relheight=0.9)

	controls.show_time_dep(pic1)

	"""END OF GRAPH 1"""


	"""GRAPH 2"""

	graph2_frame = MyFrame()
	graph2_frame.set_frame(main_frame, 0.53, 0.41, 0.45, 0.55)
	graph2_frame.set_label("Phase portrait", Width=1, Height=0.1)

	pic2 = tk.Frame(graph2_frame.frame, bg='white')
	pic2.place(relx=0,rely=0.1, relwidth=1, relheight=0.9)

	controls.show_portrait(pic2)

	"""END OF GRAPH 2"""
	

	"""VALUES TABLE"""

	table_frame = MyFrame()
	table_frame.set_frame(main_frame, 0.53, 0.075, 0.45, 0.28)
	table_frame.set_label("Result data", Width=1, Height=0.1)

	pic3 = tk.Frame(table_frame.frame, bg='white')
	pic3.place(relx=0,rely=0.1, relwidth=1, relheight=0.9)

	controls.show_table(pic3)

	"""END OF VALUES TABLE"""
Exemplo n.º 13
0
	def set_frame(self,parent_container, x_shift, y_shift, Width, Height):
		self.frame = tk.Frame(parent_container, bg=bg_color, highlightthickness=3)
		self.frame.config(highlightbackground = second_color, highlightcolor= second_color)
		self.frame.place(relx=x_shift, rely=y_shift, relwidth=Width, relheight=Height)
Exemplo n.º 14
0
entryspan = 2

# Set up row layout
accuracyRow = 0
shotsRow = accuracyRow + 1
heatRow = shotsRow + 1
caliberRow = heatRow + 1
inputRow = caliberRow
testSampleRow = inputRow + 1
buttonRow = testSampleRow + 1
secondButtonRow = buttonRow + 1
debugStartRow = secondButtonRow + 1

# Expanded frames
debugFrame = tk.Frame(top, bg=themeColor)
debugFrame.grid(row=debugStartRow, columnspan=3)

hitFrame = tk.Frame(top, bg=themeColor)
hitFrame.grid(row=debugStartRow, columnspan=3)

buttonFrame = tk.Frame(top, bg=themeColor)
buttonFrame.grid(row=buttonRow, columnspan=3)

# Trials section
tk.Label(top, text="Number Trials:", anchor="w", bg=themeColor,
         fg='white').grid(sticky='w', row=testSampleRow, column=0)
totalTestSlider = tk.Scale(top,
                           from_=1,
                           to=20,
                           orient=HORIZONTAL,
Exemplo n.º 15
0
# Labels
image_label = tk.Label(root, image=photo)
image_label.place(x=0, y=0, relwidth=1, relheight=1)
image_label.bind('<Configure>', resize_image)

name_label = tk.Label(root,
                      text='Enter Card Name: ',
                      font=('calibre', 10, 'bold'))
name_label.pack(pady=20, padx=20)
name_entry = tk.Entry(root,
                      textvariable=name_var,
                      font=('calibre', 10, 'normal'))
name_entry.pack(pady=20)

frame = tk.Frame(root, relief='raised', borderwidth=2)
frame.pack(fill=tk.BOTH, expand=tk.YES)
frame.pack_propagate(False)

text = tk.Text(frame, width=120, height=10)
text.pack(pady=1)

# Buttons
actualizar_btn = tk.Button(frame,
                           text='Update Database',
                           command=Update_database)
actualizar_btn.pack(pady=20)
submit_btn = tk.Button(frame, text='Submit', command=Seeker)
submit_btn.pack(pady=20)
root.bind('<Return>', lambda event=None: submit_btn.invoke(
))  # Click submit by pressing Enter using lambda to doing it continuosly.
Exemplo n.º 16
0
class App(object):
    #GUI-----------------------------------------|

    global top_frame
    top_frame = tk.Frame(bg="#5E647D")
    top_frame.configure()
    top_frame.grid(row=2, column=0, sticky="nsew")

    top_frame.columnconfigure(0, weight=1)
    top_frame.columnconfigure(1, weight=1)
    top_frame.columnconfigure(2, weight=1)
    top_frame.columnconfigure(3, weight=1)
    top_frame.columnconfigure(4, weight=1)
    top_frame.columnconfigure(5, weight=1)
    top_frame.columnconfigure(6, weight=1)
    top_frame.columnconfigure(7, weight=1)
    top_frame.rowconfigure(2, weight=1)

    #Function for linking new rows to the "Add Rule" button
    def __init__(self):

        self.num_rows = 1
        #Auto run function at start
        self.new_row()
        add_rule_button = tk.Button(bottom_center_frame,
                                    text='New Rule',
                                    font="bold",
                                    bg="#5E647D",
                                    fg="white",
                                    command=self.new_row)
        add_rule_button.grid(row=0, column=0)

        #Update button
        update_button = tk.Button(bottom_center_frame,
                                  text="Update",
                                  command=self.button_press,
                                  font="bold",
                                  bg="#5E647D",
                                  fg="white")
        update_button.grid(row=0, column=2)

    #rule num column header and enty box
    rule_header = tk.Label(top_frame,
                           text='  RULE No.  ',
                           font="bold",
                           bg="#5E647D",
                           fg="white")
    rule_header.grid(row=0, column=0)
    #input/output/fowrward column header and entry box
    input_output_forward = tk.Label(top_frame,
                                    text='  INPUT/OUTPUT/FORWARD  ',
                                    font="bold",
                                    fg="white",
                                    bg="#5E647D")
    input_output_forward.grid(row=0, column=1)
    #Source IP column header and entry box
    source_ip = tk.Label(top_frame,
                         text='  SOURCE IP  ',
                         font="bold",
                         bg="#5E647D",
                         fg="white")
    source_ip.grid(row=0, column=2)
    #Source port column header and entry box
    source_port = tk.Label(top_frame,
                           text='  SOURCE PORT  ',
                           font="bold",
                           bg="#5E647D",
                           fg="white")
    source_port.grid(row=0, column=3)
    #Destination IP column header and entry box
    destination_ip = tk.Label(top_frame,
                              text='  DESTINATION IP  ',
                              font="bold",
                              bg="#5E647D",
                              fg="white")
    destination_ip.grid(row=0, column=4)
    #Destination port column header and entry box
    destination_port = tk.Label(top_frame,
                                text='  DESTINATION PORT  ',
                                font="bold",
                                bg="#5E647D",
                                fg="white")
    destination_port.grid(row=0, column=5)
    #Protocol column header and drop down box
    protocol = tk.Label(top_frame,
                        text='  PROTOCOL  ',
                        font="bold",
                        bg="#5E647D",
                        fg="white")
    protocol.grid(row=0, column=6)
    #Accept or Drop column header and drop down box
    accept_or_drop_label = tk.Label(top_frame,
                                    text='  ACCEPT/DROP  ',
                                    font="bold",
                                    bg="#5E647D",
                                    fg="white")
    accept_or_drop_label.grid(row=0, column=7)

    #Function to create a new rule row
    def new_row(self):
        global rule_counter
        global table_of_rules
        global row_count
        #COLUMN0
        rule_counter += 1
        new_rule = tk.Label(top_frame,
                            text=rule_counter,
                            font="bold",
                            bg="#5E647D",
                            fg="white")
        new_rule.grid(column=0, ipady=10)
        #COLUMN1
        global input_output_forward_options
        input_output_forward_options = tk.StringVar()
        input_output_forward_options.set("INPUT")
        global input_output_forward_button
        input_output_forward_button = tk.OptionMenu(
            top_frame, input_output_forward_options, "INPUT", "OUTPUT",
            "FORWARD")
        input_output_forward_button.config(bg="#5E647D", fg="white", width=14)
        input_output_forward_button.grid(column=1)
        #COLUMN2
        global source_ip_entry
        source_ip_entry = tk.Entry(top_frame, width=14)
        source_ip_entry.config(bg="#5E647D", fg="white")
        source_ip_entry.grid(column=2)
        #COLUMN3
        global source_port_entry
        source_port_entry = tk.Entry(top_frame, width=7)
        source_port_entry.config(bg="#5E647D", fg="white")
        source_port_entry.grid(column=3)
        #COLUMN4
        global dest_ip_entry
        dest_ip_entry = tk.Entry(top_frame, width=14)
        dest_ip_entry.config(bg="#5E647D", fg="white")
        dest_ip_entry.grid(column=4)
        #COLUMN5
        global dest_port_entry
        dest_port_entry = tk.Entry(top_frame, width=7)
        dest_port_entry.config(bg="#5E647D", fg="white")
        dest_port_entry.grid(column=5)
        #COLUMN6
        global protocol_options
        protocol_options = tk.StringVar()
        protocol_options.set("tcp")
        global protocol_button
        protocol_button = tk.OptionMenu(top_frame, protocol_options, "tcp",
                                        "udp", "icmp")
        protocol_button.config(bg="#5E647D", fg="white", width=7)
        protocol_button.grid(column=6)
        #COLUMN7
        global accept_or_drop_options
        accept_or_drop_options = tk.StringVar()
        accept_or_drop_options.set("ACCEPT")
        global accept_or_drop_button
        accept_or_drop_button = tk.OptionMenu(top_frame,
                                              accept_or_drop_options, "ACCEPT",
                                              "DROP")
        accept_or_drop_button.config(bg="#5E647D", fg="white", width=7)
        accept_or_drop_button.grid(column=7)

        self.num_rows += 1
        new_rule.grid(column=0, row=self.num_rows, sticky='WE')
        input_output_forward_button.grid(column=1, row=self.num_rows)
        source_ip_entry.grid(column=2, row=self.num_rows)
        source_port_entry.grid(column=3, row=self.num_rows)
        dest_ip_entry.grid(column=4, row=self.num_rows)
        dest_port_entry.grid(column=5, row=self.num_rows)
        protocol_button.grid(column=6, row=self.num_rows)
        accept_or_drop_button.grid(column=7, row=self.num_rows)
        row_count += 1

        global row_of_boxes
        # Dictionary to save placements of input on interface for a single row
        row_of_boxes = {}
        row_of_boxes = {
            'input_output_forward_button': input_output_forward_button,
            'source_ip_entry': source_ip_entry,
            'dest_ip_entry': dest_ip_entry,
            'protocol_button': protocol_button,
            'source_port_entry': source_port_entry,
            'dest_port_entry': dest_port_entry,
            'accept_or_drop_button': accept_or_drop_button
        }
        # Add row to table_of_rules list
        table_of_rules.append(row_of_boxes)
        #print(table_of_rules)

    #----------------FUNCTION FOR UPDATE BUTTON---------|
    def button_press(self):
        global row_of_boxes
        # Dictionary to save placements of input on interface for a single row
        row_of_boxes = {}
        row_of_boxes = {
            'input_output_forward_options': input_output_forward_options,
            'source_ip_entry': source_ip_entry,
            'dest_ip_entry': dest_ip_entry,
            'protocol_options': protocol_options,
            'source_port_entry': source_port_entry,
            'dest_port_entry': dest_port_entry,
            'accept_or_drop_options': accept_or_drop_options
        }
        # Add row to table_of_rules list
        # table_of_rules.append(row_of_boxes)
        rule = {}
        chain_box = ''
        chain_box = row_of_boxes['protocol_options']
        rule['protocol'] = chain_box.get()
        chain_box = row_of_boxes['input_output_forward_options']
        rule['input_output_forward'] = chain_box.get()
        chain_box = row_of_boxes['source_ip_entry']
        rule['source_ip'] = chain_box.get()
        chain_box = row_of_boxes['source_port_entry']
        rule['source_port'] = chain_box.get()
        chain_box = row_of_boxes['dest_ip_entry']
        rule['dest_ip'] = chain_box.get()
        chain_box = row_of_boxes['dest_port_entry']
        rule['dest_port'] = chain_box.get()

        chain_box = row_of_boxes['accept_or_drop_options']
        rule['accept_or_drop'] = chain_box.get()
        #print(rule['protocol']) #------>SANITY CHECK
        # print(f"sudo iptables -A {rule['input_output_forward']} -p {rule['protocol']} -s {rule['source_ip']} --sport {rule['source_port']} -d {rule['dest_ip']} --dport {rule['dest_port']} -j {rule['accept_or_drop']}")

        process = subprocess.Popen([
            f"sudo iptables -A {rule['input_output_forward']} -p {rule['protocol']} -s {rule['source_ip']} --sport {rule['source_port']} -d {rule['dest_ip']} --dport {rule['dest_port']} -j {rule['accept_or_drop']}"
        ],
                                   stderr=subprocess.STDOUT,
                                   stdout=subprocess.PIPE,
                                   shell=True)
        output, stderr_output = process.communicate()

        global current_label
        current_label.destroy()
        updated_process = subprocess.Popen(["sudo iptables -L"],
                                           stderr=subprocess.STDOUT,
                                           stdout=subprocess.PIPE,
                                           shell=True)
        current, stderr_current = updated_process.communicate()
        current_label = tk.Label(window,
                                 text=current,
                                 font="bold",
                                 fg="white",
                                 bg="#5E647D")
        current_label.grid(row=1)

        #print(output)
        #---END OF FUNCTION FOR UPDATE BUTTON-------|

    # --------------DELETE ALL FUNCTION --------------|
    def delete_all():
        # table=iptc.Table(iptc.Table.FILTER)
        # table.flush()
        # table.refresh()
        global current_label
        current_label.destroy()
        cleared_process = subprocess.Popen(
            ["sudo iptables -F && sudo iptables -L"],
            stderr=subprocess.STDOUT,
            stdout=subprocess.PIPE,
            shell=True)
        current, stderr_current = cleared_process.communicate()
        current_label = tk.Label(window,
                                 text=current,
                                 font="bold",
                                 fg="white",
                                 bg="#5E647D")
        current_label.grid(row=1)

    #----------END OF DELETE ALL FUNCTION ----------------|

    #BUTTONS FRAMES FOR BUTTONS

#Bottom frame containing the "Add Rule", "Remove Rule", and "Save" buttons
    global bottom_frame
    bottom_frame = tk.LabelFrame(window, bg="#5E647D")
    bottom_frame.grid(row=3, column=0, sticky='se', padx=20, pady=20)

    global bottom_center_frame
    bottom_center_frame = tk.LabelFrame(window, bg="#5E647D")
    bottom_center_frame.grid(row=3, column=0, sticky='s', padx=20, pady=20)
    # #Remove rule button
    # remove_rule_button = Button(bottom_center_frame, text='Remove Rule', font="bold", bg="#353535", fg="#80FF00")
    # remove_rule_button.grid(row=0, column=1)
    # remove_rule_button.bind("<Button-1>", Remove_Rules)
    # # Remove Rule Entry Box
    # global remove_rule_entry_box
    # remove_rule_button.grid(row=0, column=1)
    # remove_rule_entry_box = Entry(bottom_center_frame, width=12, bg="#353535", fg="#80FF00")
    # remove_rule_entry_box.grid(row=0, column=2, ipady=5)

    #delete all button
    delete_all = tk.Button(bottom_frame,
                           text='Delete All',
                           font="bold",
                           bg="#5E647D",
                           fg="white",
                           command=delete_all)
    delete_all.grid(row=0, column=0)
Exemplo n.º 17
0
    def __init__(self, *args, **kwargs):
        FrameLifts.__init__(self, *args, **kwargs)

        self.winfo_toplevel().title("Select Hazard Type")
        self.winfo_toplevel().wm_geometry(
            "%dx%d" %
            (guiWindow_HazardMenu_Width, guiWindow_HazardMenu_Height))

        # Create GUI window frame for Hazard Menu widgets and buttons.
        self.winFrame = tkinter.Frame(self)
        self.winFrame.grid(column=0, row=0, padx=0, pady=0)

        # Frame for icon frame within winFrame.
        iconFrame = ttk.Frame(self.winFrame)
        iconFrame.grid(column=0, row=0, padx=25, pady=10)

        # UT-Dallas GIF logo used within the GUI.
        dirFolder = os.path.dirname(__file__)
        gifPath = os.path.join(dirFolder, "Icon_UTD.gif")
        self.photo_UTDallas_Icon = tkinter.PhotoImage(file=gifPath)
        colorCode_UTD_Orange = "#C75B12"
        self.subSampleImage = self.photo_UTDallas_Icon.subsample(4, 4)
        self.label_for_icon = ttk.Label(iconFrame,
                                        borderwidth=2,
                                        relief="solid",
                                        background=colorCode_UTD_Orange,
                                        image=self.subSampleImage)
        self.label_for_icon.photo = self.photo_UTDallas_Icon
        self.label_for_icon.grid(column=0,
                                 row=0,
                                 padx=0,
                                 pady=0,
                                 sticky=tkinter.EW)

        # Frame for widgets within winFrame.
        widgetFrame = ttk.Frame(self.winFrame)
        widgetFrame.grid(column=0, row=1, padx=25, pady=10)

        # Adding a label to widgetFrame.
        widgetLabel_HazardTypes = \
            ttk.Label(widgetFrame,text="Please select hazard type:  ")
        widgetLabel_HazardTypes.grid(column=0, row=1, padx=0, pady=0)

        # Creating/adding the combobox to the widgetFrame.
        self.stringHazardTypes = tkinter.StringVar()
        widgetCombo_HazardTypes = ttk.Combobox(
            widgetFrame,
            width=14,
            textvariable=self.stringHazardTypes,
            state="readonly")
        widgetCombo_HazardTypes["values"] = (hazardValues)
        widgetCombo_HazardTypes.grid(column=1, row=1, padx=0, pady=0)

        # Display first index of hazardValues list.
        widgetCombo_HazardTypes.current(0)

        # Frame for buttons within winFrame.
        buttonFrame = ttk.Frame(self.winFrame)
        buttonFrame.grid(column=0, row=2, padx=0, pady=10)

        # Exit button ends the application.
        buttonExit = \
            ttk.Button(buttonFrame,text="Exit",command=self.func_ExitClick)
        buttonExit.grid(column=0, row=1, padx=15, pady=0)

        # Next button takes combobox selection and proceeds to affiliated GUI.
        buttonNext = \
            ttk.Button(buttonFrame,text="Next",command=self.func_NextClick)
        buttonNext.grid(column=1, row=1, padx=15, pady=0)
Exemplo n.º 18
0
    def create_widgets(self):
        """
        Metoda zawiera inicjalizację komponentów widoku.

        """
        # FRAMES
        self.__main_frame = tk.LabelFrame(self.__container,
                                          text="Glimpse on Earth",
                                          width=self.width,
                                          height=self.height,
                                          bg=colors.main_background_color,
                                          fg=colors.main_font_color,
                                          font=("Courier", 10))
        self.__top_frame = tk.Frame(self.__main_frame,
                                    highlightbackground="Black",
                                    width=self.__width,
                                    height=self.height / 10,
                                    bg=colors.main_background_color)
        self.__picture_frame = tk.LabelFrame(
            self.__main_frame,
            text="Photo preview",
            width=self.width,
            height=((self.__height / 10) * 4),
            bg=colors.preview_backgorund_color,
            fg=colors.main_font_color,
            font=("Courier", 10))
        self.__data_frame = tk.Frame(self.__main_frame,
                                     highlightbackground="Black",
                                     width=self.__width,
                                     height=((self.__height / 10) * 4),
                                     bg=colors.preview_backgorund_color)
        self.__bottom_frame = tk.Frame(self.__main_frame,
                                       highlightbackground="Black",
                                       width=self.__width,
                                       height=self.height / 12,
                                       bg=colors.main_background_color)

        self.__coordinates_frame = tk.Frame(self.__data_frame,
                                            bg=colors.preview_backgorund_color)

        # BUTTONS
        self.__upload_earth_pic_button = tk.Button(
            self.__top_frame,
            width=20,
            text="Upload Earth pic",
            command=self.upload_earth_pic_country_changed,
            bg=colors.button_color,
            fg=colors.button_font_color)

        self.__open_in_browser_button = tk.Button(self.__bottom_frame,
                                                  width=23,
                                                  text="Open in browser",
                                                  command=self.open_in_browser,
                                                  bg=colors.button_color,
                                                  fg=colors.button_font_color)
        self.__upload_img_button = tk.Button(self.__bottom_frame,
                                             width=23,
                                             text="Show image",
                                             command=self.show_earth_image,
                                             bg=colors.button_color,
                                             fg=colors.button_font_color)
        self.___save_img_button = tk.Button(
            self.__bottom_frame,
            width=23,
            text="Save image",
            command=self.save_image_window_create,
            bg=colors.button_color,
            fg=colors.button_font_color)

        # IMAGE
        self.__img_mini_earth_label = tk.Label(
            self.__picture_frame,
            width=self.width,
            height=(int((self.__height / 10) * 3)),
            background=colors.main_background_color)

        # TEXT
        self.__latitude = tk.Text(self.__coordinates_frame,
                                  height=2,
                                  background=colors.preview_backgorund_color,
                                  foreground=colors.main_font_color)
        self.__longtitude = tk.Text(self.__coordinates_frame,
                                    height=2,
                                    background=colors.preview_backgorund_color,
                                    foreground=colors.main_font_color)

        # LABELS
        self.__latitude_label = tk.Label(
            self.__coordinates_frame,
            text="Latitude: ",
            font=("Courier", 12),
            background=colors.preview_backgorund_color,
            foreground=colors.main_font_color)
        self.__longitude_label = tk.Label(
            self.__coordinates_frame,
            text="Longitude: ",
            font=("Courier", 12),
            background=colors.preview_backgorund_color,
            foreground=colors.main_font_color)

        # COUNTRY COMBOBOX
        self.__drop_countries = ttk.Combobox(
            self.__top_frame,
            values=self.__countries_names,
            textvariable=self.__act_country,
        )
        self.__act_country.set(self.__countries_names[0])
        self.__drop_countries.current(0)
Exemplo n.º 19
0
def play_game(str_len, reverse_len, offset, num_obscured, path_len_mean=5,
        path_len_std=0.5):
    print(f''''Game with string length = {str_len}, reverse size = {reverse_len},
            offset = {offset}, path length mean = {path_len_mean}, path length
            standard deviation = {path_len_std}.''')
    steps_taken = []
    n_steps = 0

    env = ReverseEnv(str_len, reverse_len, offset, num_obscured,
            hypothesis_enabled=False, path_len_mean=path_len_mean,
            path_len_std=path_len_std)
    ep = env.start_ep()
    n_actions = len(env.actions_list)


    def leftmost(i):
        return i + 1 - math.ceil(reverse_len / 2)
    

    def rightmost(i):
        return i - 1 + math.ceil(reverse_len / 2) + (reverse_len % 2 == 0)


    def is_rotatable(i):
        lm = leftmost(i)
        return lm >= 0 and lm % offset == 0 and lm / offset < n_actions


    def press(i):
        nonlocal n_steps
        nonlocal str_len
        n_steps += 1
        lm = leftmost(i)
        action = int(lm / offset)
        nonlocal ep
        obs, _, reward, done = ep.make_action(action) # pivot is one left
        done = done # or n_steps == str_len
        if not done:
            for i, b in enumerate(current_buttons):
                b.config(text=str(obs[i]))
        else:
            steps_taken.append(n_steps)
            n_steps = 0
            ep = env.start_ep()
            obs = ep.get_obs()[0]

            current = obs[:str_len]
            goal = obs[str_len:]
            for i, (g, b) in enumerate(zip(goal_buttons, current_buttons)):
                g.config(text=str(goal[i]))
                b.config(text=str(current[i]))


    def underline(i):
        for b in current_buttons[leftmost(i):rightmost(i)+1]:
            b.config(font=tahoma_underline)

    def ununderline(i):
        for b in current_buttons[leftmost(i):rightmost(i)+1]:
            b.config(font=tahoma_small)


    root = tk.Tk()
    frame = tk.Frame(root)
    frame.winfo_toplevel().title("Reversal Game")
    frame.pack()
    
    goal_buttons = []
    current_buttons = []

    tahoma = font.Font(family='Tahoma', size=26)
    tahoma_small = font.Font(family='Tahoma', size=26)
    tahoma_small2 = font.Font(family='Tahoma', size=16)
    tahoma_bold = font.Font(family='Tahoma bold', size=26)
    tahoma_underline = font.Font(family='Tahoma', size=26, underline=True)

    obs = ep.get_obs()[0]
    current = obs[:str_len]
    goal = obs[str_len:]

    label1 = tk.Label(frame, text='target:', height=1, width=7, fg='light green')
    label1.grid(row=0, column = 0)
    label1['font'] = tahoma_small
    label2 = tk.Label(frame, text='current:', height=1, width=7, fg='teal')
    label2.grid(row=1, column = 0)
    label2['font'] = tahoma_small
    label3 = tk.Label(frame, 
            text=f'Reverse size: {reverse_len}  Offset: {offset}. Click an arrow to reverse around it. Try to obtain target string.', height=1,
            width=80, fg='teal')
    label3['font'] = tahoma_small2
    label3.grid(row=3, column=0, columnspan=1 + 2*str_len)

    for i in range(str_len):
        g = tk.Label(frame, text=goal[i], font = tahoma, height=1, width=1,
                fg='light green')
        g.grid(row=0, column = 2*i+1)
        gap1 = tk.Label(frame, text=' ',height=1, width=1)
        gap1.grid(row=0, column = 2*i + 2)
        goal_buttons.append(g)
                
        b = tk.Label(frame, text=current[i], height=1, width=1, fg='teal', 
                font = tahoma)
        b.grid(row=1, column = 2*i+1)

        current_buttons.append(b)

        gap2 = tk.Label(frame, text=' ',height=1, width=1)
        gap2.grid(row=1, column = 2*i + 2)

        a = tk.Label(frame, text='^', height=1, width=1, font=tahoma_bold,
                fg='coral' if is_rotatable(i) else 'white',
                cursor='exchange' if is_rotatable(i) else None)
        if is_rotatable(i):
            a.bind('<Button-1>', lambda event, i=i: press(i))
            a.bind('<Enter>', lambda event, i=i: underline(i))
            a.bind('<Leave>', lambda event, i=i: ununderline(i))

        a.grid(row=2, column =  2*i + 1 + (reverse_len % 2 == 0))

        gap3 = tk.Label(frame, text=' ', height=1, width=1)
        gap3.grid(row=2, column=2*i + 2 - (reverse_len % 2 == 0))

    root.mainloop()

    print('Steps taken each game: ' + str(steps_taken))
    print('reverse env config: ')
    print('\n'.join(str.format('{0}: {1}',k,v) for k, v in vars(env).items()))
Exemplo n.º 20
0
    def create_widgets(self):
        # command content variables
        self.command_content = tk.StringVar()
        self.command_content.set("")

        addresses = [k for k in ProcessNames.__dict__.keys() if k[0] != "_"]
        self.command_address = tk.StringVar()
        self.command_address.set(addresses[0])

        command_ids = [k for k in Message.__dict__.keys() if k[0] != "_"]
        self.command_ids_var = tk.StringVar()
        self.command_ids_var.set(command_ids[0])

        # create the main frames
        self.top_frame = tk.Frame(bg='cyan', padx=2, pady=2)
        self.top_frame.grid(row=0,
                            rowspan=8,
                            column=0,
                            columnspan=2,
                            sticky="wens")
        self.top_frame.grid_columnconfigure(0, weight=1)  # autoresize ???
        self.top_frame.grid_rowconfigure(0, weight=1)  # autoresize ???

        self.right_frame = tk.Frame(bg='red', padx=2, pady=2)
        self.right_frame.grid(row=0, rowspan=8, column=2, sticky="wens")

        self.command_line_frame = tk.Frame(bg='blue', padx=2, pady=2)
        self.command_line_frame.grid(row=9,
                                     column=0,
                                     columnspan=2,
                                     sticky="wens")
        self.command_line_frame.grid_columnconfigure(
            1, weight=1)  # autoresize command text section

        # configure top frame (visualizer)
        self.top_frame_canvas = tk.Canvas(self.top_frame,
                                          highlightthickness=0,
                                          highlightbackground="green")
        self.top_frame_canvas.grid(row=0, column=0, sticky="wens")
        self.top_frame_canvas.grid_columnconfigure(0,
                                                   weight=1)  # autoresize ???
        self.top_frame_canvas.grid_rowconfigure(0, weight=1)  # autoresize ???

        # raw image for robot
        # image will be positioned in self.show_robot_icon()
        self.robot_img_png = Image.open("./robot.png").resize((20, 20),
                                                              Image.ANTIALIAS)

        # image for target position
        self.target_img_png = Image.open("./target.png").resize(
            (20, 20), Image.ANTIALIAS)
        self.target_img_ref = ImageTk.PhotoImage(self.target_img_png)
        self.target_img = self.top_frame_canvas.create_image(
            0, 0, anchor="nw", image=self.target_img_ref)
        #self.top_frame_canvas.itemconfig(self.target_img, image=self.target_img_ref)

        self.top_frame_canvas.bind('<Configure>', self.redraw_map)

        # configure right frame
        self.quit = tk.Button(self.right_frame,
                              text="QUIT",
                              fg="red",
                              command=self.master.destroy)
        self.quit.grid(row=0, column=0)

        # configure command line frame
        self.command_address_dropdown = tk.OptionMenu(self.command_line_frame,
                                                      self.command_address,
                                                      *addresses)
        self.command_address_dropdown.grid(row=0,
                                           column=0,
                                           columnspan=1,
                                           sticky="we",
                                           padx=10)

        self.command_address_cmdid_dropdown = tk.OptionMenu(
            self.command_line_frame, self.command_ids_var, *command_ids)
        self.command_address_cmdid_dropdown.grid(row=0,
                                                 column=1,
                                                 columnspan=1,
                                                 sticky="we",
                                                 padx=10)

        self.command_text = tk.Entry(self.command_line_frame)
        self.command_text.grid(row=0,
                               column=2,
                               columnspan=7,
                               sticky="we",
                               padx=10)
        self.command_text.bind('<Key-Return>', self.send_message)
        self.command_text["textvariable"] = self.command_content

        # command send button
        self.send_button = tk.Button(self.command_line_frame)
        self.send_button.grid(row=0, column=9, sticky="we")
        self.send_button["text"] = "Send"
        self.send_button["command"] = self.send_message
Exemplo n.º 21
0
def again():
    ''' Main Login Window'''
    global un, pwd, WinStat, root, application, create_window, forgot_window
    if WinStat == 'application':
        application.destroy()
    elif WinStat == 'create_window':
        create_window.destroy()
    elif WinStat == 'forgot_window':
        forgot_window.destroy()
    root = Tk()
    root.title('MP AquaTech PVT. LMT.')
    root.state("zoomed")
    #root.attributes("-fullscreen",'True')
    #root.wm_iconbitmap('favicon.ico')
    root.configure(background="white")

    root_frame = tk.Frame(root, background="white")
    img = ImageTk.PhotoImage(Image.open('front.png'))
    panel = Label(root_frame, image=img).grid(row=0, column=0, columnspan=5)

    Label(root_frame,
          text='Enter Details to Login',
          font=("Belwe Bd BT", 20),
          background="white").grid(row=1, column=0, columnspan=5)
    Label(
        root_frame,
        text='--------------------------------------------------------------',
        background="white").grid(row=3, column=0, columnspan=5)
    Label(root_frame,
          text='Username : '******'Password : '******'', background="white").grid(row=6,
                                                        column=0,
                                                        columnspan=5)
    login_button = tk.Button(root_frame,
                             width=6,
                             font=("Belwe lt BT", 15),
                             text='Login',
                             command=check)
    login_button.grid(row=7, column=1)

    tk.Button(root_frame,
              width=6,
              text='Close',
              font=("Belwe lt BT", 15),
              command=root.destroy).grid(row=7, column=2)
    Label(
        root_frame,
        text='--------------------------------------------------------------',
        background="white").grid(row=8, column=0, columnspan=5)
    tk.Button(root_frame,
              text='Forgot Password',
              font=("Belwe lt BT", 15),
              command=forgot_pass).grid(row=9, column=0, columnspan=4)
    Label(
        root_frame,
        text='--------------------------------------------------------------',
        background="white").grid(row=10, column=0, columnspan=5)
    tk.Button(root_frame,
              text='Create New Account',
              font=("Belwe lt BT", 15),
              command=create_account).grid(row=11, column=0, columnspan=4)
    Label(
        root_frame,
        text='--------------------------------------------------------------',
        background="white").grid(row=12, column=0, columnspan=5)
    root.bind("<Return>", check)

    root_frame.pack(anchor=CENTER)
    root.mainloop()
Exemplo n.º 22
0
                            command=lambda: reset(canvas))
    resetButton.grid(row=12, column=0)


root = tk.Tk()
root.title("Image Editor by AUG")
root.configure(bg="black")
root.geometry('800x600')
root.minsize(800, 600)

canvasbg = tk.Canvas(root, bg="#a19f9f")
canvasbg.place(relx=0, rely=0, relheight=1, relwidth=0.95)

canvas = tk.Canvas(canvasbg, bg="white")
canvas.place(relx=0.5, rely=0.5, relheight=0.7, relwidth=0.6, anchor="center")
toolKitFrame = tk.Frame(root, bg='#474747')
toolKitFrame.pack(side='right', fill='both')

histCanvasHeight = 90
histCanvasWidth = 160
histCanvas = tk.Canvas(toolKitFrame,
                       width=histCanvasWidth,
                       height=histCanvasHeight,
                       bg='gray20')
histCanvas.grid(row=0, column=0)


class Struct:
    pass

Exemplo n.º 23
0
    def __init__(self, p_section, p_widget_configuration_frame):
        """
        Initialization of the summary widget that shows some label and data

        :param p_parent: Page that will contain this summary widget
        :param p_widget_configuration_frame: Frame in the left menu, used to edit the widget
        """

        # Saving the parameters to use them in each function
        self.section = p_section
        self.frame_widget_configuration = p_widget_configuration_frame.frame

        # Indicate the widget type
        self.type = "Summary"

        # Properties of the widget-
        self.frame = tk.Frame(self.section.frame,
                              bg="white",
                              highlightthickness=1)
        self.frame.grid_propagate(False)
        self.frame.config(highlightbackground="grey")
        self.frame.grid(sticky="news")
        self.frame.update_idletasks(
        )  # to display good dimensions with .winfo_width()
        self.frame.columnconfigure(0, weight=1)
        self.frame.rowconfigure(1, weight=10)

        # Title of the page
        self.title = tk.Label(self.frame,
                              text=" ",
                              bg="#333333",
                              fg="white",
                              compound="c",
                              borderwidth=1,
                              relief="raised")
        self.title.grid(row=0, column=0, sticky="nwes")
        self.title.config(font=("Calibri bold", 12))

        # Creation of the buttons that display data
        self.frame_data = tk.Frame(self.frame)
        self.frame_data.grid(row=1, column=0, sticky="nwes")
        self.frame_data.columnconfigure((0, 1, 2), weight=1)
        self.frame_data.rowconfigure((0, 1, 2), weight=1)

        # Creation of the buttons that display data
        self.label_data = tk.Label(self.frame_data, text=" ", fg="white")
        self.label_data.grid(row=1, column=1)
        self.label_data.config(font=("Calibri bold", 11))

        # Loading and changing the content of the buttons
        self.load()

        # Fill the data file
        fill_file()

        # User interaction with the button
        self.frame.bind("<Button-1>", self.on_click)
        self.frame_data.bind("<Button-1>", self.on_click)
        self.title.bind("<Button-1>", self.on_click)

        # User resize interaction
        self.frame_data.bind('<Configure>', self.resize)

        # lists of differents size and font
        self.list_size = [i * 10 for i in range(100)]
        self.list_font = [i * 3 for i in range(4, 60)]
        self.current_index_size = 7
        self.current_index_font = 0

        # Boolean that indicates if the image has a title or not
        self.bool_title = True
Exemplo n.º 24
0
#####################################################
# Used when the player press the button Move
#####################################################	
def move():
	global dropButton,pickButton
	dropButton.config(bg="#d9d9d9")
	pickButton.config(bg="#d9d9d9")
	playerAction(int(numberChosen.get()[0]),int(numberChosen.get()[2]),0)

	
root = tk.Tk()
board=np.zeros([10,10],dtype = int) 


#initBoard
frame1 = tk.Frame(root)
frame1.pack(side=tk.TOP, fill=tk.X)
chip1 = tk.PhotoImage(file="./pictures/chip1.png")#chip of player 1
chip2 = tk.PhotoImage(file="./pictures/chip2.png")#chip of player 2
chip3 = tk.PhotoImage(file="./pictures/free.png")#empty space

buttonPlayer = list() # Each position on the board is a button
pick=1#0drop, 1, pick, -1 invalid field was selected
pickPos=(0,0)
currentPlayer=True
pointP1 = IntVar()
pointP2 = IntVar()
pointP1.set(0)
pointP2.set(0)
tk.Label(frame1, text=' Points:', width=10).grid(row=5,column=10)
tk.Label(frame1, text=' Player1:', width=10).grid(row=6,column=10)
movies = movies.drop(0)
movies = np.asarray(movies[1])

#Create new user
user = np.zeros((9724,), dtype=np.float)

index = tk.Variable()
index.set(random.randint(0, 9724))

rating = tk.Variable()
rating.set(0)

movieName = tk.StringVar()
movieName.set(movies[index.get()])

frame1 = tk.Frame(window)
frame1.pack()
frame2 = tk.Frame(window)
frame2.pack()
frame3 = tk.Frame(window)
frame3.pack()
frame4 = tk.Frame(window)
frame4.pack()
frame5 = tk.Frame(window)
frame5.pack()

questionLabel = tk.Label(frame1, text="Please rate this movie:", font=10).pack()

movieLabel = tk.Label(frame2, textvariable=movieName, font=10).pack()

ratingLabel1 = tk.Label(frame3, text = "1", font=10)
Exemplo n.º 26
0

def decrypto_tk(mens, senha):
    label_result['text'] = VigenereLib.decrypto(mens, senha)


root = tkinter.Tk()

canvas = tkinter.Canvas(root, height=500, width=600)
canvas.pack()

imagem_de_fundo = tkinter.PhotoImage(file='cript.png')
background = tkinter.Label(root, image=imagem_de_fundo)
background.place(relheight=1, relwidth=1)

frame_mens = tkinter.Frame(root, bg='black', bd=5)
frame_mens.place(relx=0.5, rely=0.1, relwidth=0.75, relheight=0.1, anchor='n')

label_mens = tkinter.Label(frame_mens, text='Mensagem:', bg='light gray')
label_mens.place(relwidth=0.24, relheigh=1)

entrada_mens = tkinter.Entry(frame_mens)
entrada_mens.place(relx=0.25, relwidth=0.75, relheight=1)

frame_snh = tkinter.Frame(root, bg='black', bd=5)
frame_snh.place(relx=0.5, rely=0.22, relwidth=0.75, relheight=0.1, anchor='n')

label_snh = tkinter.Label(frame_snh, text='Senha:', bg='light gray')
label_snh.place(relwidth=0.24, relheigh=1)

entrada_snh = tkinter.Entry(frame_snh)
Exemplo n.º 27
0
    my_msg.set("")  # Clears input field.  
    client_socket.send(bytes(msg, "utf8"))
    if msg == "{quit}":
        client_socket.close()
        top.quit()


def on_closing(event=None):
    """This function is to be called when the window is closed."""
    my_msg.set("{quit}")
    send()

top = tkinter.Tk()
top.title("Chatter")

messages_frame = tkinter.Frame(top)
my_msg = tkinter.StringVar()  # For the messages to be sent.
my_msg.set("Type your messages here.")
scrollbar = tkinter.Scrollbar(messages_frame)  # To navigate through past messages.
# Following will contain the messages.
msg_list = tkinter.Listbox(messages_frame, height=15, width=50, yscrollcommand=scrollbar.set)
scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
msg_list.pack(side=tkinter.LEFT, fill=tkinter.BOTH)
msg_list.pack()
messages_frame.pack()

entry_field = tkinter.Entry(top, textvariable=my_msg)
entry_field.bind("<Return>", send)
entry_field.pack()
send_button = tkinter.Button(top, text="Send", command=send)
send_button.pack()
Exemplo n.º 28
0
            #print(scores[[0]])
            #os.system("mpg321 image.mp3")
            video_writer.close()
            #f = open("Ouput.txt", "w+")
            #f.close()            #f = open("Ouput.txt", "a")
            #f.write(classes)
            #language = 'en-uk'
            #with open("Ouput.txt", encoding="utf-8") as file:
            #   file=file.read()
            #   speak = gTTS(text="I think its "+file, lang=language, slow=False)
            #   file=("sold%s.mp3")
            #   speak.save(file)
            #   print(file)
            #file.close()

            #plt.figure(figsize=IMAGE_SIZE)
            #plt.imshow(image_np)


root = tk.Tk()
frame = tk.Frame(root)
frame.pack()

button = tk.Button(frame, text="CAMERA", fg="red", command=cam)
button.pack(side=tk.LEFT)
slogan = tk.Button(frame, text="VIDEO", command=write_slogan)
slogan.pack(side=tk.LEFT)
button1 = tk.Button(frame, text="IMAGE", fg="red", command=image)
button1.pack(side=tk.RIGHT)

root.mainloop()
Exemplo n.º 29
0
root.title(u" ")
root.attributes("-topmost", True)
root.geometry("180x300")
statusText = tkinter.StringVar()
statusText.set("Stopped")
startButtonText = tkinter.StringVar()
startButtonText.set("開始")
warningScreen = None

# Initialize flags
startUpFlg = "off"
warningScreenDispFlg = "off"
shutdownFlg = "off"

# GUI parts: Title
frame = tkinter.Frame(root, relief="ridge", bd=3)
frame.pack(padx=10, pady=10)

titleLabel = tkinter.Label(frame, font=("", 15), text='PeepBlocker')
titleLabel.pack(padx=10, pady=5)

# GUI parts: SubTitle
subTitleLabel1 = tkinter.Label(root, text='■ Monitoring Status ■')
subTitleLabel1.pack()

# GUI parts: statusLabel1
statusLabel = tkinter.Label(root, textvariable=statusText)
statusLabel.pack()

# GUI parts: startButton
startButton = tkinter.Button(root,
Exemplo n.º 30
0
from random import randrange as rnd, choice
import tkinter as tk
import math
import time

root = tk.Tk()
fr = tk.Frame(root)
root.geometry('800x600')
canv = tk.Canvas(root, bg='white')
canv.pack(fill=tk.BOTH, expand=1)


class ball():
    def __init__(self, x=40, y=450):
        """ Конструктор класса ball
        Args:
        x - начальное положение мяча по горизонтали
        y - начальное положение мяча по вертикали
        """
        self.x = x
        self.y = y
        self.r = 10
        self.vx = 0
        self.vy = 0
        self.ay = 0
        self.ax = 0
        self.color = choice(['blue', 'green', 'yellow', 'brown'])
        self.id = canv.create_oval(self.x - self.r,
                                   self.y - self.r,
                                   self.x + self.r,
                                   self.y + self.r,