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
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() combostyle.theme_create( 'combostyle',
police2 = pygame.font.Font("LEMONMILK-Regular.otf", 40) 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)
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()
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() time.sleep(0.01)