Exemple #1
0
def tk_init(title='tk', geometry='300x200'):
    """主窗口初始化"""
    from tkinter import Tk
    tk = Tk()
    tk.title(title)
    tk.geometry(geometry)

    # 可以设置字体
    # tk.option_add('*font', ('verdana', 12, 'bold'))
    return tk
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.title = tk.title(self, "Edit Values Page")

        text = tk.Label(text="Edit Data Page", font=("Times New Roman", 14))
        text.pack()
        heading = font.Font(text, text.cget("font"))
        text.configure(underline=True)
        heading.configure(font=text)

        #save button
        ##edited info here will be written on the csv, then the button just goes back to the graphing_page
        #to be updated
        save_button = ttk.Button(
            self,
            text="Save changes",
            command=lambda: controller.show_frame(graphing_page))

        #discard button
        discard_button = ttk.Button(
            self,
            text="Discard",
            command=lambda: controller.show_frame(graphing_page))
        discard_button.pack()

        #go and edit the csv yourself because you are adding another axis to the plot
        open_csv_button = ttk.Button(self,
                                     text="Edit File",
                                     command=lambda: controller.open_csv())
        open_csv_button.pack()
Exemple #3
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.title = tk.title(self, "Plot Page")

        ##this part can be edited if we do not want underline for the whole heading
        text = tk.Label(text="Plotting Page", font=("Arial", 12))
        text.pack()
        heading = font.Font(text, text.cget("font"))
        text.configure(underline=True)
        heading.configure(font=text)

        # if the above underlining causes issues, use the below code which has no underline
        # label = tk.label(self, text="Plotting Page", font=("Arial",12))
        # label.pack(pady=500,padx=500)

        #back to main menu button
        back_button = ttk.Button(self,
                                 text="Back to Main Menu",
                                 command=lambda: controller.show_frame(parent))
        back_button.pack()

        #to add a new button that opens the edit data page. edit_data_page is the class name for the edit data page
        edit_data_page_button = ttk.Button(
            self,
            text="Edit Data",
            command=lambda: controller.show_frame(edit_data_page))
        edit_data_page_button.pack()

        #plot the graph on matplotlib's side first
        fig = Figure(figsize(5, 5), dpi=100)

        # to show the plotted graph above on the window of tkinter. INSERT DATA EXTRACTED FROM CSV HERE. #need to do: once data is passed here,
        # need to evaluate if the data is 2d or 3d graph
        #@ BoonJuey pls edit this data = controller.list() to fit your datatype

        data = controller.list()
        graph = fig.add_subsplot(111)
        if len(data) > 3:
            raise Exception(
                "You cannot plot graphs with more than 3 dimensions! Go do math mods instead!"
            )
        elif len(data) == 3:
            graph = fig.add_subsplot(111, projection="3d")

        page = FigureCanvasTkAgg(fig, master=controller)
        page.draw()
        page.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        #toolbar page, for futher applications to edit saved data
        toolbar = NavigationToolbar2Tk(page, self)
        toolbar.update()
        page.tkcanvas.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
Exemple #4
0
    def tk_init(self):
        # 1、设置基本属性
        from tkinter import Tk
        tk = Tk()

        # 设置标题
        if 'title' not in self.kwargs:
            self.kwargs['title'] = 'AskStringByList'
        tk.title(self.kwargs['title'])

        # 设置窗口大小
        if 'geometry' not in self.kwargs:
            self.kwargs['geometry'] = '300x400'
        tk.geometry(self.kwargs['geometry'])

        # 禁用窗口调整大小
        tk.resizable(False, False)

        # 2、绑定快捷键
        tk.bind("<Return>", self.enter)  # 回车键跟 enter() 绑定
        tk.bind("<Escape>", self.esc)  # Esc键跟 esc() 绑定

        return tk
Exemple #5
0
    )


def insert_into():
    os.system(
        'C:/Users/Нурдаулет/OneDrive/"Рабочий стол"/mysql.session/insert_into_film.py'
    )


def delete_table():
    os.system(
        'C:/Users/Нурдаулет/OneDrive/"Рабочий стол"/mysql.session/delete_table_film.py'
    )


