def sound(): global files if files == 'download222.png': pygame.mixer.music.play(loops=120) #sound_photo1.place_forget() sound1 = tk.PhotoImage(file='download111.png') sound_photo1 = tk.Label(board_frame1, image=sound1, background='gray83', relief="flat") sound_photo1.image = sound1 sound_photo1.bind('<Double-Button>', lambda _: sound()) sound_photo1.grid(row=3, column=1) files = 'download111.png' else: pygame.mixer.music.stop() #sound_photo1.place_forget() sound1 = tk.PhotoImage(file='download222.png') sound_photo1 = tk.Label(board_frame1, image=sound1, background='gray83', relief="flat") sound_photo1.image = sound1 sound_photo1.bind('<Double-Button>', lambda _: sound()) sound_photo1.grid(row=3, column=1) files = 'download222.png' sound_photo1.grid(row=3, column=1)
def helpp(): global explanation_win explanation_win = tk.Toplevel(win) explanation_win.resizable(False, False) explanation_win.minsize(300, 300) explanation_win.title('help') explanation_win.configure(bg='gray83') helppp1 = '1. find all block that is not bomb' helppp2 = '2. each block show number of neighbor bomb block' helppp3 = '3. if you choose bomb block you lose' helppp4 = '4. if you choose all safe block you win' explanation_label1 = tk.Label(explanation_win, text=helppp1, bg='gray83') explanation_label1.place(x=0, y=0) explanation_label2 = tk.Label(explanation_win, text=helppp2, bg='gray83') explanation_label2.place(x=0, y=50) explanation_label3 = tk.Label(explanation_win, text=helppp3, bg='gray83') explanation_label3.place(x=0, y=100) explanation_label4 = tk.Label(explanation_win, text=helppp4, bg='gray83') explanation_label4.place(x=0, y=150) close_btn = tk.Button(explanation_win, text='close', command=explanation_win.destroy) close_btn.config(font='mitra', activeforeground='red', activebackground='gray83', background='gray83', foreground='black') close_btn.place(x=120, y=250, width=60, height=30)
def QR_Code(self): if re.match(r'^https?:/{2}\w.+$', self.url.get()): #视频链接获取 ip = self.url.get() #视频链接加密 ip = parse.quote_plus(ip) url = 'http://www.wmxz.wang/video.php?url=%s' % ip words = url images_pwd = os.getcwd() + '\Images\\' png_path = images_pwd + 'bg.png' qr_name = 'qrcode.png' qr_path = images_pwd + 'qrcode.png' run(words=words, picture=png_path, save_name=qr_name, save_dir=images_pwd) top = tk.Toplevel(self.root) img = tk.PhotoImage(file=qr_path) text_label = tk.Label(top, fg='red', font=('楷体', 15), text="手机浏览器扫描二维码,在线观看视频!") img_label = tk.Label(top, image=img) text_label.pack() img_label.pack() top.mainloop() else: msgbox.showerror(title='错误', message='视频链接地址无效,请重新输入!')
def __init__(self, master): tk.Frame.__init__(self, master) self.status = tk.Label(self, relief=tk.SUNKEN, anchor=tk.W) #self.label.pack(fill=tk.X) self.status.pack(side=tk.LEFT, fill=tk.X, expand=1) self.note_status = tk.Label(self, relief=tk.SUNKEN, anchor=tk.W) self.note_status.pack(side=tk.LEFT, fill=tk.X)
def level_of_game(): # delete first page welcom_page_label.place_forget() welcom_page_photo.place_forget() ############################################################### # ------------second page : choose level of game -------------# ############################################################### global logo_photo logo = tk.PhotoImage(file='download-Copy.png') logo_photo = tk.Label(win, image=logo, background='gray83') logo_photo.image = logo logo_photo.place(x=200, y=20) global hardness global hardness_label hardness = tk.StringVar() # easy/medium/hard hardness_label = tk.Label(win, text='level of game') hardness_label.config(font='mitra', background='gray83', foreground='black') hardness_label.place(x=190, y=150) global hardness_om # Choose how hard it is hardness_om = tk.OptionMenu(win, hardness, 'easy', 'medium', 'hard') hardness_om.config(width=12, height=1, background='gray83', activebackground='gray83', foreground='black') hardness_om.place(x=190, y=180) global help_btn # help : explanation of the game help_btn = tk.Button(win, text='help') help_btn.config(font='mitra', activeforeground='red', activebackground='gray83', background='gray83', foreground='black') help_btn.bind('<Button>', lambda _: helpp()) help_btn.place(x=190, y=250, width=115, height=30) global start_btn # start the game start_btn = tk.Button(win, text='start') start_btn.config(font='mitra', activeforeground='green', activebackground='red', background='red', foreground='black') start_btn.bind('<Button>', lambda _: game_page()) start_btn.place(x=170, y=350, width=150, height=50) global worn_label # how many bomb there are worn_label = tk.Label(win)
def get_value_os(): try: print(os_str_var.get()) tk.Label(root,text=f"{os_str_var.get()}").pack() get_os_input = os_str_var.get() startfile(f"{get_os_input}") tk.Label(root, text=f"Good News! The system can find the path({get_os_input}) specified. ").pack() print(f"Good News! The system can find the path({get_os_input}) specified. ") return get_os_input except: tk.Label(root,text="The system cannot find the path specified. ").pack() print("The system cannot find the path specified. ")
def _create_ui(self): # these two variables determine the final dimensions of our interface #FRAME_HEIGHT=400 TEXT_WIDTH = 80 self.root = tk.Tk() self.root.title("nvPY") #self.root.configure(background="#b2b2b2") # with iconphoto we have to use gif, also on windows icon_fn = 'nvpy.gif' iconpath = os.path.join(self.config.app_dir, 'icons', icon_fn) self.icon = tk.PhotoImage(file=iconpath) self.root.tk.call('wm', 'iconphoto', self.root._w, self.icon) # create menu ################################################### self._create_menu() # separator after menu ########################################## #separator = tk.Frame(self.root, height=2, bd=1, relief=tk.SUNKEN) #separator.pack(fill=tk.X, padx=5, pady=2, side=tk.TOP) # setup statusbar ############################################### # first pack this before panedwindow, else behaviour is unexpected # during sash moving and resizing self.statusbar = StatusBar(self.root) self.statusbar.set_status('%s', 'Welcome to nvPY!') self.statusbar.pack(fill=tk.X, side=tk.BOTTOM) search_frame = tk.Frame(self.root) search_entry.make_style() self.search_entry_var = tk.StringVar() #self.search_entry = tk.Entry(search_frame, textvariable=self.search_entry_var, style="Search.entry") self.search_entry = TriggeredcompleteEntry( search_frame, self.config.case_sensitive, textvariable=self.search_entry_var, style="Search.entry") #self.search_entry.set_completion_list(self.taglist) self.search_entry_var.trace('w', self.handler_search_entry) self.search_entry.pack(fill=tk.X, padx=5, pady=5) search_frame.pack(side=tk.TOP, fill=tk.X) # the paned window ############################################## paned_window = tk.PanedWindow(self.root, orient=tk.HORIZONTAL) paned_window.pack(fill=tk.BOTH, expand=1) left_frame = tk.Frame(paned_window, width=100) paned_window.add(left_frame) self.notes_list = NotesList(left_frame, self.config.list_font_family, self.config.list_font_size, self.config.background_color) self.notes_list.pack(fill=tk.BOTH, expand=1) right_frame = tk.Frame(paned_window, width=400) paned_window.add(right_frame) note_meta_frame = tk.Frame(right_frame) note_meta_frame.pack(side=tk.BOTTOM, fill=tk.X) pinned_label = tk.Label(note_meta_frame, text="Pinned") pinned_label.pack(side=tk.LEFT) self.pinned_checkbutton_var = tk.IntVar() pinned_checkbutton = tk.Checkbutton( note_meta_frame, variable=self.pinned_checkbutton_var) pinned_checkbutton.pack(side=tk.LEFT) tags_label = tk.Label(note_meta_frame, text="Tags") tags_label.pack(side=tk.LEFT) self.tags_entry_var = tk.StringVar() self.tags_entry = tk.Entry(note_meta_frame, textvariable=self.tags_entry_var) self.tags_entry.pack(side=tk.LEFT, fill=tk.X, expand=1, pady=3, padx=3) # we'll use this method to create the different edit boxes def create_scrolled_text(master): yscrollbar = tk.Scrollbar(master) yscrollbar.pack(side=tk.RIGHT, fill=tk.Y) #f = tkFont.nametofont('TkFixedFont') f = tkFont.Font(family=self.config.font_family, size=-self.config.font_size) # tkFont.families(root) returns list of available font family names # this determines the width of the complete interface (yes) text = RedirectedText(master, height=25, width=TEXT_WIDTH, wrap=tk.WORD, font=f, tabs=(4 * f.measure(0), 'left'), tabstyle='wordprocessor', yscrollcommand=yscrollbar.set, undo=True, background=self.config.background_color) # change default font at runtime with: text.config(font=f) text.pack(fill=tk.BOTH, expand=1) #xscrollbar.config(command=text.xview) yscrollbar.config(command=text.yview) return text # setup user_text ############################################### self.text_note = create_scrolled_text(right_frame) # finish UI creation ########################################### # now set the minsize so that things can not disappear self.root.minsize(self.root.winfo_width(), self.root.winfo_height()) # call update so we know that sizes are up to date self.root.update_idletasks()
def play(x, y): # after every click on the table this function run bomb_list = [] isbomb = 0 print('mypos', x - dim + 1, y - dim + 1) for k in range(len(bomb_pos)): (i, j) = bomb_pos[k] if (x - dim + 1 - 1) == i and ( y - dim + 1 - 1) == j: # if block that click on is bomb isbomb = 1 photo22 = tk.PhotoImage(file="images(8).png") #l.config(win,image=photo1) buttons_dict[str(x) + "_" + str(y)].config(image=photo22, width="48", height="48", bd=1) buttons_dict[str(x) + "_" + str(y)].image = photo22 #board_frame.place_forget() label4 = tk.Label(win, text='Game over') label4.config(bg='red', font=('mitra', 25)) label4.place(x=150, y=200) try_again = messagebox.askyesno('do you want try again?') if try_again == True: label4.place_forget() game_page() elif try_again == False: EXIT = messagebox.askyesno('close the app?') if EXIT == True: win.destroy() elif EXIT == False: label4.place_forget() worn_label.place_forget() home() global win_photo if isbomb == 0: #print('answer:\n',x,y,data) buttons_dict[str(x) + "_" + str(y)].config( bg='gray76', relief="sunken", text=str(data[x - dim + 1 - 1][y - dim + 1 - 1])) if 0 in winner: winner[x - dim + 1 - 1][y - dim + 1 - 1] = 1 if 0 not in winner: print('you win') game_photo11 = tk.PhotoImage( file= '5330082-win-png-97-images-in-collection-page-3-win-png-423_169_preview.png' ) # icon for game win_photo = tk.Label(win, compound=tk.CENTER, image=game_photo11, background='gray83') win_photo.image = game_photo11 win_photo.config(font=("mitra", 25), foreground='darkorange') win_photo.place(x=30, y=200) try_again = messagebox.askyesno('do you want try again?') if try_again == True: win_photo.place_forget() game_page() elif try_again == False: EXIT = messagebox.askyesno('close the app?') if EXIT == True: pygame.mixer.music.stop() win.destroy() elif EXIT == False: win_photo.place_forget() worn_label.place_forget() home()
def minesweeper(): # window configuration global win win = tk.Tk() win.resizable(False, False) win.minsize(500, 500) win.title('minesweeper') win.configure(bg='gray83') game_photo = tk.PhotoImage(file='download.png') # icon for game win.iconphoto(True, game_photo) ############################################################### # -------------------first page : welcom page ----------------# ############################################################### global welcom_page_photo welcom_page_photo = tk.Label(win, compound=tk.CENTER, image=game_photo, background='gray83') welcom_page_photo.image = game_photo welcom_page_photo.config(font=("mitra", 25), foreground='darkorange') welcom_page_photo.place(x=150, y=200) welcom_page_photo.bind('<Button>', lambda _: level_of_game()) global welcom_page_label welcom_page_label = tk.Label(win, text='minesweeper', background='gray83') welcom_page_label.config(font=("mitra", 25)) welcom_page_label.place(x=150, y=100) welcom_page_label.bind('<Button>', lambda _: level_of_game()) pygame.mixer.init() # music of game pygame.mixer.music.load('1.mp3') pygame.mixer.music.play(loops=120) ############################################################### # -------------------------variation--------------------------# ############################################################### global worn_label worn_label = tk.Label(win) worn_label.place(x=700, y=700) global bomb bomb = 0 global logo_photo1 logo1 = tk.PhotoImage(file='download-Copy.png') logo_photo1 = tk.Label(win, image=logo1, background='gray83') logo_photo1.image = logo1 global board_frame board_frame = tk.Frame(win) board_frame.config(highlightbackground="gray83", relief="ridge", highlightcolor='gray25', highlightthickness=6) global board_frame1 board_frame1 = tk.Frame(win) board_frame1.config(highlightbackground="gray77", relief="ridge", highlightcolor='gray77', highlightthickness=8) global files global sound_photo1 files = 'download111.png' sound1 = tk.PhotoImage(file=files) sound_photo1 = tk.Label(board_frame1, image=sound1, background='gray83', relief="flat") sound_photo1.image = sound1 sound_photo1.bind('<Double-Button>', lambda _: sound()) global home_photo1 home1 = tk.PhotoImage(file='download333.png') home_photo1 = tk.Label(board_frame1, image=home1, relief="flat", background='gray83') home_photo1.image = home1 home_photo1.bind('<Double-Button>', lambda _: home()) global reset_btn reset = tk.PhotoImage(file='download444.png') reset_btn = tk.Label(board_frame1, image=reset, relief="flat", background='gray83') reset_btn.image = reset reset_btn.bind('<Double-Button>', lambda _: game_page())
def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self.control = tk.Label( parent, text = '', anchor = 'e' )
def __init__(self, width=500, height=300): self.w = width self.h = height self.title = ' VIP视频破解助手' self.root = tk.Tk(className=self.title) self.url = tk.StringVar() self.v = tk.IntVar() self.v.set(1) #Frame空间 frame_1 = tk.Frame(self.root) frame_2 = tk.Frame(self.root) frame_3 = tk.Frame(self.root) #Menu菜单 menu = tk.Menu(self.root) self.root.config(menu=menu) filemenu = tk.Menu(menu, tearoff=0) moviemenu = tk.Menu(menu, tearoff=0) menu.add_cascade(label='菜单', menu=filemenu) menu.add_cascade(label='友情链接', menu=moviemenu) filemenu.add_command( label='使用说明', command=lambda: webbrowser.open( 'http://blog.csdn.net/c406495762/article/details/71334633')) filemenu.add_command( label='关于作者', command=lambda: webbrowser.open('http://blog.csdn.net/c406495762')) filemenu.add_command(label='退出', command=self.root.quit) #各个网站链接 moviemenu.add_command( label='网易公开课', command=lambda: webbrowser.open('http://open.163.com/')) moviemenu.add_command( label='腾讯视频', command=lambda: webbrowser.open('http://v.qq.com/')) moviemenu.add_command( label='搜狐视频', command=lambda: webbrowser.open('http://tv.sohu.com/')) moviemenu.add_command( label='芒果TV', command=lambda: webbrowser.open('http://www.mgtv.com/')) moviemenu.add_command( label='爱奇艺', command=lambda: webbrowser.open('http://www.iqiyi.com/')) moviemenu.add_command( label='PPTV', command=lambda: webbrowser.open('http://www.bilibili.com/')) moviemenu.add_command( label='优酷', command=lambda: webbrowser.open('http://www.youku.com/')) moviemenu.add_command( label='乐视', command=lambda: webbrowser.open('http://www.le.com/')) moviemenu.add_command( label='土豆', command=lambda: webbrowser.open('http://www.tudou.com/')) moviemenu.add_command( label='A站', command=lambda: webbrowser.open('http://www.acfun.tv/')) moviemenu.add_command( label='B站', command=lambda: webbrowser.open('http://www.bilibili.com/')) #控件内容设置 group = tk.Label(frame_1, text='请选择一个视频播放通道:', padx=10, pady=10) tb1 = tk.Radiobutton(frame_1, text='通道一', variable=self.v, value=1, width=10, height=3) tb2 = tk.Radiobutton(frame_1, text='通道二', variable=self.v, value=2, width=10, height=3) label1 = tk.Label(frame_2, text="请输入视频链接:") entry = tk.Entry(frame_2, textvariable=self.url, highlightcolor='Fuchsia', highlightthickness=1, width=35) label2 = tk.Label(frame_2, text=" ") play = tk.Button(frame_2, text="播放", font=('楷体', 12), fg='Purple', width=2, height=1, command=self.video_play) label3 = tk.Label(frame_2, text=" ") # download = tk.Button(frame_2, text = "下载", font = ('楷体',12), fg = 'Purple', width = 2, height = 1, command = self.download_wmxz) QR_Code = tk.Button(frame_3, text="手机观看", font=('楷体', 12), fg='Purple', width=10, height=2, command=self.QR_Code) label_explain = tk.Label( frame_3, fg='red', font=('楷体', 12), text='\n注意:支持大部分主流视频网站的视频播放!\n此软件仅用于交流学习,请勿用于任何商业用途!') label_warning = tk.Label(frame_3, fg='blue', font=('楷体', 12), text='\n建议:将Chrome内核浏览器设置为默认浏览器\n作者:Jack_Cui') #控件布局 frame_1.pack() frame_2.pack() frame_3.pack() group.grid(row=0, column=0) tb1.grid(row=0, column=1) tb2.grid(row=0, column=2) label1.grid(row=0, column=0) entry.grid(row=0, column=1) label2.grid(row=0, column=2) play.grid(row=0, column=3, ipadx=10, ipady=10) label3.grid(row=0, column=4) # download.grid(row = 0, column = 5,ipadx = 10, ipady = 10) QR_Code.grid(row=0, column=0) label_explain.grid(row=1, column=0) label_warning.grid(row=2, column=0)