def make_pane(tool_frame): """Create the styleVar pane. """ global window window = SubPane( TK_ROOT, options=BEE2_config.GEN_OPTS, title=_('Style/Item Properties'), name='style', resize_y=True, tool_frame=tool_frame, tool_img=img.png('icons/win_stylevar'), tool_col=3, ) UI['nbook'] = nbook = ttk.Notebook(window) nbook.grid(row=0, column=0, sticky=NSEW) window.rowconfigure(0, weight=1) window.columnconfigure(0, weight=1) nbook.enable_traversal() stylevar_frame = ttk.Frame(nbook) stylevar_frame.rowconfigure(0, weight=1) stylevar_frame.columnconfigure(0, weight=1) nbook.add(stylevar_frame, text=_('Styles')) UI['style_can'] = Canvas(stylevar_frame, highlightthickness=0) # need to use a canvas to allow scrolling UI['style_can'].grid(sticky='NSEW') window.rowconfigure(0, weight=1) UI['style_scroll'] = ttk.Scrollbar( stylevar_frame, orient=VERTICAL, command=UI['style_can'].yview, ) UI['style_scroll'].grid(column=1, row=0, rowspan=2, sticky="NS") UI['style_can']['yscrollcommand'] = UI['style_scroll'].set utils.add_mousewheel(UI['style_can'], stylevar_frame) canvas_frame = ttk.Frame(UI['style_can']) frame_all = ttk.Labelframe(canvas_frame, text=_("All:")) frame_all.grid(row=0, sticky='EW') frm_chosen = ttk.Labelframe(canvas_frame, text=_("Selected Style:")) frm_chosen.grid(row=1, sticky='EW') ttk.Separator( canvas_frame, orient=HORIZONTAL, ).grid(row=2, sticky='EW', pady=(10, 5)) frm_other = ttk.Labelframe(canvas_frame, text=_("Other Styles:")) frm_other.grid(row=3, sticky='EW') UI['stylevar_chosen_none'] = ttk.Label( frm_chosen, text=_('No Options!'), font='TkMenuFont', justify='center', ) UI['stylevar_other_none'] = ttk.Label( frm_other, text=_('None!'), font='TkMenuFont', justify='center', ) all_pos = 0 for all_pos, var in enumerate(styleOptions): # Add the special stylevars which apply to all styles tk_vars[var.id] = int_var = IntVar(value=var.default) checkbox_all[var.id] = ttk.Checkbutton( frame_all, variable=int_var, text=var.name, ) checkbox_all[var.id].grid(row=all_pos, column=0, sticky="W", padx=3) # Special case - this needs to refresh the filter when swapping, # so the items disappear or reappear. if var.id == 'UnlockDefault': def cmd(): update_filter() checkbox_all[var.id]['command'] = cmd tooltip.add_tooltip( checkbox_all[var.id], make_desc(var, is_hardcoded=True), ) for var in VAR_LIST: tk_vars[var.id] = IntVar(value=var.enabled) args = { 'variable': tk_vars[var.id], 'text': var.name, } desc = make_desc(var) if var.applies_to_all(): # Available in all styles - put with the hardcoded variables. all_pos += 1 checkbox_all[var.id] = check = ttk.Checkbutton(frame_all, **args) check.grid(row=all_pos, column=0, sticky="W", padx=3) tooltip.add_tooltip(check, desc) else: # Swap between checkboxes depending on style. checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args) checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args) tooltip.add_tooltip( checkbox_chosen[var.id], desc, ) tooltip.add_tooltip( checkbox_other[var.id], desc, ) UI['style_can'].create_window(0, 0, window=canvas_frame, anchor="nw") UI['style_can'].update_idletasks() UI['style_can'].config( scrollregion=UI['style_can'].bbox(ALL), width=canvas_frame.winfo_reqwidth(), ) if utils.USE_SIZEGRIP: ttk.Sizegrip( window, cursor=utils.CURSORS['stretch_vert'], ).grid(row=1, column=0) UI['style_can'].bind('<Configure>', flow_stylevar) item_config_frame = ttk.Frame(nbook) nbook.add(item_config_frame, text=_('Items')) itemconfig.make_pane(item_config_frame)
def clicked(): # print(selected.get()) # res = "Servidor " + txt.get() lbl.configure(text="Servidor selecionado: " + selected.get()) ttk.Separator(window, orient=HORIZONTAL).grid(row=5, columnspan=5, sticky=EW) messagebox.showinfo('Título', 'Servidor selecionado: ' + selected.get())
def createWidgets(self): top = self.winfo_toplevel() top.rowconfigure(0, weight=1) top.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) self.frameMain = ttk.Frame(self) self.frameMain.grid(sticky=tk.N + tk.S + tk.E + tk.W) self.frameMain.columnconfigure(0, weight=1) self.frameMain.rowconfigure(0, weight=1) self.frameMain.rowconfigure(1, pad=15) self.frameTop = ttk.Frame(self.frameMain, padding=5) self.frameTop.grid(column=0, row=0, sticky=tk.N + tk.S + tk.E + tk.W) self.frameTop.columnconfigure(1, weight=1) self.frameTop.rowconfigure(3, weight=1) self.labelSourceFolder = ttk.Label(self.frameTop, text="Source Folder:") self.labelSourceFolder.grid(column=0, row=0, sticky=tk.W, pady=2) self.entrySourceFolder = ttk.Entry(self.frameTop, textvariable=self.sourceFolderValue) self.entrySourceFolder.grid(column=1, row=0, sticky=tk.E + tk.W, pady=2) self.buttonSourceFolder = ttk.Button( self.frameTop, text="...", width="3", command=self.eventSourceFolderClicked) self.buttonSourceFolder.grid(column=2, row=0, pady=2) self.labelReadyFolder = ttk.Label(self.frameTop, text="Ready Folder:") self.labelReadyFolder.grid(column=0, row=1, sticky=tk.W, pady=2) self.entryReadyFolder = ttk.Entry(self.frameTop, textvariable=self.readyFolderValue) self.entryReadyFolder.grid(column=1, row=1, sticky=tk.E + tk.W, pady=2) self.buttonReadyFolder = ttk.Button( self.frameTop, text="...", width="3", command=self.eventReadyFolderClicked) self.buttonReadyFolder.grid(column=2, row=1, pady=2) self.labelDesiredSize = ttk.Label(self.frameTop, text="Desired Size:") self.labelDesiredSize.grid(column=0, row=2, sticky=tk.W, pady=2) self.spinboxDesiredSize = tk.Spinbox( self.frameTop, textvariable=self.desiredSizeValue, from_=PICTURE_SIZE_MIN, to=PICTURE_SIZE_MAX, width=6) self.spinboxDesiredSize.grid(column=1, row=2, sticky=tk.W, pady=2) self.frameSeparator = ttk.Frame(self.frameMain, padding=5) self.frameSeparator.grid(column=0, row=2, sticky=tk.N + tk.S + tk.E + tk.W) self.frameSeparator.columnconfigure(0, weight=1) self.separatorBottom = ttk.Separator(self.frameSeparator, orient=tk.HORIZONTAL) self.separatorBottom.grid(column=0, row=0, sticky=tk.W + tk.E) self.frameBotom = ttk.Frame(self.frameMain, padding=5) self.frameBotom.grid(column=0, row=3, sticky=tk.N + tk.S + tk.E + tk.W) self.frameBotom.columnconfigure(0, weight=1) self.buttonProceed = ttk.Button(self.frameBotom, text='Proceed', command=self.eventProceedClicked) self.buttonProceed.grid(column=0, row=0, sticky=tk.E) self.buttonClose = ttk.Button(self.frameBotom, text='Close', command=self.quit) self.buttonClose.grid(column=1, row=0, sticky=tk.E) self.frameProgress = ttk.Frame(self.frameMain, padding=3) self.frameProgress.grid(column=0, row=4, sticky=tk.N + tk.S + tk.E + tk.W) self.frameProgress.columnconfigure(0, weight=1) self.labelProgress = ttk.Label(self.frameProgress, borderwidth=1, relief=tk.SUNKEN, textvariable=self.processValue) self.labelProgress.grid(column=0, row=0, sticky=tk.E + tk.W) self.update()
def janela_banco(self): ''' Método que oferece opções para alterar ou criar um banco de dados. Altera as variáveis globais NOME_BANCO e NOME_TABELA ''' def escolhas(param): if param == "criar": self.listagem.configure(background="gray", state=tk.DISABLED) self.entrada1.configure(state=tk.NORMAL) self.entrada2.configure(state=tk.NORMAL) else: self.listagem.configure(background="white", state=tk.NORMAL) self.entrada1.configure(state=tk.DISABLED) self.entrada2.configure(state=tk.DISABLED) self.botao_escolhido.set(param) def buscar(): self.controlador.busca_bds() self.controlador.bancos.remove(NOME_BANCO) if self.primeiravez: self.primeiravez = False else: self.listagem.delete(0, "end") for item in self.controlador.bancos: self.listagem.insert(tk.END, item) self.listagem.selection_set(first=0) def confirmar(): global NOME_BANCO global NOME_TABELA validacao = False if self.botao_escolhido.get() == "criar": self.controlador.busca_bds() try: if not is_valid_filename( self.entrada1.get()) or self.entrada1.get( ) + ".db" in self.controlador.bancos: raise Exception numero = int(self.entrada2.get()) if numero < 1 or numero > 10_000: raise Exception except: tk.messagebox.showinfo( title="ERROU!!!", message= f"O número da temporada deve estar entre 1 e 10.000.\n\nAlém disso, não é possível usar um nome já existente ou que contenha os seguites caracteres:\n:, *, /, \", ?, >, |, <, \\.\n\nTente novamente!" ) janela.focus_force() else: self.controlador.altera_cria_bd( (self.entrada1.get() + ".db", self.entrada2.get())) NOME_BANCO = self.entrada1.get() + ".db" NOME_TABELA = self.entrada2.get() validacao = True tk.messagebox.showinfo( title="Sucesso!!", message= f"Criado BD com nome {self.entrada1.get()} e temporada {self.entrada2.get()}!" ) else: try: nome = self.controlador.altera_cria_bd( (self.listagem.get(self.listagem.curselection()), None)) NOME_BANCO = self.listagem.get( self.listagem.curselection()) NOME_TABELA = nome validacao = True tk.messagebox.showinfo( title="Sucesso!!", message= f"Alterado o BD para {self.listagem.get(self.listagem.curselection())}!" ) except: pass if validacao: janela.destroy() janela = tk.Tk() janela.iconbitmap(janela, ICONE) janela.wm_title("Opções em banco de dados") janela.grid_rowconfigure(0, weight=1) janela.grid_columnconfigure(0, weight=1) self.botao_escolhido = tk.StringVar() self.botao_escolhido.set("criar") self.botao_rad_1 = ttk.Radiobutton( janela, text="Escolher BD", variable=self.botao_escolhido, value="localizar", command=lambda: escolhas("localizar")) self.botao_rad_1.grid(row=1, column=0, pady=10) botao_rad_2 = ttk.Radiobutton(janela, text="Criar BD", variable=self.botao_escolhido, value="criar", command=lambda: escolhas("criar")) botao_rad_2.grid(row=1, column=4, pady=10) self.listagem = tk.Listbox(janela, selectmode=tk.SINGLE) self.listagem.configure(background="gray") self.listagem.configure(disabledforeground="black") self.listagem.grid(columnspan=2, row=2, rowspan=4, padx=10, pady=10) sep1 = ttk.Separator(janela) sep1.configure(orient="vertical") sep1.grid(row=1, column=2, rowspan=5, sticky="ns") msg1 = tk.Label(janela, text="Nome:") msg1.grid(row=3, column=3) self.entrada1 = ttk.Entry(janela) self.entrada1.grid(row=3, column=4, padx=5) msg2 = tk.Label(janela, text="Temporada:") msg2.grid(row=4, column=3, padx=5) self.entrada2 = ttk.Entry(janela) self.entrada2.insert(0, "1 a 10000") self.entrada2.grid(row=4, column=4, padx=5) sep2 = ttk.Separator(janela) sep2.configure(orient="horizontal") sep2.grid(row=6, column=0, columnspan=6, sticky="we") self.botao_buscar = tk.Button(janela, text="Buscar BDs", command=buscar, bg="blue", fg="white") self.botao_buscar.grid(row=7, column=0, pady=10) botao1 = tk.Button(janela, text="Sair", command=janela.destroy, bg="orange", fg="white") botao1.grid(row=7, column=3, pady=10, padx=30) botao2 = tk.Button(janela, text="Confirmar", command=confirmar, bg="green", fg="white") botao2.grid(row=7, column=4, pady=10) self.primeiravez = True self.botao_escolhido.set("localizar") self.botao_buscar.invoke() self.botao_escolhido.set("criar") botao_rad_2.invoke() tk.mainloop()
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.control=controller def key(event): self.pos.remove() c= str(repr(event.char)) if c[1] == 'w': self.y=self.y+0.000028 elif c[1] == 's': self.y=self.y-0.000028 elif c[1] == 'a': self.x=self.x-0.000028 elif c[1] == 'd': self.x=self.x+0.000028 self.pos = self.ax.scatter(self.x,self.y) p=Point(self.x,self.y) for i in range(0,len(self.figures)): if self.figures[i].contains(p): self.ax.set_title("Inside " + self.info[i+1]) self.cur=i+1 break else: self.cur=0 self.ax.set_title("Inside AKGEC") self.canves.draw() def callback(event): frame.focus_set() print("Ready to go for the Virtual Tour ....") frame= Frame(self,width=100,height=100) frame.bind("<Key>", key) frame.bind("<Button-1>", callback) frame.grid(row=8,column=6) self.read_building_data() self.plot() self.canves = FigureCanvasTkAgg(self.fig, self) self.canves.get_tk_widget().grid(row=0,column=0,columnspan=4,rowspan=20,sticky='ew') self.canves.draw() self.base_map() self.boundaries() self.pos = self.ax.scatter(self.x,self.y) seconds = time.time() t = time.ctime(seconds) self.v = StringVar() Label(self, textvariable=self.v,height=1,width=20).grid(row=0,column=0,rowspan=2,columnspan=5) self.v.set(t) self.after(1000,self.showtime) b1= Button(self,text="Base Map",relief=FLAT, command = self.base_map) b1['font']=BFONT b1.grid(row=0,column=6, padx = 10) sep = ttk.Separator(self, orient="horizontal") sep.grid(row=1,column=6,sticky='ew') b2= Button(self,text="Boundaries",relief=FLAT, command = self.boundaries) b2['font']=BFONT b2.grid(row=2,column=6, padx = 10) sep = ttk.Separator(self, orient="horizontal") sep.grid(row=3,column=6,sticky='ew') b3= Button(self,text="scatter",relief=FLAT, command = self.scatter) b3['font']=BFONT b3.grid(row=4,column=6, padx = 10) sep = ttk.Separator(self, orient="horizontal") sep.grid(row=5,column=6,sticky='ew') b4= Button(self,text="Path",relief=FLAT, command = self.path_draw) b4['font']=BFONT b4.grid(row=6,column=6, padx = 10) sep = ttk.Separator(self, orient="horizontal") sep.grid(row=7,column=6,sticky='ew') sep = ttk.Separator(self, orient="horizontal") sep.grid(row=12,column=6,sticky='ew') b5 = Button(self, text ="Profile",relief=FLAT, command = lambda : controller.show_frame(Profile)) b5['font']=BFONT b5.grid(row = 13, column = 6, padx = 10) sep = ttk.Separator(self, orient="horizontal") sep.grid(row=14,column=6,sticky='ew') b6 = Button(self, text ="Settings",relief=FLAT, command = lambda : controller.show_frame(Settings)) b6['font']=BFONT b6.grid(row = 15, column = 6, padx = 10) b7 = Button(self, text ="Analysis",relief=FLAT, command = lambda : self.control.show_frame(Visualize)) b7['font']=BFONT b7.grid(row = 10, column = 6, padx = 10) photo = PhotoImage(file = r"nav.png") self.photo = photo.subsample(3, 3) self.b8 = Button(self,image=self.photo,command=self.speech_rec) self.b8.image=photo self.b8.grid(row=15,column=3) sep1 = ttk.Separator(self, orient=VERTICAL) sep1.grid(row=0,column=4,sticky='ns',columnspan=2,rowspan=17) sep2 = ttk.Separator(self, orient=VERTICAL) sep2.grid(row=0,column=7,sticky='ns',columnspan=2,rowspan=17) sep3 = ttk.Separator(self, orient=HORIZONTAL) sep3.grid(row=9,column=6,sticky='ew') sep4 = ttk.Separator(self, orient=HORIZONTAL) sep4.grid(row=16,column=6,sticky='ew')
def boton_altura_maximaf(self): #ecuacion de altura maxima x0 = self.x0 y0 = self.y0 angulo_inicial = self.angulo v_inicial = self.velocidad_inicial arriba = pow((v_inicial * sin(angulo_inicial)), 2) #la parte de arriba de la fraccion result = (arriba / (2 * 9.8)) #La parte de abajo de la ecuacion result = result + y0 # lo sumar la posicion incicial del eje y final = round(result, 5) def copiar_valores(event): self.tiempo_datos[0] = entrada_tiempo.get() master.destroy() # Metodo para validar la entrada de datos (Solo Numeros por ahora) def check(v, p): if p.isdigit(): return True elif p is "": return True else: return False # Datos Iniciales # inicializa la ventana popup master = tk.Tk() master.title("Posicion") # Crea un frame contenedor para la izquierda y la derecha frame_arriba = ttk.Frame(master) frame_centro = ttk.Frame(master) frame_abajo = ttk.Frame(master) frame_aceptar = ttk.Frame(master) validacion_tiempo = (frame_abajo.register(check), '%v', '%P') # validacion_y = (frame_derecha.register(check), '%v', '%P') frame_arriba.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_centro.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_abajo.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_aceptar.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) # Crea las titulos de la entrada de datos tiempo = ttk.Label(frame_abajo, text="Tiempo: ") tiempo_init = ttk.Label(frame_arriba, text="Intervalo de tiempo") tiempo_init_x = ttk.Entry(frame_arriba, state='readonly', justify='center') tiempo_init_y = ttk.Entry(frame_arriba, state='readonly', justify='center') tiempo_init.pack(side=tk.TOP) tiempo_init_x.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_x.configure(state='normal') tiempo_init_x.delete(0, 'end') tiempo_init_x.insert(0, "0") tiempo_init_x.configure(state='readonly') # inicializa el punto de interseccion del eje Y tiempo_init_y.configure(state='normal') tiempo_init_y.delete(0, 'end') tiempo_init_y.insert(0, time_impact(self)) tiempo_init_y.configure(state='readonly') # Separador de datos separador = ttk.Separator(frame_centro, orient="horizontal") separador.pack(side=tk.TOP, expand=False, fill=tk.X) # Crea formularios para entrada de datos entrada_tiempo = ttk.Entry(frame_abajo, validate="key", validatecommand=validacion_tiempo) # entrada_y = ttk.Entry(frame_derecha, validate="key", validatecommand=validacion_y) tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) # posicion_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) entrada_tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) # entrada_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) aceptar = ttk.Button(frame_aceptar, text="ACEPTAR") aceptar.pack(fill=tk.BOTH, expand=1) aceptar.bind("<Button-1>", copiar_valores) #posible desplazamiento con pass
def create_widgets(self): def f_posicion_x0(event): print(posicion_x0.get()) def f_posicion_y0(event): print(posicion_y0.get()) def f_angulo_inicial(event): print(angulo_inicial.get()) def f_Rapidez_inicial(event): print(Rapidez_inicial.get()) # Limpia Entry iniciales, de modo que al hacer click estos se vacian def limpiar_entrada_x0(event): if self.entrada_posicion_x0.get() == "X0": self.entrada_posicion_x0.delete(0, 'end') def update_x0(event): # todo ecuacion que se actualiza automatricamente input_x0 = self.entrada_posicion_x0.get() if input_x0 == '': input_x0 = 0 self.actualizar_grafico(self.ecuacion * float(5), 8, 8, 8) self.actualizar_grafico(self.ecuacion * float(5), 8, 8, 8) def limpiar_entrada_y0(event): if self.entrada_posicion_y0.get() == "Y0": self.entrada_posicion_y0.delete(0, 'end') def limpiar_entrada_angulo(event): if self.entrada_angulo_inicial.get() == "Angulo": self.entrada_angulo_inicial.delete(0, 'end') def limpiar_entrada_Rapidez(event): if self.entrada_Rapidez_inicial.get() == "Rapidez Inicial": self.entrada_Rapidez_inicial.delete(0, 'end') # Variables de los deslizadores posicion_x0 = tk.IntVar() posicion_y0 = tk.IntVar() angulo_inicial = tk.IntVar() Rapidez_inicial = tk.IntVar() self.pestañas.pack(side=tk.TOP, fill=tk.BOTH, expand=True, ipadx=10, ipady=10) tab_balistica = tk.Frame(self.pestañas) tab_seguridad = tk.Frame(self.pestañas) self.pestañas.add(self.tab_ideal, text="Movimiento Ideal", compound=tk.TOP) self.pestañas.add(tab_seguridad, text="Parabola de Seguridad", compound=tk.TOP) self.pestañas.add(tab_balistica, text="Movimiento Balistico", compound=tk.TOP) # tutorial = ttk.LabelFrame(self.window, text="Instrucciones") # tutorial.pack(side=tk.RIGHT, fill=tk.X, expand=True, padx=10, pady=10) self.opciones.pack(side=tk.RIGHT, fill=tk.BOTH, expand=False, padx=5, pady=5) self.boton_posicion.pack(side=tk.TOP, padx=10, pady=10) self.boton_velocidad.pack(side=tk.TOP, padx=10, pady=10) self.boton_aceleracion.pack(side=tk.TOP, padx=10, pady=10) self.boton_alcance_horizontal.pack(side=tk.TOP, padx=10, pady=10) self.boton_altura_maxima.pack(side=tk.TOP, padx=10, pady=10) self.boton_camino_recorrido.pack(side=tk.TOP, padx=10, pady=10) self.boton_radio_y_centro_de_curvatura_circulo_obsculador.pack( side=tk.TOP, padx=10, pady=10) self.boton_aceleracion_normal_y_tangencial.pack(side=tk.TOP, padx=10, pady=10) self.boton_vector_normal.pack(side=tk.TOP, padx=10, pady=10) #self.boton_circulo_osculador.pack(side=tk.TOP, padx=10, pady=10) self.graphics.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) separador = ttk.Separator(self.tab_ideal, orient="horizontal") separador.pack(side=tk.TOP, expand=False, fill=tk.X) variables = ttk.LabelFrame(self.tab_ideal, text="Controles") variables.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=5, pady=5) # Contenedores de los controles posicion = ttk.Frame(variables) posicion.pack(side=tk.LEFT, expand=True, padx=5, pady=5) Rapidez = ttk.Frame(variables) Rapidez.pack(side=tk.LEFT, expand=True, padx=5, pady=5) angulo = ttk.Frame(variables) angulo.pack(side=tk.LEFT, expand=True, padx=5, pady=5) #todo añadir titulos self.entrada_posicion_x0 = ttk.Entry(posicion, justify=tk.CENTER) self.entrada_posicion_x0.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.entrada_posicion_x0.insert(tk.END, "0") self.entrada_posicion_x0.bind("<Button-1>", limpiar_entrada_x0) self.entrada_posicion_x0.bind("<Key>", update_x0) self.entrada_posicion_y0 = ttk.Entry(posicion, justify=tk.CENTER) self.entrada_posicion_y0.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.entrada_posicion_y0.insert(tk.END, "0") self.entrada_posicion_y0.bind("<Button-1>", limpiar_entrada_y0) # todo titulos para rapidez inicial self.entrada_Rapidez_inicial = ttk.Entry(Rapidez, justify=tk.CENTER) self.entrada_Rapidez_inicial.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.entrada_Rapidez_inicial.insert(tk.END, "Rapidez Inicial") self.entrada_Rapidez_inicial.bind("<Button-1>", limpiar_entrada_Rapidez) # todo titulos para angulo inicial self.entrada_angulo_inicial = ttk.Entry(angulo, justify=tk.CENTER) self.entrada_angulo_inicial.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.entrada_angulo_inicial.insert(tk.END, "Angulo Inicial") self.entrada_angulo_inicial.bind("<Button-1>", limpiar_entrada_angulo) # Añadir elementos deslizadores para actualizar datos self.deslizador_posicion_x0 = ttk.Scale(posicion, variable=posicion_x0, from_=0, to=100, orient=tk.HORIZONTAL) self.deslizador_posicion_x0.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=10, pady=10) self.deslizador_posicion_x0.set(50) self.deslizador_posicion_x0.bind("<B1-Motion>", f_posicion_x0) self.deslizador_posicion_x0.bind("<ButtonRelease-1>", f_posicion_x0) self.deslizador_posicion_y0 = ttk.Scale(posicion, variable=posicion_y0, from_=0, to=100, orient=tk.HORIZONTAL) self.deslizador_posicion_y0.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=10, pady=10) self.deslizador_posicion_y0.set(50) self.deslizador_posicion_y0.bind("<B1-Motion>", f_posicion_y0) self.deslizador_posicion_y0.bind("<ButtonRelease-1>", f_posicion_y0) self.deslizador_angulo_inicial = ttk.Scale(angulo, variable=angulo_inicial, from_=0, to=90, orient=tk.HORIZONTAL) self.deslizador_angulo_inicial.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=10, pady=10) self.deslizador_angulo_inicial.set(180) self.deslizador_angulo_inicial.bind("<B1-Motion>", f_angulo_inicial) self.deslizador_Rapidez_inicial = ttk.Scale(Rapidez, variable=Rapidez_inicial, from_=0, to=100, orient=tk.HORIZONTAL) self.deslizador_Rapidez_inicial.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=10, pady=10) self.deslizador_Rapidez_inicial.set(50) self.deslizador_Rapidez_inicial.bind("<B1-Motion>", f_Rapidez_inicial) self.deslizador_Rapidez_inicial.bind("<ButtonRelease-1>", f_Rapidez_inicial)
def Start(self): self.title("Welcome to BcD") self.grid_columnconfigure(0, weight=1) self.grid_columnconfigure(1, weight=1) login = tk.Frame(self) login.grid(row=1, column=0, columnspan=2, pady=(5,5)) ttk.Separator(self, orient="horizontal").grid(row=2, column=0, columnspan=2, sticky='nsew') signup = tk.Frame(self) signup.grid(row=3, column=0, columnspan=2, pady=(5,5)) #login loginText = tk.Label(login, text='Login', font='Fixedsys 16 bold', fg='darkblue') loginText.grid(row=0, column=0, columnspan=2, pady=(10,10)) name = tk.Label(login, text='Username', font='Verdana 11') pword = tk.Label(login, text='Password', font='Verdana 11') name.grid(row=1, column=0, padx=(30,5), pady=(5,5), sticky="e") pword.grid(row=2, column=0, padx=(30,5), pady=(5,5), sticky="e") nameBox = tk.Entry(login) pwordBox = tk.Entry(login, show='*') nameBox.grid(row=1, column=1, padx=(0,30), pady=(5,5), sticky="w") nameBox.focus() pwordBox.grid(row=2, column=1, padx=(0,30), pady=(5,5), sticky="w") stud = tk.IntVar() stud.set(0) checkStud = tk.Checkbutton(login, text='Login as Student', font='Fixedsys 8', variable=stud, onvalue=1, offvalue=0) checkStud.grid(row=3, column=1, padx=(0,30), sticky="w") loginButton = tk.Button(login, text='Login', bg='blue', fg='white', activebackground='blue3', activeforeground='white', command=lambda: self.CheckLogin(nameBox.get(), pwordBox.get(), stud.get())) loginButton.grid(row=4, column=0, columnspan=2, pady=(5,10)) loginButton.bind('<Return>', lambda e: self.CheckLogin(nameBox.get(), pwordBox.get(), stud.get())) #Sign Up signUpTextF = tk.Frame(signup) signUpText = tk.Label(signUpTextF, text='Sign Up', font='Fixedsys 16 bold', fg='brown') instr_only = tk.Label(signUpTextF, text='(For Instructors only)', font='Verdana 8 italic', fg='gray25') signUpText.grid(row=0, column=0) instr_only.grid(row=1, column=0) signUpTextF.grid(row=0, column=0, columnspan=2, pady=(10,10)) SuName = tk.Label(signup, text='Choose Username', font='Verdana 11') SuPword = tk.Label(signup, text='Enter Password', font='Verdana 11') SuName.grid(row=1, column=0, padx=(30,5), pady=(5,1), sticky="e") SuPword.grid(row=2, column=0, padx=(30,5), pady=(1,5), sticky="e") SuNameBox = tk.Entry(signup) SuPwordBox = tk.Entry(signup, show='*') SuNameBox.grid(row=1, column=1, padx=(0,30), pady=(5,1), sticky="w") SuPwordBox.grid(row=2, column=1, padx=(0,30), pady=(1,5), sticky="w") SuPP = tk.Label(signup, text='Enter PassPhrase', font='Verdana 11') SuPP.grid(row=3, column=0, padx=(30,5), pady=(5,5), sticky="e") PPframe = tk.Frame(signup) passPh = tk.Entry(PPframe, show='*') passPh.grid(row=0, column=0, sticky="w") help_img = "R0lGODlhDAANAPZCACAgICEhISkpKTIyMj09PUJCQkZGRkpKSktLS1dXV1hYWF1dXV5eXmBgYGFhYWRkZHBwcHR0dHZ2dnd3d4SEhIWFhYeHh4qKio+Pj5GRkZKSkpmZmZubm52dnZ+fn6Ojo6ioqK2tra+vr7CwsLa2tre3t7y8vMPDw8jIyMvLy83NzdLS0tXV1dfX19jY2NnZ2eHh4eTk5OXl5enp6e7u7vHx8fLy8vPz8/X19fb29vf39/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sOZ2FtbWE9MC40NTQ1NDUALAAAAAAMAA0AAAeNgDg5PTIhFhYhMjw5jDkkDRIdHRMNJDo4OyILKjEgHispCyM7LQstMAQDBgImpS0XGUIlCC84BQ5CGhcNKEI8N0EkABhCKA0JLUJBQicBEDZCLQq8ykIUBzVCxQ0XGtUkH0DaGRcuCyzaFQ8+QiymOyMLKUA0Mz8pDKM5Oo8RGxwRKjXKwaPQoUSLcgQCADs=" img = tk.PhotoImage(data=help_img) PPhelp = tk.Button(PPframe, image=img, command=lambda: msgbox.showinfo('Help', 'This PassPhrase will be used for generating your Private Key')) PPhelp.image = img PPhelp.grid(row=0, column=1, sticky="w") PPframe.grid(row=3, column=1, padx=(0,30), sticky="w") SignUpButton = tk.Button(signup, text='Sign Up', bg='brown', fg='white', activebackground='brown4', activeforeground='white', command=lambda: self.SignUp(SuNameBox.get(), SuPwordBox.get(), passPh.get())) SignUpButton.grid(row=4, column=0, columnspan=2, pady=(5,10)) SignUpButton.bind('<Return>', lambda e: self.SignUp(SuNameBox.get(), SuPwordBox.get(), passPh.get())) #Footer Footer = tk.Frame(self, bg='black') Footer.grid(row=4, column=0, columnspan=2, sticky='ew') logos = tk.Frame(Footer, bg='black') logos.grid(row=0, column=0) py_img = "iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAMAAADW3miqAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAIKUExURUdwTP/gSDNxpP/ZRDR5rzNvoP/RPDR4ri1roDR2qjR4rf/POv/TQDR2qv/TP+XITv/YRv/dQ//aSP/fSzRwoS1pnP/NODR4rv/NODFzqv/SPjR6sP/OOf/MNv/UQP/WQjRzpS5wqzt0nDNqlytupjR5rjR4rjR1qP/RPDd0ov/ZQTR1qP/NOP/LNTV7sjR4rP/LNv/QPf/MNzR4rzR5sDR6sP/PO//LNTR3rTR4rjR0pjR4rv/TP//TQDR0pzBvozR0pjRzpf7ZRjRyozJxpf/XQjRyo//ZRjRvoP/ZRv/XRP/WQv/XRP/bSjJqlzNsm//gSf/jS//WQjR6sP/POv7RPDR4rzV7sv/MN//ROv/LNTR3rTR6sP/OODV7s//LNjRyozV7sv/KNf/YRv/LNv/OOf/KNf/WRP/QPf/RPj10mjRyo//aR//WQ//VQv/bQP/VQitnmzRxoSxomv/lSjR4rillmzRzpP/hTP/fTo6kayhlmzNql/DeTzRypP/gT//UQf/NOP/LNjV7sv/LNf/OOf/LNv/OOv/POv/TQDR1qTR3rTR4rv/UQTR2qv/NODRun//QPP/RPv/POf/XRDR0pv/SPzRzpDRxof/WQzNtnTR0pTR1p//ZRzRyo//VQv/YRjRyov/XRTRxoP/dSzNsmzR6sf/aSP/eTv/bSjNrmf/PPP/MNjRypC6D/7MAAACJdFJOUwCACT+mnj4CZy706YmjGAQCgKml8puN+9NG99W0oXG1pCY4/iG3iKEtFB3rKN78G5GJPO3Mq/dfPHvA3v3h5HDt4BWwgoz21cH19u7MwqK4NW+U+OANcu7yN8nsnvtQahFr76X38lN9yqYr/BT95VXiWTiMRfwvtpr4DljsEdfPUJqFYkWr5O1nrM9NyAAAAj5JREFUOMt11GdXGkEUgOEbSlAwYFQCBKRE4NARJdh7TdTYK2p67733CkJQsYCJAmoAhfzHzLAscMLwft3n7Nm9e3cAslk/s6S1409F3NZGbT0DSHEW7ZZo1ONZWvrpdv9uZ6tJaHHaIrWL0mb912ajlXCj+ajGqmdlzE6kjYBOR7UAU1kTYBORVCKxZ80eEXk8XG6OWSah+Vqn02k0GtvTJg9xUOpiKkkrZbbYgjudnZO0qNeyUMdSKZVdvZTZEo4M9vUNXedjw2iYxjNMDSjzPMj8ETLPhHeDQQVWF8fJBiNkQt6SUlBJC5hDIfMsNq4WHUxZCpjDxwgh42qWg4Y27v9M1ev7d7HZWJVBUyEzrB+jzIoYuPRyrOeaqjfn1LP3KJPgQWY5NjvYbUV0D5+9Yg56vdis+K+CiDbPVW+fjB7BHUf1KAZo458Bbtq8U40MvYzH9/cPYtvh8Bp6L9r4eNBEffidbsP7ONn4xKBJmb+9klHabKOPEQplTbISGlImUvHoRZ5ZpcyVOijuwAMKVJwqzzcJbJJzfOB04yHuIVTAXLoGAHrl7UhgGSOiMdcJAAAuFHX19w/fKj+IxbAZGCtB2Wy2E7jzpszyMhgMQRllgg8+HKUy5f8IpWWUCXlPohwOx8JHEkob1wYaEO+731dJQuHdtWB6OWSmGnGSgOBy1iR+AFQTkTxr/F8NurlkNQHxFRnjXzB/S5pnSQeUoaelmTJohjOyGuJRBwKd/OaNCR5vQiz79GUy58I/v4utx9RLivoAAAAASUVORK5CYII=" py_logo = tk.PhotoImage(data=py_img) py = tk.Label(logos, image=py_logo, font='Verdana 7 bold', bg='black') py.image = py_logo py.grid(row=0, column=0, sticky='e') php_img = "iVBORw0KGgoAAAANSUhEUgAAAC4AAAAYCAMAAACyRD+1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAIWUExURUdwTDxRfENcjUFYh0BObCcwRzdJbU1poThKb0plnEdhlk9qpExnnkFaiUVfkkNbjUJbi1FtqUJbikZillBsplNvrT9Wg5Kcsz1Tf0lkmkpkmkRekVBrpUlfjKKtxUtlnERekGV9rEhjmklkmV13r0ZhlrfB1ay52b/H1oOWvp6symyDs2J4o22Bp3eMuXuMsFJrnEBXhj9UgUVgk4GRsISWvUVfkpKhwKazzZChyF11pKCv0UdhlFFqnLnD2663yVNvqre/z7zG3sjQ4cvR33WKtZys0qm1zJKjxrjB0mF9v2B8vwAAAWF9wAICBWN/wl97vHKLx2N+wV16um6Ixn2KqV98vl97v2SAwlZzsWmExHuQxVddaneOxlx4uCUmKzs+RExooAoLDl56u1l2tX6SxHaPyUNGTwwMEGWBv3GKxWyGxGaCxEBCSg8QE32LrWpwgGRqeSkqLzU3PV5jchITFwoLDQYHC1t3tXeNwoOPrYSUvH6RwVVZZXuFnX+OsxkaH3eCm0xOVx4fImJ9u3+QuI6gzGBkbYCRvAUFCIWPp3uJqnF6kC8xNoOVwIGVxhcYG0dLU4CWynJ8lDc5QGNnc01po1RxrnqRxmmDv2J9v1thbkhKUYORtXuGpCAhJGt0iIibyYaUtnyDklBTXYGImZSetpqkvZihuHl7f2tzhpWn0m12jW13i4GOrpObsWRkZ2VmaJzAJoAAAABKdFJOUwAadUkEAgzvCNrG9eVTonlw/WO5+f43DSXr4If5LFD+ktfR8v6wnPlT1NTyXHTyX5c7M6o14JqtuvfT9Zu93CD+LOTEk9T+vdR6sKwRmAAAAxVJREFUOMt1lHVbG0EQxi9JIYZbqbu7u/vt3BLjuHgIgSSXECOGu1YoNJS2uD9Q/4bdO0gbSvv+cTe3z2/2mZl7dykqU9sfHH9x9NnJk89PnHhy4Oad2/m5e7Kpfyvr3vHHjx4ee9o3auV9H73enp6ksVSdo9qfK8naAm/fe/Tusc+jPh0i4kx+hiYiD43NWKK8Ksv+C75+q4/XsSwiEPJVfmkzCxG9nqM3qotzMxIuX7vxwYvSAKp1gKP2Ny5ksC71pYsb8LZzVxq9iNZVCGIQzfTOgKVOpyMhLa4JEWvcWbRNpM+c/Uh2MM1XCmpvMVVMe3B/08vggJZp/CasBXutOpq2yQsE/vQpr1CBedLpicc9bx1tdbMYD8adMXvYHOz2OOPxwExrM0fTenkuRe050COWN2AHe9dIygndyxbw1LsdMfA0vcPY0eW2Y1gkrTM2ZTl1/rDYTUVlAIdGrcNhDKv1kJprHB2DxFAU3s5brc0N0DElTLZ0P5WjF3HTK5zo5BDXlsA/7NCqrTJEIbbshtctVWzdIsTaSfW0bSdVrRGHp52AjnYGGdZw4mcAz/pYsxsiK3bosqIqMlh7s7C7pjqNm+uhYZgzNKcgsoqd0xwaiMDI9wCEtP66zgC0WtE6vkOf7rSh7V0ohRMLY9Ddy+iCMQgvYdzf+SraAZEpTqBsO6i8cbHTYAATAe5e63NAqhb5yVCWxoCMFMOgo8kn/uTxPOqC2CvpdHDEYol+bTfUhloXeNY0ZImuuKHDYrGEO1tMIq3PKaOypLs1NOInyMi0vMGkQxyv9X2iP/l47ZsIdM0ZeIN/3Tma3QXEyYpdJTVCp2Rk6y5D4gsh5mUAwgZ2w2tMTckuhWAaRb7cNdxfH7JmmpCIa5p0D/nTX0m5VLFhSZnqcKNZsNFm8R/MfNryhSrZnzMlkR4sdLE0sxlHYlkMzSYLDxZINp0nSVGxfDxZQ1IyckjM1iRL5cVFki2nNbtMekSpLjW6bHqNKL3NZbyvVh6Rlv3nNlCUy/LzVMpD+6rfv6/ed0ipysuXlSsyiV9vlTIDzjmxEgAAAABJRU5ErkJggg==" php_logo = tk.PhotoImage(data=php_img) php = tk.Label(logos, image=php_logo, font='Verdana 7 bold', bg='black') php.image = php_logo php.grid(row=0, column=1) mc_img = "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAKpUExURUdwTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBASYXBigwMzPBcwMLBQUEBA8DAw0PEERBLB0AAFpSpyNAK4WRwSgyQBUdJm3IhwAWKrphgnAMPAknQV2b0UN9rw58yXx3cTstGCggFf3BPA0LIz1EURISKKWOjo97fBsxIYm3kH+php7M5e+vexAkFUMeLCFILjRPYyF3RmAWNxBWMLUWZSZDXLgnayoQGhVgN7rU0TwvKpGATPrso3ORdx8mJZZ7WxgUDbWufloAAWw7Ih0gGi4zKv/UaUw0B+YREetxQh4SAWpOFvKyMa5KKEwJA4zDlp59g7SPliIeSWx3myMpLbLI2naFlazCzzw1dX+Qlnijf1dkaJem0Es3PHbEihsMEXzOkWdtnS5BTGlzlzceJSIhQjo+YFRSk1FMk1qSaI21yrZthWRhsGaldm51rEFBc0NJaMF1jYhWZndMWAZ2wXWbe1FtgAE3X0syHz1OVHeaqwZLenSt35SopxhuPzNBR2YGNrlaflULLgMZC4asi4ibmGQoQFkGLid+TEx1lyNSNJuOi1YiNotrTHSPlWXFg+7dl5WQiSFxrxw9Wh9sqXZvTOi8jAlblPjPcXVkNoinrv/mgq10TsuoWFxNKegBC6TFyMqqgfUGDrEABl50YI1vM62sgql4HN7Jn/+LVT4eDmyJb19eV86pV+Dirk5JONBlPCQLA+MsGfYjGPm3NZo9IN1SLWEeDKEgENutTseUM1VBGLeWRPlrPhHtYWsAAAAsdFJOUwAsd6T4vwXs5RDya0zLHdfbFvyBNvPh1FRkXa1EbpEofyTE3/u0nz6ZiYKGtEp+SgAAAwpJREFUGBmFwINiY2kYgOEvRNukSZVaw919/7RNbWJs2xbWtm3btm3bxJVMcoIeJDOPWPim2R2u8KRJYZejtjIkx+ArrfCi45lSHpLsfPYgFt7jQ5JFeZCMvFVuySBQQVYum1gUlXAUnjwxycshbn8Ek7Y24iaXiUGek7g9B387gMHhvR9uR1MmOkXFaL4cH/8Hg79+/eRTNAV5khbwkrDn4PgBDA7/snc7CTk2SZlCyv4IJm1tpPjdklCOzr//jZL286E/0bGLxlfCBPX37u8VKYf+/yPKBE9A4uzofb77rQ9I+mbfvt/Rq5YYXwl60fff3UDSjq9/akYvJyAipRioyNvNJKkdEYyqRKQCI8XWVjSjERRGfhGfB5Poho2tAGML38PMWSfTsBh9aRvAloV3YVEutZgp9frGVhh743msposDK7XtC9jycRQrl9RjFR37YdfWr9aTQVjyAbVibRMsmrtIkdS6s+VHUi5cswbUI09GgRLxAisaG5ex5MWeC65m7vxzbt/07WcA342MzJlz0npuvbbv4edYvnrlQ4BHvMDaxsaneKan56Lr6Thx3rzH5m+KAiMvPzt79snnc8vNfX1PsHz1yn7AI0Gg6YFlj0LHko4mUApgc0vTLgClIHrZ4sWK5v7+ZsAr9WTQ8lHDznWbySBfKsjghXcUj9+vsHLJCVjdveBBaFh3LlZTJQ+L7mvuATj7zNOwyJVQDmZ3LLgEoOH0MzCbXCPiwqx7KZqZDZiF3SJlGEW7SOtqwahWREIeDJ6+bylJM887VaHnrJOY49BbNTi4iqSuzs6b0HNIXMCDztDgkCLl0s4bFBOcNtHY0Xl1aIC07ouvQKdaEtx+UpQCRYpSgCIl6JMkWzEJva+9MoDBrCuvmkVCQaWklSo09w4Pv4nBjde1n0VCrujkohm4bfhODC5vbz8FTaEYVCniensxmTEDTaGYlBZzFAW5YlHkJ6tgpWTgLswhI2e1TzKrmV6MhdNRJNnV2f1OdArChTY5hpqyqa58r8fjza935NrcYnIEmix9iJZ6/U8AAAAASUVORK5CYII=" mc_logo = tk.PhotoImage(data=mc_img) mc = tk.Label(logos, image=mc_logo, font='Verdana 7 bold', bg='black') mc.image = mc_logo mc.grid(row=0, column=2, sticky='w') tk.Label(logos, text='Powered By Python, PHP & MultiChain', font='Verdana 7 bold', bg='black', fg='white', bd=0).grid(row=1, column=0, columnspan=3) logos.grid_columnconfigure(0, weight=1) logos.grid_columnconfigure(1, weight=1) Footer.grid_columnconfigure(0, weight=1) tk.Label(Footer, text='Developed By', font='Verdana 7 underline', bg='black', fg='gray40', bd=0).grid(row=1, column=0, pady=(5,0)) tk.Label(Footer, text='Rishabh Raj | Kumar Saurav | Kumar Saunack | Shourya Pandey', font='Fixedsys 7 bold', bg='black', fg='gray50', bd=0).grid(row=2, column=0) tk.Label(Footer, text='Contact', font='Verdana 7 underline', bg='black', fg='gray40', bd=0).grid(row=3, column=0) tk.Label(Footer, text='*****@*****.**', font='Fixedsys 7 bold', bg='black', fg='gray50', bd=0).grid(row=4, column=0) self.update_idletasks() h = self.winfo_reqheight() hs = self.winfo_screenheight() w = self.winfo_reqwidth() ws = self.winfo_screenwidth() x = (ws/2) - (w/2) self.geometry("+%d+%d" % (x, hs-h*11/10))
'stock.csv') # transfers tempfile data into loading file load_stock_data( ) # resets and restarts program from scratch state, loading from stock.csv. #*** TKINTER WINDOW ***# # Tkinter style with Dark Sky Blue background, used to colour item headers appropriately s = ttk.Style() s.configure('new.TFrame', background='#7AC5CD') # Configure top level parent frames index_parent = ttk.Frame(root) index_parent.grid(column=0, row=0, sticky='n') root.grid_columnconfigure(0, weight=1) parent_separator = ttk.Separator(root, orient=VERTICAL) parent_separator.grid(column=1, row=0, sticky='ns', padx=5, pady=5) root.grid_columnconfigure(1, weight=0) modify_parent = ttk.Frame(root) modify_parent.grid(column=2, row=0, sticky=N) root.grid_columnconfigure(2, weight=7) root.grid_rowconfigure(0, weight=1) #* Index Frames *# index_label = ttk.Label(index_parent, text="INDEX", font=("Bahnschrift", 25)) index_label.grid(row=0, column=0, columnspan=2, sticky="n") # THESE WERE REMOVED due to a lack of time to build the associated function, and serve no purpose here. #index_search_label = ttk.Label(index_parent, text="Index Search: ") #index_search_label.grid(row=1, column=0, padx=2)
path = "./Logo.png" img = Image.open(path) # PIL solution img = img.resize((LOGO_SIZE, LOGO_SIZE), Image.ANTIALIAS) #The (250, 250) is (height, width) img = ImageTk.PhotoImage(img) panel = ttk.Label(root, image=img, anchor='center') panel.image = img panel.pack(side=TOP, fill=X) panel.configure(background=root.cget('bg')) lab = Label(root, width=20, text=description, font='Helvetica 14', pady=5) lab.pack(side=TOP, fill=X) ents = makeform(root) ttk.Separator(root, orient=HORIZONTAL).pack(side=TOP, fill=X) b1 = Button(root, text='Calculate', bg="#81b4d4", width=22, command=lambda e=ents: fetch(e)) b1.pack(side=RIGHT, padx=5, pady=5) btn_clear = Button(root, text="Clear", bg="#81b4d4", width=22, command=(lambda e=ents, root=root: clear(root, e))) btn_clear.pack(side=LEFT, padx=5, pady=5) #b2 = Button(root, text="Quit", command=exitApp).pack() #b2.pack(side=RIGHT, padx=5, pady=5)
def makeform(root): "Function creating the entry widgets for the data, includes combo box, text entry and checkbuttons" entries = [] for field in Sex: ttk.Separator(root, orient=HORIZONTAL).pack(side=TOP, fill=X) row = Frame(root) lab = Label(row, width=20, text=field, anchor='w') ent = IntVar() ent.set(1) rad1 = Radiobutton(row, text="Male", var=ent, value=1) # 1 for male rad2 = Radiobutton(row, text="Female", var=ent, value=0) # 0 for female row.pack(side=TOP, fill=X, padx=5, pady=5) lab.pack(side=LEFT) rad1.pack(side=LEFT, anchor='w') rad2.pack(side=LEFT, anchor='w') entries.append((field, ent)) for field in FIELDS.keys(): ttk.Separator(root, orient=HORIZONTAL).pack(side=TOP, fill=X) row = Frame(root) lab = Label(row, width=20, text=field, anchor='w') ent = EntryWithPlaceholder(row, FIELDS[field][0]) entries.append((field, ent)) row.pack(side=TOP, fill=X, padx=5, pady=5) lab.pack(side=LEFT) ent.pack(side=LEFT) labelText = StringVar() labelText.set(FIELDS[field][1]) labelDir = Label(row, textvariable=labelText) labelDir.pack(side=LEFT) for field in check: ttk.Separator(root, orient=HORIZONTAL).pack(side=TOP, fill=X) row = Frame(root) lab = Label(row, width=20, text=field, anchor='w') ent = IntVar() ent.set(0) chk = Checkbutton(row, var=ent) row.pack(side=TOP, fill=X, padx=5, pady=5) lab.pack(side=LEFT) chk.pack() entries.append((field, ent)) for field in education: ttk.Separator(root, orient=HORIZONTAL).pack(side=TOP, fill=X) row = Frame(root) lab = Label(row, width=20, text=field, anchor='w') # ent = ttk.Combobox(row, values = ['0', '1', '2', '3', '4']) # 1 for some high school e.g. GCSE, 2 for a # high school diploma or GED e.g. A levels, 3 # for some college or vocational school e.g Other post , and 4 for a college degree. OPTIONS = [ "High school/ GCSE level", "Sixth Form/ A level", "Post 18 training", "College/ University Degree" ] ent = StringVar() ent.set(OPTIONS[0]) # default value menu = OptionMenu(row, ent, *OPTIONS) menu.config(width=25) row.pack(side=TOP, fill=X, padx=5, pady=5) lab.pack(side=LEFT) menu.pack(side=RIGHT, expand=NO, fill=X) entries.append((field, ent)) return entries
def boton_aceleracionf(self): #funcion para la obtencion de tiempo impacto final def time_impact(self): t = ((self.velocidad_inicial * sin(self.angulo)) / (2 * self.gravedad)) + ( (1 / self.gravedad) * (sqrt(((self.velocidad_inicial * sin(self.angulo))**2) + (2 * self.y0 * self.gravedad)))) print(t) return t # funcion para el calculo de la coordenada horizontal def cord_x(self, t): x = self.x0 + ((self.velocidad_inicial * cos(self.angulo)) * t) return x # funcion para el calculo de la coordenada vertical def cord_y(self, t): y = self.y0 + (((self.velocidad_inicial * (cos(self.angulo))) * t) - ((self.gravedad / 2) * (t**2))) return y # funcion altura maxima para graficar def altura_max(self): r = self.y0 + (((self.velocidad_inicial * (sin(self.angulo)))**2) / (2 * self.gravedad)) return r # funcion alcance maximo para graficar def alcance_max(self): alc = self.x0 + ((self.velocidad_inicial*sin(2*self.angulo))/(2*self.gravedad)) + \ ((self.velocidad_inicial*cos(self.angulo)) / (self.gravedad))*sqrt(((self.velocidad_inicial*sin(self.angulo))**2) + 2*self.y0*self.gravedad) return alc # generamiento de la grafica def GraficarFuncion(self, entrada_tiempo): # generacion de la grafica del tiempo ingresado time = np.arange(0, entrada_tiempo, 0.01) x = cord_x(self, time) y = cord_y(self, time) # grafica completa del lanzamiento time_complete = np.arange(0, time_impact(self) + 4, 0.01) x2 = cord_x(self, time_complete) y2 = cord_y(self, time_complete) # generacion del punto de posicion a medir x3 = cord_x(self, entrada_tiempo) y3 = cord_y(self, entrada_tiempo) # estetica de la grafica mpl.title("Aceleracion") mpl.xlim(0, alcance_max(self) + self.x0) mpl.ylim(0, altura_max(self) + self.y0) mpl.xlabel("-Distancia-") mpl.ylabel("-Altura-") # generamiento de las curvas mpl.plot(self.x0, self.y0, "k-o") # punto pos inicial mpl.plot(x, y, "y-") # curva del usuario mpl.plot(x2, y2, "k--") # lanzamiento completo mpl.plot(x3, y3, "r-o") # punto del usuario mpl.grid() # cuadriculado # generacion del vector con origen en el punto de posicion mpl.plot(x3, y3 - time_impact(self), "g-o") mpl.show() return 0 # pop up de ingreso de datos def copiar_valores(event): self.tiempo_datos[0] = entrada_tiempo.get() master.destroy() # Metodo para validar la entrada de datos (Solo Numeros por ahora) def check(v, p): if p.isdigit(): return True elif p is "": return True else: return False # Datos Iniciales # inicializa la ventana popup master = tk.Tk() master.title("Posicion") # Crea un frame contenedor para la izquierda y la derecha frame_arriba = ttk.Frame(master) frame_centro = ttk.Frame(master) frame_abajo = ttk.Frame(master) frame_aceptar = ttk.Frame(master) validacion_tiempo = (frame_abajo.register(check), '%v', '%P') # validacion_y = (frame_derecha.register(check), '%v', '%P') frame_arriba.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_centro.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_abajo.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_aceptar.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) # Crea las titulos de la entrada de datos tiempo = ttk.Label(frame_abajo, text="Tiempo: ") tiempo_init = ttk.Label(frame_arriba, text="Intervalo de tiempo") tiempo_init_x = ttk.Entry(frame_arriba, state='readonly', justify='center') tiempo_init_y = ttk.Entry(frame_arriba, state='readonly', justify='center') tiempo_init.pack(side=tk.TOP) tiempo_init_x.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_x.configure(state='normal') tiempo_init_x.delete(0, 'end') tiempo_init_x.insert(0, "0") tiempo_init_x.configure(state='readonly') # inicializa el punto de interseccion del eje Y tiempo_init_y.configure(state='normal') tiempo_init_y.delete(0, 'end') tiempo_init_y.insert(0, time_impact(self)) tiempo_init_y.configure(state='readonly') # Separador de datos separador = ttk.Separator(frame_centro, orient="horizontal") separador.pack(side=tk.TOP, expand=False, fill=tk.X) # Crea formularios para entrada de datos entrada_tiempo = ttk.Entry(frame_abajo, validate="key", validatecommand=validacion_tiempo) # entrada_y = ttk.Entry(frame_derecha, validate="key", validatecommand=validacion_y) tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) # posicion_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) entrada_tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) # entrada_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) aceptar = ttk.Button(frame_aceptar, text="ACEPTAR") aceptar.pack(fill=tk.BOTH, expand=1) aceptar.bind("<Button-1>", copiar_valores) #posible desplazamiento con pass
def boton_posicionf(self): alcanze_horizontal = self.x0 + ((self.velocidad_inicial*sin(2*self.angulo))/(2*self.gravedad)) + \ ((self.velocidad_inicial*cos(self.angulo)) / (self.gravedad))*sqrt(((self.velocidad_inicial*sin(self.angulo))**2) + 2*self.y0*self.gravedad) x = linspace(0, alcanze_horizontal, 601) ecuacion_parametrica_x = ( self.x0 + self.velocidad_inicial * cos(self.angulo) * x) ecuacion_parametrica_y = ( self.y0 + self.velocidad_inicial * sin(self.angulo) * x - (self.gravedad / 2) * x**2) self.actualizar_grafico(ecuacion_parametrica_x, ecuacion_parametrica_y) # Metodo para almacenar datos de las entradas de datos def copiar_valores(event): self.tiempo_datos[0] = entrada_tiempo.get() master.destroy() # Metodo para validar la entrada de datos (Solo Numeros por ahora) def check(v, p): if p.isdigit(): return True elif p is "": return True else: return False # Datos Iniciales # inicializa la ventana popup master = tk.Tk() master.title("Posicion") # Crea un frame contenedor para la izquierda y la derecha frame_arriba = ttk.Frame(master) frame_centro = ttk.Frame(master) frame_abajo = ttk.Frame(master) frame_aceptar = ttk.Frame(master) validacion_tiempo = (frame_abajo.register(check), '%v', '%P') #validacion_y = (frame_derecha.register(check), '%v', '%P') frame_arriba.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_centro.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_abajo.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_aceptar.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) # Crea las titulos de la entrada de datos tiempo = ttk.Label(frame_abajo, text="Tiempo: ") aceptar = ttk.Button(frame_aceptar, text="ACEPTAR") tiempo_init = ttk.Label(frame_arriba, text="Intervalo de tiempo") tiempo_init_x = ttk.Entry(frame_arriba, state='readonly', justify='center') tiempo_init_y = ttk.Entry(frame_arriba, state='readonly') tiempo_init.pack(side=tk.TOP) tiempo_init_x.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_x.configure(state='normal') tiempo_init_x.delete(0, 'end') tiempo_init_x.insert(0, "0") tiempo_init_x.configure(state='readonly') # inicializa el punto de interseccion del eje Y tiempo_init_y.configure(state='normal') tiempo_init_y.delete(0, 'end') tiempo_init_y.insert(0, "0") tiempo_init_y.configure(state='readonly') #Separador de datos separador = ttk.Separator(frame_centro, orient="horizontal") separador.pack(side=tk.TOP, expand=False, fill=tk.X) # Crea formularios para entrada de datos entrada_tiempo = ttk.Entry(frame_abajo, validate="key", validatecommand=validacion_tiempo) #entrada_y = ttk.Entry(frame_derecha, validate="key", validatecommand=validacion_y) tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) #posicion_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) entrada_tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) # entrada_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) aceptar.pack(fill=tk.BOTH, expand=1) aceptar.bind("<Button-1>", copiar_valores)
def add_track(i): image_frame = tk.Frame(list_frame) image_frame.grid(row=i, sticky="W") image_frame.list_index = i image_frame.nw = SimpleNamespace() # For accessing values later # Separator ttk.Separator(image_frame, orient="horizontal").grid(row=0, columnspan=5, sticky="EW") # Delete tk.Button(image_frame, text="Delete", command=lambda: remove_track(image_frame.list_index)) \ .grid(row=1, sticky="W") # Files file_frame = tk.Frame(image_frame) file_frame.grid(row=2, columnspan=5, sticky="W") tk.Label(file_frame, text="Image src:", fg="red").grid(row=0, column=0) image_frame.nw.input_type_var = tk.StringVar() image_frame.nw.input_type_var.set(SOURCE_TYPES[0]) input_type_menu = tk.OptionMenu(file_frame, image_frame.nw.input_type_var, *SOURCE_TYPES) input_type_menu.grid(row=0, column=1) image_frame.nw.src_label = tk.Label(file_frame, text="") image_frame.nw.src_label.grid(row=0, column=3) tk.Button(file_frame, text="Browse", command=lambda: self.src_file_dialog( image_frame.nw.input_type_var, image_frame.nw. src_label)).grid(row=0, column=2) ## todo: optional kitti file # Options options_frame = tk.Frame(image_frame) options_frame.grid(row=3, columnspan=5, sticky="W") image_frame.nw.bbox_var = tk.IntVar() bbox_check = tk.Checkbutton(options_frame, text="Bounding Box", variable=image_frame.nw.bbox_var) bbox_check.grid(row=2, column=0, sticky="W") # image_frame.nw.graph_var = tk.IntVar() # graph_check = tk.Checkbutton(options_frame, text="Graphs", variable=image_frame.nw.graph_var) # graph_check.grid(row=2, column=1, sticky="W") image_frame.nw.obj_id_var = tk.IntVar() obj_id_check = tk.Checkbutton(options_frame, text="Object IDs", variable=image_frame.nw.obj_id_var) obj_id_check.grid(row=2, column=2, sticky="W") ## Logo logo_frame = tk.Frame(image_frame) logo_frame.grid(row=4, sticky="W") image_frame.nw.logo_var = tk.IntVar() logo_check = tk.Checkbutton( logo_frame, text="Logo", variable=image_frame.nw.logo_var, command=lambda: self.toggle_frame_visibility( logo_toggle_frame, dict(row=0, column=1), image_frame.nw. logo_var), ) logo_check.grid(row=0, column=0, sticky="NW") logo_toggle_frame = tk.Frame(logo_frame) image_frame.nw.logo_file_label = tk.Label(logo_toggle_frame, text="") image_frame.nw.logo_file_label.grid(row=0, column=1, columnspan=5) tk.Button(logo_toggle_frame, text="Browse", command=lambda: self.ask_open_filename( image_frame.nw.logo_file_label, kind="file")).grid( row=0, column=0) logo_corner_label = tk.Label(logo_toggle_frame, text="Corner:") logo_corner_label.grid(row=1, column=0) image_frame.nw.logo_corner_var = tk.StringVar() image_frame.nw.logo_corner_var.set(LOGO_CORNERS[0]) logo_corner_menu = tk.OptionMenu(logo_toggle_frame, image_frame.nw.logo_corner_var, *LOGO_CORNERS) logo_corner_menu.grid(row=1, column=1) logo_height_label = tk.Label(logo_toggle_frame, text="Height:") logo_height_label.grid(row=1, column=2) image_frame.nw.logo_height_entry = tk.Entry( logo_toggle_frame, width=6, validate="key", validatecommand=self.val_cmd(logo_toggle_frame, self.validate_integer)) image_frame.nw.logo_height_entry.insert(0, "100") image_frame.nw.logo_height_entry.grid(row=1, column=3) logo_width_label = tk.Label(logo_toggle_frame, text="Width:") logo_width_label.grid(row=1, column=4) image_frame.nw.logo_width_entry = tk.Entry( logo_toggle_frame, width=6, validate="key", validatecommand=self.val_cmd(logo_toggle_frame, self.validate_integer)) image_frame.nw.logo_width_entry.insert(0, "200") image_frame.nw.logo_width_entry.grid(row=1, column=5) self.tracks.append(image_frame)
def boton_posicionf(self): xli = np.array([]) yli = np.array([]) x01 = 10 y01 = 10 angulox = degrees(20) v01 = 5 t_impacto = ((v01 * sin(angulox)) / (2 * self.gravedad)) + ((1 / self.gravedad) * (sqrt(((v01 * sin(angulox))**2) + (2 * y01 * self.gravedad)))) t = linspace(0, t_impacto, 601) for d in t: #np.append(xli,x01 + ((v01 * cos(angulox)) * d)) ex = x01 + ((v01 * cos(angulox)) * d) xli = np.append(xli, ex) ex2 = y01 + (((v01 * (cos(angulox))) * d) - ((self.gravedad / 2) * (d**2))) yli = np.append(yli, ex2) # Ecuaciones #Update de grafico self.ax.set_title('Grafico Posicion') self.ax.set_xlabel('distancia') self.ax.set_ylabel('altura') self.ax.set_xlim(0, 20) self.ax.set_ylim(0, 20) self.ax.grid() self.ax.plot(xli, yli, "--") self.figure.canvas.draw() #alcanze_horizontal = self.x0 + ((self.velocidad_inicial*sin(2*self.angulo))/(2*self.gravedad)) + \ # ((self.velocidad_inicial*cos(self.angulo)) / # (self.gravedad))*sqrt(((self.velocidad_inicial*sin(self.angulo))**2) + 2*self.y0*self.gravedad) #x = linspace(0, alcanze_horizontal, 601) #ecuacion_parametrica_x = (self.x0 + self.velocidad_inicial*cos(self.angulo)*x) #ecuacion_parametrica_y = (self.y0 + self.velocidad_inicial*sin(self.angulo)*x-(self.gravedad/2)*x**2) #self.actualizar_grafico(ecuacion_parametrica_x,ecuacion_parametrica_y) # Metodo para almacenar datos de las entradas de datos def copiar_valores(event): self.tiempo_datos[0] = entrada_tiempo.get() #self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.graphics) #self.toolbar.pack() #self.toolbar.update() master.destroy() # Metodo para validar la entrada de datos (Solo Numeros por ahora) def check(v, p): if p.isdigit(): return True elif p is "": return True else: return False # Datos Iniciales # inicializa la ventana popup master = tk.Tk() master.title("Posicion") # Crea un frame contenedor para la izquierda y la derecha frame_arriba = ttk.Frame(master) frame_centro = ttk.Frame(master) frame_abajo = ttk.Frame(master) frame_aceptar = ttk.Frame(master) validacion_tiempo = (frame_abajo.register(check), '%v', '%P') #validacion_y = (frame_derecha.register(check), '%v', '%P') frame_arriba.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_centro.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_abajo.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_aceptar.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) # Crea las titulos de la entrada de datos tiempo = ttk.Label(frame_abajo, text="Tiempo: ") aceptar = ttk.Button(frame_aceptar, text="ACEPTAR") tiempo_init = ttk.Label(frame_arriba, text="Intervalo de tiempo") tiempo_init_x = ttk.Entry(frame_arriba, state='readonly', justify='center') tiempo_init_y = ttk.Entry(frame_arriba, state='readonly') tiempo_init.pack(side=tk.TOP) tiempo_init_x.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_x.configure(state='normal') tiempo_init_x.delete(0, 'end') tiempo_init_x.insert(0, "0") tiempo_init_x.configure(state='readonly') # inicializa el punto de interseccion del eje Y tiempo_init_y.configure(state='normal') tiempo_init_y.delete(0, 'end') tiempo_init_y.insert(0, "0") tiempo_init_y.configure(state='readonly') #Separador de datos separador = ttk.Separator(frame_centro, orient="horizontal") separador.pack(side=tk.TOP, expand=False, fill=tk.X) # Crea formularios para entrada de datos entrada_tiempo = ttk.Entry(frame_abajo, validate="key", validatecommand=validacion_tiempo) #entrada_y = ttk.Entry(frame_derecha, validate="key", validatecommand=validacion_y) tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) #posicion_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) entrada_tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) # entrada_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) aceptar.pack(fill=tk.BOTH, expand=1) aceptar.bind("<Button-1>", copiar_valores)
def __init__(self): self.BUFSIZ = 1024 self.client_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Tkinter GUI self.win = tk.Tk() self.win.title('PGP Client') self.win.resizable(False, False) ttk.Label(self.win, text='Host :').grid(row=1, column=0) ttk.Label(self.win, text='Port :').grid(row=2, column=0) ttk.Label(self.win, text='Client').grid(row=0, column=3) ttk.Separator(self.win, orient='vertical').grid(row=1, column=3, rowspan=6, sticky='ns') ttk.Separator(self.win, orient='horizontal').grid(row=0, column=0, columnspan=3, sticky='we') ttk.Separator(self.win, orient='horizontal').grid(row=0, column=4, columnspan=3, sticky='we') ttk.Label(self.win, text='© Jaehee').grid(column=3, row=7) ttk.Separator(self.win, orient='horizontal').grid(row=7, column=0, columnspan=3, sticky='we') ttk.Separator(self.win, orient='horizontal').grid(row=7, column=4, columnspan=3, sticky='we') self.chat_host = tk.StringVar() self.chat_host.set('localhost') chat_host_entered = ttk.Entry(self.win, width=30, textvariable=self.chat_host).grid( row=1, column=1) self.chat_port = tk.StringVar() chat_port_entered = ttk.Entry(self.win, width=30, textvariable=self.chat_port).grid( row=2, column=1) run_client = ttk.Button( self.win, text='서버 접속', command=lambda: Thread(target=self.join_chat).start()) run_client.grid(row=1, column=2) ttk.Separator(self.win, orient='horizontal').grid(row=3, column=0, sticky='we') ttk.Label(self.win, text='Message').grid(column=1, row=3) ttk.Separator(self.win, orient='horizontal').grid(row=3, column=2, sticky='we') self.scr_message = scrolledtext.ScrolledText(self.win, width=62, height=24, wrap=tk.WORD) self.scr_message.grid(column=0, row=4, columnspan=3) ttk.Separator(self.win, orient='horizontal').grid(row=5, column=0, sticky='we') ttk.Label(self.win, text='Input').grid(column=1, row=5) ttk.Separator(self.win, orient='horizontal').grid(row=5, column=2, sticky='we') self.chat_message = tk.StringVar() chat_message_entered = ttk.Entry(self.win, width=30, textvariable=self.chat_message).grid( row=6, column=1) send_message = ttk.Button(self.win, text='전송', command=self.submit_chat).grid(row=6, column=2) ttk.Label(self.win, text='Log').grid(row=3, column=4) self.scr_log = scrolledtext.ScrolledText(self.win, width=62, height=24, wrap=tk.WORD) self.scr_log.grid(row=4, column=4)
def boton_aceleracionf(self): #funcion para la obtencion de tiempo impacto final def time_impact(self): t = ((self.velocidad_inicial * sin(self.angulo)) / (2 * self.gravedad)) + ( (1 / self.gravedad) * (sqrt(((self.velocidad_inicial * sin(self.angulo))**2) + (2 * self.y0 * self.gravedad)))) print(t) return t # funcion para el calculo de la coordenada horizontal def cord_x(self, t): x = self.x0 + ((self.velocidad_inicial * cos(self.angulo)) * t) return x # funcion para el calculo de la coordenada vertical def cord_y(self, t): y = self.y0 + (((self.velocidad_inicial * (cos(self.angulo))) * t) - ((self.gravedad / 2) * (t**2))) return y # funcion altura maxima para graficar def altura_max(self): r = self.y0 + (((self.velocidad_inicial * (sin(self.angulo)))**2) / (2 * self.gravedad)) return r # funcion alcance maximo para graficar def alcance_max(self): alc = self.x0 + ((self.velocidad_inicial*sin(2*self.angulo))/(2*self.gravedad)) + \ ((self.velocidad_inicial*cos(self.angulo)) / (self.gravedad))*sqrt(((self.velocidad_inicial*sin(self.angulo))**2) + 2*self.y0*self.gravedad) return alc # pop up de ingreso de datos Pop_Up = tk.Tk() Pop_Up.title("Aceleracion") frame_arriba = ttk.Frame(Pop_Up) frame_centro = ttk.Frame(Pop_Up) frame_abajo = ttk.Frame(Pop_Up) frame_evaluar = ttk.Frame(Pop_Up) frame_salir = ttk.Frame(Pop_Up) frame_arriba.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_centro.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_abajo.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_evaluar.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) frame_salir.pack(side=tk.TOP, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo = ttk.Label(frame_abajo, text="Tiempo(s):") aceptar = ttk.Button(frame_evaluar, text="ACEPTAR") tiempo_init = ttk.Label(frame_arriba, text="Intervalo de tiempo") tiempo_init_x = ttk.Entry(frame_arriba, state='readonly', justify='center') tiempo_init_y = ttk.Entry(frame_arriba, state='readonly') tiempo_init.pack(side=tk.TOP) tiempo_init_x.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) tiempo_init_x.configure(state='normal') tiempo_init_x.delete(0, 'end') tiempo_init_x.insert(0, "0") tiempo_init_x.configure(state='readonly') # inicializa el punto de interseccion del eje Y tiempo_init_y.configure(state='normal') tiempo_init_y.delete(0, 'end') tiempo_init_y.insert(0, time_impact(self)) tiempo_init_y.configure(state='readonly') # Separador de datos separador = ttk.Separator(frame_centro, orient="horizontal") separador.pack(side=tk.TOP, expand=False, fill=tk.X) # Crea formularios para entrada de datos entrada_tiempo = ttk.Entry(frame_abajo, validate="key") # entrada_y = ttk.Entry(frame_derecha, validate="key", validatecommand=validacion_y) tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) # posicion_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) entrada_tiempo.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) # entrada_y.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5, pady=5) button = ttk.Button(frame_evaluar, text='Salir', width=8, command=Pop_Up.destroy) button.pack(side=tk.BOTTOM) button2 = ttk.Button(frame_evaluar, text='Evaluar', width=8, command=Pop_Up.mainloop) button2.pack(side=tk.BOTTOM) mpl.show() #tiempo ingresado por el usuario(temporal) time_usuario = 1 # generamiento de la grafica #generacion de la grafica del tiempo ingresado time = np.arange(0, time_usuario, 0.01) x = cord_x(self, time) y = cord_y(self, time) #grafica completa del lanzamiento time_complete = np.arange(0, time_impact(self) + 4, 0.01) x2 = cord_x(self, time_complete) y2 = cord_y(self, time_complete) #generacion del punto de posicion a medir x3 = cord_x(self, time_usuario) y3 = cord_y(self, time_usuario) #estetica de la grafica mpl.title("Aceleracion") mpl.xlim(0, alcance_max(self) + self.x0) mpl.ylim(0, altura_max(self) + self.y0) mpl.xlabel("-Distancia-") mpl.ylabel("-Altura-") #generamiento de las curvas mpl.plot(self.x0, self.y0, "k-o") #punto pos inicial mpl.plot(x, y, "y-") #curva del usuario mpl.plot(x2, y2, "k--") #lanzamiento completo mpl.plot(x3, y3, "r-o") #punto del usuario mpl.grid() #cuadriculado #generacion del vector con origen en el punto de posicion mpl.plot(x3, y3 - time_impact(self), "g-o") # inicializa el punto de interseccion del eje Y tiempo_init_y.configure(state='normal') tiempo_init_y.delete(0, 'end') tiempo_init_y.insert(0, time_impact(self)) tiempo_init_y.configure(state='readonly')
def __init__(self): super().__init__() _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#d9d9d9' # X11 color: 'gray85' font11 = "-family {bitstream charter} -size 14 -weight normal " \ "-slant roman -underline 0 -overstrike 0" font9 = "-family {bitstream charter} -size 14 -weight bold " \ "-slant italic -underline 0 -overstrike 0" self.style = ttk.Style() if sys.platform == "win32": self.style.theme_use('winnative') self.style.configure('.', background=_bgcolor) self.style.configure('.', foreground=_fgcolor) self.style.configure('.', font="TkDefaultFont") self.style.map('.', background=[('selected', _compcolor), ('active', _ana2color)]) self.geometry("764x612+321+82") self.minsize(1, 1) self.maxsize(1351, 738) self.resizable(1, 1) self.title("New selflevel") self.configure(background="#1b5f8c") self.power_val = tk.IntVar() self.power_val.set(0) self.freq_val = tk.IntVar() self.freq_val.set(0) self.power_low = tk.Button(self, command=self.power_low_func) self.power_low.place(relx=0.17, rely=0.644, height=25, width=84) self.power_low.configure(activebackground="#d9d9d9") self.power_low.configure(text='''Decrease''') self.power_rise = tk.Button(self, command=self.power_rise_func) self.power_rise.place(relx=0.17, rely=0.556, height=25, width=84) self.power_rise.configure(activebackground="#d9d9d9") self.power_rise.configure(text='''Increase''') self.freq_rise = tk.Button(self, command=self.freq_rise_func) self.freq_rise.place(relx=0.694, rely=0.556, height=25, width=84) self.freq_rise.configure(activebackground="#d9d9d9") self.freq_rise.configure(text='''Increase''') self.freq_low = tk.Button(self, command=self.freq_low_func) self.freq_low.place(relx=0.694, rely=0.644, height=25, width=84) self.freq_low.configure(activebackground="#d9d9d9") self.freq_low.configure(text='''Decrease''') self.Label1 = tk.Label(self) self.Label1.place(relx=0.302, rely=0.304, height=55, width=279) self.Label1.configure(background="#1b5f8c") self.Label1.configure(font=font9) self.Label1.configure(foreground="#fff7fa") self.Label1.configure(text='''The LASER Control GUI''') self.Label2 = tk.Label(self) self.Label2.place(relx=0.108, rely=0.222, height=27, width=118) self.Label2.configure(activebackground="#1b5f8c") self.Label2.configure(activeforeground="white") self.Label2.configure(background="#1b5f8c") self.Label2.configure(font=font11) self.Label2.configure(text='''Set the Power''') self.power_label = tk.Label(self) self.power_label.place(relx=0.185, rely=0.422, height=25, width=59) self.power_label.configure(textvar=self.power_val) self.Label5 = tk.Label(self) self.Label5.place(relx=0.34, rely=0.422, height=25, width=49) self.Label5.configure(background="#1b5f8c") self.Label5.configure(text='''mJ''') self.Label6 = tk.Label(self) self.Label6.place(relx=0.046, rely=0.422, height=25, width=49) self.Label6.configure(background="#1b5f8c") self.Label6.configure(text='''Power:''') self.TSeparator1 = ttk.Separator(self) self.TSeparator1.place(relx=0.463, rely=0.444, relheight=0.322) self.TSeparator1.configure(orient="vertical") self.Label2_1 = tk.Label(self) self.Label2_1.place(relx=0.626, rely=0.222, height=27, width=198) self.Label2_1.configure(activebackground="#f9f9f9") self.Label2_1.configure(background="#1b5f8c") self.Label2_1.configure(font="-family {bitstream charter} -size 14") self.Label2_1.configure(text='''Set the Frequency''') self.Label6_2 = tk.Label(self) self.Label6_2.place(relx=0.509, rely=0.422, height=25, width=119) self.Label6_2.configure(activebackground="#f9f9f9") self.Label6_2.configure(background="#1b5f8c") self.Label6_2.configure(text='''Frequency:''') self.Freq_label = tk.Label(self) self.Freq_label.place(relx=0.71, rely=0.422, height=25, width=59) self.Freq_label.configure(activebackground="#f9f9f9") self.Freq_label.configure(textvar=self.freq_val) self.Label5_4 = tk.Label(self) self.Label5_4.place(relx=0.864, rely=0.422, height=25, width=49) self.Label5_4.configure(activebackground="#f9f9f9") self.Label5_4.configure(background="#1b5f8c") self.Label5_4.configure(text='''Hz''') self.Label3 = tk.Label(self) self.Label3.place(relx=0.28, rely=0, height=195, width=280) photo_location = os.path.join(prog_location, "./images.jpg") global _img0 _img0 = ImageTk.PhotoImage(file=photo_location) self.Label3.configure(image=_img0) self.Label3.configure(text='''Label''')
def boton_vector_normalf(self): velocidad = int(self.entrada_Rapidez_inicial.get()) angulo_inicial = int(self.entrada_angulo_inicial.get()) nose = (self.gravedad * int(self.entrada_posicion_y0.get()) / math.pow(velocidad, 2)) tiempo_maximov1 = (velocidad / self.gravedad) * ( (math.sin(math.radians(angulo_inicial))) + math.sqrt( math.pow(math.sin(math.radians(angulo_inicial)), 2) + 2 * nose)) tiempo_maximo = tiempo_maximov1 print(tiempo_maximov1) label = tk.Label(Pop_Up) label.pack() # Crea un cuadro que contiene los datos # Organiza los datos separador = ttk.Separator(Pop_Up, orient="horizontal") separador.pack(side=tk.TOP, expand=False, fill=tk.X) # Tiempo Impacto def time_impact(self): t = ((self.velocidad_inicial * sin(self.angulo)) / (2 * self.gravedad)) + ( (1 / self.gravedad) * (sqrt(((self.velocidad_inicial * sin(self.angulo))**2) + (2 * self.y0 * self.gravedad)))) print(t) return t # Coordenada X def cord_x(self, t): x = self.x0 + ((self.velocidad_inicial * cos(self.angulo)) * t) return x # # Coordenada Y def cord_y(self, t): y = self.y0 + (((self.velocidad_inicial * (cos(self.angulo))) * t) - ((self.gravedad / 2) * (t**2))) return y # Altura máxima gráfica def altura_max(self): r = self.y0 + (((self.velocidad_inicial * (sin(self.angulo)))**2) / (self.gravedad)) return r # Alcance maximo gráfica def alcance_max(self): alc = self.x0 + ((self.velocidad_inicial * sin(2 * self.angulo)) / (self.gravedad)) + \ ((self.velocidad_inicial * cos(self.angulo)) / (self.gravedad)) * sqrt( ((self.velocidad_inicial * sin(self.angulo)) ** 2) + 2 * self.y0 * self.gravedad) return alc time_usuario = 1 # Tiempo ingresado(arreglar) # Grafica del tiempo ingresado time = np.arange(0, time_usuario, 0.01) x = cord_x(self, time) y = cord_y(self, time) # Grafica completa lanzamiento time_complete = np.arange(0, time_impact(self) + 4, 0.01) x2 = cord_x(self, time_complete) y2 = cord_y(self, time_complete) # Punto de posicion a medir x3 = cord_x(self, time_usuario) y3 = cord_y(self, time_usuario) # Detalles gráfica mpl.title("Aceleracion normal y tangencial") mpl.xlim(0, alcance_max(self) + self.x0) mpl.ylim(0, altura_max(self) + self.y0) mpl.xlabel("Distancia") mpl.ylabel("Altura") # Generación curvas mpl.plot(self.x0, self.y0, "k-o") # Posición inicial mpl.plot(x, y, "y-") # Curva mpl.plot(x2, y2, "k--") # Lanzamiento # mpl.plot(x3, y3, "r-o") # Punto ingresado #Punto rojo de altura maxima mpl.grid() # Cuadriculacion del grafico # Generación de las flechas para aceleración normal y tangencial # >>>>Genera bien las flechas y texto, pero tira un warning. Falta arreglar<<<< ax = mpl.axes() ax1 = mpl.axes() ax.text(15.4, 10.8, 'an', fontsize=9) # Texto aceleracion normal ax.arrow(x3, y3, 0, -4, head_width=0.5, head_length=1, fc='k', ec='k') # Flecha de aceleracion normal ax.text(18.7, 13.7, 'at', fontsize=9) # Texto aceleracion tangencial ax1.arrow(x3, y3, 5, 0, head_width=0.5, head_length=1, fc='k', ec='k') # Flecha de aceleracion tangencial # Muestra el grafico mpl.plot() mpl.show() pass
def create_widgets(self): """Widgets creation.""" self.TagB = tk.Button(self, text=_("Tag Game"), command=self.BeginTag, justify='center') self.TagB.grid(row=0, column=0, sticky="NEWS") self.separ = ttk.Separator(self, orient='horizontal') self.separ.grid(row=1, column=0, columnspan=5, sticky="WE") self.two_separ = ttk.Separator(self, orient='horizontal') self.two_separ.grid(row=3, column=0, columnspan=5, sticky="NWE") self.one_two_separ = ttk.Separator(self, orient='vertical') self.one_two_separ.grid(row=0, column=1, rowspan=3, sticky="NS") self.TagIm = ImageTk.PhotoImage( (Image.open("./Entertainment/pyatna.png")).resize((200, 200), Image.ANTIALIAS)) self.TagLab = tk.Label(self, image=self.TagIm, width=200, height=200) self.TagLab.grid(row=2, column=0, sticky="N") self.GraphB = tk.Button(self, text=_("Simple Graphics"), command=self.BeginGraph) self.GraphB.grid(row=0, column=2, sticky="NEWS") self.GraphIm = ImageTk.PhotoImage( (Image.open("./Entertainment/paint.png")).resize((200, 200), Image.ANTIALIAS)) self.GraphLab = tk.Label(self, image=self.GraphIm, width=200, height=200) self.GraphLab.grid(row=2, column=2, sticky="N") self.two_three_separ = ttk.Separator(self, orient='vertical') self.two_three_separ.grid(row=0, column=3, rowspan=3, sticky="NS") self.TTTB = tk.Button(self, text=_("Tic-tac-toe"), command=self.BeginTTT) self.TTTB.grid(row=0, column=4, sticky="NEWS") self.TTTIm = ImageTk.PhotoImage( (Image.open("./Entertainment/tictactoe.png")).resize( (200, 200), Image.ANTIALIAS)) self.TTTLab = tk.Label(self, image=self.TTTIm, width=200, height=200) self.TTTLab.grid(row=2, column=4, sticky="N") self.QuitB = tk.Button(self, text=_("Quit"), command=self.go_back) self.QuitB.grid(row=4, column=0, columnspan=5, sticky="NWE") self.menubar = tk.Menu(self) self.filemenu = tk.Menu(self.menubar, tearoff=0) self.filemenu.add_separator() self.filemenu.add_command(label=_("Go to Main Menu"), command=self.go_back) self.filemenu.add_command(label=_("Close"), command=self.quit) self.menubar.add_cascade(label=_("Menu"), menu=self.filemenu) self.master.config(menu=self.menubar)
def janela_temporada(self): ''' Método que oferece opções para alterar o criar uma temporada. Altera a variável global NOME_TABELA. ''' def escolhas(param): if param == "criar": self.listagem.configure(background="gray", state=tk.DISABLED) self.entrada1.configure(state=tk.NORMAL) else: self.listagem.configure(background="white", state=tk.NORMAL) self.entrada1.configure(state=tk.DISABLED) self.botao_escolhido.set(param) def buscar(param): self.temporadas, self.temp_atual = param if self.primeiravez: self.primeiravez = False else: self.listagem.delete(0, "end") for item in self.temporadas: self.listagem.insert(tk.END, item) self.listagem.selection_set(first=0) def verif_tabela_existente(lista, entrada, temp_atual): if entrada == temp_atual.replace("temporada_", ""): return False for x in lista: if entrada == x.replace("temporada_", ""): return False return entrada def confirmar(): global NOME_TABELA validar = False msg = "Erro!\n" if self.botao_escolhido.get() == "criar": try: numero = int(self.entrada1.get()) if numero < 1 or numero > 10_000: msg += "O número da temporada deve estar entre 1 e 10.000. Tente novamente!" raise Exception verif = verif_tabela_existente(self.temporadas, self.entrada1.get(), self.temp_atual) if not verif: msg += "Não foi possível criar essa temporada pois a numeração escolhida já consta no BD." raise Exception except ValueError: tk.messagebox.showinfo( title="ERROU!!!", message="Valor inválido na numeração da temporada!") janela.focus_force() except Exception: tk.messagebox.showinfo(title="ERROU!!!", message=msg) janela.focus_force() else: self.controlador.altera_cria_temp("criação", self.entrada1.get()) NOME_TABELA = self.entrada1.get() validar = True tk.messagebox.showinfo( title="Sucesso!", message= f"Temporada {self.entrada1.get()} criada com sucesso!") else: try: self.controlador.altera_cria_temp( "alterar", self.listagem.get(self.listagem.curselection())) NOME_TABELA = self.listagem.get( self.listagem.curselection()).replace( "temporada_", "") validar = True tk.messagebox.showinfo( title="Sucesso!", message= f"Alteração com sucesso para temporada {NOME_TABELA}!") except: pass if validar: self.botao_buscar.invoke() janela.destroy() janela = tk.Tk() janela.iconbitmap(janela, ICONE) janela.wm_title("Opções em temporadas") janela.grid_rowconfigure(0, weight=1) janela.grid_columnconfigure(0, weight=1) self.botao_escolhido = tk.StringVar() self.botao_escolhido.set("criar") self.botao_rad_1 = ttk.Radiobutton( janela, text="Temporadas localizadas", variable=self.botao_escolhido, value="localizar", command=lambda: escolhas("localizar")) self.botao_rad_1.grid(row=1, column=0, pady=10) self.botao_rad_2 = ttk.Radiobutton(janela, text="Criar temporada", variable=self.botao_escolhido, value="criar", command=lambda: escolhas("criar")) self.botao_rad_2.grid(row=1, column=4, pady=10) self.listagem = tk.Listbox(janela, selectmode=tk.SINGLE) self.listagem.configure(background="gray") self.listagem.configure(disabledforeground="black") self.listagem.grid(columnspan=2, row=2, rowspan=4, padx=10, pady=10) sep1 = ttk.Separator(janela) sep1.configure(orient="vertical") sep1.grid(row=1, column=2, rowspan=5, sticky="ns") msg1 = tk.Label(janela, text="Temporada:") msg1.grid(row=3, column=3) self.entrada1 = ttk.Entry(janela) self.entrada1.insert(0, "1 a 10000") self.entrada1.grid(row=3, column=4, padx=5) sep2 = ttk.Separator(janela) sep2.configure(orient="horizontal") sep2.grid(row=6, column=0, columnspan=6, sticky="we") self.botao_buscar = tk.Button( janela, text="Buscar temporadas", command=lambda: buscar(self.controlador.altera_cria_temp("inicial") ), bg="blue", fg="white") self.botao_buscar.grid(row=7, column=0, pady=10) botao1 = tk.Button(janela, text="Sair", command=janela.destroy, bg="orange", fg="white") botao1.grid(row=7, column=3, pady=10, padx=30) botao2 = tk.Button(janela, text="Confirmar", command=confirmar, bg="green", fg="white") botao2.grid(row=7, column=4, pady=10) self.primeiravez = True self.botao_escolhido.set("localizar") self.botao_buscar.invoke() self.botao_escolhido.set("criar") self.botao_rad_2.invoke() tk.mainloop()
def __init__(self, top=None): '''This class configures and populates the toplevel window. top is the toplevel containing window.''' _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#ececec' # Closest X11 color: 'gray92' font9 = "-family {Segoe UI} -size 24 -weight normal -slant " \ "roman -underline 0 -overstrike 0" self.style = ttk.Style() if sys.platform == "win32": self.style.theme_use('winnative') self.style.configure('.', background=_bgcolor) self.style.configure('.', foreground=_fgcolor) self.style.configure('.', font="TkDefaultFont") self.style.map('.', background=[('selected', _compcolor), ('active', _ana2color)]) root.iconbitmap('vlogo.ico') top.geometry("600x450+698+293") top.title("SARAF ROOMS ALLOTMENT") top.configure(background="#d9d9d9") self.Message1 = tk.Message(top) self.Message1.place(relx=0.05, rely=0.067, relheight=0.296, relwidth=0.367) self.Message1.configure(background="#d9d9d9") self.Message1.configure(font=font9) self.Message1.configure(foreground="#000000") self.Message1.configure(highlightbackground="#d9d9d9") self.Message1.configure(highlightcolor="black") self.Message1.configure(text='''LOGIN PAGE FOR SARAF FACULTIES''') self.Message1.configure(width=220) self.menubar = tk.Menu(top, font="TkMenuFont", bg=_bgcolor, fg=_fgcolor) top.configure(menu=self.menubar) self.TSeparator1 = ttk.Separator(top) self.TSeparator1.place(relx=0.467, rely=0.022, relheight=0.356) self.TSeparator1.configure(orient="vertical") self.Message2 = tk.Message(top) self.Message2.place(relx=0.017, rely=0.6, relheight=0.14, relwidth=0.233) self.Message2.configure(background="#d9d9d9") self.Message2.configure(foreground="#000000") self.Message2.configure(highlightbackground="#d9d9d9") self.Message2.configure(highlightcolor="black") self.Message2.configure(text='''ADMIN PASSWORD:''') self.Message2.configure(width=140) mystring = StringVar() self.TEntry1 = ttk.Entry(top, textvariable=mystring) self.TEntry1.place(relx=0.233, rely=0.644, relheight=0.047, relwidth=0.243) self.TEntry1.configure(width=146) self.TEntry1.configure(takefocus="") self.TEntry1.configure(cursor="ibeam") self.TEntry1.configure(show="*", width=15) def getvalue(): print(mystring.get()) mystring.get() self.style.map('TCheckbutton', background=[('selected', _bgcolor), ('active', _ana2color)]) self.TCheckbutton2 = ttk.Checkbutton(top) self.TCheckbutton2.place(relx=0.217, rely=0.756, relwidth=0.218, relheight=0.0, height=21) self.TCheckbutton2.configure(variable=tch50) self.TCheckbutton2.configure(takefocus="") self.TCheckbutton2.configure(text='''KEEP ME SIGNED IN''') self.TCheckbutton2.configure(width=131) def login_admin(): login_message() def update(): top = Toplevel() top.geometry("475x291+652+297") top.title("UPDATE") top.configure(background="#8eb574") x = IntVar() y = StringVar() z = IntVar() w = StringVar() p = IntVar() def run_update(): sql= "insert into room (roomid, type, beds, block, rno, taken)"\ + " values (%s, %s, %s, %s, %s, %s) " cur.execute(sql, ("'x.get'", 'y.get', "'z.get'", 'w.get', "'p.get'", '0')) self.Entry1 = tk.Entry(top, textvariable=x) self.Entry1.place(relx=0.253, rely=0.103, height=20, relwidth=0.345) self.Entry1.configure(background="white") self.Entry1.configure(disabledforeground="#a3a3a3") self.Entry1.configure(font="TkFixedFont") self.Entry1.configure(foreground="#000000") self.Entry1.configure(insertbackground="black") self.Entry2 = tk.Entry(top, textvariable=y) self.Entry2.place(relx=0.253, rely=0.206, height=20, relwidth=0.345) self.Entry2.configure(background="white") self.Entry2.configure(disabledforeground="#a3a3a3") self.Entry2.configure(font="TkFixedFont") self.Entry2.configure(foreground="#000000") self.Entry2.configure(insertbackground="black") self.Entry3 = tk.Entry(top, textvariable=z) self.Entry3.place(relx=0.253, rely=0.412, height=20, relwidth=0.345) self.Entry3.configure(background="white") self.Entry3.configure(disabledforeground="#a3a3a3") self.Entry3.configure(font="TkFixedFont") self.Entry3.configure(foreground="#000000") self.Entry3.configure(insertbackground="black") self.Entry4 = tk.Entry(top, textvariable=w) self.Entry4.place(relx=0.253, rely=0.309, height=20, relwidth=0.345) self.Entry4.configure(background="white") self.Entry4.configure(disabledforeground="#a3a3a3") self.Entry4.configure(font="TkFixedFont") self.Entry4.configure(foreground="#000000") self.Entry4.configure(insertbackground="black") self.Entry6 = tk.Entry(top, textvariable=p) self.Entry6.place(relx=0.253, rely=0.515, height=20, relwidth=0.345) self.Entry6.configure(background="white") self.Entry6.configure(disabledforeground="#a3a3a3") self.Entry6.configure(font="TkFixedFont") self.Entry6.configure(foreground="#000000") self.Entry6.configure(insertbackground="black") self.Button1 = tk.Button(top, command=run_update) self.Button1.place(relx=0.253, rely=0.722, height=64, width=187) self.Button1.configure(activebackground="#ececec") self.Button1.configure(activeforeground="#000000") self.Button1.configure(background="#d9d9d9") self.Button1.configure(disabledforeground="#a3a3a3") self.Button1.configure(foreground="#000000") self.Button1.configure(highlightbackground="#d9d9d9") self.Button1.configure(highlightcolor="black") self.Button1.configure(pady="0") self.Button1.configure(text='''UPDATE''') self.Button1.configure(width=187) self.Message1 = tk.Message(top) self.Message1.place(relx=0.042, rely=0.103, relheight=0.079, relwidth=0.128) self.Message1.configure(background="#d9d9d9") self.Message1.configure(foreground="#000000") self.Message1.configure(highlightbackground="#d9d9d9") self.Message1.configure(highlightcolor="black") self.Message1.configure(text='''ROOMID''') self.Message1.configure(width=60) self.Message2 = tk.Message(top) self.Message2.place(relx=0.042, rely=0.206, relheight=0.096, relwidth=0.135) self.Message2.configure(background="#d9d9d9") self.Message2.configure(foreground="#000000") self.Message2.configure(highlightbackground="#d9d9d9") self.Message2.configure(highlightcolor="black") self.Message2.configure(text='''TYPE''') self.Message2.configure(width=64) self.Message3 = tk.Message(top) self.Message3.place(relx=0.042, rely=0.309, relheight=0.079, relwidth=0.086) self.Message3.configure(background="#d9d9d9") self.Message3.configure(foreground="#000000") self.Message3.configure(highlightbackground="#d9d9d9") self.Message3.configure(highlightcolor="black") self.Message3.configure(text='''BEDS''') self.Message3.configure(width=60) self.Message4 = tk.Message(top) self.Message4.place(relx=0.042, rely=0.412, relheight=0.079, relwidth=0.107) self.Message4.configure(background="#d9d9d9") self.Message4.configure(foreground="#000000") self.Message4.configure(highlightbackground="#d9d9d9") self.Message4.configure(highlightcolor="black") self.Message4.configure(text='''BLOCK''') self.Message4.configure(width=60) self.Message5 = tk.Message(top) self.Message5.place(relx=0.042, rely=0.515, relheight=0.079, relwidth=0.149) self.Message5.configure(background="#d9d9d9") self.Message5.configure(foreground="#000000") self.Message5.configure(highlightbackground="#d9d9d9") self.Message5.configure(highlightcolor="black") self.Message5.configure(text='''ROOMNO.''') self.Message5.configure(width=60) self.Message6 = tk.Message(top) self.Message6.place(relx=0.042, rely=0.619, relheight=0.079, relwidth=0.107) self.Message6.configure(background="#d9d9d9") self.Message6.configure(foreground="#000000") self.Message6.configure(highlightbackground="#d9d9d9") self.Message6.configure(highlightcolor="black") self.Message6.configure(text='''TAKEN''') self.Message6.configure(width=60) self.Message7 = tk.Message(top) self.Message7.place(relx=0.253, rely=0.619, relheight=0.079, relwidth=0.337) self.Message7.configure(background="#d9d9d9") self.Message7.configure(foreground="#000000") self.Message7.configure(highlightbackground="#d9d9d9") self.Message7.configure(highlightcolor="black") self.Message7.configure(text='''0''') self.Message7.configure(width=160) class Toplevel1_1: top = Toplevel() def __init__(self, top=None): #This class configures and populates the toplevel window.top is the toplevel containing window _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#ececec' # Closest X11 color: 'gray92' font12 = "-family Rockwell -size 40 -weight normal -slant " \ "roman -underline 0 -overstrike 0" top.geometry("600x450+670+298") top.title("ADMIN") top.configure(background="#c2d89c") top.configure(highlightbackground="#6ee6ef") def add_bed(): print("beds gonna be added soon...........") mbox.showinfo("ADDING BEDS", "YOU WILL BE ADDING BEDS....") update() def add_room(): print("rooms gonna be added soon...........") mbox.showinfo("ADDING ROOMS", "YOU WILL BE ADDING ROOMS....") update() def add_block(): print("blocks gonna be added soon...........") mbox.showinfo("ADDING BLOCKS", "YOU WILL BE ADDING BLOCKS....") update() def add_student(): print("student is gonna be added soon...........") mbox.showinfo("ADDING STUDENTS", "YOU WILL BE ADDING STUDENTS....") self.Button1 = tk.Button(top, command=add_room) self.Button1.place(relx=0.017, rely=0.422, height=64, width=197) self.Button1.configure(activebackground="#ececec") self.Button1.configure(activeforeground="#000000") self.Button1.configure(background="#d9d9d9") self.Button1.configure(cursor="hand2") self.Button1.configure(disabledforeground="#a3a3a3") self.Button1.configure(foreground="#000000") self.Button1.configure(highlightbackground="#d9d9d9") self.Button1.configure(highlightcolor="black") self.Button1.configure(pady="0") self.Button1.configure(text='''ADD ROOMS''') self.Button1.configure(width=197) self.Button2 = tk.Button(top, command=add_block) self.Button2.place(relx=0.383, rely=0.422, height=64, width=157) self.Button2.configure(activebackground="#ececec") self.Button2.configure(activeforeground="#000000") self.Button2.configure(background="#d9d9d9") self.Button2.configure(cursor="hand2") self.Button2.configure(disabledforeground="#a3a3a3") self.Button2.configure(foreground="#000000") self.Button2.configure(highlightbackground="#d9d9d9") self.Button2.configure(highlightcolor="black") self.Button2.configure(pady="0") self.Button2.configure(text='''ADD BLOCKS''') self.Button2.configure(width=157) self.Button3 = tk.Button(top, command=add_bed) self.Button3.place(relx=0.683, rely=0.422, height=64, width=167) self.Button3.configure(activebackground="#ececec") self.Button3.configure(activeforeground="#000000") self.Button3.configure(background="#d9d9d9") self.Button3.configure(cursor="hand2") self.Button3.configure(disabledforeground="#a3a3a3") self.Button3.configure(foreground="#000000") self.Button3.configure(highlightbackground="#d9d9d9") self.Button3.configure(highlightcolor="black") self.Button3.configure(pady="0") self.Button3.configure(text='''ADD BEDS''') self.Button3.configure(width=167) self.Message1 = tk.Message(top) self.Message1.place(relx=0.067, rely=0.089, relheight=0.229, relwidth=0.6) self.Message1.configure(background="#d9d9d9") self.Message1.configure(font=font12) self.Message1.configure(foreground="#000000") self.Message1.configure(highlightbackground="#d9d9d9") self.Message1.configure(highlightcolor="black") self.Message1.configure(text='''__ADMIN__''') self.Message1.configure(width=360) self.Button4 = tk.Button(top, command=add_student) self.Button4.place(relx=0.017, rely=0.622, height=74, width=197) self.Button4.configure(activebackground="#ececec") self.Button4.configure(activeforeground="#000000") self.Button4.configure(background="#9fe889") self.Button4.configure(cursor="hand2") self.Button4.configure(disabledforeground="#a3a3a3") self.Button4.configure(foreground="#000000") self.Button4.configure(highlightbackground="#d9d9d9") self.Button4.configure(highlightcolor="black") self.Button4.configure(pady="0") self.Button4.configure(text='''ADD STUDENT''') self.Button4.configure(width=197) def quit_1(): print("time to say good bye!!!!") root.destroy() self.Button5 = tk.Button(top, command=quit_1) self.Button5.place(relx=0.367, rely=0.644, height=64, width=357) self.Button5.configure(activebackground="#ececec") self.Button5.configure(activeforeground="#000000") self.Button5.configure(background="#bc4f5a") self.Button5.configure(cursor="hand2") self.Button5.configure(disabledforeground="#a3a3a3") self.Button5.configure(foreground="#000000") self.Button5.configure(highlightbackground="#000000") self.Button5.configure(highlightcolor="black") self.Button5.configure(pady="0") self.Button5.configure(text='''LOGOUT''') self.Button5.configure(width=357) def link(): webbrowser.open("http://www.rset.edu.in/gscc/") self.Button6 = tk.Button(top, command=link) self.Button6.place(relx=0.683, rely=0.0, height=164, width=177) self.Button6.configure(activebackground="#ececec") self.Button6.configure(activeforeground="#000000") self.Button6.configure(background="#d9d9d9") self.Button6.configure(cursor="hand2") self.Button6.configure(disabledforeground="#a3a3a3") self.Button6.configure(foreground="#000000") self.Button6.configure(highlightbackground="#d9d9d9") self.Button6.configure(highlightcolor="black") self._img2 = tk.PhotoImage(file="./saraf.png") self.Button6.configure(image=self._img2) self.Button6.configure(pady="0") self.Button6.configure(text='''Button''') self.Button6.configure(width=177) self.Button7 = tk.Button(top) self.Button7.place(relx=0.017, rely=0.844, height=64, width=247) self.Button7.configure(activebackground="#ececec") self.Button7.configure(activeforeground="#000000") self.Button7.configure(background="#d9d9d9") self.Button7.configure(disabledforeground="#a3a3a3") self.Button7.configure(foreground="#000000") self.Button7.configure(highlightbackground="#d9d9d9") self.Button7.configure(highlightcolor="black") self.Button7.configure(pady="0") self.Button7.configure(text='''CANCELATION''') self.Button7.configure(width=247) def login_message(): mbox.showinfo("LOGIN STATUS", "You Are Bieng Succesfully Logged In") def button_clicked(): if mystring.get() == 'secret': getvalue() login_admin() else: getvalue() ppopup = tk.Toplevel() ppopup.title("DENIED") ppopup.geometry("300x300") pic = Image.open('ad.png') ren = ImageTk.PhotoImage(pic) w1 = tk.Label(ppopup, image=ren) w1.image = ren w1.pack() inv = tk.Label(ppopup, text="INVALID PASSWORD", font=F_FONT) inv.pack(side=tk.TOP) self.Button1 = tk.Button(top, command=button_clicked) self.Button1.place(relx=0.533, rely=0.778, height=84, width=257) self.Button1.configure(activebackground="#ececec") self.Button1.configure(activeforeground="#000000") self.Button1.configure(background="#d9d9d9") self.Button1.configure(cursor="hand2") self.Button1.configure(disabledforeground="#a3a3a3") self.Button1.configure(font=font9) self.Button1.configure(foreground="#000000") self.Button1.configure(highlightbackground="#d9d9d9") self.Button1.configure(highlightcolor="black") self.Button1.configure(pady="0") self.Button1.configure(text='''LOGIN''') self.Button1.configure(width=257) self.Label1 = tk.Label(top) self.Label1.place(relx=0.517, rely=0.111, height=171, width=254) self.Label1.configure(background="#d9d9d9") self.Label1.configure(disabledforeground="#a3a3a3") self.Label1.configure(foreground="#000000") self._img1 = tk.PhotoImage( file="./Ghanshyamdas-Saraf-College-of-Arts-and-Commerce.png") self.Label1.configure(image=self._img1) self.Label1.configure(text='''Label''') self.Label1.configure(width=254)
# radio buttons' variable var = tk.StringVar() var.set('test') # lets print selection value var.trace_add('write', lambda *args: print(var.get())) # atk radiobutton, you can control indicator ring, fill, and mark color atk.Radiobutton(f, text='AwesomeTkinter Radiobutton', variable=var).pack(padx=17, pady=10, anchor='w') atk.Radiobutton(f, text='AwesomeTkinter Radiobutton, selected', value='test', variable=var).pack(padx=17, pady=10, anchor='w') ttk.Separator(f).pack(expand=True, fill='x') # standard tk button tk.Radiobutton(f, text='standard tk Radiobutton', variable=var, value='standard tk Radiobutton', fg='black', bg='white').pack(padx=10, pady=10, anchor='w') tk.Radiobutton(f, text='standard tk Radiobutton, selected', variable=var, value='test', bg='white', fg='black').pack(padx=10, pady=10, anchor='w')
def widgets(self): font15 = "-family Arial -size 12 -weight bold -slant roman " \ "-underline 0 -overstrike 0" font16 = "-family Arial -size 18 -weight bold -slant roman " \ "-underline 0 -overstrike 0" font9 = "-family Arial -size 20 -weight bold -slant roman " \ "-underline 0 -overstrike 0" self.Label1 = Label(self.master) self.Label1.place(relx=0.0, rely=0.018, height=51, width=284) self.Label1.configure(background="#d9d9d9") self.Label1.configure(disabledforeground="#a3a3a3") self.Label1.configure(font=font9) self.Label1.configure(foreground="#000000") self.Label1.configure(text='''Staff Member Info''') self.Label1.configure(width=284) self.TSeparator1 = ttk.Separator(self.master) self.TSeparator1.place(relx=0.037, rely=0.107, relwidth=0.935) self.name = Label(self.master) self.name.place(relx=0.046, rely=0.179, height=31, width=84) self.name.configure(background="#d9d9d9") self.name.configure(disabledforeground="#a3a3a3") self.name.configure(font=font15) self.name.configure(foreground="#000000") self.name.configure(text='''Name :''') self.name.configure(width=84) self.name_entry = Entry(self.master) self.name_entry.place(relx=0.176, rely=0.196, height=20, relwidth=0.152) self.name_entry.configure(background="white") self.name_entry.configure(disabledforeground="#a3a3a3") self.name_entry.configure(font="TkFixedFont") self.name_entry.configure(foreground="#000000") self.name_entry.configure(insertbackground="black") self.gender = Label(self.master) self.gender.place(relx=0.046, rely=0.304, height=31, width=84) self.gender.configure(activebackground="#f9f9f9") self.gender.configure(activeforeground="black") self.gender.configure(background="#d9d9d9") self.gender.configure(disabledforeground="#a3a3a3") self.gender.configure(font=font15) self.gender.configure(foreground="#000000") self.gender.configure(highlightbackground="#d9d9d9") self.gender.configure(highlightcolor="black") self.gender.configure(text='''Gender :''') self.gender.configure(width=84) self.gender_v = StringVar() self.gender_rm = Radiobutton(self.master, value="Male", variable=self.gender_v, text="Male", bg='#d9d9d9', activebackground='#d9d9d9').place( relx=0.176, rely=0.313, relheight=0.045, relwidth=0.05) self.gender_rf = Radiobutton(self.master, value="Female", variable=self.gender_v, text="Female", bg='#d9d9d9', activebackground='#d9d9d9').place( relx=0.241, rely=0.313, relheight=0.045, relwidth=0.05) self.dob = Label(self.master) self.dob.place(relx=0.046, rely=0.571, height=31, width=84) self.dob.configure(activebackground="#f9f9f9") self.dob.configure(activeforeground="black") self.dob.configure(background="#d9d9d9") self.dob.configure(disabledforeground="#a3a3a3") self.dob.configure(font=font15) self.dob.configure(foreground="#000000") self.dob.configure(highlightbackground="#d9d9d9") self.dob.configure(highlightcolor="black") self.dob.configure(text='''D.O.B :''') self.dob.configure(width=84) self.dob_e = DateEntry(self.master, background='grey', foreground='white', borderwidth=2) self.dob_e.place(relx=0.176, rely=0.580, height=20, width=120) self.marital_status = Label(self.master) self.marital_status.place(relx=0.046, rely=0.429, height=31, width=134) self.marital_status.configure(activebackground="#f9f9f9") self.marital_status.configure(activeforeground="black") self.marital_status.configure(background="#d9d9d9") self.marital_status.configure(disabledforeground="#a3a3a3") self.marital_status.configure(font=font15) self.marital_status.configure(foreground="#000000") self.marital_status.configure(highlightbackground="#d9d9d9") self.marital_status.configure(highlightcolor="black") self.marital_status.configure(text='''Marital Status :''') self.marital_status.configure(width=134) self.marital_combobox = ttk.Combobox( self.master, values=["Single", "Married", "Divorced"]) self.marital_combobox.current(0) self.marital_combobox.place(relx=0.176, rely=0.444, height=20, relwidth=0.152) self.Member_id = Label(self.master) self.Member_id.place(relx=0.417, rely=0.179, height=31, width=121) self.Member_id.configure(activebackground="#f9f9f9") self.Member_id.configure(activeforeground="black") self.Member_id.configure(background="#d9d9d9") self.Member_id.configure(disabledforeground="#a3a3a3") self.Member_id.configure(font=font15) self.Member_id.configure(foreground="#000000") self.Member_id.configure(highlightbackground="#d9d9d9") self.Member_id.configure(highlightcolor="black") self.Member_id.configure(text='''Staff ID :''') self.Member_id.configure(width=121) self.phone_number = Label(self.master) self.phone_number.place(relx=0.417, rely=0.304, height=36, width=134) self.phone_number.configure(activebackground="#f9f9f9") self.phone_number.configure(activeforeground="black") self.phone_number.configure(background="#d9d9d9") self.phone_number.configure(disabledforeground="#a3a3a3") self.phone_number.configure(font=font15) self.phone_number.configure(foreground="#000000") self.phone_number.configure(highlightbackground="#d9d9d9") self.phone_number.configure(highlightcolor="black") self.phone_number.configure(text='''Phone Number :''') self.phone_number.configure(width=134) self.adhaar_number = Label(self.master) self.adhaar_number.place(relx=0.407, rely=0.429, height=36, width=154) self.adhaar_number.configure(activebackground="#f9f9f9") self.adhaar_number.configure(activeforeground="black") self.adhaar_number.configure(background="#d9d9d9") self.adhaar_number.configure(disabledforeground="#a3a3a3") self.adhaar_number.configure(font=font15) self.adhaar_number.configure(foreground="#000000") self.adhaar_number.configure(highlightbackground="#d9d9d9") self.adhaar_number.configure(highlightcolor="black") self.adhaar_number.configure(text='''Adhaar Number :''') self.adhaar_number.configure(width=154) self.address = Label(self.master) self.address.place(relx=0.407, rely=0.571, height=36, width=184) self.address.configure(activebackground="#f9f9f9") self.address.configure(activeforeground="black") self.address.configure(background="#d9d9d9") self.address.configure(disabledforeground="#a3a3a3") self.address.configure(font=font15) self.address.configure(foreground="#000000") self.address.configure(highlightbackground="#d9d9d9") self.address.configure(highlightcolor="black") self.address.configure(text='''Permanent Address :''') self.address.configure(width=184) self.ph_number_entry = Entry(self.master) self.ph_number_entry.place(relx=0.611, rely=0.321, height=20, relwidth=0.152) self.ph_number_entry.configure(background="white") self.ph_number_entry.configure(disabledforeground="#a3a3a3") self.ph_number_entry.configure(font="TkFixedFont") self.ph_number_entry.configure(foreground="#000000") self.ph_number_entry.configure(highlightbackground="#d9d9d9") self.ph_number_entry.configure(highlightcolor="black") self.ph_number_entry.configure(insertbackground="black") self.ph_number_entry.configure(selectbackground="#c4c4c4") self.ph_number_entry.configure(selectforeground="black") self.adhaar_entry = Entry(self.master) self.adhaar_entry.place(relx=0.611, rely=0.446, height=20, relwidth=0.152) self.adhaar_entry.configure(background="white") self.adhaar_entry.configure(disabledforeground="#a3a3a3") self.adhaar_entry.configure(font="TkFixedFont") self.adhaar_entry.configure(foreground="#000000") self.adhaar_entry.configure(highlightbackground="#d9d9d9") self.adhaar_entry.configure(highlightcolor="black") self.adhaar_entry.configure(insertbackground="black") self.adhaar_entry.configure(selectbackground="#c4c4c4") self.adhaar_entry.configure(selectforeground="black") self.TSeparator2 = ttk.Separator(self.master) self.TSeparator2.place(relx=0.037, rely=0.768, relwidth=0.935) self.staff_id_entry = Entry(self.master) self.staff_id_entry.place(relx=0.611, rely=0.196, height=20, relwidth=0.152) self.staff_id_entry.configure(background="white") self.staff_id_entry.configure(disabledforeground="#a3a3a3") self.staff_id_entry.configure(font="TkFixedFont") self.staff_id_entry.configure(foreground="#000000") self.staff_id_entry.configure(highlightbackground="#d9d9d9") self.staff_id_entry.configure(highlightcolor="black") self.staff_id_entry.configure(insertbackground="black") self.staff_id_entry.configure(selectbackground="#c4c4c4") self.staff_id_entry.configure(selectforeground="black") #self.staff_id_entry.insert(END,"Auto Assigned") self.search_button = Button(self.master) self.search_button.place(relx=0.157, rely=0.786, height=34, width=107) self.search_button.configure(activebackground="#ececec") self.search_button.configure(activeforeground="#000000") self.search_button.configure(background="#d9d9d9") self.search_button.configure(disabledforeground="#a3a3a3") self.search_button.configure(font=font16) self.search_button.configure(foreground="#000000") self.search_button.configure(highlightbackground="#d9d9d9") self.search_button.configure(highlightcolor="black") self.search_button.configure(pady="0") self.search_button.configure(text='''Search''') self.search_button.configure(width=107) self.search_button.configure(command=self.search) self.addnew_button = Button(self.master) self.addnew_button.place(relx=0.046, rely=0.786, height=34, width=117) self.addnew_button.configure(activebackground="#ececec") self.addnew_button.configure(activeforeground="#000000") self.addnew_button.configure(background="#d9d9d9") self.addnew_button.configure(disabledforeground="#a3a3a3") self.addnew_button.configure(font=font16) self.addnew_button.configure(foreground="#000000") self.addnew_button.configure(highlightbackground="#d9d9d9") self.addnew_button.configure(highlightcolor="black") self.addnew_button.configure(pady="0") self.addnew_button.configure(text='''Add New''') self.addnew_button.configure(width=117) self.addnew_button.configure(command=self.addnew) self.update_button = Button(self.master) self.update_button.place(relx=0.259, rely=0.786, height=34, width=107) self.update_button.configure(activebackground="#ececec") self.update_button.configure(activeforeground="#000000") self.update_button.configure(background="#d9d9d9") self.update_button.configure(disabledforeground="#a3a3a3") self.update_button.configure(font=font16) self.update_button.configure(foreground="#000000") self.update_button.configure(highlightbackground="#d9d9d9") self.update_button.configure(highlightcolor="black") self.update_button.configure(pady="0") self.update_button.configure(text='''Update''') self.delete_button = Button(self.master) self.delete_button.place(relx=0.361, rely=0.786, height=34, width=107) self.delete_button.configure(activebackground="#ececec") self.delete_button.configure(activeforeground="#000000") self.delete_button.configure(background="#d9d9d9") self.delete_button.configure(disabledforeground="#a3a3a3") self.delete_button.configure(font=font16) self.delete_button.configure(foreground="#000000") self.delete_button.configure(highlightbackground="#d9d9d9") self.delete_button.configure(highlightcolor="black") self.delete_button.configure(pady="0") self.delete_button.configure(text='''Delete''') self.scroll_frame = Frame(self.master, bg="red") self.scroll_frame.place(relx=0.611, rely=0.571, height=35, relwidth=0.152) self.scrollbar = Scrollbar(self.scroll_frame, orient="horizontal") self.scrolled_entry = Entry(self.scroll_frame, xscrollcommand=self.scrollbar.set) self.scrolled_entry.focus() self.scrolled_entry.pack(side="top", fill="x") self.scrollbar.pack(fill="x") self.scrollbar.config(command=self.scrolled_entry.xview) self.scrolled_entry.config()
def __init__(self, parent, controller): global r1 tk.Frame.__init__(self, parent) label = ttk.Label(self, text ="Profile", font = LARGEFONT) label.grid(row = 0, column = 0,columnspan=5) f=LabelFrame(self,height=500,width=700,text="Information") f.grid(row = 3, column = 4,padx=10,rowspan=100,columnspan=100) l1=Label(self,text ="Name :", font = TFONT) l1.grid(row = 4, column = 5,padx=10,pady=10) l2=Label(self,text ="Branch :", font = TFONT) l2.grid(row = 5, column = 5,padx=10,pady=10) l3=Label(self,text ="Section :", font = TFONT) l3.grid(row = 6, column = 5,padx=10,pady=10) l4=Label(self,text ="Student Number :", font = TFONT) l4.grid(row = 7, column = 5,padx=10,pady=10) l5=Label(self,text ="Roll Number :", font = TFONT) l5.grid(row = 8, column = 5,padx=10,pady=10) l6=Label(self,text ="Gender :", font = TFONT) l6.grid(row = 9, column = 5,padx=10,pady=10) l7=Label(self,text ="Email Id :", font = TFONT) l7.grid(row = 10, column = 5,padx=10,pady=10) self.t1= Entry(self,width=15) self.t1.grid(row = 4, column = 7) self.t2= Entry(self,width=15) self.t2.grid(row = 4, column = 8) self.t3= Entry(self,width=15) self.t3.grid(row = 4, column = 9) self.t4= Entry(self,width=15) self.t4.grid(row = 5, column = 7) self.t5= Entry(self,width=15) self.t5.grid(row = 6, column = 7) self.t6= Entry(self,width=15) self.t6.grid(row = 7, column = 7) self.t7= Entry(self,width=15) self.t7.grid(row = 8, column = 7) self.gender = IntVar() self.R.append(Radiobutton(self, text="Male", variable=self.gender, value=1)) self.R[0].grid(row = 9, column = 7) self.R.append(Radiobutton(self, text="Female", variable=self.gender, value=2)) self.R[1].grid(row = 9, column = 8) self.t9= Entry(self,width=30) self.t9.grid(row = 10, column = 7,columnspan=2) self.feed() be = Button(self, text ="Edit",relief=GROOVE,command=self.edit) be['font']=BFONT be.grid(row = 12, column = 14,padx=10,pady=10) b0 = Button(self, text ="Save",relief=GROOVE,command=self.update) b0['font']=BFONT b0.grid(row = 12, column = 15,padx=10,pady=10) b1 = Button(self, text ="Map",relief=FLAT, command = lambda : controller.show_frame(StartPage)) b1['font']=BFONT b1.grid(row = 2, column = 0,columnspan=2,padx=15,pady=10) b2 = Button(self, text ="Settings",relief=FLAT, command = lambda : controller.show_frame(Settings)) b1['font']=BFONT b2.grid(row = 3, column = 0,columnspan=2,padx=15,pady=10) sep = ttk.Separator(self, orient=HORIZONTAL) sep.grid(row=1,column=0,sticky='ew',columnspan=25) sep = ttk.Separator(self, orient=VERTICAL) sep.grid(row=2,column=3,sticky='ns',rowspan=17,pady=5)
def _init_ui(self): # Configure default theme style = ttk.Style(self) style.theme_use('clam') style.map("TEntry", fieldbackground=[("active", "white"), ("disabled", "#DCDCDC")]) self.bg = self.cget('bg') style.configure('My.TFrame', background=self.bg) style.configure("blue.Horizontal.TProgressbar", background='#778899', troughcolor=self.bg) style.configure("green.Horizontal.TProgressbar", background='#2E8B57', troughcolor=self.bg) self.option_add('*Dialog.msg.font', 'Helvetica 10') # Configure menubar menu = Menu(self) self.config(menu=menu) # File menu item file_menu = Menu(menu, tearoff=False) menu.add_cascade(label='File', menu=file_menu) dir_submenu = Menu(file_menu, tearoff=False) dir_submenu.add_command(label='Source', command=lambda: self._show_diag('source')) dir_submenu.add_command(label='Destination', command=lambda: self._show_diag('destination')) file_menu.add_cascade(label='Open', menu=dir_submenu) file_menu.add_separator() file_menu.add_command(label='Quit', command=self._show_exit_dialog, accelerator="Ctrl+Q") # View menu item view_menu = Menu(menu, tearoff=False) menu.add_cascade(label='View', menu=view_menu) view_menu.add_command(label='History', command=self._show_history) # Help menu item help_menu = Menu(menu, tearoff=False) menu.add_cascade(label='Help', menu=help_menu) help_menu.add_command(label='Help', command=self._show_help, accelerator='F1') usage_link = descriptions.HOMEPAGE + '#usage' help_menu.add_command( label='Tutorial', command=lambda link=usage_link: self._open_link(link)) help_menu.add_command(label='Refresh', command=self._delete_db) help_menu.add_command( label='Update', command=lambda: self._check_for_update(user_checked=True)) help_menu.add_command(label='About', command=self._show_about) self.bind_all('<F1>', self._show_help) self.bind_all('<Control-q>', lambda event=None: self._show_exit_dialog()) # Create main frames self.top_frame = ttk.Frame(self, style='My.TFrame') self.top_frame.pack(side=TOP, expand=YES, fill=X) self.mid_frame = ttk.Frame(self, style='My.TFrame') self.mid_frame.pack(side=TOP, expand=YES, fill=BOTH) self.bottom_frame = ttk.Frame(self, style='My.TFrame') self.bottom_frame.pack(side=TOP, expand=YES, fill=X) # Configure frame for Label widgets label_frame = ttk.Frame(self.top_frame, style='My.TFrame') label_frame.pack(side=LEFT, fill=Y, expand=YES) source_label = ttk.Label(label_frame, text='Source', anchor=W, background=self.bg) source_label.pack(ipady=2.5, pady=5, side=TOP, fill=X) dst_label = ttk.Label(label_frame, text='Destination', anchor=W, background=self.bg) dst_label.pack(ipady=2.5, pady=5, side=BOTTOM, fill=X) # Configure frame for Entry widgets entry_frame = ttk.Frame(self.top_frame, style='My.TFrame') entry_frame.pack(side=LEFT, fill=Y, expand=YES) self.source_entry = ttk.Entry(entry_frame, width=50) self.source_entry.pack(ipady=2.5, pady=5, side=TOP, expand=YES) self.dst_entry = ttk.Entry(entry_frame, width=50, state='disabled') self.dst_entry.pack(ipady=2.5, pady=5, side=BOTTOM, expand=YES) self.dst_entry.bind( '<FocusIn>', lambda event, widget=self.dst_entry, variable=self.dst_entry: self. _clear_entry_help(widget, variable)) self.dst_entry.bind('<FocusOut>', lambda event, widget=self.dst_entry, variable=self. dst_entry: self._show_entry_help(widget, variable)) # Configure frame for dialog buttons diag_frame = ttk.Frame(self.top_frame, style='My.TFrame') diag_frame.pack(side=LEFT, expand=YES) source_button = ttk.Button(diag_frame, text='Choose', command=lambda: self._show_diag('source')) source_button.pack(side=TOP, pady=5) dst_button = ttk.Button(diag_frame, text='Choose', command=lambda: self._show_diag('destination')) dst_button.pack(side=BOTTOM, pady=5) # Variables self.sort_folders = IntVar() self.recursive = IntVar() types_value = IntVar() self.file_types = ['*'] self.by_extension = IntVar() self.progress_info = StringVar() self.show_logs = IntVar() # Configure Options frame options_frame = LabelFrame(self.mid_frame, text='Options') options_frame.pack(fill=BOTH, expand=YES, padx=5, pady=10) frame_left = ttk.Frame(options_frame, style="My.TFrame") frame_left.pack(side=LEFT, fill=Y, anchor=W, padx=20) frame_right = ttk.Frame(options_frame, style="My.TFrame") frame_right.pack(side=LEFT, fill=Y, anchor=W, padx=10) # For frame_right group_separator = ttk.Separator(frame_left) group_separator.grid(row=0, column=0, pady=1) self.search_string = StringVar() search_entry = ttk.Entry(frame_left, width=15, state='disabled', textvariable=self.search_string) search_entry.grid(row=1, column=1, padx=5, pady=2) search_entry.bind( '<FocusIn>', lambda event, widget=search_entry, variable=self.search_string: self._clear_entry_help(widget, variable)) search_entry.bind( '<FocusOut>', lambda event, widget=search_entry, variable=self.search_string: self._show_entry_help(widget, variable)) self.search_option_value = IntVar() search_option = Checkbutton( frame_left, text='Search for:', variable=self.search_option_value, anchor=E, command=lambda: self._enable_entry_widget(search_entry, self. search_option_value)) search_option.grid(row=1, column=0, pady=3, sticky=W, padx=5) self.group_folder_name = StringVar() group_folder_entry = ttk.Entry(frame_left, width=15, state='disabled', textvariable=self.group_folder_name) group_folder_entry.grid(row=2, column=1, padx=5, pady=2, sticky=S) group_folder_entry.bind( '<FocusIn>', lambda event, widget=group_folder_entry, variable=self. group_folder_name: self._clear_entry_help(widget, variable)) group_folder_entry.bind( '<FocusOut>', lambda event, widget=group_folder_entry, variable=self. group_folder_name: self._show_entry_help(widget, variable)) self.group_folder_value = IntVar() group_folder_option = Checkbutton( frame_left, text='Group into folder', variable=self.group_folder_value, command=lambda: self._enable_entry_widget(group_folder_entry, self. group_folder_value)) group_folder_option.grid(row=2, column=0, pady=3, sticky=W, padx=5) extension_button = Checkbutton(frame_left, text='Group by file type', variable=self.by_extension) extension_button.grid(row=3, column=0, pady=3, sticky=W, padx=5) # For frame_left other_separator = ttk.Separator(frame_right) other_separator.grid(row=0, column=0) recursive_option = Checkbutton(frame_right, text='Look into sub-folders', variable=self.recursive) recursive_option.grid(row=1, column=0, sticky=W, pady=3) self.types_window = None self.items_option = Checkbutton( frame_right, text='Select file types', variable=types_value, command=lambda: self._show_types_window(types_value)) self.items_option.grid(row=2, column=0, sticky=W, pady=3) self.logs_option = Checkbutton(frame_right, text='Show logs', variable=self.show_logs, command=self._show_progress) self.logs_option.grid(row=3, column=0, sticky=W, pady=3) # Configure action buttons self.run_button = ttk.Button(self.bottom_frame, text='Run', command=self._run_sorter) self.run_button.pack(side=LEFT, padx=5) self.quit_button = ttk.Button(self.bottom_frame, text='Quit', command=self._show_exit_dialog) self.quit_button.pack(side=RIGHT, padx=5) # Configure status bar self.status_bar = ttk.Label(self, text=' Ready', relief=SUNKEN, anchor=W) self.status_bar.pack(side=BOTTOM, fill=X) # Configure progress bar self.progress_var = DoubleVar() self.progress_bar = ttk.Progressbar( self.status_bar, style="blue.Horizontal.TProgressbar", variable=self.progress_var, orient=HORIZONTAL, length=120) self.progress_bar.pack(side=RIGHT, pady=3, padx=5) self.progress_var.set(100) self.interface_helper = InterfaceHelper( progress_bar=self.progress_bar, progress_var=self.progress_var, status=self.status_bar, messagebox=messagebox, progress_info=self.progress_info) logger.info('Finished GUI initialisation. Waiting...') self.progress_info.set('{} Ready.\n'.format(datetime.now()))
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.controller = controller self.parent=parent controller.geometry(frame_size) controller.pack_propagate(0) #topFrame top_frame=tk.Frame(self,bg='white') top_frame.place(x=0,y=0) top_frame.pack(fill="both") #checking if user exist login_text,flag=self.get_user_name() #login image + button self.user_auth=tk.PhotoImage(file='./b_gui/auth_user1.png') #login button self.login_button=tk.Button(top_frame,fg=login_toplabel_color,command=lambda : controller.show_frame("TwitterLogin"),bg='white') self.login_button.config(image=self.user_auth,width="28",height="24",relief=tk.FLAT) self.login_button.pack(side=tk.TOP,anchor='ne',pady=1,padx=5) #verification label self.verified_label=tk.Label(top_frame,bg='white') if flag==True: self.verified_label.config(text="Verified",fg='green') else: self.verified_label.config(text="Autenticate",fg='red') self.verified_label.pack(side=tk.TOP,anchor='ne') # ~ MAIN LOGO ~ self.main_logo=tk.PhotoImage(file='./b_gui/MainLogo2.png') self.top_label=tk.Label(top_frame,bg='white') self.top_label.pack(side=tk.TOP) self.top_label.config(image=self.main_logo) #Seperator Frame between text and fields separator_label_frame=tk.Frame(self) separator_label_frame.configure(bg=button_background_color) separator_label_frame.pack(fill="both") #separator self.sep_style=ttk.Style() self.sep_style.configure('s.TSeparator') separator = ttk.Separator(separator_label_frame, orient='horizontal',style='s.TSeparator') separator.pack(side="top",fill='both') #images for center frame self.insert_hashtag=tk.PhotoImage(file='./b_gui/insert_hashtag.png') self.set_duration=tk.PhotoImage(file='./b_gui/set_duration.png') self.percentage=tk.PhotoImage(file='./b_gui/percentage.png') # ~~ CENTER FRAME ~~ #MIDDLE MAIN FRAME self.centerFrame=tk.Frame(separator_label_frame,bg=button_background_color) self.centerFrame.pack(side=tk.TOP,anchor='w',pady=10,padx=10) #LABELS FRAME self.labelsFrame=tk.Frame(self.centerFrame,bg=button_background_color) self.labelsFrame.pack(anchor='nw',pady=10) #label insert label_h=tk.Label(self.labelsFrame,image=self.insert_hashtag,font=controller.text_font,fg=text_color,bg=button_background_color) label_h.pack(side=tk.LEFT,pady=15) #TextBox self.textbox_h=tk.Entry(self.labelsFrame,bg='white') self.textbox_h.insert(0, 'Any Topic') self.textbox_h.bind('<FocusIn>', self.on_entry_click) self.textbox_h.bind('<FocusOut>', self.on_focusout) self.textbox_h.config(fg = 'black',width=30) self.textbox_h.pack(side=tk.LEFT,padx=5) #duration FRAME self.durationFrame=tk.Frame(self.centerFrame,bg=button_background_color) self.durationFrame.pack(anchor='nw',pady=10) #label duration label_ts=tk.Label(self.durationFrame,image=self.set_duration,font=controller.text_font,fg=text_color,bg=button_background_color,borderwidth=0) label_ts.pack(side=tk.LEFT,pady=10) #option bar for days selection self.time_options={"1 Day":1,"2 Days":2,"3 Days":3,"4 Days":4,"5 Days":5,"6 Days":6,"7 Days":7} self.variable=tk.StringVar(self.durationFrame) self.variable.set("1 Day") option_menu_time=tk.OptionMenu(self.durationFrame,self.variable,*self.time_options.keys()) option_menu_time["menu"].config(fg=login_toplabel_color,font=controller.text_font,bg=button_background_color) option_menu_time.configure(highlightbackground=button_background_color,width = 6,height=1,relief=tk.GROOVE,bg=button_background_color,foreground=login_toplabel_color, activebackground = "#33B5E5") option_menu_time.pack(side=tk.RIGHT) self.variable.trace("w",self.get_duration) #percentage FRAME self.percentageFrame=tk.Frame(self.centerFrame,bg=button_background_color) self.percentageFrame.pack(anchor='nw',pady=10) # ~ BOTTOM FRAME ~ self.bottomFrame=tk.Frame(self,bg=button_background_color) self.bottomFrame.pack(side=tk.TOP,fill='both') self.runFrame=tk.Frame(self.bottomFrame,bg=button_background_color) self.runFrame.pack(side=tk.RIGHT,padx=20) #run button self.run_img=tk.PhotoImage(file='./b_gui/run2.png') self.run_button=tk.Button(self.runFrame,text="Search",fg=text_color,font=controller.text_font,compound="right",command=lambda: self.check_input(parent,self.textbox_h),bg=button_background_color) self.run_button.config(image=self.run_img,relief=tk.FLAT) #if Authentication failed if flag==False: self.run_button.config(command=lambda: self.user_error_dialog) self.run_button.pack(side=tk.RIGHT,anchor="se",padx=30,fill='both') #separator self.sep_style=ttk.Style() self.sep_style.configure('s.TSeparator') separator = ttk.Separator(self, orient='horizontal',style='s.TSeparator') separator.pack(side="top",fill='both') #LstmFrame self.lstmFrame=tk.Frame(self,bg='white') self.lstmFrame.pack(side=tk.BOTTOM,fill='both') #lstm label self.or_image=tk.PhotoImage(file='./b_gui/or_label.png') self.lstmLabel=tk.Label(self.lstmFrame,image=self.or_image,highlightthickness=0,borderwidth=0) self.lstmLabel.pack(side=tk.TOP) #Lstm button self.run_lstm_image=tk.PhotoImage(file='./b_gui/run_lstm_only.png') self.lstmButton=tk.Button(self.lstmFrame,image=self.run_lstm_image,command=lambda:self.check_input_lstm(),relief=tk.FLAT) self.lstmButton.pack(side=tk.BOTTOM,pady=10) self.configure(background='white')
def setupGUI(self, root): self.root = root self.root.title('GPI Valve Control') win_width = int(1200) win_height = int(600) self.screen_width = self.root.winfo_screenwidth() self.screen_height = self.root.winfo_screenheight() x = (self.screen_width / 2) - (win_width / 2) y = (self.screen_height / 2) - (win_height / 2) self.root.geometry('%dx%d+%d+%d' % (win_width, win_height, x, y)) self.root.protocol('WM_DELETE_WINDOW', self._quit_tkinter) s = ttk.Style() s.theme_use('alt') gray = '#A3A3A3' self.root.config(background=gray) system_frame = tk.Frame(self.root, background=gray) image = Image.open('background.png') #image = image.resize((469, 600)) # I just resized the actual image photo = ImageTk.PhotoImage(image) background = tk.Label(system_frame, image=photo) background.image = photo background.configure(background=gray) font = tkinter.font.Font(size=6) self.shutter_setting_indicator = tk.Label(system_frame, width=7, height=1, text='Shutter setting', fg='white', bg='black', font=font, relief=tk.RAISED, borderwidth=2, cursor='hand1') createToolTip(self.shutter_setting_indicator, 'Open/close camera turning mirror') self.shutter_sensor_indicator = tk.Label(system_frame, width=7, height=1, text='Shutter sensor', fg='white', bg='black', font=font) createToolTip(self.shutter_sensor_indicator, 'Camera turning mirror status unknown') self.FV2_indicator = tk.Label(system_frame, width=3, height=1, text='FV2', fg='white', bg='black', font=font, relief=tk.RAISED, borderwidth=2, cursor='hand1') createToolTip(self.FV2_indicator, 'Open/close puff valve') self.V5_indicator = tk.Label(system_frame, width=2, height=1, text='V5', fg='white', bg='black', font=font, relief=tk.RAISED, borderwidth=2, cursor='hand1') createToolTip(self.V5_indicator, 'Open/close gas source valve') self.V4_indicator = tk.Label(system_frame, width=1, height=1, text='V4', fg='white', bg='black', font=font, relief=tk.RAISED, borderwidth=2, cursor='hand1') createToolTip(self.V4_indicator, 'Open/close mechanical pump valve') self.V3_indicator = tk.Label(system_frame, width=2, height=1, text='V3', fg='white', bg='black', font=font, relief=tk.RAISED, borderwidth=2, cursor='hand1') createToolTip(self.V3_indicator, 'Open/close plenum valve') self.V7_indicator = tk.Label(system_frame, width=2, height=1, text='V7', fg='white', bg='black', font=font, relief=tk.RAISED, borderwidth=2, cursor='hand1') createToolTip(self.V7_indicator, 'Open/close exhaust valve') self.bindValveButtons() # Entire column to the right of the live graphs controls_frame = tk.Frame(self.root, background=gray) # State display and control ## Line 1 state_frame = tk.Frame(controls_frame, background=gray) state_frame_line1 = tk.Frame(state_frame, background=gray, pady=5) self.state_text = tk.StringVar() self.state_text.set('State: middle server not connected') state_label = tk.Label(state_frame_line1, textvariable=self.state_text, background=gray) ## Line 2 state_frame_line2 = tk.Frame(state_frame, background=gray, pady=5) cancel_button = ttk.Button(state_frame_line2, text='Cancel and reset valves', command=self.handleInterrupt) # Pump and fill controls fill_controls_frame = tk.Frame(controls_frame, background=gray) ## Line 1 fill_controls_line1 = tk.Frame(fill_controls_frame, background=gray, pady=5) desired_pressure_label = tk.Label(fill_controls_line1, text='Desired pressure [mbar]:', background=gray) self.desired_pressure_entry = ttk.Entry(fill_controls_line1, width=10, background=gray) ## Line 2 fill_controls_line2 = tk.Frame(fill_controls_frame, background=gray) self.pumpOut = tk.IntVar() pump_out_label = tk.Label(fill_controls_line2, text='Pump out first', background=gray) createToolTip(pump_out_label, 'Pump out before filling to desired pressure') self.pump_out_check = tk.Checkbutton(fill_controls_line2, variable=self.pumpOut, background=gray) self.exhaust = tk.IntVar() self.exhaust.set(1) exhaust_label = tk.Label(fill_controls_line2, text='Exhaust >1 bar', background=gray) createToolTip(exhaust_label, 'Exhaust to atmosphere before using mechanical pump') self.exhaust_check = tk.Checkbutton(fill_controls_line2, variable=self.exhaust, background=gray) ## Line 3 fill_controls_line3 = tk.Frame(fill_controls_frame, background=gray) self.pump_fill_button = ttk.Button(fill_controls_line3, text='Pump and/or fill', command=self.handlePumpFill) # Puff controls ## Line 1 self.enable_puff_1 = tk.IntVar() puff_controls_frame = tk.Frame(controls_frame, background=gray) self.enable_puff_1_check = tk.Checkbutton(puff_controls_frame, variable=self.enable_puff_1, background=gray) self.start_1_entry = ttk.Entry(puff_controls_frame, width=10) self.duration_1_entry = ttk.Entry(puff_controls_frame, width=10) self.duration_1_entry.insert(0, str(DEFAULT_PUFF)) ## Line 2 self.enable_puff_2 = tk.IntVar() self.enable_puff_2_check = tk.Checkbutton(puff_controls_frame, variable=self.enable_puff_2, background=gray) self.start_2_entry = ttk.Entry(puff_controls_frame, width=10) self.duration_2_entry = ttk.Entry(puff_controls_frame, width=10) self.duration_2_entry.insert(0, str(DEFAULT_PUFF)) permission_controls_line1 = tk.Frame(controls_frame, background=gray) self.w7x_permission_text = tk.StringVar() self.w7x_permission_text.set('W7-X permission signal: unknown') self.w7x_permission_label = tk.Label( permission_controls_line1, textvariable=self.w7x_permission_text, background=gray) createToolTip( self.w7x_permission_label, 'W7-X permission signal is required by the black box\nin order to open puff valve during a shot' ) permission_controls_line2 = tk.Frame(controls_frame, background=gray) self.t1_text = tk.StringVar() self.t1_text.set('T1 HW or SW signal: unknown') self.t1_label = tk.Label(permission_controls_line2, textvariable=self.t1_text, background=gray) createToolTip( self.t1_label, 'T1 HW or SW signal should be always low except during T1 of puff') action_controls_frame = tk.Frame(controls_frame, background=gray) self.T0_button = ttk.Button(action_controls_frame, text='T0 trigger', width=10, command=self.handleT0) self.fig = Figure(figsize=(3.5, 6), dpi=100, facecolor=gray) self.fig.subplots_adjust(left=0.2, right=0.8, top=0.925, hspace=0.5) # Absolute pressure plot matplotlib setup self.ax_abs = self.fig.add_subplot(211) self.ax_abs.margins(y=0.2) self.ax_abs.yaxis.set_ticks_position('both') label = self.ax_abs.yaxis.get_ticklabels() self.ax_abs.yaxis.set_tick_params(which='both', labelleft=label, labelright=label) self.ax_abs.set_xlabel('Time [s]') self.ax_abs.set_title('Absolute gauge') self.ax_abs.grid(True, color='#c9dae5') self.ax_abs.patch.set_facecolor('#e3eff7') self.line_abs, = self.ax_abs.plot([], [], c='C0', linewidth=1) self.abs_text = self.ax_abs.text(0.97, 0.97, '? mbar', horizontalalignment='right', verticalalignment='top', transform=self.ax_abs.transAxes, fontsize=10) # Differential pressure plot matplotlib setup self.ax_diff = self.fig.add_subplot(212) self.ax_diff.margins(y=0.2) self.ax_diff.yaxis.set_ticks_position('both') label = self.ax_diff.yaxis.get_ticklabels() self.ax_diff.yaxis.set_tick_params(which='both', labelleft=label, labelright=label) self.ax_diff.set_xlabel('Time [s]') self.ax_diff.set_title('Differential gauge') self.ax_diff.grid(True, color='#e5d5c7') self.ax_diff.patch.set_facecolor('#f7ebe1') self.line_diff, = self.ax_diff.plot([], [], c='C1', linewidth=1) self.diff_text = self.ax_diff.text(0.97, 0.97, '? mbar', horizontalalignment='right', verticalalignment='top', transform=self.ax_diff.transAxes, fontsize=10) # Plot tkinter setup self.canvas = FigureCanvasTkAgg(self.fig, master=self.root) self.canvas.draw() # Uncomment to see click x/y positions, useful for interface building # def click_location(event): # print('%.4f, %.4f' % (event.x/469, event.y/600)) # divide by image dimensions # self.root.bind('<Button-1>', click_location) # GUI element placement ## Column 1 background.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) self.V3_indicator.place(relx=.476, rely=.562, relwidth=.036, relheight=.038) self.V4_indicator.place(relx=.092, rely=.395, relwidth=.036, relheight=.038) self.V5_indicator.place(relx=.364, rely=.315, relwidth=.047, relheight=.026) self.V7_indicator.place(relx=.200, rely=.277, relwidth=.04, relheight=.028) self.FV2_indicator.place(relx=.635, rely=.067, relwidth=.05, relheight=.026) self.shutter_setting_indicator.place(relx=.79, rely=.067, relwidth=.2, relheight=.026) self.shutter_sensor_indicator.place(relx=.79, rely=.097, relwidth=.2, relheight=.026) system_frame.pack(side=tk.LEFT) ## Column 2 self.canvas.get_tk_widget().pack(side=tk.LEFT) self.canvas.get_tk_widget().configure() ## Column 3 ### Fill controls frame desired_pressure_label.pack(side=tk.LEFT) self.desired_pressure_entry.pack(side=tk.LEFT) self.pump_fill_button.pack(side=tk.LEFT, fill=tk.X, expand=True) pump_out_label.pack(side=tk.LEFT, pady=5) self.pump_out_check.pack(side=tk.LEFT, pady=5, padx=5) exhaust_label.pack(side=tk.LEFT, pady=5) self.exhaust_check.pack(side=tk.LEFT, pady=5, padx=5) fill_controls_line1.pack(side=tk.TOP, fill=tk.X) fill_controls_line2.pack(side=tk.TOP, fill=tk.X) fill_controls_line3.pack(side=tk.TOP, fill=tk.X) fill_controls_frame.pack(side=tk.TOP, fill=tk.X, pady=10) ttk.Separator(controls_frame, orient=tk.HORIZONTAL).pack(side=tk.TOP, fill=tk.X) ### Puff controls frame tk.Label(puff_controls_frame, text='Enable', background=gray).grid(row=0, column=7) tk.Label(puff_controls_frame, text='Start [s]', background=gray).grid(row=0, column=8) tk.Label(puff_controls_frame, text='Duration [s]', background=gray).grid(row=0, column=9) tk.Label(puff_controls_frame, text='Puff 1', background=gray).grid(row=1, column=6) tk.Label(puff_controls_frame, text='Puff 2', background=gray).grid(row=2, column=6) self.enable_puff_1_check.grid(row=1, column=7) self.start_1_entry.grid(row=1, column=8) self.duration_1_entry.grid(row=1, column=9) self.enable_puff_2_check.grid(row=2, column=7) self.start_2_entry.grid(row=2, column=8) self.duration_2_entry.grid(row=2, column=9) puff_controls_frame.pack(side=tk.TOP, pady=10, fill=tk.X) ### Permission controls frame self.w7x_permission_label.pack(side=tk.LEFT) permission_controls_line1.pack(side=tk.TOP, fill=tk.X, pady=2) self.t1_label.pack(side=tk.LEFT) permission_controls_line2.pack(side=tk.TOP, fill=tk.X, pady=2) ### Action controls frame self.T0_button.pack(side=tk.LEFT, fill=tk.X, expand=True) action_controls_frame.pack(side=tk.TOP, fill=tk.X, pady=10) ttk.Separator(controls_frame, orient=tk.HORIZONTAL).pack(side=tk.TOP, fill=tk.X) ### State frame state_label.pack(side=tk.LEFT) state_frame_line1.pack(side=tk.TOP, fill=tk.X) cancel_button.pack(side=tk.LEFT, fill=tk.X, expand=True) state_frame_line2.pack(side=tk.TOP, fill=tk.X) state_frame.pack(side=tk.TOP, fill=tk.X, pady=5) ttk.Separator(controls_frame, orient=tk.HORIZONTAL).pack(side=tk.TOP, fill=tk.X) ### Log log_controls_frame = tk.Frame(controls_frame, background=gray) label_log_controls_frame = tk.Frame(log_controls_frame, background=gray) tk.Label(label_log_controls_frame, text='Event log', background=gray).pack(side=tk.LEFT, fill=tk.X) label_log_controls_frame.pack(side=tk.TOP, fill=tk.X) self.log = tk.Listbox(log_controls_frame, background=gray, highlightbackground=gray, font=font) self.log.pack(side=tk.TOP, fill=tk.BOTH, expand=True) log_controls_frame.pack(side=tk.TOP, fill=tk.BOTH, pady=10, expand=True) controls_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=5)
def __init__(self): self.argument = GetArgument( ) #Get argument (file or folder name) if program was executed from a context menu self.window = tk.Tk() #Create main window self.settings = Settings_class() #This object holds user settings self.settings.Load( ) #Load settings saved in an external file (Config.ini) atexit.register(self.settings.Save ) #Set settings.Save() to run when program is closed # _____ _ _ _____ # / ____| | | |_ _| # | | __| | | | | | # | | |_ | | | | | | # | |__| | |__| |_| |_ # \_____|\____/|_____| #GUI uses the Tkinter framework. The elements are positioned using pack(), rather than grid(), #as I found it easier for correct alignments as long as inline elements are grouped inside frames ''' ----- Main window ----- ''' self.window.geometry("300x350") self.window.title("Comic Resizer") ''' ----- Source ----- ''' self.frameSource = tk.Frame(self.window) self.frameSource.pack(side=tk.TOP, fill=tk.BOTH, expand=False) self.label = tk.Label(self.frameSource, text="Source") self.label.pack(side=tk.TOP, fill=tk.NONE, expand=True, padx=5, pady=0, anchor='sw') self.pathTextBox = tk.Entry(self.frameSource, width=42) self.pathTextBox.pack(side=tk.LEFT, fill=tk.NONE, expand=False, padx=5, pady=0, anchor='nw') self.pathTextBox.insert(0, self.argument) self.dirDialogButton = tk.Button( self.frameSource, text="...", height=1, command=lambda: OpenFileDialog(self.pathTextBox)) self.dirDialogButton.pack(side=tk.LEFT, fill=tk.NONE, expand=False, padx=5, pady=0) ''' ----- Width ----- ''' self.frameWidth = tk.Frame(self.window) self.frameWidth.pack(side=tk.TOP, fill=tk.BOTH, expand=False) self.label = tk.Label(self.frameWidth, text="Width (px)") self.label.pack(side=tk.LEFT, fill=tk.NONE, expand=False, padx=5, pady=5, anchor="w") self.widthTextBox = tk.Entry(self.frameWidth, width=5) self.widthTextBox.pack(side=tk.LEFT, fill=tk.NONE, expand=False, padx=5, pady=5) self.widthTextBox.insert(0, '1280') ''' ----- Settings ----- ''' self.separ = ttk.Separator(self.window, orient=tk.HORIZONTAL) self.separ.pack(side=tk.TOP, fill=tk.BOTH, expand=False, padx=5, pady=0) self.frameSett = tk.Frame(self.window) #Frame for all checkboxes self.frameSett.pack(side=tk.TOP, fill=tk.BOTH, expand=False, anchor='n') self.frame1 = tk.Frame( self.frameSett ) #Subframe to put the first two checboxes on same row self.frame1.pack(side=tk.TOP, fill=tk.BOTH, expand=False) self.checkBoxDelete = tk.Checkbutton( self.frame1, text="Delete original", variable=self.settings.deleteOriginal) self.checkBoxDelete.pack(side=tk.LEFT, fill=tk.NONE, expand=False, padx=5, pady=0, anchor="w") self.checkBoxDeleteTemp = tk.Checkbutton( self.frame1, text="Delete temp folder", variable=self.settings.deleteTemp) self.checkBoxDeleteTemp.pack(side=tk.RIGHT, fill=tk.NONE, expand=False, padx=5, pady=0, anchor="w") self.checkBoxSmart = tk.Checkbutton( self.frameSett, text="Smart resizing (detect doublepages, etc.)", variable=self.settings.smartResize) self.checkBoxSmart.pack(side=tk.TOP, fill=tk.NONE, expand=False, padx=5, pady=0, anchor="w") self.checkBoxOnlyReduce = tk.Checkbutton( self.frameSett, text="Only reduce size, don't increase", variable=self.settings.onlyReduce) self.checkBoxOnlyReduce.pack(side=tk.TOP, fill=tk.NONE, expand=False, padx=5, pady=0, anchor="w") self.separ = ttk.Separator(self.window, orient=tk.HORIZONTAL) self.separ.pack(side=tk.TOP, fill=tk.BOTH, expand=False, padx=5, pady=5) ''' ----- Buttons ----- ''' self.frameStartBtns = tk.Frame(self.window) self.frameStartBtns.pack(side=tk.TOP, fill=tk.BOTH, expand=False, anchor='n') self.font1 = font.Font(size=20) self.buttonResize = tk.Button( self.frameStartBtns, text="Resize", font=self.font1, height=1, command=lambda: GlobalControl.ResizeComic( self.pathTextBox.get(), int(self.widthTextBox.get()), self. settings)) self.buttonResize.pack(side=tk.TOP, fill=tk.BOTH, expand=False, padx=10, pady=5) self.frame1 = tk.Frame(self.frameStartBtns) self.frame1.pack(side=tk.TOP, fill=tk.BOTH, expand=False, anchor='n') self.label = tk.Label(self.frame1, text="Substeps:") self.label.pack(side=tk.LEFT, fill=tk.NONE, expand=True, padx=0, pady=0) self.buttonExtractAndPreview = tk.Button( self.frame1, text="1/2\nExtract & preview", height=2, command=lambda: GlobalControl.ExtractAndPreview( self.pathTextBox.get(), self.settings)) self.buttonExtractAndPreview.pack(side=tk.LEFT, fill=tk.NONE, expand=False, padx=0, pady=5) self.buttonResize = tk.Button( self.frame1, text="2/2\nResize & compress", height=2, command=lambda: GlobalControl.ResizeAndCompress( self.pathTextBox.get(), int(self.widthTextBox.get()), self. settings)) self.buttonResize.pack(side=tk.LEFT, fill=tk.NONE, expand=False, padx=5, pady=5) self.separ = ttk.Separator(self.window, orient=tk.HORIZONTAL) self.separ.pack(side=tk.TOP, fill=tk.BOTH, expand=False, padx=5, pady=5) ''' ----- Footer ----- ''' self.frameFooter = tk.Frame(self.window) self.frameFooter.pack(side=tk.TOP, fill=tk.BOTH, expand=False, anchor='n') self.checkBoxClose = tk.Checkbutton( self.frameFooter, text="Close when finished", variable=self.settings.closeWhenFinished) self.checkBoxClose.pack(side=tk.LEFT, fill=tk.NONE, expand=False, padx=5, pady=0, anchor="w") self.buttonContextMenu = tk.Button( self.frameFooter, text="Add context\nmenu item", command=ContextMenu.AddToContextMenu) self.buttonContextMenu.pack(side=tk.RIGHT, fill=tk.NONE, expand=False, padx=5, pady=5)
def set_reddit_whitelist(root, comment_bool, reddit_state): """ Creates a window to let users select which comments or posts to whitelist :param root: the reference to the actual tkinter GUI window :param comment_bool: true for comments, false for posts :param reddit_state: dictionary holding reddit settings :return: none """ # TODO: update this to get whether checkbox is selected or unselected instead of blindly flipping from true to false def flip_whitelist_dict(id, identifying_text): whitelist_dict = reddit_state[f'whitelisted_{identifying_text}'] whitelist_dict[id] = not whitelist_dict[id] reddit_state[f'whitelisted_{identifying_text}'] = whitelist_dict reddit_state.sync if reddit_state['whitelist_window_open'] == 1: return if comment_bool: identifying_text = 'comments' item_array = reddit_state['user'].comments.new(limit=None) else: identifying_text = 'posts' item_array = reddit_state['user'].submissions.new(limit=None) whitelist_window = tk.Toplevel(root) reddit_state['whitelist_window_open'] = 1 reddit_state.sync whitelist_window.protocol( 'WM_DELETE_WINDOW', lambda: close_window( whitelist_window, reddit_state, 'whitelist_window_open')) frame = build_window(root, whitelist_window, f'Pick {identifying_text} to save') counter = 3 for item in item_array: if (item.id not in reddit_state[f'whitelisted_{identifying_text}']): # I wish I could tell you why I need to copy the dictionary of whitelisted items, and then modify it, and then # reassign it back to the persistant shelf. I don't know why this is needed, but it works. whitelist_dict = reddit_state[f'whitelisted_{identifying_text}'] whitelist_dict[item.id] = False reddit_state[f'whitelisted_{identifying_text}'] = whitelist_dict reddit_state.sync whitelist_checkbutton = tk.Checkbutton( frame, command=lambda id=item.id: flip_whitelist_dict( id, identifying_text)) if (reddit_state[f'whitelisted_{identifying_text}'][item.id]): whitelist_checkbutton.select() else: whitelist_checkbutton.deselect() whitelist_checkbutton.grid(row=counter, column=0) tk.Label(frame, text=helpers.format_snippet( item.body if comment_bool else item.title, 100)).grid(row=counter, column=1) ttk.Separator(frame, orient=tk.HORIZONTAL).grid(row=counter + 1, columnspan=2, sticky=(tk.E, tk.W), pady=5) counter = counter + 2