tk = Tk()
tk.title("FOR FILMS")
canvas = Canvas(tk, width=800, height=800, bg="#ff9666", highlightthickness=0)
canvas.pack()
b1 = Button(tk, text="Show Table", command=show_table)
b1.place(x=300, y=200)
b2 = Button(tk, text="Insert values", command=insert_into)
b2.place(x=300, y=300)
b3 = Button(tk, text="Update values", command=update_table)
b3.place(x=300, y=400)
b4 = Button(tk, text="Delete table", command=delete_table)
b4.place(x=300, y=500)
b5 = Button(tk, text="Create table", command=create_table)
b5.place(x=300, y=600)
tk.mainloop()
Exemple #6
0
# from tkinter import *
import tkinter as tk
import tkinter.constants
import tkinter.filedialog
from multiprocessing import Pool
import multiprocessing
from tkinter import ttk
from tkinter.filedialog import *
from MainProcessGUI import CSTProcess

#翻译方式
cc_num = 0

#创建容器
tk = tk.Tk()
tk.title("epub繁简转换(opencc)")
#固定窗口大小
tk.resizable(0, 0)

fram = Frame(tk, width=460, height=135, bg='#333333')
fram.grid_propagate(0)
fram.grid()
e = Entry(fram, width=40, fg="#ededed", bg='#565656', relief=FLAT, bd=3)
e.grid(row=0, column=1, padx=0, pady=15)

e.delete(0, END)  # 将输入框里面的内容清空
e.insert(0, '')
filepath = StringVar()

#下拉列表样式
combostyle = ttk.Style()
    )


def insert_into():
    os.system(
        'C:/Users/Нурдаулет/OneDrive/"Рабочий стол"/mysql.session/insert_into_director.py'
    )


def delete_table():
    os.system(
        'C:/Users/Нурдаулет/OneDrive/"Рабочий стол"/mysql.session/delete_table_director.py'
    )


tk = Tk()
tk.title("FOR Director")
canvas = Canvas(tk, width=800, height=800, bg="#b3590b", highlightthickness=0)
canvas.pack()
b1 = Button(tk, text="Show Table", command=show_table)
b1.place(x=300, y=200)
b2 = Button(tk, text="Insert values", command=insert_into)
b2.place(x=300, y=300)
b3 = Button(tk, text="Update values", command=update_table)
b3.place(x=300, y=400)
b4 = Button(tk, text="Delete table", command=delete_table)
b4.place(x=300, y=500)
b5 = Button(tk, text="Create table", command=create_table)
b5.place(x=300, y=600)
tk.mainloop()
Exemple #8
0
class ClassUI():         
    #Configurações gerais
    wd= Tk()      
    wd.title('Hashing program')  
    #Frames
    frameExterno = Frame(wd, width=1400, height=1400, bg='SteelBlue1')
    frameExterno.pack()
    frameExterno.place(x=0,y=0)
    frameList = Frame(wd, width=610, height=355, bg="Gray")
    frameList.pack()
    frameList.place(x=10, y=220)
    frameForm = Frame(wd, width=610, height=200, bg="Gray")
    frameForm.pack()
    frameForm.place(x=10, y=10)

    #Variáveis de entrada
    txtOriginal = StringVar()      
    txtHash = StringVar() 
    txtUso = StringVar()
   
    #Componentes da janela
    lblNome = Label(frameForm, text="Digite uma senha",bg="Gray",fg="White",font=("Courier sans-serif",16))
    lblNome.pack()
    lblNome.place(x=10,y=10)
    entNome = Entry(frameForm, textvariable=txtOriginal,width=80)
    entNome.pack()
    entNome.place(x=10,y=40)

    lblHash = Label(frameForm, text="Hash",bg="Gray",fg="White",font=("Courier sans-serif",13))
    lblHash.pack()
    lblHash.place(x=10,y=60)
    entHash = Entry(frameForm, textvariable=txtHash,width=80)
    entHash.pack()
    entHash.place(x=10,y=80)

    lblUso = Label(frameForm, text="Onde será usada",bg="Gray",fg="White",font=("Courier sans-serif",13))
    lblUso.pack()
    lblUso.place(x=10,y=100)
    entUso = Entry(frameForm, textvariable=txtUso,width=80)
    entUso.pack()
    entUso.place(x=10,y=120)

    btnCreate = Button(frameForm, text="Criar")
    btnCreate.pack()
    btnCreate.place(x=10,y=170)
    btnView = Button(frameForm, text="Ver todos")
    btnView.pack()
    btnView.place(x=50,y=170)
    btnSearch = Button(frameForm, text="Procurar")
    btnSearch.pack()
    btnSearch.place(x=115,y=170)
    btnDelete = Button(frameForm, text="Deletar")
    btnDelete.pack()
    btnDelete.place(x=176,y=170)

    #Cria uma lista e as suas configurações
    listPasswords= ttk.Treeview(frameList, column=("column1", "column2", "column3","column4"), show='headings',height=16)
    listPasswords.heading("#1", text="ID")
    listPasswords.heading("#2", text="Original")
    listPasswords.heading("#3", text="Hash")
    listPasswords.heading("#4", text="Uso")
    listPasswords.column('#1', width=40)
    listPasswords.column('#2', width=180)
    listPasswords.column('#3', width=180)
    listPasswords.column('#4', width=180)
    scrollPasswords = Scrollbar(frameList)
    #Associando a Scrollbar com a Listbox...
    listPasswords.configure(yscrollcommand=scrollPasswords.set)   
    scrollPasswords.configure(command=listPasswords.yview)       
    
    listPasswords.pack()
    listPasswords.place(x=5,y=5)
    scrollPasswords.pack()
    scrollPasswords.place(x=585,y=6,height=345)

    #Organiza os widgets na janela de acordo com a classe do widget ( para organizar a casa )
    wd.geometry("630x590")
    wd.resizable(width=False,height=False)
    def runEST():
        wd.mainloop() 
                             database='session',
                             cursorclass=pymysql.cursors.DictCursor)


