コード例 #1
0
ファイル: gui.py プロジェクト: DaanZVW/Encrypter
 def __setEntryField(self,
                     entry_field: tk,
                     text: str,
                     end_state: tk = tk.NORMAL) -> None:
     entry_field.configure(state=tk.NORMAL)
     entry_field.delete(1.0, tk.END)
     entry_field.insert(1.0, text)
     entry_field.configure(state=end_state)
コード例 #2
0
    def quiz():
        mat = Tk()
        global count, score
        score = 0
        count = 0
        mat.geometry("800x400")
        mat.title("English Quiz")
        mat.configure(background="yellow")

        def ask_question():
            global score, count
            # get globals
            qq = get_questions("english.json")
            score_readout = Label(mat,
                                  text="Score: " + str(score) + "/" +
                                  str(count),
                                  font=(None, 15),
                                  fg="blue",
                                  bg="yellow")
            score_readout.pack(side="top", anchor="w")
            # retrive questions from json parcer with inputed json files
            eh1 = Label(mat,
                        text="Question " + str(count + 1),
                        font=(None, 15),
                        fg="blue",
                        bg="yellow")
            eh1.pack(side="top", anchor="e")

            spacing_label = Label(mat,
                                  text="",
                                  font=(None, 15),
                                  fg="blue",
                                  bg="yellow")
            spacing_label.pack()

            question_label = Label(mat,
                                   text=qq[4],
                                   font=(None, 10),
                                   fg="blue",
                                   bg="yellow",
                                   wraplength=750)
            question_label.pack(side="top", anchor="w")

            def correct():
                global score, count
                mixer.init(22050, -8, 4, 65536)
                mixer.music.load('rr.ogg')
                mixer.music.play(0)
                score = score + 1
                count = count + 1
                unpack_all()
                if count < 10:
                    ask_question()
                else:
                    end_score = str(score) + " / " + str(10)
                    messagebox.showinfo(
                        "Score", "Your Score Was: %s" % score + " Out of 10")
                    mat.destroy()

            def incorrect():
                global count, score
                mixer.init(22050, -8, 4, 65536)
                mixer.music.load('ww.ogg')
                mixer.music.play(0)
                count = count + 1
                unpack_all()
                if count < 10:
                    ask_question()
                else:
                    # end_score = str(score)+"/"+"10"
                    mat.destroy()
                    messagebox.showinfo(
                        "Score", "Your Score Was: %s" % score + " Out of 10")
                    mat.destroy()
                    score = 0
                    count = 0
                    # end_score = 0

            spacing_label2 = Label(mat, text="", bg='yellow')
            spacing_label2.pack()

            def unpack_all():
                for mat_b in bttns:
                    mat_b.pack_forget()
                score_readout.pack_forget()
                eh1.pack_forget()
                question_label.pack_forget()
                spacing_label.pack_forget()
                spacing_label2.pack_forget()

            mat_b1 = Button(mat,
                            text=qq[0],
                            command=correct,
                            font=(None, 12),
                            width=80,
                            bg='gold',
                            fg='blue')
            mat_b2 = Button(mat,
                            text=qq[1],
                            command=incorrect,
                            font=(None, 12),
                            width=80,
                            bg='gold',
                            fg='blue')
            mat_b3 = Button(mat,
                            text=qq[2],
                            command=incorrect,
                            font=(None, 12),
                            width=80,
                            bg='gold',
                            fg='blue')
            mat_b4 = Button(mat,
                            text=qq[3],
                            command=incorrect,
                            font=(None, 12),
                            width=80,
                            bg='gold',
                            fg='blue')
            bttns = [mat_b1, mat_b2, mat_b3, mat_b4]
            shuffle(bttns)
            for mat_ in bttns:
                mat_.pack(side="top", anchor="w")

        ask_question()
        mat.mainloop()
コード例 #3
0
#!/usr/bin/env python
# coding: utf-8

# In[21]:

import tkinter as Tk
from tkinter import *
import tkinter

# In[54]:

top = Tk()

top.title("Data Science")
top.geometry("1200x800+0+0")
top.configure(background="powderblue")


def func():
    n = name.get()
    print(n)


tkinter.Label(top,
              text="Today's Visitor",
              font=('times', 20, 'bold'),
              height='1',
              width='13').grid(row=0, column=0, sticky=W)

