def ask_quiz_name(): """Get name of users quiz to create.""" Bg.quiz_name_btn = Button(quiz_name_btn_frame, bg='gold', font=('Helvetica', 11, 'bold'), text='Step 1: Name your quiz below, ' 'then click here', command=create_dir) Bg.quiz_name_btn.grid(row=0, column=0, sticky=W + E, pady=15, padx=15) ttips.Create(Bg.quiz_name_btn, 'Fill in the input box below\n' 'with the name of your quiz\n' 'and then click here.', fontname="helvetica", fontsize=12, showtime=10) Bg.E0 = Entry(quiz_name_btn_frame, bd=3) Bg.E0.grid(pady=5) Bg.E0.insert(0, 'Your quiz name') Bg.E0.focus() ttips.Create(Bg.E0, 'Type in the Name of your quiz\n' 'and then click the button above.', showtime=10) return
def step_3(): """The area where we display question and answers inputs and file selectors.""" msg_lbl = Label(inputs_frame, bg='gold', font=('Helvetica', 11, 'bold'), text='Step 3: Click both the ... buttons, ' 'below right, \n' 'to load in your Question and Answers ' 'text files.') msg_lbl.grid(row=5, columnspan=2) ttips.Create(msg_lbl, 'Available only when you have completed steps 1 and 2.', fontname='helvetica', fontsize=12, showtime=12) Bg.E1 = Entry(inputs_frame, bd=3) Bg.E1.grid(pady=5) Bg.E1.insert(0, 'Your questions file') Bg.qf_btn = Button(inputs_frame, text='...', command=load_questions) Bg.qf_btn.grid(row=6, column=1) ttips.Create(Bg.E1, 'Please load your questions text file,\n' 'This file must be in the exact format described' ' in the help file.\nSee drop down menu for help.', fontname='helvetica', fontsize=12, showtime=12) ttips.Create(Bg.qf_btn, 'Click here to load your questions file', fontname='helvetica', fontsize=12, showtime=12) Bg.E2 = Entry(inputs_frame, bd=3) Bg.E2.grid(pady=5) Bg.E2.insert(0, 'Your answers file') Bg.af_btn = Button(inputs_frame, text='...', command=load_answers) Bg.af_btn.grid(row=7, column=1) ttips.Create(Bg.E2, 'Please load your answers text file,\n' 'This file must be in the exact format described' ' in the help file.\nSee drop down menu for help.', fontname='helvetica', fontsize=12, showtime=12) ttips.Create(Bg.af_btn, 'Click here to load your answers file', fontname='helvetica', fontsize=12, showtime=12)
def load_questions(): """File selector for user to load in their questions file.""" qf_selected = filedialog.askopenfilename( title='Select your questions file', filetypes=[('Text', ('*.txt')), ('All', '*.*')]) if qf_selected: Bg.E1.delete(0, END) Bg.E1.insert(0, qf_selected) copyfile(qf_selected, 'questions.txt') ttips.Create(Bg.E1, qf_selected, showtime=10) Bg.qf_btn.configure(state=DISABLED)
def load_answers(): """File selector for user to load in their answers file.""" file_selected = filedialog.askopenfilename(title='Select your answers file', filetypes=[('Text', ('*.txt')), ('All', '*.*')]) if file_selected: Bg.E2.delete(0, END) Bg.E2.insert(0, file_selected) copyfile(file_selected, 'answers.txt') ttips.Create(Bg.E2, file_selected, showtime=10) Bg.save_btn.configure(state=NORMAL) Bg.test_btn.configure(state=NORMAL) Bg.af_btn.configure(state=DISABLED)
def logo_load_btn(): """The load logo button.""" Bg.logo_btn = Button(load_logo_btn_frame, bg='gold', font=('Helvetica', 11, 'bold'), text=' Step 2:' 'Click here to load a logo image ', command=load_logo) Bg.logo_btn.grid(row=1, column=0, sticky=W + E, pady=15, padx=15) ttips.Create(Bg.logo_btn, 'You can try out as many images as you want.\n' 'What you see is what you will get.', fontname="helvetica", fontsize=12, showtime=14)
def accept_btn(): """The accept image button.""" # blanks = '' * 17 Bg.accept_logo_btn = Button( accept_logo_btn_frame, bg='gold', font=('Helvetica', 11, 'bold'), text=' Click here to use the above image ', command=accept_logo) Bg.accept_logo_btn.grid(row=4, column=0, sticky=W + E, pady=15, padx=15) ttips.Create(Bg.accept_logo_btn, 'Once clicked here your image is finalized.', fontname="helvetica", fontsize=12, showtime=6)
def __init__(self, master=None): Thread(target=self.user_check_updates, daemon=True).start() # preparing containers c1 = Frame(master) c1['pady'] = 20 c1.pack() c2 = Frame(master) c2.pack() c3 = Frame(master) c3['pady'] = 20 c3.pack() c4 = Frame(master) c4.pack() c5 = Frame(master) c5.pack() c6 = Frame(master) c6.pack() c7 = Frame(master) c7.pack() # Menubar menubar = Menu(window, tearoff=0, bd=0, bg='#d9d9d9') file = Menu(menubar, tearoff=0, bd=0) menubar.add_cascade(label=_('File'), menu=file) file.add_command(label=_('Load audio file...'), accelerator='Ctrl+O', command=lambda: self.btnLoadAudio()) file.add_command(label=_('Save all tags'), accelerator='Ctrl+S', command=lambda: self.btnSaveTags()) file.add_separator() file.add_command(label=_('Exit'), accelerator='Ctrl+Q', command=lambda: window.destroy()) help = Menu(menubar, tearoff=0, bd=0) menubar.add_cascade(label=_('Help'), menu=help) help.add_command(label='GitHub', accelerator='Ctrl+G', command=lambda: window.bind('<Button-1>', webbrowser.open('https://github.com/Alexsussa/eyed3-gtk-gui'))) help.add_command(label=_('License'), accelerator='Ctrl+I', command=lambda: window.bind('<Button-1>', webbrowser.open('https://github.com/Alexsussa/eyed3-gtk-gui/blob/master/LICENSE'))) help.add_command(label=_('Documentation'), accelerator='Ctrl+D', command=lambda: window.bind('<Button-1>', webbrowser.open('https://github.com/Alexsussa/eyed3-gtk-gui#eyed3-gtk-gui'))) help.add_command(label=_('Search for new updates...'), accelerator='Ctrl+N', command=lambda: self.check_updates()) help.add_separator() help.add_command(label=_('About'), accelerator='Ctrl+H', command=lambda: About.about(self, window=window)) window.config(menu=menubar) # preparing interface self.lbtitle = Label(c1, text=_('Title')) self.lbtitle.pack(side=LEFT, padx=5) self.txttitle = Entry(c1, width=40, bg='white', fg='black') self.txttitle.pack(side=LEFT) self.lbartist = Label(c1, text=_('Artist')) self.lbartist.pack(side=LEFT, padx=5) self.txtartist = Entry(c1, width=40, bg='white', fg='black') self.txtartist.pack(side=LEFT) self.lbtrack_num = Label(c1, text=_('Track Number')) self.lbtrack_num.pack(side=LEFT, padx=5) self.txttrack_num = Entry(c1, width=4, bg='white', fg='black') self.txttrack_num.pack(side=LEFT) self.lbalbum = Label(c2, text=_('Album')) self.lbalbum.pack(side=LEFT, padx=5) self.txtalbum = Entry(c2, width=36, bg='white', fg='black') self.txtalbum.pack(side=LEFT) self.lbalbum_artist = Label(c2, text=_('Album Artist')) self.lbalbum_artist.pack(side=LEFT, padx=5) self.txtalbum_artist = Entry(c2, width=36, bg='white', fg='black') self.txtalbum_artist.pack(side=LEFT) self.btnremove_all_tags = Button(c2, text=_('Remove All Tags'), width=15, command=self.btnRemoveAllTags) self.btnremove_all_tags.pack(side=LEFT, padx=5) ttips.Create(self.btnremove_all_tags, text=_('Remove completly all tags from audio')) self.lbgenre = Label(c3, text=_('Genre')) self.lbgenre.pack(side=LEFT, padx=5) self.txtgenre = Entry(c3, width=15, bg='white', fg='black') self.txtgenre.pack(side=LEFT) self.lbyear = Label(c3, text=_('Year')) self.lbyear.pack(side=LEFT, padx=5) self.txtyear = Entry(c3, width=5, bg='white', fg='black') self.txtyear.pack(side=LEFT) self.txtlyrics = Entry(c3, width=31, bg='white', fg='black') self.txtlyrics.pack(side=LEFT, padx=5) self.txtlyrics.drop_target_register(DND_FILES) ttips.Create(self.txtlyrics, text=_('Select a txt file with lyrics by clicking the button')) self.btnlyrics = Button(c3, text=_('Lyrics'), command=self.btnLoadLyrics) self.btnlyrics.pack(side=LEFT) ttips.Create(self.btnlyrics, text=_('Select a txt file with lyrics')) self.txtcover = Entry(c3, width=31, bg='white', fg='black') self.txtcover.pack(side=LEFT, padx=5) self.txtcover.drop_target_register(DND_FILES) ttips.Create(self.txtcover, text=_('Select an image file as front cover by clicking the button')) self.btncover = Button(c3, text=_('Cover'), command=self.btnLoadCover) self.btncover.pack(side=LEFT) ttips.Create(self.btncover, text=_('Select an image file as front cover')) self.lbcommposer = Label(c4, text=_('Composer(s)')) self.lbcommposer.pack(side=LEFT) self.txtcomposer = Entry(c4, width=102, bg='white', fg='black') self.txtcomposer.pack(side=LEFT, padx=5) self.lbcomment = Label(c5, text=_('Comments')) self.lbcomment.pack(side=LEFT, padx=5) self.txtcomment = Text(c5, width=105, height=5, bg='white', fg='black') self.txtcomment.pack(side=LEFT, pady=15) self.txtload_audio = Entry(c6, width=53, bg='white', fg='black') self.txtload_audio.pack(side=LEFT, padx=5, pady=2) self.txtload_audio.drop_target_register(DND_FILES) ttips.Create(self.txtload_audio, text=_('Select an audio file by clicking the button')) self.btnload_audio = Button(c6, text=_('Load Audio'), width=15, command=self.btnLoadAudio) self.btnload_audio.pack(side=LEFT) ttips.Create(self.btnload_audio, text=_('Select an audio file, Ctrl+O')) self.btnclear_fields = Button(c6, text=_('Clear Fields'), width=15, command=self.btnClearFields) self.btnclear_fields.pack(side=LEFT, padx=5) ttips.Create(self.btnclear_fields, text=_('Clear all fields, Ctrl+L')) self.btnsave_tags = Button(c6, text=_('Save Tags'), width=16, command=self.btnSaveTags) self.btnsave_tags.pack(side=LEFT) ttips.Create(self.btnsave_tags, text=_('Save all tags into the audio file, Ctrl+S')) self.bgimg = PhotoImage(file='icons/bg.png') self.bg = Label(c7, image=self.bgimg) self.bg.pack(pady=30) self.bg.image = self.bgimg self.mouseMenu = Menu(window, tearoff=0) self.mouseMenu.add_command(label=_('Cut')) self.mouseMenu.add_command(label=_('Copy')) self.mouseMenu.add_command(label=_('Paste')) # Binds window.bind('<Control-O>', lambda e: self.btnLoadAudio()) window.bind('<Control-o>', lambda e: self.btnLoadAudio()) window.bind('<Control-S>', lambda e: self.btnSaveTags()) window.bind('<Control-s>', lambda e: self.btnSaveTags()) window.bind('<Control-Q>', lambda e: window.destroy()) window.bind('<Control-q>', lambda e: window.destroy()) window.bind('<Control-G>', lambda e: webbrowser.open('https://github.com/Alexsussa/eyed3-gtk-gui')) window.bind('<Control-g>', lambda e: webbrowser.open('https://github.com/Alexsussa/eyed3-gtk-gui')) window.bind('<Control-I>', lambda e: webbrowser.open('https://github.com/Alexsussa/eyed3-gtk-gui/blob/master/LICENSE')) window.bind('<Control-i>', lambda e: webbrowser.open('https://github.com/Alexsussa/eyed3-gtk-gui/blob/master/LICENSE')) window.bind('<Control-D>', lambda e: webbrowser.open('https://github.com/Alexsussa/eyed3-gtk-gui#eyed3-gtk-gui')) window.bind('<Control-d>', lambda e: webbrowser.open('https://github.com/Alexsussa/eyed3-gtk-gui#eyed3-gtk-gui')) window.bind('<Control-N>', lambda e: self.check_updates()) window.bind('<Control-n>', lambda e: self.check_updates()) window.bind('<Control-H>', lambda e: About.about(self, window=window)) window.bind('<Control-h>', lambda e: About.about(self, window=window)) window.bind('<Control-L>', lambda e: self.btnClearFields()) window.bind('<Control-l>', lambda e: self.btnClearFields()) window.bind('<Button-3><ButtonRelease-3>', self.mouse) self.txtlyrics.dnd_bind('<<Drop>>', self.dnd) self.txtcover.dnd_bind('<<Drop>>', self.dnd) self.txtload_audio.dnd_bind('<<Drop>>', self.dnd)
txt_lab = Label(root, bg='plum', text='This is text on a simple label') txt_lab.grid() # Add the tooltips text to the buttons. #-------------------------------------- # tooltips.Create(widget, text, bgcol, fgcol, fontname, fontsize, showtime) # Optional background\foreground color, or defaults to yellow-black. # Optional fontname, default times, fontsize, default 8, # showtime, default is 2 (seconds) # Use '\n' in text for multi-lines. ttips.Create(btn1, 'Default tooltip over button 1') ttips.Create(btn2, 'Tooltip with colors over button 2', bgcol='green', fgcol='white') ttips.Create(btn3, 'Font changed to helvetica over btn 3', fontname='helvetica') ttips.Create(btn4, 'Tooltip fontsize changed to 16, over button 4', fontsize=16) ttips.Create(btn5, 'This will display for 8 seconds,\n'
''' 140-Tooltips module simple example stevepython.wordpress.com source: https://stevepython.wordpress.com/2019/08/16/how-to-create-a-cool-module ''' from tkinter import Tk, Button import ttips root = Tk() btn = Button(root, text='A Button') btn.pack() ttips.Create(btn, "This is a tooltip") root.mainloop()
def finished(): """The last area with help, save, test, view and quit buttons.""" Bg.q_a_btn = Button(finished_btn_frame, bg='springgreen', text=' QA ', command=check_qa) Bg.q_a_btn.grid(row=8, column=0, pady=15, padx=15) ttips.Create(Bg.q_a_btn, 'Click here to check that your\n' 'answers match your questions.', fontname='helvetica', fontsize=12, showtime=12) Bg.q_a_btn.configure(state=DISABLED) help_btn = Button(finished_btn_frame, bg='yellow', text=' Help ', command=display_help_text) help_btn.grid(row=8, column=1, pady=15, padx=15) ttips.Create(help_btn, 'Click here to show a full help guide.', fontname='helvetica', fontsize=12, showtime=12) Bg.save_btn = Button(finished_btn_frame, bg='white', text=' Save ', command=save_settings) Bg.save_btn.grid(row=8, column=2, pady=15, padx=15) ttips.Create(Bg.save_btn, 'Save all your settings', fontname='helvetica', fontsize=12, showtime=12) Bg.test_btn = Button(finished_btn_frame, bg='plum', text=' Test ', command=test_quiz) Bg.test_btn.grid(row=8, column=3, pady=15, padx=15) ttips.Create(Bg.test_btn, 'Run your quiz in test mode.', fontname='helvetica', fontsize=12, showtime=12) Bg.open_folder_btn = Button(finished_btn_frame, bg='lightblue', text=' View ', command=open_folder) Bg.open_folder_btn.grid(row=8, column=4, pady=15, padx=15) ttips.Create(Bg.open_folder_btn, 'Click here to view the folder containing all\n' 'the files your program needs to run independently.', fontname='helvetica', fontsize=12, showtime=12) quit_btn = Button(finished_btn_frame, bg='orange', text=' Quit ', command=quit_prg) quit_btn.grid(row=8, column=5, pady=15, padx=15) ttips.Create(quit_btn, 'Quit SQM.', fontname='helvetica', fontsize=12, showtime=12)
quiz_name_btn_frame.configure(borderwidth=2, relief='ridge') quiz_name_btn_frame.grid(row=0, column=0, sticky=W + E) # Frame for big yellow btn display. load_logo_btn_frame = LabelFrame(root) load_logo_btn_frame.configure(borderwidth=2, relief='ridge', bg='limegreen') load_logo_btn_frame.grid(row=1, column=0, sticky=W + E) # Frame for logo display. logo_frame = LabelFrame(root, width=454, height=253) logo_frame.configure(borderwidth=2, relief='ridge', bg='grey') logo_frame.grid(row=2, column=0) ttips.Create(logo_frame, 'Your image will be auto resized\n' 'if it is not 450x253 pixels.', fontname="helvetica", fontsize=12, showtime=12) # Accept logo btn frame. accept_logo_btn_frame = LabelFrame(root) accept_logo_btn_frame.configure(borderwidth=2, relief='ridge', bg='limegreen') accept_logo_btn_frame.grid(row=4, column=0, sticky=W + E) # Frame for inputs. inputs_frame = LabelFrame(root) inputs_frame.grid(row=5, column=0, pady=30) # Finished_btn_frame. finished_btn_frame = LabelFrame(root) finished_btn_frame.configure(borderwidth=2, relief='ridge', bg='indianred')
useImg2 = ImageTk.PhotoImage(img2) img3 = Image.open(r'icons/website.png') useImg3 = ImageTk.PhotoImage(img3) img4 = Image.open(r'icons/search.png') useImg4 = ImageTk.PhotoImage(img4) img5 = Image.open(r'icons/music.png') useImg5 = ImageTk.PhotoImage(img5) img6 = Image.open(r'icons/exit.png') useImg6 = ImageTk.PhotoImage(img6) # Set up all the buttons for use on the toolbars. about_btn = Button(toolbar, image=useImg1, command=lambda: callback("clicked about icon")) about_btn.pack(side=LEFT, fill=X) ttips.Create(about_btn, 'About') help_btn = Button(toolbar, image=useImg2, command=lambda: callback("clicked help icon")) help_btn.pack(side=LEFT, fill=X) ttips.Create(help_btn, 'Help') website_btn = Button(toolbar, image=useImg3, command=lambda: callback("clicked visit blog icon")) website_btn.pack(side=LEFT, fill=X) ttips.Create(website_btn, 'Visit blog') search_btn = Button(toolbar, image=useImg4,
'gray31', 'gray32', 'gray33', 'gray34', 'gray35', 'gray36', 'gray37', 'gray38', 'gray39', 'gray40', 'gray42', 'gray43', 'gray44', 'gray45', 'gray46', 'gray47', 'gray48', 'gray49', 'gray50', 'gray51', 'gray52', 'gray53', 'gray54', 'gray55', 'gray56', 'gray57', 'gray58', 'gray59', 'gray60', 'gray61', 'gray62', 'gray63', 'gray64', 'gray65', 'gray66', 'gray67', 'gray68', 'gray69', 'gray70', 'gray71', 'gray72', 'gray73', 'gray74', 'gray75', 'gray76', 'gray77', 'gray78', 'gray79', 'gray80', 'gray81', 'gray82', 'gray83', 'gray84', 'gray85', 'gray86', 'gray87', 'gray88', 'gray89', 'gray90', 'gray91', 'gray92', 'gray93', 'gray94', 'gray95', 'gray97', 'gray98', 'gray99' ] root = Tk() root.title("Named colour chart") row = 0 col = 0 for color in COLORS: e = Label(root, text=color, background=color, font=(None, -FONT_SIZE)) e.grid(row=row, column=col, sticky=E + W) ttips.Create(e, color, fontsize=16, showtime=4) #tool tip row += 1 if (row > 36): row = 0 col += 1 root.mainloop()
useImg6 = ImageTk.PhotoImage(img6) img7 = Image.open(r'icons/ytube.png') useImg7 = ImageTk.PhotoImage(img7) img8 = Image.open(r'icons/reddit.png') useImg8 = ImageTk.PhotoImage(img8) img9 = Image.open(r'icons/python.png') useImg9 = ImageTk.PhotoImage(img9) img10 = Image.open(r'icons/qstart32.png') useImg10 = ImageTk.PhotoImage(img10) img11 = Image.open(r'icons/exit.png') useImg11 = ImageTk.PhotoImage(img11) # Set up the buttons for use on the icon toolbar. qstart_btn = Button(toolbar, image=useImg10, command=quick_help) qstart_btn.grid(row=0, column=0) ttips.Create(qstart_btn, 'Quick start help', fontname='helvetica', fontsize=12) about_btn = Button(toolbar, image=useImg1, command=about_menu) about_btn.grid(row=0, column=2) ttips.Create(about_btn, 'About Tk Assistant', fontname='helvetica', fontsize=12) help_btn = Button(toolbar, image=useImg2, command=help_page) help_btn.grid(row=0, column=1) ttips.Create(help_btn, 'Online help page', fontname='helvetica', fontsize=12) website_btn = Button(toolbar, image=useImg3, command=visit_blog) website_btn.grid(row=0, column=3) ttips.Create(website_btn,