def for_actor():
    os.system(
        'C:/Users/Нурдаулет/OneDrive/"Рабочий стол"/mysql.session/director.py'
    )  #location


def for_director():
    os.system(
        'C:/Users/Нурдаулет/OneDrive/"Рабочий стол"/mysql.session/actor.py')


def for_films():
    os.system(
        'C:/Users/Нурдаулет/OneDrive/"Рабочий стол"/mysql.session/films.py')


tk = Tk()
tk.title("MYSQL")
canvas = Canvas(tk, width=600, height=600, bg="#ebb14d", highlightthickness=0)
canvas.pack()
b1 = Button(tk, text="Working with ACTOR list", command=for_director)
b1.place(x=200, y=200)
b2 = Button(tk, text="Working with DIRECTOR list", command=for_actor)
b2.place(x=200, y=300)
b3 = Button(tk, text="Working with FILM list", command=for_films)
b3.place(x=200, y=400)
Exemple #10
0
def about():

    tk = Tk()
    tk.title("About us")
    tk.geometry("500x500")
     tk.configure(background="#A9C6D9")
Exemple #11
0
police3 = pygame.font.Font("LEMONMILK-Regular.otf", 20)


class CreateButton():
    def __init__(self, window, label, command, txtcolor, backgroundcolor, s,
                 a):
        self.button = Button(tk, text=label, fg=txtcolor, bg=backgroundcolor)
        self.button.pack(side=s, anchor=a, padx=20)


#Bar tk

tk = Tk()
menu = Menu(tk)
tk.resizable(False, False)
tk.title("LOADING !")
tk.geometry("389x129")
settingsmenu = Menu(menu, tearoff=False)
tk.config(menu=menu, bg="black")
load = Progressbar(tk, orient=HORIZONTAL, length=400, mode="determinate")
img = ImageTk.PhotoImage(Image.open("1.jpg"))
panel = Label(tk, image=img)
panel.pack(side="top", fill="both", expand="yes")


def bar():
    for i in range(5, 101, 5):
        load['value'] = i
        tk.update_idletasks()
        time.sleep(1)
from tkinter import *
import tkinter as tk
import tkinter.messagebox
tk = Tk()
tk.title("Hi! Welcome to the tic tic toe game")
tk.config(bd=50, bg="red")
click = True