tkinter.Label(top,
              text="0",
コード例 #4
0

# In[19]:


import tkinter as Tk
import tkinter
from tkinter import *


# In[39]:


top=Tk()
top.geometry('1600x800+0+0')
top.configure(background='orange')

variable = StringVar(top)
variable.set("1") # default value

variable = StringVar(top)
variable.set("1") # default value

tkinter.Label(top, text='Soils:', bg='orange',fg='black', font='none 12 bold').grid(row=1,column=0,sticky=W)
w = OptionMenu(top, variable,"1","2","3","4","5","6").grid(row=1, column=1,sticky=W)

tkinter.Label(top, text='Month:', bg='orange',fg='black', font='none 12 bold').grid(row=2,column=0,sticky=W)
w = OptionMenu(top, variable,"1","2","3","4","5","6").grid(row=2, column=1,sticky=W)

variable = StringVar(top)
variable.set("1") # default value
コード例 #5
0
grey = "#E3E2E1"


#Procédure de fermeture de le fenêtre princiaple
def Exit():
    if askyesno("Exit", "Do you really want to exit kofi :'( ?"):
        showwarning('Exit', "Exiting...see you soon") 
        main.destroy()

    else:
        showinfo('Exit', 'Welcome back on kofi!')

#Initailisation de la fenêtre principale
main = Tk()
main.title("Kofi")
main.configure(bg = "white")
main.resizable(0,0)
#main.attributes("-fullscreen", 2)
#On récupère la largeur (ws) et la hauteur (hs) de la fenêtre
ws = main.winfo_screenwidth()
hs = main.winfo_screenheight()
#calcul la position de la fenetre adaptée à l'écra,
x = (ws/2) - (ws/2)
y = (hs/2) - (hs/2)
#applique la taille et la position
main.geometry('%dx%d+%d+%d' % (ws, hs, 0, 0))

#intercepte l'evenement quit pour informer l'utilisateur, appel la fonction Exit
main.protocol("WM_DELETE_WINDOW", Exit)

コード例 #6
0
            canvas.get_tk_widget().pack()
            ani = animation.FuncAnimation(fig, update, frames=200, interval = 20, 
                                          init_func = init, blit = False, repeat=False)
            canvas.draw()
            plt.show(ani)
            plt.show()
            plot_button['text'] = 'Exit'
        else:
            window.destroy()
    window.counter += 1
    
from tkinter import *
from tkinter import ttk

window = Tk()
window.configure(background='grey')
window.title('Virtual warehouse')
window.counter = 0



w, h = window.winfo_screenwidth(), window.winfo_screenheight()
window.geometry("%dx%d+0+0" % (w, h))

nb = ttk.Notebook(window, width=200, height=580)

page1 = ttk.Frame(nb)
nb.add(page1, text='Shortest Path'
                       '\n'
                       'Start with (0,0)!')
コード例 #7
0
    #biimg = PhotoImage(file="bw_image.png")
    #Label (win9, image=biimg) .grid(row=0,column=0,sticky=E)
    #label4 = Label(image=biimg)
    #label4.image = biimg # keep a reference!

    #label4.pack()

# main
window = Tk()
window.title("Rice Quality Analyser")
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
window.geometry('%sx%s' % (width, height))
#window.geometry("900x250")
window.configure(background="white")
#Text
Label(window,
      text="WELCOME TO RICE QUALITY ANALYZER",
      bg="white",
      fg="black",
      font="none 11 bold").grid(row=0, column=0, sticky=W)
# logo
#PhotoImage.zoom(25,35)
photologo = PhotoImage(file="logo3.GIF")

Label(window, image=photologo).grid(row=0, column=1, sticky=E)
#l.pack()

##CREATE A BUTON
Button(window, text="Capture Image", width=15, command=click).grid(row=2,
コード例 #8
0
    global img_dir
    global arr
    img_dir = filedialog.askdirectory()
    print(img_dir)
    for category in CATEGORIES:
        path = os.path.join(img_dir, category)
        for img in os.listdir(path):
            arr.append(os.path.join(path, img))
    print(arr[0])


# Declaration of the window with size and title
root = Tk()
root.geometry("1200x600")
root.title("Intern Work - Ankit Saini")
root.configure(background='white')
# Opening folder path

i = 0
flag = 1
path = ''


def image_next():
    while 1:
        global flag
        if flag == 1:
            global i
            i = i + 1
            load = Image.open(arr[i])
            global path
コード例 #9
0
from tkinter import *

t = Tk()
import math
import locale
import tkinter as Tk

t.minsize(850, 600)
t.configure(background='pink')


def detail():
    f3 = Frame(bg="pink")
    f3.place(x=100, y=0, width=800, height=600)
    u = Label(f3, text="REGISTRATION DETAILS", bg="sky blue", fg="black")
    u.place(x=270, y=30)
    u1 = Label(f3, text="First Name", bg="black", fg="white")
    u1.place(x=250, y=90)

    e1 = Entry(f3, font=("", 12))
    e1.place(x=350, y=90, width=120)

    u2 = Label(f3, text="Last Name", bg="black", fg="white")
    u2.place(x=250, y=130)

    e1 = Entry(f3, font=("", 12))
    e1.place(x=350, y=130, width=120)

    u2 = Label(f3, text="Registration ID", bg="black", fg="white")
    u2.place(x=250, y=170)