bg="#fff") if asvariable == False: BTN.grid(row=row, column=column, padx=20, pady=10) else: return BTN play_button = control(PLAY, start, asvariable=True) play_button.grid(row=0, column=1) pause_button = control(PAUSE, sigh, asvariable=True) control(PREVIOUS, prior, 0) control(NEXT, skip, 2) control(STOP, halt, 3) def volume_management(self): pygame.mixer.music.set_volume(volume.get() / 100) volume = ttk.Scale(DIV_BTN, orient=HORIZONTAL, length=140, from_=0, to=100, value=30, command=volume_management) volume.grid(row=0, column=6) window.mainloop()
def __init__(self, master): tk.Frame.__init__(self) master.geometry(set_size(master, 520, 450)) master.resizable(False, True) master.title("Barcode generator v1.0") self.barcode_bg_color = (255, 255, 255) self.barcode_bar_color = (0, 0, 0) self.barcode_text_color = (0, 0, 0) self.barcode_list = { "EAN-13": "ean13", "EAN-8": "ean8", "EAN-5": "ean5" } self.bcsize = tk.IntVar() self.bctype = tk.StringVar() self.bcvalue = tk.StringVar() self.ean13start = self.ean08start = self.ean05start = '' self.existcomment = '' self.filedir = '' self.filetype = 'PNG' self.edited = False self.selected = '' self.oldvalue = '' self.master = master master.rowconfigure(1, weight=1) self.frameTopLeft = tk.Frame(master) self.frameTopLeft.grid(row=0, column=0, sticky='nw', padx=(10, 0)) self.frameTopRight = tk.Frame(master, width=280) self.frameTopRight.grid(row=0, column=1, sticky='nsw', padx=(0, 0)) self.frameTopRight.grid_propagate(False) self.frameMain = ttk.Frame(master) self.frameMain.grid(row=1, column=0, columnspan=2, sticky='nswe', padx=(10, 0), pady=(0, 10)) # Menubar master.option_add('*tearOff', False) self.menubar = tk.Menu(master) master.config(menu=self.menubar) self.file = tk.Menu(self.menubar) help_ = tk.Menu(self.menubar) self.menubar.add_cascade(menu=self.file, label='File') self.file.add_command(label='Save as', command=self.saveasfile) self.file.add_command(label='Settings', command=self.settings) self.file.add_command(label='Info', command=self.helpwin) self.file.entryconfig('Save as', accelerator='Ctrl+S') #Entries self.frameType = ttk.Frame(self.frameTopLeft, padding=(5, 5)) self.frameType.grid(row=0, column=0, sticky="nswe", padx=(0, 0), pady=(2, 2)) ttk.Label(self.frameType, text='Barcode type: ').grid(row=0, column=0, sticky='w', pady=(0, 0)) options = ['EAN-13', 'EAN-8', 'EAN-5'] self.bcode_type = ttk.OptionMenu(self.frameType, self.bctype, options[0], *options, style='raised.TMenubutton') self.bcode_type.config(width=10) self.bcode_type.grid(row=0, column=1, sticky='we') self.frameSize = ttk.LabelFrame(self.frameTopLeft, text="Barcode size:", padding=(3, 3)) self.frameSize.grid(row=1, column=0, sticky="nswe", padx=(5, 5), pady=(2, 2)) self.bcode_size = ttk.Scale(self.frameSize, value=1, from_=1, to=10, variable=self.bcsize, command=self.setscale) self.bcode_size.grid(row=0, column=0, sticky='we', pady=(5, 0)) ttk.Label(self.frameSize, text=' 1 2 3 4 5 6 7 8 9 10 ').grid( row=1, column=0, sticky='w') ttk.Label(self.frameTopLeft, text='Barcode value:').grid(row=2, column=0, sticky='w', padx=(5, 0)) self.bcode_val = ttk.Entry(self.frameTopLeft, width=17, textvariable=self.bcvalue, font=('Arial', 21)) self.bcode_val.grid(row=3, column=0, pady=(0, 0)) ttk.Label(self.frameTopLeft, text='Comment:').grid(row=4, column=0, sticky='w', padx=(5, 0), pady=(5, 0)) self.textFrame = ttk.Frame(self.frameTopLeft, height=50, width=180) self.textFrame.grid(row=5, column=0, pady=(0, 0)) self.textFrame.columnconfigure(0, weight=1) self.bcode_comment = tkst.ScrolledText(self.textFrame, wrap=tk.WORD, width=23, height=3, font=('Arial', 15)) self.bcode_comment.grid(row=0, column=0, pady=(0, 0), sticky='we') # Buttons self.frameButton = ttk.Frame(self.frameTopRight) self.frameButton.grid(row=0, column=0, sticky="nswe", padx=(0, 5), pady=(5, 5)) self.frameButton.grid_columnconfigure(0, weight=1) self.frameButton.grid_columnconfigure(1, weight=1) self.btnGenerate = ttk.Button(self.frameButton, text='Generate', command=self.generate) self.btnGenerate.grid(row=0, column=0, pady=(0, 0), padx=(0, 2), sticky="we") self.btnSave = ttk.Button(self.frameButton, text='Save', command=self.saveasfile) self.btnSave.grid(row=0, column=1, pady=(0, 0), padx=(2, 0), sticky="we") # Preview self.imagepanel = tk.Canvas(self.frameTopRight, width=250, height=175) self.imagepanel.configure(background='#c1c1c1') self.imagepanel.config(highlightbackground='#5f5f5f') self.vsb = ttk.Scrollbar(self.frameTopRight, orient="vertical", command=self.imagepanel.yview) self.hsb = ttk.Scrollbar(self.frameTopRight, orient="horizontal", command=self.imagepanel.xview) self.vsb.grid(row=1, column=1, sticky="nse") self.hsb.grid(row=2, column=0, sticky="sew") self.imagepanel.config( yscrollcommand=lambda f, l: self.autoscroll(self.vsb, f, l)) self.imagepanel.config( xscrollcommand=lambda f, l: self.autoscroll(self.hsb, f, l)) self.imagepanel.grid(row=1, column=0, sticky="nswe", padx=(0, 5), pady=(0, 5)) # Table self.frameMain.rowconfigure(0, weight=1) self.tree = ttk.Treeview(self.frameMain, selectmode="extended", height=10, columns=("barcodes", "type", "comment"), displaycolumns="barcodes type comment") self.tree.grid(row=0, column=0, sticky="ns", padx=(5, 5), pady=(5, 5)) self.vsb1 = ttk.Scrollbar(self.frameMain, orient="vertical", command=self.tree.yview) self.hsb1 = ttk.Scrollbar(self.frameMain, orient="horizontal", command=self.tree.xview) self.vsb1.grid(row=0, column=1, sticky="nse") self.hsb1.grid(row=1, column=0, sticky="sew") self.tree.config( yscrollcommand=lambda f, l: self.autoscroll(self.vsb1, f, l)) self.tree.config( xscrollcommand=lambda f, l: self.autoscroll(self.hsb1, f, l)) self.tree.heading("#0", text="#") self.tree.heading("barcodes", text="Barcodes") self.tree.heading("type", text="Type") self.tree.heading("comment", text="Comment") self.tree.column("#0", minwidth=20, width=55, stretch=True, anchor="center") self.tree.column("barcodes", minwidth=50, width=120, stretch=True, anchor="center") self.tree.column("type", minwidth=40, width=65, stretch=True, anchor="center") self.tree.column("comment", minwidth=120, width=240, stretch=True, anchor="center") self.tree.tag_configure('even', background='#d9dde2') self.tree.bind('<Double-Button-1>', self.edit) master.bind("<Escape>", self.exit_ui) master.bind('<Control-s>', self.saveasfile) self.get_from_ini() self.read_file()
# Add Add Song Menu add_song_menu = Menu(my_menu) my_menu.add_cascade(label="Add Song", menu=add_song_menu) add_song_menu.add_command(label="Add One Song To Playlist", command=add_song) # Add Many songs to play add_song_menu.add_command(label="Add Many Songs To Playlist", command=add_many_songs) # Create Delete Song Menu remove_song_menu = Menu(my_menu) my_menu.add_cascade(label="Remove Songs", menu=remove_song_menu) remove_song_menu.add_command(label="Delete A Song From Playlist", command=delete_song) remove_song_menu.add_command(label="Delete All Songs From Playlist", command=delete_all_songs) # Create Status Bar status_bar = Label(root, text='', bd=1, relief=GROOVE, anchor=E) status_bar.pack(fill=X, side=BOTTOM, ipady=2) # Create Music Position Slider my_slider = ttk.Scale(master_frame, from_=0, to=100, orient=HORIZONTAL, value=0, command=slide, length=360) my_slider.grid(row=2, column=0, pady=10) # Create Volume Slider Volume_slider = ttk.Scale(volume_frame, from_=0, to=1, orient=VERTICAL, value=1, command=volume, length=125) Volume_slider.pack(pady=10) # Create Temporary Slider Label #slider_label = Label(root, text="0") #slider_label.pack(pady=10) root.mainloop()
def __init__(self, root): self.root = root self.root.geometry("860x560+397+243") self.root.minsize(148, 1) self.root.maxsize(1924, 1055) self.root.resizable(0, 0) self.root.title("Caesar Cypher Tool") self.scale = IntVar() self.scale_value = IntVar() self.Text1 = Text(self.root) self.Text1.place(relx=0.081, rely=0.606, relheight=0.282, relwidth=0.591) self.Text1.configure(background="white") self.Text1.configure(font="TkTextFont") self.Text1.configure(foreground="black") self.Text1.configure(highlightbackground="#d9d9d9") self.Text1.configure(highlightcolor="black") self.Text1.configure(insertbackground="black") self.Text1.configure(selectbackground="blue") self.Text1.configure(selectforeground="white") self.Text1.configure(wrap="word") self.TEntry1 = Text(self.root) self.TEntry1.configure(font="TkTextFont") self.TEntry1.place(relx=0.083, rely=0.157, relheight=0.278, relwidth=0.586) self.TLabel1 = ttk.Label(self.root, text='''Insert your sentence below''') self.TLabel1.place(relx=0.081, rely=0.107, height=24, width=184) self.TLabel1.configure(font="TkDefaultFont") self.TLabel1.configure(relief="flat") self.TLabel1.configure(anchor='w') self.TLabel1.configure(justify='left') self.TLabel2 = ttk.Label(self.root, text='''Here is the result''') self.TLabel2.place(relx=0.081, rely=0.553, height=24, width=138) self.TLabel2.configure(font="TkDefaultFont") self.TLabel2.configure(relief="flat") self.TLabel2.configure(anchor='w') self.TLabel2.configure(justify='left') self.Label1 = ttk.Label(self.root) self.Label1.place(relx=0.788, rely=0.178, height=26, width=79) self.Label1.configure(text='''Select shift''') self.Label2 = ttk.Label(self.root, textvariable=self.scale_value) self.Label2.place(relx=0.892, rely=0.178, height=26, width=42) self.TButton1 = ttk.Button(self.root, command=lambda: self.code('encode')) self.TButton1.place(relx=0.336, rely=0.446, height=30, width=98) self.TButton1.configure(takefocus="") self.TButton1.configure(text='''Encode''') self.TButton2 = ttk.Button(self.root, command=self.clear_text) self.TButton2.place(relx=0.081, rely=0.446, height=30, width=98) self.TButton2.configure(takefocus="") self.TButton2.configure(text='''Clear''') self.TScale1 = ttk.Scale(self.root, from_=26, to=-26, variable=self.scale, command=self.set_int_scale_val) self.TScale1.place(relx=0.823, rely=0.267, relwidth=0.0, relheight=0.57, width=26, bordermode='ignore') self.TScale1.configure(orient="vertical") self.TScale1.configure(takefocus="") self.TButton3 = ttk.Button(self.root, command=lambda: self.code('decode')) self.TButton3.place(relx=0.209, rely=0.446, height=30, width=98) self.TButton3.configure(takefocus="") self.TButton3.configure(text='''Decode''')
#bandera=False Controls = ttk.Labelframe(miFrame, text='Controls') Controls.grid(row=0, column=0, ipadx=5, ipady=5, sticky=(N, W)) #####Banda Frame####### lfBanda = ttk.Labelframe(Controls, text='Banda') lfBanda.grid(row=0, column=0, padx=10, pady=10, sticky=(N, W)) one = ttk.Checkbutton(lfBanda, text="Activar", variable=onevar, onvalue=True) one.grid(column=0, row=0, sticky=W) Labels = ttk.Label(lfBanda, text='Velocidad').grid(row=1, column=1, sticky=W) s = ttk.Scale(lfBanda, orient=HORIZONTAL, length=100, from_=0.0, to=99.0, variable=velbanda) s.grid(row=1, column=0, padx=10, pady=10) #######Tolva Frame###### lfTolva = ttk.Labelframe(Controls, text='Tolva') lfTolva.grid(row=2, column=0, padx=10, pady=10, sticky=(N, W)) two = ttk.Checkbutton(lfTolva, text="Activar", variable=twovar, onvalue=True) two.grid(column=0, row=0, sticky=W) Labels2 = ttk.Label(lfTolva, text='Velocidad').grid(row=1, column=1, sticky=W) s2 = ttk.Scale(lfTolva, orient=HORIZONTAL, length=100,
def __init__(self, master): ttk.Label(master, text="PROGRESS CONTROL").pack() # Inderterminant Progressbar ttk.Label(master, text='Inderterminant Progress').pack() self.prgrsbr_indtr = ttk.Progressbar(master, orient=tk.HORIZONTAL, length=300, mode='indeterminate') self.prgrsbr_indtr.pack() self.checkpbi = tk.StringVar() self.checkpbi.set("Start") # Button self.btn1 = ttk.Button(master, text="{} Inderterminant Progress Bar".format( self.checkpbi.get()), command=self.btn1cmd) self.btn1.pack() # Derterminant progress ttk.Label(master, text='Derterminant Progress').pack() self.prgrsbr_dtr = ttk.Progressbar(master, orient=tk.HORIZONTAL, length=300, mode='determinate') self.prgrsbr_dtr.pack() self.prgrsbr_dtr.config( maximum=10.0, value=2.0) # notice both these properties have float values # Button ttk.Button(master, text='Reset Progress Bar to zero', command=self.resetProgressBarVal).pack() # Button ttk.Button(master, text='Increase Progress Bar by 2', command=self.shift2ProgressBarVal).pack() # create double variable self.prgrsBrVal = tk.DoubleVar() self.prgrsbr_dtr.config( variable=self.prgrsBrVal ) # set variable property of progressbar to look at DoubleVar() # Scale widget self.scalebar = ttk.Scale(master, orient=tk.HORIZONTAL, length=400, variable=self.prgrsBrVal, from_=0.0, to=10.0) self.scalebar.pack() # Label to display current value of scalebar ttk.Label(master, text="Current value of Progress Bar is as below:").pack() self.scalebar_label = ttk.Label(master, textvariable=self.prgrsBrVal) self.scalebar_label.pack()
#create main frame main_frame = Frame(root) main_frame.pack(pady=20) #create volume slider frame volume_frame = LabelFrame(main_frame, text="Volume", fg="red") volume_frame.grid(row=0, column=1, padx=20, pady=10) #create volume slider volume_slider = ttk.Scale(volume_frame, from_=0, to=1, orient=VERTICAL, length=125, value=1, command=volume) volume_slider.pack(pady=20) #create song slider song_slider = ttk.Scale(main_frame, from_=0, to=100, orient=HORIZONTAL, length=360, value=0, command=slide) song_slider.grid(row=2, column=0, pady=20) #create playlist box
def __init__(self, master): self.master = master self.master.geometry('950x380') self.frame = tk.Frame(self.master) self.frame.grid_rowconfigure(0, weight=1) self.frame.grid_columnconfigure(0, weight=1) self.master.title('серво менеджер') #################### # here unpack values from additional files ===>variables self.values() # TODO change this shit on func self.loop_l_e = ttk.Checkbutton(self.master, command = lambda: self.one_more_window(self.loop_sec_entry1,self.loop_l_e,2,2,5), offvalue = tk.DISABLED,onvalue = tk.NORMAL ).grid(row=1, column=2, padx=10) self.loop_r_e = ttk.Checkbutton(self.master, command = lambda: self.one_more_window(self.loop_sec_entry2,self.loop_r_e,5,2,5), offvalue = tk.DISABLED,onvalue = tk.NORMAL ).grid(row=4, column=2, padx=10) self.loop_r_s = ttk.Checkbutton(self.master).grid(row=8, column=2, padx=10) self.loop_r_h = ttk.Checkbutton(self.master).grid(row=1, column=4, padx=10) self.loop_r_l = ttk.Checkbutton(self.master).grid(row=4, column=4, padx=10) self.loop_l_l = ttk.Checkbutton(self.master).grid(row=8, column=4, padx=10) self.loop_r_l = ttk.Checkbutton(self.master).grid(row=1, column=7, padx=10) self.loop_res = ttk.Checkbutton(self.master).grid(row=4, column=7, padx=10) self.loop_res2 = ttk.Checkbutton(self.master).grid(row=8, column=7, padx=10) self.play_butt = ttk.Button(self.master,text='проиграть',).grid(row=12, column=3) self.button = ttk.Button(self.master, text='записать позиции') self.button.grid(row=10, column=3,columnspan=1) self.button_save = ttk.Button(self.master,text='сохранить сценарий ').grid(row=11, column=3) self.choose_current_music =ttk.Button(self.master,text = 'музыка',) self.choose_current_music.grid(row=11, column=9,columnspan=15) self.sql_model_upload = ttk.Button(self.master,text = 'проиграть существующий сценарий',) self.clean_model_button = ttk.Button(self.master,text = 'удалить',).grid(row=10, column=3,columnspan=6) self.sql_model_upload.grid(row=12, column=8,columnspan=15) self.speed_slider = ttk.Scale(self.master, orient="horizontal", length=100, from_=0, to=200,command=self.printspeed ) self.time_scale = ttk.Scale(self.master,orient='horizontal',length=400,from_=0, to=self.duration, command = self.printime) self.time_scale.grid(row=19, column=0, columnspan=8) # digit near "время" self.window_db = Listbox(self.master, width=28, height=8) self.window_db.grid(row=2, column=8,rowspan=8,columnspan=10) self.speed_slider.grid(row=23, column=0,columnspan=3) # bigin speed state 50 self.speed_slider.set(50) self.show_last_values = Listbox(self.master, width=62, height=5,selectmode=tk.MULTIPLE) self.show_last_values.grid(row=17 ,column=8,rowspan=8,columnspan=12) self.request_butt = ttk.Label(self.master, text='текущая база данных: не выбрана',) self.request_butt.grid(row=10, column=8,columnspan=4) self.current_music = ttk.Label(self.master, text='музыка : -- ',) self.current_music.grid(row=11, column=7,columnspan=3,) self.time_label = ttk.Label(self.master, text="время").grid(row=17, column=1) self.time_digit = ttk.Label(self.master) self.time_digit.grid(row=17, column=0,rowspan=1,columnspan=7) self.speed_label = ttk.Label(self.master, text="cкорость").grid(row=22, column=1) self.speed_digit = ttk.Label(self.master) self.speed_digit.grid(row=22, column=1,columnspan=6) self.show_last_values_label = Label(text = 'последние значения').grid(row=16, column=8,columnspan=15) self.label_time = ttk.Label(self.master) self.label_time.grid(row=11, column=3) # create interval_window self.draw_entrys(self.loop_int_entry1,self.interval_1,2,2,5, self.loop_int_entry2,self.interval_2,5,2,5, self.loop_int_entry3,self.interval_3,9,2,5, self.loop_int_entry4,self.interval_4,2,4,5, self.loop_int_entry5,self.interval_5,5,4,5, self.loop_int_entry6,self.interval_6,9,4,5, self.loop_int_entry7,self.interval_7,2,7,5, self.loop_int_entry8,self.interval_8,5,7,5, self.loop_int_entry9,self.interval_9,9,7,5, ) # create servo angle window self.draw_entrys(self.left_eye,self.angle_box1,2,1,0, self.right_e,self.angle_box2,5,1,0, self.right_sholder,self.angle_box3,9,1,0, self.right_hand,self.angle_box4,2,3,0, self.left_hand,self.angle_box5,5,3,0, self.left_leg,self.angle_box6,9,3,0, self.right_leg,self.angle_box7,2,6,0, self.reserved_1,self.angle_box8,5,6,0, self.reserved_2,self.angle_box9,9,6,0) self.draw_labels(self.lab_ser_1,'глаз левый',1,1, self.lab_ser_2,'глаз правый',4,1, self.lab_ser_3,'плечо левое',8,1, self.lab_ser_4,'плечо правое',1,3, self.lab_ser_5,'рука левая',4,3, self.lab_ser_6,'рука правая',8,3, self.lab_ser_7,'нога правая',1,6, self.lab_ser_8,'нога левая',4,6, self.lab_ser_9,'жопа',8,6)
radio1.place(x=20, y=20) radio2 = ttk.Radiobutton(radioframe, text='Selected', variable=d, value=2) radio2.place(x=20, y=60) radio3 = ttk.Radiobutton(radioframe, text='Disabled', state='disabled') radio3.place(x=20, y=100) # Separator separator = ttk.Separator() separator.place(x=20, y=235, width=210) # Function for move the Progressbar when the Scale is moved def scaleFunction(*args): g.set(scale.get()) # Scale scale = ttk.Scale(root, from_=100, to=0, variable=g, command=scaleFunction) scale.place(x=80, y=430) # Progressbar progress = ttk.Progressbar(root, value=0, variable=g, mode='determinate') progress.place(x=80, y=480) # Entry entry = ttk.Entry(root) entry.place(x=250, y=20) entry.insert(0, 'Entry') # Spinbox spinbox = ttk.Spinbox(root, from_=0, to=100, increment=0.1) spinbox.place(x=250, y=70) spinbox.insert(0, 'Spinbox')
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 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) graphics = ttk.LabelFrame(self.tab_ideal, text="Gráfica") 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) # Añadir elementos de entrada de texto 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, "X0") self.entrada_posicion_x0.bind("<Button-1>", limpiar_entrada_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, "Y0") self.entrada_posicion_y0.bind("<Button-1>", limpiar_entrada_y0) 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) 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) #Insercion Grafico en la zona indicada figura = Figure(figsize=(4, 3), dpi=100) # define la proporcion del gráfico ecuacion = np.arange(0, 10, .01) figura.add_subplot(111).plot(ecuacion, ecuacion * ecuacion) canvas = FigureCanvasTkAgg(figura, master=graphics) canvas.draw() canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
#frame for slider sliderframe = Frame(bframe) sliderframe.pack(side=TOP) #frame for Buttons butframe = Frame(bframe) butframe.pack(side=BOTTOM) #buttons in the button frame ttk.Button(butframe, text="sketch", command=sketch).grid(column=0, row=0) ttk.Button(butframe, text="sharpen", command=sharp).grid(column=1, row=0) ttk.Button(butframe, text="contour", command=conto).grid(column=2, row=0) ttk.Button(butframe, text="cartoon", command=cartoon).grid(column=3, row=0) ttk.Button(butframe, text="kelvin", command=jeetesh).grid(column=4, row=0) ttk.Button(butframe, text="reset", command=reset).grid(column=5, row=0) #slider txtbrit = Label(sliderframe, text="Brightness:").grid(row=0, column=3) txtcon = Label(sliderframe, text="Contrast:").grid(row=1, column=3) slider = ttk.Scale(sliderframe, from_=0, to=100, command=adjust_brightness).grid(row=0, column=4) slider = ttk.Scale(sliderframe, from_=1, to=5, command=adjust_contrast).grid(row=1, column=4) txtbrit_per = Label(sliderframe, text="0%").grid(row=0, column=5) txtcon_per = Label(sliderframe, text="0%").grid(row=1, column=5) #====================== # Start GUI #====================== win.config(menu=menubar) win.mainloop()
def __init__(self): self.window = tk.Tk() self.window.title("Fisica") self.window.minsize(800, 600) self.window.maxsize(1280, 960) self.entrada_posicion_x0 = ttk.Entry() self.entrada_posicion_y0 = ttk.Entry() self.entrada_angulo_inicial = ttk.Entry() self.entrada_aceleracion_inicial = ttk.Entry() self.deslizador_posicion_x0 = ttk.Scale() self.deslizador_posicion_y0 = ttk.Scale() self.deslizador_angulo_inicial = ttk.Scale() self.deslizador_aceleracion_inicial = ttk.Scale() self.pestañas = ttk.Notebook(self.window) self.tab_ideal = ttk.Frame(self.pestañas) self.opciones = ttk.Frame(self.tab_ideal) # Inicializar los botones de la interfaz self.boton_posicion = ttk.Button( self.opciones, text="Posición", width=10, command=lambda: self.boton_posicionf()) self.boton_velocidad = ttk.Button( self.opciones, text="Velocidad", width=10, command=lambda: self.boton_velocidadf()) self.boton_aceleracion = ttk.Button( self.opciones, text="Aceleración", width=10, command=lambda: self.boton_aceleracionf()) self.boton_alcance_horizontal = ttk.Button( self.opciones, text="Alcance Horizontal", width=10, command=lambda: self.boton_alcance_horizontalf()) self.boton_altura_maxima = ttk.Button( self.opciones, text="Altura Màxima", width=10, command=lambda: self.boton_altura_maximaf()) self.boton_camino_recorrido = ttk.Button( self.opciones, text="Camino Recorrido", width=10, command=lambda: self.boton_camino_recorridof()) self.boton_radio_y_centro_de_curvatura_circulo_obsculador = ttk.Button( self.opciones, text="Radio y Centro de Curvatura y Circulo Obsculador", width=10, command=lambda: self. boton_radio_y_centro_de_curvatura_circulo_obsculadorf()) self.boton_aceleracion_normal_y_tangencial = ttk.Button( self.opciones, text="A. normal y tangencial", width=10, command=lambda: self.boton_aceleracion_normal_y_tangencialf()) self.boton_vector_normal = ttk.Button( self.opciones, text="Vector normal", width=10, command=lambda: self.boton_vector_normalf()) #self.boton_circulo_osculador = ttk.Button(self.opciones, text="Circulo Osculador", width=10, #command=lambda: self.boton_circulo_osculadorf()) self.create_widgets()
launch_button = Button(root, text="Launch Window", command=launch) launch_button.pack(pady=20) width_frame = LabelFrame(root, text="Width") width_frame.pack(pady=20) height_frame = LabelFrame(root, text="Height") height_frame.pack(pady=20) both_frame = LabelFrame(root, text="Both") both_frame.pack(pady=20) width_slider = ttk.Scale(width_frame, from_=100, to=500, orient=HORIZONTAL, length=200, command=width_slide, value=100) width_slider.pack(pady=20, padx=20) height_slider = ttk.Scale(height_frame, from_=100, to=500, orient=VERTICAL, length=200, command=height_slide, value=100) height_slider.pack(pady=20, padx=20) both_slider = ttk.Scale(both_frame,
def __init__(self, notebook): self.tiles_frame = [] self.board = Board(0, 0) self.is_job_done = False # creating Tab1 main = ttk.Frame(notebook) main.columnconfigure(0, weight=1) main.columnconfigure(1, weight=2) # left side leftside_tab = ttk.Frame(main, borderwidth=0, relief="", width=200, height=400) leftside_tab.grid(column=0, row=0) # right side rightside_tab = ttk.Frame(main, borderwidth=0, relief="", width=400, height=400) rightside_tab.grid(column=1, row=0) # Creating left side. # leftside.rowconfigure(0, weight=1) # leftside.rowconfigure(1, weight=1) # leftside.rowconfigure(2, weight=1) # leftside.rowconfigure(3, weight=1) # leftside.rowconfigure(4, weight=1) # leftside.rowconfigure(5, weight=1) # leftside.rowconfigure(6, weight=1) ttk.Frame(leftside_tab, height=100, width=100, relief="").grid(column=0, row=0, sticky=("N", "W", "E", "S")) nframe = ttk.Frame(leftside_tab, relief="") nframe.grid(column=0, row=1) label1_var = StringVar() ttk.Label(nframe, text="n: ", textvariable=label1_var).grid(column=0, row=0) self.n_var = IntVar() n_var = self.n_var def label1(self): label1_var.set("n: " + str(n_var.get())) n = ttk.Scale(nframe, orient="horizontal", length=100, from_=5.0, to=20.0, variable=n_var, command=label1) n.grid(column=1, row=0) n.set(5) ttk.Frame(leftside_tab, height=40).grid(column=0, row=2) colorframe = ttk.Frame(leftside_tab) colorframe.grid(column=0, row=3) label2_var = StringVar() ttk.Label(colorframe, text="Colors: ", textvariable=label2_var).grid(column=0, row=0) self.color_var = IntVar() color_var = self.color_var def label2(self): label2_var.set("Colors: " + str(color_var.get())) color = ttk.Scale(colorframe, orient="horizontal", length=100, from_=2, to=15.0, variable=color_var, command=label2) color.grid(column=1, row=0) color.set(2) ttk.Frame(leftside_tab, height=40).grid(column=0, row=4) intervalframe = ttk.Frame(leftside_tab) intervalframe.grid(column=0, row=5) ttk.Label(intervalframe, text="Interval: ").grid(column=0, row=0) self.interval_var = IntVar() interval_var = self.interval_var interval = ttk.Scale(intervalframe, orient="horizontal", length=100, from_=1, to=1000, variable=interval_var) interval.grid(column=1, row=0) interval.set(300) ttk.Frame(leftside_tab, height=40).grid(column=0, row=6) buttonframe = ttk.Frame(leftside_tab) buttonframe.grid(column=0, row=7) self.reset = ttk.Button(buttonframe, text="Reset", command=self.reset_func) self.reset.grid(column=0, row=0) self.run = False self.stun = ttk.Button(buttonframe, text="Run/Stop", command=self.stun_func) self.stun.grid(column=1, row=0) statusframe = ttk.Frame(leftside_tab) statusframe.grid(column=0, row=8) self.status_var = StringVar() status_var = self.status_var status = ttk.Label(statusframe, textvariable=status_var) status.grid(column=0, row=0) roundsframe = ttk.Frame(leftside_tab) roundsframe.grid(column=0, row=9) self.rounds_var = StringVar(value="Rounds: 0") rounds_var = self.rounds_var rounds = ttk.Label(roundsframe, textvariable=rounds_var) rounds.grid(column=0, row=0) self.main = main self.leftside_tab1 = leftside_tab self.rightside_tab1 = rightside_tab self.reset_func()
#my_canvas.create_line(150, 0, 150, 200, fill="red") my_canvas.bind('<B1-Motion>', paint) # Create Brush Options Frame brush_options_frame = Frame(root) brush_options_frame.pack(pady=20) # Brush Size brush_size_frame = LabelFrame(brush_options_frame, text="Brush Size") brush_size_frame.grid(row=0, column=0, padx=50) # Brush Slider my_slider = ttk.Scale(brush_size_frame, from_=1, to=100, command=change_brush_size, orient=VERTICAL, value=10) my_slider.pack(pady=10, padx=10) # Brush Slider Label slider_label = Label(brush_size_frame, text=my_slider.get()) slider_label.pack(pady=5) # Brush Type brush_type_frame = LabelFrame(brush_options_frame, text="brush Type", height=400) brush_type_frame.grid(row=0, column=1, padx=50) brush_type = StringVar()
###################################################################### #volume control widget def Set_vol(val): value = float(val) pg.mixer.music.set_volume(value / 100) pg.mixer.music.set_volume(0.0) vol = Label(f1, text="Volume:", font=("Ms Sheriff", 15), fg="red", bg="black") vol.place(x=290, y=5) s1 = ttk.Scale(f1, from_=0, to=100, command=Set_vol, orient=HORIZONTAL, length=100) s1.place(x=370, y=5) ###################################################################### #listbox with scrollbar to list out songs f2 = Frame(root, bg="black", width=300) f2.pack(side=LEFT, fill=Y, padx=5, pady=5) scrollbar = Scrollbar(f2) scrollbar.pack(side=RIGHT, fill=Y) global lst
style = ttk.Style() style.theme_use(theme) # layout = style.layout(stylename) config = widget.configure() print('{:*^50}\n'.format(f'Theme = {theme}')) # print('{:*^50}\n'.format(f'Style = {stylename}')) print('{:*^50}'.format('Config')) for key, value in config.items(): print('{:<15}{:^10}{}'.format(key, '=>', value)) print('\n{:*^50}'.format('Layout')) elements = iter_layout(layout) # Get options of widget elements print('\n{:*^50}'.format('element options')) for element in elements: print('{0:30} options: {1}'.format( element, style.element_options(element))) except tk.TclError: print('_tkinter.TclError: "{0}" in function' 'widget_elements_options({0}) is not a regonised stylename.' .format(stylename)) widget = ttk.Scale(None) class_ = widget.winfo_class() Theme = 'default' stylename_elements_options('Horizontal.'+class_, widget, Theme)
def __init__(self, root): root.title("Regularization for Machine Learning") root.resizable(width=False, height=False) Main = ttk.Frame(root, padding=(3, 3, 12, 12)) #,width=600, height=600) f1 = ttk.Labelframe(Main, text='Input', borderwidth=1, relief="sunken", width=300, height=300, padding=(10, 10, 12, 12)) # f2 = ttk.Frame(Main, borderwidth=1, relief="sunken", width=300, height=400, padding=(10, 10, 12, 12)) self.f3 = ttk.Frame(Main, borderwidth=5, relief="sunken", width=300, height=400, padding=(1, 1, 1, 1)) f4 = ttk.Frame(Main, borderwidth=1, relief="sunken", width=300, height=300, padding=(3, 3, 3, 3)) f11 = ttk.Labelframe(f1, text='Task', borderwidth=1, relief="sunken", width=300, height=100, padding=(3, 3, 12, 12)) # f12 = ttk.Labelframe(f1, text='Dataset', borderwidth=1, relief="sunken", width=300, height=200, padding=(3, 3, 20, 20)) # f21 = ttk.Labelframe(f2, text='Filter', borderwidth=1, relief="sunken", width=300, height=50, padding=(3, 3, 12, 12)) f22 = ttk.Labelframe(f2, text='Kernal', borderwidth=1, relief="sunken", width=300, height=100, padding=(3, 3, 12, 12)) f23 = ttk.Labelframe(f2, text='Learning', borderwidth=1, relief="sunken", width=300, height=200, padding=(3, 3, 12, 12)) f41 = ttk.Labelframe(f4, text='Result', borderwidth=1, relief="sunken", width=400, height=70, padding=(3, 3, 1, 1)) self.f42 = ttk.Labelframe(f4, borderwidth=5, relief="sunken", width=400, height=220, padding=(0, 0, 0, 0)) Main.grid(column=0, row=0, sticky=(N, S, E, W)) f1.grid(column=0, row=0, columnspan=1, rowspan=1, sticky=(N, S, E, W)) f2.grid(column=1, row=0, columnspan=3, rowspan=2, sticky=(N, S, E, W)) self.f3.grid(column=0, row=1, columnspan=1, rowspan=2, sticky=(N, S, E, W)) f4.grid(column=1, row=2, columnspan=3, rowspan=1, sticky=(N, S, E, W)) f11.grid(column=0, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f12.grid(column=0, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f21.grid(column=0, row=0, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f22.grid(column=0, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f23.grid(column=0, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) f41.grid(row=0, sticky=(N, S, E, W), pady=5) self.f42.grid(row=1, sticky=(N, S)) ###-------------------------------- F1------------------------------------ label1f1 = ttk.Label(f1, text='Input ') label2f1 = ttk.Label(f11, text='Task') label3f1 = ttk.Label(f12, text='Dataset') tFont = tkFont.Font(f12, family='Times', weight='bold') #, size=12 label4f1 = ttk.Label( f12, text='# Training Samples') #,style ="B.TLabel")#,font =tFont) label5f1 = ttk.Label(f12, text='# Test Samples') label6f1 = ttk.Label(f12, text='Wrong labels ratio[0-1]') labelfont = ('timesroman', 15, 'bold') self.task = IntVar() self.task.set(1) self.Clf = ttk.Radiobutton(f11, text='Claasification', variable=self.task, value=1, command=self.TaskSelF) self.Reg = ttk.Radiobutton(f11, text='Regression ', variable=self.task, value=0, command=self.TaskSelF, state='disabled') self.dt = StringVar() self.eData = ttk.Radiobutton(f12, text='Existing Dataset', variable=self.dt, value=1, command=self.seDataFun) self.sData = ttk.Radiobutton( f12, text='Simulation ', variable=self.dt, value=0, command=self.seDataFun) #, state='disabled') self.Browse = ttk.Button(f12, text="Browse", command=self.BrowseDataFun) #self.eDataO = StringVar() self.eDataG = ttk.Entry(f12, width=8) self.sDataG = ttk.Combobox(f12) #, textvariable = self.sDataO) self.sDataG['values'] = ('Moons', 'Gaussians', 'Linear', 'Sinusoidal', 'Spiral') #,'Toy') #MOONS, GAUSSIANS, LINEAR, SINUSOIDAL, SPIRAL self.sDataG.current(0) self.nTr = StringVar() self.nTs = StringVar() self.nE = StringVar() self.nTrain = ttk.Entry(f12, textvariable=self.nTr, width=7) self.nTest = ttk.Entry(f12, textvariable=self.nTs, width=7) self.nWL = ttk.Entry(f12, textvariable=self.nE, width=7) self.nTrain.insert(0, '100') self.nTest.insert(0, '100') self.nWL.insert(0, '0.0') self.LoadData = ttk.Button(f12, text="LoadData", command=self.LoadDataFun) ## --------------F1----------Grid-------------------------------- #F11 self.Clf.grid(column=0, row=2, columnspan=2, rowspan=1, sticky=(N, S, E, W)) self.Reg.grid(column=3, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W)) #F12 self.eData.grid(column=0, row=1, columnspan=2, rowspan=1, sticky=(N, S, E, W)) self.eDataG.grid(column=2, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=5) self.Browse.grid(column=3, row=1, columnspan=2, rowspan=1, sticky=(S, W), padx=10) self.sData.grid(column=0, row=2, columnspan=2, rowspan=1, sticky=(N, S, E, W)) self.sDataG.grid(column=2, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W)) label4f1.grid(column=2, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W)) label5f1.grid(column=2, row=4, columnspan=1, rowspan=1, sticky=(N, S, E, W)) label6f1.grid(column=2, row=5, columnspan=1, rowspan=1, sticky=(N, S, E, W)) self.nTrain.grid(column=3, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=2) self.nTest.grid(column=3, row=4, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=2) self.nWL.grid(column=3, row=5, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=2) self.LoadData.grid(column=0, row=6, columnspan=1, rowspan=1, sticky=(N, S, E, W)) ###-------------------------------- F2------------------------------------ #Filter------ label1f2 = ttk.Label(f21, text='Filter') # DropDown self.ftrO = ttk.Combobox(f21, width=30) self.ftrO['values'] = ('Regularized Least Squares', 'nu-method', 'Truncated SVD', 'Spectral cut-off', 'Iterative Landweber') self.ftrO.current(0) self.ftrO.bind("<<ComboboxSelected>>", self.filtrUpdate) #Kernal------ label2f2 = ttk.Label(f22, text='Kernal') # DropDown self.krnlO = ttk.Combobox(f22) self.krnlO['values'] = ('Linear', 'Polynomial', 'Gaussian') self.krnlO.current(0) self.krnlO.bind("<<ComboboxSelected>>", self.kpRangeUpdate) #self.kparVar = StringVar() self.kParaO = ttk.Scale(f22, orient=HORIZONTAL, length=200) #, from_=0.0, to=100.0) self.kParaO['command'] = self.kParaSelFun self.kParaO['from_'] = 1.0 self.kParaO['to'] = 30.0 self.label3f2 = ttk.Label(f22, text='kpar : 0.0') self.aSigVar = IntVar() self.aSigmaO = ttk.Checkbutton(f22, text='AutoSigma', variable=self.aSigVar, command=self.aSigmaSelFun) ukpar = DoubleVar() self.ukparO = ttk.Entry(f22, width=8) #textvariable=ukpar, self.ukparO.insert(0, 0.0) label3f2 = ttk.Label(f23, text='Learning') self.tVar = IntVar() self.cKvcO = ttk.Checkbutton(f23, text='use KCV', variable=self.tVar, onvalue=1, offvalue=0, command=self.cKCVSelfun) self.fixedVO = ttk.Checkbutton(f23, text='Fixed Value', variable=self.tVar, onvalue=0, offvalue=1, command=self.cKCVSelfun) label31f2 = ttk.Label(f23, text='Split') label32f2 = ttk.Label(f23, text='# split') label33f2 = ttk.Label(f23, text='t min') label34f2 = ttk.Label(f23, text='t max') label35f2 = ttk.Label(f23, text='# of values') # DropDown1 #splitype = StringVar() self.splitO = ttk.Combobox(f23) #, textvariable = splitype) self.splitO['values'] = ('Sequential', 'Random') self.splitO.current(0) # DropDown2 self.vScaleO = ttk.Combobox(f23) self.vScaleO['values'] = ('Linear Space', 'Log Space') self.vScaleO.current(0) self.nSO = ttk.Entry(f23, width=4) self.tMnO = ttk.Entry(f23, width=4) self.tMxO = ttk.Entry(f23, width=4) self.nSvO = ttk.Entry(f23, width=4) self.fixVO = ttk.Entry(f23, width=4) self.nSO.insert(0, 5) self.tMnO.insert(0, 0.0) self.tMxO.insert(0, 1.0) self.nSvO.insert(0, 10) self.fixVO.insert(0, 1.3) ## --------------F2----------Grid-------------------------------- ##F21 self.ftrO.grid(column=0, row=0, columnspan=2, rowspan=1, sticky=(N, S, E, W), padx=10) ## F22 #Kernal------ # DropDown self.krnlO.grid(column=1, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=5) self.kParaO.grid(column=1, row=2, columnspan=2, rowspan=1, sticky=(N, S, E, W), padx=10, pady=5) self.label3f2.grid(column=0, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=5, pady=5) self.aSigmaO.grid(column=0, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W)) self.ukparO.grid(column=2, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=2) ## F23 self.cKvcO.grid(column=0, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W)) label31f2.grid(column=0, row=2, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) label32f2.grid(column=0, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) label33f2.grid(column=0, row=4, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) label34f2.grid(column=0, row=5, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) label35f2.grid(column=0, row=6, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=15) # DropDown2 self.vScaleO.grid(column=0, row=7, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=20) self.fixedVO.grid(column=0, row=8, columnspan=1, rowspan=1, sticky=(N, S, E, W)) # DropDown1 self.splitO.grid(column=1, row=2, columnspan=2, rowspan=1, sticky=(N, S, E, W), pady=4) #Entry-- self.nSO.grid(column=2, row=3, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) self.tMnO.grid(column=2, row=4, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) self.tMxO.grid(column=2, row=5, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) self.nSvO.grid(column=2, row=6, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) self.fixVO.grid(column=1, row=8, columnspan=1, rowspan=1, sticky=(N, S, E, W), pady=2) ###-------------------------------- F3------------------------------------ ## Plot ###-------------------------------- F4------------------------------------ #F4 self.label1f41 = ttk.Label(f41, text='Training Error - ') self.label2f41 = ttk.Label(f41, text='Testing Error - ') self.label3f41 = ttk.Label(f41, text='Selected t - ') self.sep1f41 = ttk.Separator(f41, orient="vertical") ##--------------- F4---------Grid--------------------------- self.label1f41.grid(column=0, row=0, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=5) self.label2f41.grid(column=0, row=1, columnspan=1, rowspan=1, sticky=(N, S, E, W), padx=10, pady=5) self.sep1f41.grid(column=1, row=0, columnspan=1, rowspan=3, sticky='NS', padx=10, pady=0) self.label3f41.grid(column=2, row=0, columnspan=1, rowspan=2, sticky=(N, S, E, W), padx=10, pady=5) #######----------MAIN Frame---------------------------------------------------------- Plot = ttk.Button(Main, text="Plot Test/Train", command=self.PlotTrTsTT) RUN = ttk.Button(Main, text="RUN", command=self.runLEARN) CLOSE = ttk.Button(Main, text="Close", command=self.Qt) Reset = ttk.Button(Main, text="Reset", command=self.ResetSetting) Plot.grid(column=0, row=3) RUN.grid(column=1, row=3) Reset.grid(column=2, row=3) CLOSE.grid(column=3, row=3) #---------Default--Initial Setting variable/Items------------------- self.plotTrain = True self.trained = False self.Clf.invoke() self.sData.invoke() self.aSigmaO.state(['selected']) self.kParaO.state(['disabled']) self.fixedVO.state(['selected']) self.fixedVO.invoke() self.ftrO.current(0)
def get_my_frame(root, window, mqtt_sender): # Construct your frame: frame = ttk.Frame(window, padding=10, borderwidth=5, relief="ridge") frame_label = ttk.Label(frame, text="Ben Wilfong") frame_label.grid(row=0, column=0, columnspan=2) # Done 2: Put your name in the above. # speed_entry = ttk.Entry(frame, width=10) # speed_entry.grid(row=1, column=1) speed_slider = ttk.Scale(frame, from_=0, to=100) speed_slider.set(50) speed_slider.grid(row=1, column=1) speed_entry_label = ttk.Label(frame, text='Speed (0 - 100)') speed_entry_label.grid(row=1, column=0) distance_entry = ttk.Entry(frame, width=10) distance_entry.insert(0, "50") distance_entry.grid(row=2, column=1) distance_entry_label = ttk.Label(frame, text='Distance in Degrees') distance_entry_label.grid(row=2, column=0) spin_left_button = ttk.Button(frame, text='Spin Left') spin_left_button.grid(row=3, column=0) spin_right_button = ttk.Button(frame, text='Spin Right') spin_right_button.grid(row=3, column=1) spin_left_button['command'] = lambda: handle_spin_left( speed_slider, distance_entry, mqtt_sender) spin_right_button['command'] = lambda: handle_spin_right( speed_slider, distance_entry, mqtt_sender) ################################################################################ spin_until_facing_label = ttk.Label(frame, text="Spin Until") spin_until_facing_label.grid(column=3, row=0, columnspan = 4) speed_label_for_spin_until = ttk.Label(frame, text="Speed 0-100") speed_label_for_spin_until.grid(column=3, row=1) speed_entry_for_spin_until = ttk.Entry(frame, width=4) speed_entry_for_spin_until.grid(column=4, row=1) x_label_for_spin_until = ttk.Label(frame, text='X') x_label_for_spin_until.grid(column=5, row=1) x_entry_for_spin_until = ttk.Entry(frame, width=4) x_entry_for_spin_until.grid(column=6, row=1) big_enough_label_for_spin_until = ttk.Label(frame, text="Size") big_enough_label_for_spin_until.grid(column=3, row=2) big_enough_entry_for_finding_spin_until = ttk.Entry(frame, width=4) big_enough_entry_for_finding_spin_until.grid(column=4, row=2) delta_label_for_spin_until = ttk.Label(frame, text="Delta") delta_label_for_spin_until.grid(column=5, row=2) delta_entry_for_spin_until = ttk.Entry(frame, width=4) delta_entry_for_spin_until.grid(column=6, row=2) spin_until_button = ttk.Button(frame, text="Spin Until") spin_until_button.grid(column=3, row=3, columnspan=4) spin_until_button['command'] = lambda: handle_spin_until(speed_entry_for_spin_until, x_entry_for_spin_until, big_enough_entry_for_finding_spin_until, delta_entry_for_spin_until, mqtt_sender) ####################################################################################################### dance_button = ttk.Button(frame, text="Dance!") dance_button.grid(row=8, column=0) dance_colors_entry = ttk.Entry(frame) dance_colors_entry.grid(row=8, column=1, columnspan=7) dance_colors_entry.insert(0, "DOES NOT WORK") dance_button['command'] = lambda: handle_dance(dance_colors_entry, mqtt_sender) # Return your frame: return frame
def Scale(self, min=1, max=10, initial=5, orient=HORIZONTAL): s = ttk.Scale(self.widget, from_=min, to_=max, orient=orient) s.set(initial) return self.layout(s)
pygame.mixer.music.set_volume(volume_slider.get()) main_frame = Frame(root) main_frame.pack(pady=20) control_frame = Frame(main_frame) control_frame.grid(row=1, column=0, pady=20) playlist_box = Listbox(main_frame, bg="black", fg="green", width=80, selectbackground="green") playlist_box.grid(row=0, column=0) volume_frame = LabelFrame(main_frame, text="Volume") volume_frame.grid(row=0, column=1, padx=25) volume_slider = ttk.Scale(volume_frame, from_=0, to=1, orient=VERTICAL, length=125, value=.5, command=set_volume) volume_slider.pack(pady=10) back_button_img = PhotoImage(file='img/back50.png') forward_button_img = PhotoImage(file='img/forward50.png') play_button_img = PhotoImage(file='img/play50.png') pause_button_img = PhotoImage(file='img/pause50.png') stop_button_img = PhotoImage(file='img/stop50.png') back_button = Button(control_frame, image=back_button_img, borderwidth=0, command=back) forward_button = Button(control_frame, image=forward_button_img, borderwidth=0, command=forward) play_button = Button(control_frame, image=play_button_img, borderwidth=0, command=play) pause_button = Button(control_frame, image=pause_button_img, borderwidth=0, command=lambda: pause(paused)) stop_button = Button(control_frame, image=stop_button_img, borderwidth=0, command=stop) buttons = [back_button, forward_button, play_button, pause_button, stop_button]
def body(self, master): # Battery self.batteryGroup = ttk.LabelFrame(self, text="Battery", underline=0) self.batteryGroup.grid(column=0, row=0, columnspan=2, sticky=(tk.N, tk.W, tk.E, tk.S), padx=6, pady=(6, 0)) ttk.Label(self.batteryGroup, text="Cell Type:", underline=5).grid(column=0, row=0, sticky=tk.E, padx=(4, 0), pady=4) self.batteryCellTypeCombo = ttk.Combobox( self.batteryGroup, state='readonly', width=10, values=["NiCd", "NiMH", "LiPo", "LiNP", "PbAcid"]) # FIXME: Get this list from somewhere self.batteryCellTypeCombo.grid(column=1, row=0, sticky=tk.W, padx=(4, 0), pady=4) self.batteryCellTypeCombo.current(1) ttk.Label(self.batteryGroup, text="Capacity:", underline=1)\ .grid(column=2, row=0, sticky=tk.E, padx=(4,0), pady=4) self.batteryCapacity = ttk.Entry(self.batteryGroup, width=10) self.batteryCapacity.grid(column=3, row=0, padx=(4, 0), pady=4) ttk.Label(self.batteryGroup, text="mAh").grid(column=4, row=0, sticky=tk.W, padx=(4, 0), pady=4) ttk.Label(self.batteryGroup, text="Number of Cells:", underline=0)\ .grid(column=5, row=0, sticky=tk.E, padx=(4,0), pady=4) self.batteryNumberOfCells = tk.Spinbox(self.batteryGroup, width=5, from_=1, to=12) self.batteryNumberOfCells.grid(column=6, row=0, padx=4, pady=4) # Discharge self.dischargeRate = tk.IntVar() self.dischargeGroup = ttk.LabelFrame(self, text="Discharge", underline=0) self.dischargeGroup.grid(column=0, row=1, sticky=(tk.N, tk.W, tk.E, tk.S), padx=(6, 0), pady=(6, 0)) ttk.Label(self.dischargeGroup, text="Rate:", underline=3)\ .grid(column=0, row=0, sticky=tk.W, padx=(4,0), pady=4) dischargeRateScale = ttk.Scale(self.dischargeGroup, command=self.updateDischargeRate, variable=self.dischargeRate, from_=1, to=settings.numChargeRates - 1, orient=tk.HORIZONTAL) dischargeRateScale.grid(column=1, row=0, sticky=tk.W, padx=4, pady=4) self.dischargeRate.set(1) self.dischargeRateLabel = ttk.Label(self.dischargeGroup) self.dischargeRateLabel.grid(column=1, row=1, padx=4, pady=(0, 4)) self.updateDischargeRate() # Charge self.chargeRate = tk.IntVar() self.chargeGroup = ttk.LabelFrame(self, text="Charge", underline=0) self.chargeGroup.grid(column=1, row=1, sticky=(tk.N, tk.W, tk.E, tk.S), padx=6, pady=(6, 0)) ttk.Label(self.chargeGroup, text="Rate:", underline=0)\ .grid(column=0, row=0, sticky=tk.W, padx=(4,0), pady=4) chargeRateScale = ttk.Scale(self.chargeGroup, command=self.updateChargeRate, variable=self.chargeRate, from_=1, to=settings.numChargeRates - 1, orient=tk.HORIZONTAL) chargeRateScale.grid(column=1, row=0, sticky=tk.W, padx=4, pady=4) self.chargeRate.set(1) self.chargeRateLabel = ttk.Label(self.chargeGroup) self.chargeRateLabel.grid(column=1, row=1, padx=4, pady=(0, 4)) self.updateChargeRate() # Auto Cycle self.stopCheckBox = tk.BooleanVar() self.saveGraphCheckBox = tk.BooleanVar() self.autoCycleGroup = ttk.LabelFrame(self, text="Auto Cycle", underline=1) self.autoCycleGroup.grid(column=0, row=2, columnspan=2, sticky=(tk.N, tk.W, tk.E, tk.S), padx=6, pady=(6, 0)) ttk.Label(self.autoCycleGroup, text="Maximum Number of Cycles:", underline=0).grid(column=0, row=0, sticky=tk.E, padx=(4, 0), pady=4) self.autoCycleMaxCycles = tk.Spinbox(self.autoCycleGroup, width=5, from_=1, to=99) self.autoCycleMaxCycles.grid(column=1, row=0, padx=(4, 0), pady=4) autoCycleStop = ttk.Checkbutton( self.autoCycleGroup, text="Stop when capacity increases by less than 0.5%", underline=5, variable=self.stopCheckBox) autoCycleStop.grid(column=2, row=0, sticky=tk.W, padx=4, pady=4) autoCycleSave = ttk.Checkbutton( self.autoCycleGroup, text="Save graph as BMP file after each cycle", underline=9, variable=self.saveGraphCheckBox) autoCycleSave.grid(column=2, row=1, sticky=tk.W, padx=4, pady=4) self.startIcon = tk.PhotoImage(data=settings.tickicon) self.cancelIcon = tk.PhotoImage(data=settings.exiticon) ttk.Button(self, text="Start", underline=0, compound=tk.TOP, image=self.startIcon, command=self.ok).grid(column=0, row=3, sticky=tk.W, padx=6, pady=6) ttk.Button(self, text="Cancel", underline=5, compound=tk.TOP, image=self.cancelIcon, command=self.cancel).grid(column=1, row=3, sticky=tk.E, padx=6, pady=6) self.showControls(self.kwargs['mode']) self.resizable(False, False) return self.batteryCellTypeCombo
def init(cback: Callable[[dict[str, str]], None]) -> None: """Build the properties window widgets.""" global callback callback = cback win.title("BEE2") win.resizable(False, False) tk_tools.set_window_icon(win) win.protocol("WM_DELETE_WINDOW", exit_win) if utils.MAC: # Switch to use the 'modal' window style on Mac. TK_ROOT.call('::tk::unsupported::MacWindowStyle', 'style', win, 'moveableModal', '') # Stop our init from triggering UI sounds. sound.block_fx() frame = ttk.Frame(win, padding=10) frame.grid(row=0, column=0, sticky='NSEW') frame.rowconfigure(0, weight=1) frame.columnconfigure(0, weight=1) labels['noOptions'] = ttk.Label(frame, text=gettext('No Properties available!')) widgets['saveButton'] = ttk.Button(frame, text=gettext('Close'), command=exit_win) widgets['titleLabel'] = ttk.Label(frame, text='') widgets['titleLabel'].grid(columnspan=9) widgets['div_1'] = ttk.Separator(frame, orient="vertical") widgets['div_2'] = ttk.Separator(frame, orient="vertical") widgets['div_h'] = ttk.Separator(frame, orient="horizontal") for key, (prop_type, prop_name) in PROP_TYPES.items(): # Translate property names from Valve's files. if prop_name.startswith('PORTAL2_'): prop_name = gameMan.translate(prop_name) + ':' labels[key] = ttk.Label(frame, text=prop_name) if prop_type is PropTypes.CHECKBOX: values[key] = tk.IntVar(value=DEFAULTS[key]) out_values[key] = srctools.bool_as_int(DEFAULTS[key]) widgets[key] = ttk.Checkbutton( frame, variable=values[key], command=func_partial(set_check, key), ) widgets[key].bind('<Return>', func_partial( toggle_check, key, values[key], )) elif prop_type is PropTypes.OSCILLATE: values[key] = tk.IntVar(value=DEFAULTS[key]) out_values[key] = srctools.bool_as_int(DEFAULTS[key]) widgets[key] = ttk.Checkbutton( frame, variable=values[key], command=func_partial(save_rail, key), ) elif prop_type is PropTypes.PANEL: frm = ttk.Frame(frame) widgets[key] = frm values[key] = tk.StringVar(value=DEFAULTS[key]) for pos, (angle, disp_angle) in enumerate(PANEL_ANGLES): ttk.Radiobutton( frm, variable=values[key], value=str(angle), text=gameMan.translate(disp_angle), command=func_partial(save_angle, key, angle), ).grid(row=0, column=pos) frm.columnconfigure(pos, weight=1) elif prop_type is PropTypes.GELS: frm = ttk.Frame(frame) widgets[key] = frm values[key] = tk.IntVar(value=DEFAULTS[key]) for pos, text in enumerate(PAINT_OPTS): ttk.Radiobutton( frm, variable=values[key], value=pos, text=gameMan.translate(text), command=func_partial(save_paint, key, pos), ).grid(row=0, column=pos) frm.columnconfigure(pos, weight=1) out_values[key] = str(DEFAULTS[key]) elif prop_type is PropTypes.PISTON: widgets[key] = pist_scale = ttk.Scale( frame, from_=0, to=4, orient="horizontal", command=func_partial(save_pist, key), ) values[key] = DEFAULTS[key] out_values[key] = str(DEFAULTS[key]) if ((key == 'toplevel' and DEFAULTS['startup']) or (key == 'bottomlevel' and not DEFAULTS['startup'])): pist_scale.set( max(DEFAULTS['toplevel'], DEFAULTS['bottomlevel'])) if ((key == 'toplevel' and not DEFAULTS['startup']) or (key == 'bottomlevel' and DEFAULTS['startup'])): pist_scale.set( min(DEFAULTS['toplevel'], DEFAULTS['bottomlevel'])) elif prop_type is PropTypes.TIMER: widgets[key] = ttk.Scale( frame, from_=0, to=30, orient="horizontal", command=func_partial(save_tim, key), ) values[key] = DEFAULTS[key] values['startup'] = DEFAULTS['startup']
canvas.place(relx=0.03, rely=0.052) ############################## ### Zoom elements' section ### ############################## zoom_label = ttk.Label(root, text="Zoom:", foreground="#ffffff", background="#131113") zoom_label.place(relx=0.97, rely=0.052, relheight=0.035, relwidth=0.2, anchor="ne") zoom_slider = ttk.Scale(root, from_=500, to=1, orient="horizontal") zoom_slider.set(zoom) zoom_slider.place(relx=0.97, rely=0.088, relheight=0.04, relwidth=0.2, anchor="ne") ########################################################## ### Separating line between zoom and rotation elements ### ########################################################## zoom_rot_seperator = ttk.Separator(root, orient="horizontal") zoom_rot_seperator.place(relx=0.97, rely=0.160, relwidth=0.2, anchor="ne") ############################################
topframe = Frame(root) topframe.pack(side=TOP) topframe.configure(background="gray26") # Create a scale label scalelabel = ttk.Label(topframe, text='Range from 1 to 100:', font="Arial 15 italic", foreground="white") scalelabel.grid(row=0, column=1) scalelabel.configure(background="gray26") # Create scale scale = ttk.Scale(topframe, from_=1, to=100, length=300, orient=HORIZONTAL, command=set_number) scale.set(25) #default volume for the scale bar scale.grid(row=0, column=2, pady=15) # Create a sort label sortlabel = ttk.Label(topframe, text='Algorithms:', font="Arial 30 italic", foreground="white") sortlabel.grid(column=1, rowspan=2) sortlabel.configure(background="gray26") # 4 radio buttons rb1 = ttk.Radiobutton(topframe,
def main(): root = tkinter.Tk() root.title('Choose Autograde Settings') main_frame = ttk.Frame(root) main_frame.pack(fill='both', padx=25, pady=25) ############## # Misc. Options ############## # Misc. Options frame misc_options_frame = ttk.Frame(main_frame) misc_options_frame.grid_columnconfigure(0, weight=1) misc_options_frame.grid_columnconfigure(1, weight=1) misc_options_frame.pack(fill='both', pady=10, ipadx=100) # Test run checkbutton and label test_run_label = ttk.Label(misc_options_frame, text='Test Run?') test_run_label.grid(row=0, column=1) test_run_value = tkinter.BooleanVar() test_run_value.set(int(defaults['Test Run'])) test_run_list_checkbutton = ttk.Checkbutton(misc_options_frame, variable=test_run_value) test_run_list_checkbutton.grid(row=1, column=1) # Minimum missing assignments spinbox minimum_missing_label = ttk.Label(misc_options_frame, text='Minimum Missing Assignments') minimum_missing_label.grid(row=0, column=0) def minimum_missing_helper(): try: int(minimum_missing_spinbox.get()) except ValueError: if minimum_missing_spinbox.get() != '': minimum_missing_spinbox.set(int(defaults['Minimum Missing Assignments Default'])) return if int(minimum_missing_spinbox.get()) > int(defaults['Minimum Missing Assignments Maximum']): minimum_missing_spinbox.set(int(defaults['Minimum Missing Assignments Maximum'])) minimum_missing_value = tkinter.IntVar() minimum_missing_spinbox = ttk.Spinbox(misc_options_frame, from_=0, to=int(defaults['Minimum Missing Assignments Maximum']), textvariable=minimum_missing_value) minimum_missing_spinbox.set(int(defaults['Minimum Missing Assignments Default'])) minimum_missing_spinbox.grid(row=1, column=0) minimum_missing_value.trace('w', lambda *args: minimum_missing_helper()) ############### # Email options ############### # TODO: error handling (bad email, password, can't connect to service provider, etc.) # Email options frame email_options_frame = ttk.Frame(main_frame) email_options_frame.grid_columnconfigure(0, weight=0) email_options_frame.grid_columnconfigure(1, weight=0) email_options_frame.grid_columnconfigure(2, weight=1) email_options_frame.pack(fill='both', pady=10) # Sender login info sender_email_label = ttk.Label(email_options_frame, text='Sender Email:') sender_email_label.grid(row=0, column=0, sticky='w') sender_email_entry = ttk.Entry(email_options_frame) sender_email_entry.grid(row=0, column=1) sender_password_label = ttk.Label(email_options_frame, text='Sender Password:'******'w') sender_password_entry = ttk.Entry(email_options_frame, show='*') sender_password_entry.grid(row=1, column=1) # Email host email_host_label = ttk.Label(email_options_frame, text='Email Host:') email_host_label.grid(row=0, column=2) # TODO move host list to defaults email_host_value = ttk.Combobox(email_options_frame, values=['Gmail', 'Outlook'], state='readonly')#, 'Yahoo'], state='readonly') email_host_value.set(defaults['Email Host']) email_host_value.grid(row=1, column=2) # Email message format email_parameter_list = [defaults['Email Subject'], defaults['CC Emails'], str(defaults['Email Message'])] email_format_button = ttk.Button(email_options_frame, text='Change Message Format', command=lambda: email_format_window(root, email_parameter_list)) email_format_button.grid(row=2, columnspan=3, pady=10) ############################### # Gradebook file path selection ############################### # Gradebook path selection frame gradebook_path_selection_frame = ttk.Frame(main_frame) gradebook_path_selection_frame.grid_columnconfigure(0, weight=1) gradebook_path_selection_frame.grid_columnconfigure(1, weight=1) gradebook_path_selection_frame.pack(fill='both', pady=10) # Gradebook path selection button and labels gradebook_file = tkinter.StringVar() gradebook_file.set(defaults['Gradebook Path']) gradebook_path_label1 = ttk.Label(gradebook_path_selection_frame, text='Current Gradebook Path:') gradebook_path_label1.grid(row=0, column=0, sticky='w') gradebook_path_label2 = ttk.Label(gradebook_path_selection_frame, textvariable=gradebook_file, font='Helvetica 8 bold') gradebook_path_label2.grid(row=1, columnspan=3, pady=20) # TODO: add error handling gradebook_full_path = defaults['Gradebook Path'] gradebook_path_button = ttk.Button(gradebook_path_selection_frame, text='Select File', command=lambda: gradebook_file.set(get_gradebook_path())) gradebook_path_button.grid(row=0, column=1) def get_gradebook_path(): nonlocal gradebook_full_path max_path_characters = 65 gradebook_path = tkinter.filedialog.askopenfilename(filetypes=[('csv', '.csv')], initialdir='.') if gradebook_path == '': gradebook_path = defaults['Gradebook Path'] gradebook_full_path = gradebook_path if len(gradebook_path) > max_path_characters: gradebook_path = '...'+gradebook_path[len(gradebook_path)-max_path_characters+3:len(gradebook_path)] return gradebook_path ############################### # Student list file path selection ############################### # Student list path selection frame student_list_path_selection_frame = ttk.Frame(main_frame) student_list_path_selection_frame.grid_columnconfigure(0, weight=1) student_list_path_selection_frame.grid_columnconfigure(1, weight=1) student_list_path_selection_frame.pack(fill='both', pady=10) # Student list path selection button and labels student_list_file = tkinter.StringVar() student_list_file.set(defaults['Student List Path']) student_list_path_label1 = ttk.Label(student_list_path_selection_frame, text='Current Student List Path:') student_list_path_label1.grid(row=0, column=0, sticky='w') student_list_path_label2 = ttk.Label(student_list_path_selection_frame, textvariable=student_list_file, font='Helvetica 8 bold') student_list_path_label2.grid(row=1, columnspan=3, pady=20) # TODO: add error handling student_list_full_path = defaults['Student List Path'] student_list_path_button = ttk.Button(student_list_path_selection_frame, text='Select File', command=lambda: student_list_file.set(get_student_list_path())) student_list_path_button.grid(row=0, column=1) def get_student_list_path(): nonlocal student_list_full_path max_path_characters = 65 student_list_path = tkinter.filedialog.askopenfilename(filetypes=[('txt', '.txt')], initialdir='.') if student_list_path == '': student_list_path = defaults['Student List Path'] student_list_full_path = student_list_path if len(student_list_path) > max_path_characters: student_list_path = '...' + student_list_path[ len(student_list_path) - max_path_characters + 3:len(student_list_path)] return student_list_path ################################# # Assignments file path selection ################################# # Assignments path selection frame assignments_path_selection_frame = ttk.Frame(main_frame) assignments_path_selection_frame.grid_columnconfigure(0, weight=1) assignments_path_selection_frame.grid_columnconfigure(1, weight=1) assignments_path_selection_frame.pack(fill='both', pady=10) # Assignment path selection button and labels assignments_file = tkinter.StringVar() assignments_file.set(defaults['Assignments Path']) assignments_path_label1 = ttk.Label(assignments_path_selection_frame, text='Current Assignments Path:') assignments_path_label1.grid(row=0, column=0, sticky='w') assignments_path_label2 = ttk.Label(assignments_path_selection_frame, textvariable=assignments_file, font='Helvetica 8 bold') assignments_path_label2.grid(row=1, columnspan=3, pady=20) # TODO: add error handling assignments_full_path = defaults['Assignments Path'] assignments_path_button = ttk.Button(assignments_path_selection_frame, text='Select File', command=lambda: assignments_file.set(get_assignments_path())) assignments_path_button.grid(row=0, column=1) def get_assignments_path(): nonlocal assignments_full_path max_path_characters = 65 assignments_path = tkinter.filedialog.askopenfilename(filetypes=[('csv', '.csv')], initialdir='.') if assignments_path == '': assignments_path = defaults['Assignments Path'] assignments_full_path = assignments_path if len(assignments_path) > max_path_characters: assignments_path = '...' + assignments_path[ len(assignments_path) - max_path_characters + 3:len(assignments_path)] return assignments_path ############################# # Percent threshold selection ############################# # Percent threshold frame threshold_frame = ttk.Frame(main_frame) threshold_frame.grid_columnconfigure(0, weight=1) threshold_frame.grid_columnconfigure(1, weight=1) threshold_frame.pack(fill='both', pady=20) # Assignments file selection toggles the percentage threshold scale def check_percent_threshold_scale_active(*args): nonlocal percent_threshold_value_label if assignments_file.get() != defaults['Assignments Path']: percent_threshold_scale.set(int(defaults['Default Percentage Threshold'])) percent_threshold_value_label.config(text=str(int(defaults['Default Percentage Threshold'])) + '%') percent_threshold_value.set(int(defaults['Default Percentage Threshold'])) assignments_file.trace('w', check_percent_threshold_scale_active) # Percent threshold scale and labels percent_threshold_value_label = ttk.Label(threshold_frame, font='Helvetica 18 bold', anchor=tkinter.CENTER, width=5) percent_threshold_value_label.grid(row=0, column=1, rowspan=2) percent_threshold_value = tkinter.IntVar() percent_threshold_scale = ttk.Scale(threshold_frame, from_=0, to=100, variable=percent_threshold_value, command=lambda value: percent_threshold_value_label.config(text=str(int(float(value))) + '%')) percent_threshold_scale.set(int(defaults['Default Percentage Threshold'])) percent_threshold_scale.grid(row=1) percent_threshold_value.trace('w', check_percent_threshold_scale_active) percentage_threshold_text_label = ttk.Label(threshold_frame, text='Assignment Percentage Threshold:', anchor=tkinter.CENTER) percentage_threshold_text_label.grid(row=0, column=0) ####################### # action buttons ####################### # action buttons frame action_button_frame = ttk.Frame(main_frame) action_button_frame.grid_columnconfigure(0, weight=1) action_button_frame.grid_columnconfigure(1, weight=1) action_button_frame.pack(fill='both', pady=10) # action buttons ok_button = ttk.Button(action_button_frame, text='Ok', command=lambda: ok_helper()) ok_button.grid(row=0, column=0) cancel_button = ttk.Button(action_button_frame, text='Cancel', command=lambda: root.quit()) cancel_button.grid(row=0, column=1) def ok_helper(): subject = 0 cc_emails = 1 message = 2 root.quit() auto_grade(student_list_full_path, gradebook_full_path, assignments_full_path, test_run_value.get(), percent_threshold_value.get(), int(minimum_missing_spinbox.get()), sender_email_entry.get(), sender_password_entry.get(), email_host_value.get(), email_parameter_list[subject], email_parameter_list[cc_emails], email_parameter_list[message]) root.resizable(width=False, height=False) root.mainloop()
from tkinter import * from tkinter import ttk root = Tk() progressbar = ttk.Progressbar(root, orient=HORIZONTAL, length=200) progressbar.pack() progressbar.config(mode='indeterminate') progressbar.config(mode='determinate', maximum=11.0, value=4.2) progressbar.config(value=8.0) progressbar.step() progressbar.step(5) value = DoubleVar() progressbar.config(variable=value) scale = ttk.Scale(root, orient=HORIZONTAL, length=400, variable=value, from_=0.0, to=11.0) scale.pack() scale.set(4.1)
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' font11 = "-family {Avenir Next Cyr Medium} -size 23 -weight " \ "normal -slant roman -underline 0 -overstrike 0" font12 = "-family {Avenir Next Cyr} -size 9 -weight bold " \ "-slant roman -underline 0 -overstrike 0" font13 = "-family {Vivaldi} -size 22 -weight " \ "bold -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)]) top.geometry("687x526+558+155") top.title("New Toplevel") top.configure(background="#fff") self.top=top self.songName = tk.Label(top) self.songName.place(relx=0.437, rely=0.038, height=44, width=281) self.songName.configure(background="#fff") self.songName.configure(disabledforeground="#a3a3a3") self.songName.configure(font=font13) self.songName.configure(foreground="#000000") self.songName.configure(text='''Ladki Aankh Maare''') self.songProgress = ttk.Progressbar(top) self.songProgress.place(relx=0.393, rely=0.209, relwidth=0.495 , relheight=0.0, height=7) self.songTotalDuration = ttk.Label(top) self.songTotalDuration.place(relx=0.844, rely=0.171, height=19, width=29) self.songTotalDuration.configure(background="#fff") self.songTotalDuration.configure(foreground="#3399ff") self.songTotalDuration.configure(font=font12) self.songTotalDuration.configure(relief='flat') self.songTimePassed = ttk.Label(top) self.songTimePassed.place(relx=0.393, rely=0.171, height=19, width=29) self.songTimePassed.configure(background="#ffffff") self.songTimePassed.configure(foreground="#000000") self.songTimePassed.configure(font=font12) self.songTimePassed.configure(relief='flat') self.pauseButton = tk.Button(top) self.pauseButton.place(relx=0.568, rely=0.266, height=34, width=34) self.pauseButton.configure(activebackground="#ececec") self.pauseButton.configure(activeforeground="#000000") self.pauseButton.configure(background="#fff") self.pauseButton.configure(borderwidth="0") self.pauseButton.configure(disabledforeground="#a3a3a3") self.pauseButton.configure(foreground="#000000") self.pauseButton.configure(highlightbackground="#d9d9d9") self.pauseButton.configure(highlightcolor="black") self._img1 = tk.PhotoImage(file="./icons/pause.png") self.pauseButton.configure(image=self._img1) self.pauseButton.configure(pady="0") self.pauseButton.configure(text='''Button''') self.playButton = tk.Button(top) self.playButton.place(relx=0.64, rely=0.266, height=34, width=34) self.playButton.configure(activebackground="#ececec") self.playButton.configure(activeforeground="#000000") self.playButton.configure(background="#fff") self.playButton.configure(borderwidth="0") self.playButton.configure(disabledforeground="#a3a3a3") self.playButton.configure(foreground="#000000") self.playButton.configure(highlightbackground="#d9d9d9") self.playButton.configure(highlightcolor="black") self._img2 = tk.PhotoImage(file="./icons/play.png") self.playButton.configure(image=self._img2) self.playButton.configure(pady="0") self.playButton.configure(text='''Button''') self.stopButton = tk.Button(top) self.stopButton.place(relx=0.713, rely=0.266, height=34, width=34) self.stopButton.configure(activebackground="#ececec") self.stopButton.configure(activeforeground="#000000") self.stopButton.configure(background="#fff") self.stopButton.configure(borderwidth="0") self.stopButton.configure(disabledforeground="#a3a3a3") self.stopButton.configure(foreground="#000000") self.stopButton.configure(highlightbackground="#d9d9d9") self.stopButton.configure(highlightcolor="black") self._img3 = tk.PhotoImage(file="./icons/stop.png") self.stopButton.configure(image=self._img3) self.stopButton.configure(pady="0") self.stopButton.configure(text='''Button''') self.vinylRecordImage = tk.Label(top) self.vinylRecordImage.place(relx=0.0, rely=0.0, height=204, width=204) self.vinylRecordImage.configure(background="#d9d9d9") self.vinylRecordImage.configure(disabledforeground="#a3a3a3") self.vinylRecordImage.configure(foreground="#000000") self._img4 = tk.PhotoImage(file="./icons/vinylrecord.png") self.vinylRecordImage.configure(image=self._img4) self.vinylRecordImage.configure(text='''Label''') self.playList = ScrolledListBox(top) self.playList.place(relx=0.0, rely=0.38, relheight=0.532, relwidth=0.999) self.playList.configure(background="white") self.playList.configure(disabledforeground="#a3a3a3") self.playList.configure(font="TkFixedFont") self.playList.configure(foreground="black") self.playList.configure(highlightbackground="#d9d9d9") self.playList.configure(highlightcolor="#d9d9d9") self.playList.configure(selectbackground="#c4c4c4") self.playList.configure(selectforeground="black") self.playList.configure(width=10) self.previousButton = tk.Label(top) self.previousButton.place(relx=0.509, rely=0.285, height=16, width=16) self.previousButton.configure(background="#fff") self.previousButton.configure(borderwidth="0") self.previousButton.configure(disabledforeground="#a3a3a3") self.previousButton.configure(foreground="#000000") self._img5 = tk.PhotoImage(file="./icons/previous.png") self.previousButton.configure(image=self._img5) self.previousButton.configure(text='''Label''') self.bottomBar = ttk.Label(top) self.bottomBar.place(relx=0.0, rely=0.913, height=49, width=686) self.bottomBar.configure(background="#d9d9d9") self.bottomBar.configure(foreground="#000000") self.bottomBar.configure(font="TkDefaultFont") self.bottomBar.configure(relief='flat') self.bottomBar.configure(width=686) self.bottomBar.configure(state='disabled') self.vol_scale = ttk.Scale(top) self.vol_scale.place(relx=0.015, rely=0.932, relwidth=0.146, relheight=0.0 , height=26, bordermode='ignore') self.vol_scale.configure(takefocus="") self.addSongsToPlayListButton = tk.Button(top) self.addSongsToPlayListButton.place(relx=0.961, rely=0.323, height=17 , width=17) self.addSongsToPlayListButton.configure(activebackground="#ececec") self.addSongsToPlayListButton.configure(activeforeground="#d9d9d9") self.addSongsToPlayListButton.configure(background="#fff") self.addSongsToPlayListButton.configure(borderwidth="0") self.addSongsToPlayListButton.configure(disabledforeground="#a3a3a3") self.addSongsToPlayListButton.configure(foreground="#000000") self.addSongsToPlayListButton.configure(highlightbackground="#d9d9d9") self.addSongsToPlayListButton.configure(highlightcolor="black") self._img6 = tk.PhotoImage(file="./icons/add.png") self.addSongsToPlayListButton.configure(image=self._img6) self.addSongsToPlayListButton.configure(pady="0") self.addSongsToPlayListButton.configure(text='''Button''') self.deleteSongsFromPlaylistButton = tk.Button(top) self.deleteSongsFromPlaylistButton.place(relx=0.917, rely=0.323 , height=18, width=18) self.deleteSongsFromPlaylistButton.configure(activebackground="#ececec") self.deleteSongsFromPlaylistButton.configure(activeforeground="#000000") self.deleteSongsFromPlaylistButton.configure(background="#fff") self.deleteSongsFromPlaylistButton.configure(borderwidth="0") self.deleteSongsFromPlaylistButton.configure(disabledforeground="#a3a3a3") self.deleteSongsFromPlaylistButton.configure(foreground="#000000") self.deleteSongsFromPlaylistButton.configure(highlightbackground="#d9d9d9") self.deleteSongsFromPlaylistButton.configure(highlightcolor="black") self._img7 = tk.PhotoImage(file="./icons/delete.png") self.deleteSongsFromPlaylistButton.configure(image=self._img7) self.deleteSongsFromPlaylistButton.configure(pady="0") self.deleteSongsFromPlaylistButton.configure(text='''Button''') self.Button9 = tk.Button(top) self.Button9.place(relx=0.932, rely=0.913, height=42, width=42) self.Button9.configure(activebackground="#ececec") self.Button9.configure(activeforeground="#000000") self.Button9.configure(background="#d9d9d9") self.Button9.configure(borderwidth="0") self.Button9.configure(disabledforeground="#a3a3a3") self.Button9.configure(foreground="#000000") self.Button9.configure(highlightbackground="#d9d9d9") self.Button9.configure(highlightcolor="black") self._img8 = tk.PhotoImage(file="./icons/like.png") self.Button9.configure(image=self._img8) self.Button9.configure(pady="0") self.Button9.configure(text='''Button''') self.Button9.configure(width=42) self.Button10 = tk.Button(top) self.Button10.place(relx=0.873, rely=0.913, height=42, width=42) self.Button10.configure(activebackground="#ececec") self.Button10.configure(activeforeground="#000000") self.Button10.configure(background="#d9d9d9") self.Button10.configure(borderwidth="0") self.Button10.configure(disabledforeground="#a3a3a3") self.Button10.configure(foreground="#000000") self.Button10.configure(highlightbackground="#d9d9d9") self.Button10.configure(highlightcolor="black") self._img9 = tk.PhotoImage(file="./icons/broken-heart.png") self.Button10.configure(image=self._img9) self.Button10.configure(pady="0") self.Button10.configure(text='''Button''') self.Button10.configure(width=48) self.Button11 = tk.Button(top) self.Button11.place(relx=0.83, rely=0.932, height=26, width=26) self.Button11.configure(activebackground="#ececec") self.Button11.configure(activeforeground="#000000") self.Button11.configure(background="#d9d9d9") self.Button11.configure(borderwidth="0") self.Button11.configure(disabledforeground="#a3a3a3") self.Button11.configure(foreground="#000000") self.Button11.configure(highlightbackground="#d9d9d9") self.Button11.configure(highlightcolor="black") self._img10 = tk.PhotoImage(file="./icons/refresh.png") self.Button11.configure(image=self._img10) self.Button11.configure(pady="0") self.Button11.configure(text='''Button''') self.setup_player()
muted = TRUE middleframe = Frame(rightframe) middleframe.pack(pady=30, padx=30) playPhoto = PhotoImage(file='images/play.png') playBtn = ttk.Button(middleframe, image=playPhoto, command=play_music) playBtn.grid(row=0, column=0, padx=10) stopPhoto = PhotoImage(file='images/stop.png') stopBtn = ttk.Button(middleframe, image=stopPhoto, command=stop_music) stopBtn.grid(row=0, column=1, padx=10) pausePhoto = PhotoImage(file='images/pause.png') pauseBtn = ttk.Button(middleframe, image=pausePhoto, command=pause_music) pauseBtn.grid(row=0, column=2, padx=10) // Bottom Frame for volume, rewind, mute etc. bottomframe = Frame(rightframe) bottomframe.pack() rewindPhoto = PhotoImage(file='images/rewind.png') rewindBtn = ttk.Button(bottomframe, image=rewindPhoto, command=rewind_music) rewindBtn.grid(row=0, column=0) mutePhoto = PhotoImage(file='images/mute.png') volumePhoto = PhotoImage(file='images/volume.png') volumeBtn = ttk.Button(bottomframe, image=volumePhoto, command=mute_music) volumeBtn.grid(row=0, column=1) scale = ttk.Scale(bottomframe, from_=0, to=100, orient=HORIZONTAL, command=set_vol) scale.set(70) # implement the default value of scale when music player starts mixer.music.set_volume(0.7) scale.grid(row=0, column=2, pady=15, padx=30) def on_closing(): stop_music() root.destroy() root.protocol("WM_DELETE_WINDOW", on_closing) root.mainloop()
mixer.init() root.geometry("300x160") root.title("Mini Music Player") root.configure(bg='white') s = ttk.Style(root) s.theme_use('vista') # adding buttons .... ttk.Button(root, text="Play", width=10, command=play_song).place(x=10, y=10) ttk.Button(root, text="Stop", width=10, command=mixer.music.stop).place(x=10, y=40) ttk.Button(root, text="Pause", width=10, command=mixer.music.pause).place(x=10, y=70) ttk.Button(root, text="UnPause", width=10, command=mixer.music.unpause).place(x=10, y=100) ttk.Button(root, text="Open", width=10, command=open_folder).place(x=10, y=130) music_frame = Frame(root, bd=2, relief=RIDGE) music_frame.place(x=90, y=10, width=200, height=110) scroll_y = ttk.Scrollbar(music_frame) play_list = Listbox(music_frame, width=29, yscrollcommand=scroll_y.set) scroll_y.config(command=play_list.yview) scroll_y.pack(side=RIGHT, fill=Y) play_list.pack(side=LEFT, fill=BOTH) vol = ttk.Scale(root, from_=0, to_=100, length=180, command=set_vol) vol.set(50) vol.place(x=100, y=130) root.mainloop()