def check(buttons):
    global click
    if buttons["text"] == " " and click == True:
        buttons["text"] = "X"
        click = False
    elif buttons["text"] == " " and click == False:
        buttons["text"] = "O"
        click = True

    if ((button1["text"] == "X" and button2["text"] == "X"
         and button3["text"] == "X")
            or (button4["text"] == "X" and button5["text"] == "X"
                and button6["text"] == "X")
            or (button7["text"] == "X" and button8["text"] == "X"
                and button9["text"] == "X")
            or (button3["text"] == "X" and button5["text"] == "X"
                and button7["text"] == "X")
            or (button1["text"] == "X" and button5["text"] == "X"
                and button9["text"] == "X")
            or (button1["text"] == "X" and button4["text"] == "X"
                and button7["text"] == "X")
            or (button2["text"] == "X" and button5["text"] == "X"
def set_tk_title(tk, title):
    '''给窗口定义title'''
    if title is not None and title != '':
        tk.title(title)
    else:
        tk.title('chenfufeng v1.0')
Exemple #14
0
flag = False

reader = SimpleMFRC522()
import pyrebase as pyrebase
config = {
    "apiKey": "AIzaSyDGitbXcZNZrjvLyFAbcMNAAcDT_SDRx6o",
    "authDomain": "agshack-a80f1.firebaseapp.com",
    "databaseURL": "https://agshack-a80f1.firebaseio.com/",
    "storageBucket": "",
    "serviceAccount": "agshack-a80f1-firebase-adminsdk-baydy-c53fa0f114.json"
}
firebase = pyrebase.initialize_app(config)
db = firebase.database()
tk = tk.Tk()
tk.title("Welcome to bank")
tk.geometry("700x500")
#tk.attributes("-fullscreen", True)
frame = Frame(tk, borderwidth=2)
frame.pack(expand=1, fill=BOTH)
amount = ""
pin = ""
cid = "12345"


def clearFrame():
    list = frame.winfo_children()
    for l in list:
        l.destroy()

Exemple #15
0
    def pong2():
    
        wn = turtle.Screen()
        wn.title("Pong")
        wn.bgcolor("black")
        wn.setup(width=800, height=600)
        wn.tracer(0)

        # Score
        score_a = 0
        score_b = 0

        # Paddle A
        paddle_a = turtle.Turtle()
        paddle_a.speed(0)
        paddle_a.shape("square")
        paddle_a.color("white")
        paddle_a.shapesize(stretch_wid=5,stretch_len=1)
        paddle_a.penup()
        paddle_a.goto(-350, 0)

        # Paddle B
        paddle_b = turtle.Turtle()
        paddle_b.speed(0)
        paddle_b.shape("square")
        paddle_b.color("white")
        paddle_b.shapesize(stretch_wid=5,stretch_len=1)
        paddle_b.penup()
        paddle_b.goto(350, 0)

        # Ball
        ball = turtle.Turtle()
        ball.speed('slow')
        ball.shape("circle")
        ball.color("white")
        ball.penup()
        ball.goto(0, 0)
        ball.dx = 2
        ball.dy = 2

        # Pen
        pen = turtle.Turtle()
        pen.speed(0)
        pen.shape("square")
        pen.color("white")
        pen.penup()
        pen.hideturtle()
        pen.goto(0, 260)
        pen.write("Player A: 0  Player B: 0", align="center", font=("Courier", 24, "normal"))


        # Functions
        def paddle_a_up():
            y = paddle_a.ycor()
            y += 20
            paddle_a.sety(y)

        def paddle_a_down():
            y = paddle_a.ycor()
            y -= 20
            paddle_a.sety(y)

        def paddle_b_up():
            y = paddle_b.ycor()
            y += 20
            paddle_b.sety(y)

        def paddle_b_down():
            y = paddle_b.ycor()
            y -= 20
            paddle_b.sety(y)

        # Keyboard bindings
        wn.listen()
        wn.onkeypress(paddle_a_up, "w")
        wn.onkeypress(paddle_a_down, "s")
        wn.onkeypress(paddle_b_up, "Up")
        wn.onkeypress(paddle_b_down, "Down")

        # Main game loop
        while True:
            wn.update()
            
            # Move the ball
            ball.setx(ball.xcor() + ball.dx)
            ball.sety(ball.ycor() + ball.dy)

            # Border checking

            # Top and bottom
            if ball.ycor() > 290:
                ball.sety(290)
                ball.dy *= -1
        #        os.system("afplay bounce.wav&")
            
            elif ball.ycor() < -290:
                ball.sety(-290)
                ball.dy *= -1
        #        os.system("afplay bounce.wav&")

            # Left and right
            if ball.xcor() > 350:
                score_a += 1
                pen.clear()
                pen.write("Player A: {}  Player B: {}".format(score_a, score_b), align="center", font=("Courier", 24, "normal"))
                ball.goto(0, 0)
                ball.dx *= -1
            elif score_b == 10:
                tk = Tk()
                tk.title("score")
                tk.geometry("100x100")
                lbl= Label(tk, text="Player B win" , fg="red", font=("Jokerman", 10))
                lbl.grid(row=0, column = 1)
                btn=Button(tk, text= "Exit", fg="red" ,font=("Niagara Engraved", 15))
                btn.grid(row=1, column = 0)
                btn=Button(tk, text= "Try again", fg="black" ,font=("Niagara Engraved", 15))
                btn.grid(row=1, column = 1)
                tk.mainloop ()
                
            elif ball.xcor() < -350:
                score_b += 1
                pen.clear()
                pen.write("Player A: {}  Player B: {}".format(score_a, score_b), align="center", font=("Courier", 24, "normal"))
                ball.goto(0, 0)
                ball.dx *= -1
                
            elif score_a == 10 :
                tk = Tk()
                tk.title("score")
                tk.geometry("100x100")
                lbl= Label(tk, text="Player A win" , fg="red", font=("Jokerman", 10))
                lbl.grid(row=0, column = 1)
                btn=Button(tk, text= "Exit", fg="red" ,font=("Niagara Engraved", 15))
                btn.grid(row=1, column = 0)
                btn=Button(tk, text= "Try again", fg="black" ,font=("Niagara Engraved", 15))
                btn.grid(row=1, column = 1) 
                tk.mainloop ()

            # Paddle and ball collisions
            if ball.xcor() < -340 and ball.ycor() < paddle_a.ycor() + 50 and ball.ycor() > paddle_a.ycor() - 50:
                ball.dx *= -1 
        #        os.system("afplay bounce.wav&")
            
            elif ball.xcor() > 340 and ball.ycor() < paddle_b.ycor() + 50 and ball.ycor() > paddle_b.ycor() - 50:                 
                ball.dx *= -1
    )


def insert_into():
    os.system(
        'C:/Users/Нурдаулет/OneDrive/"Рабочий стол"/mysql.session/insert_into_actor.py'
    )


def delete_table():
    os.system(
        'C:/Users/Нурдаулет/OneDrive/"Рабочий стол"/mysql.session/delete_table_actor.py'
    )


tk = Tk()
tk.title("FOR ACTORS")
canvas = Canvas(tk, width=800, height=800, bg="#f4a460", highlightthickness=0)
canvas.pack()
b1 = Button(tk, text="Show Table", command=show_table)
b1.place(x=300, y=200)
b2 = Button(tk, text="Insert values", command=insert_into)
b2.place(x=300, y=300)
b3 = Button(tk, text="Update values", command=update_table)
b3.place(x=300, y=400)
b4 = Button(tk, text="Delete table", command=delete_table)
b4.place(x=300, y=500)
b5 = Button(tk, text="Create table", command=create_table)
b5.place(x=300, y=600)
tk.mainloop()
Exemple #17
0
        self.canvas.bind_all("<Key-Right>", self.turn_right)

    def draw(self):
        pos = self.canvas.coords(self.id)
        if (pos[0] + self.x >= 0 and pos[2] + self.x <= self.canvas_width):
            self.canvas.move(self.id, self.x, 0)
        #self.x = 0
    def turn_left(self, event):
        self.x = -4

    def turn_right(self, event):
        self.x = 4


tk = Tk()
tk.title("Game")
tk.resizable(0, 0)  #not resizable
tk.wm_attributes("-topmost", 1)  #at top
canvas = Canvas(tk, width=500, height=500, bd=0, highlightthickness=0)
canvas.pack()
tk.update()  #init

paddle = Paddle(canvas, 'blue')
ball = Ball(canvas, paddle, 'red')

while 1:
    if (ball.hit_bottom == False):
        ball.draw()
        paddle.draw()
    tk.update_idletasks()
    tk.update()