示例#1
0
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)
示例#2
0
    def createWidgets(self):
        self.QUIT = tk.Button(self)
        self.QUIT["text"] = "QUIT"
        self.QUIT["fg"]   = "red"
        self.QUIT["command"] =  self.quit

        self.QUIT.pack({"side": "left"})

        self.hi_there = tk.Button(self)
        self.hi_there["text"] = "Hello",
        self.hi_there["command"] = self.say_hi

        self.hi_there.pack({"side": "left"})
示例#3
0
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)
示例#4
0
 def init(self, parent):
     """ Finishes initializing the editor by creating the underlying toolkit
         widget.
     """
     label = self.factory.label
     if label == '':
         label = user_name_for(self.name)
     self.control = tk.Button(parent,
                              text=label,
                              command=self.update_object)
示例#5
0
def game_page():

    #   delete second page
    logo_photo.place_forget()
    hardness_label.place_forget()
    hardness_om.place_forget()
    help_btn.place_forget()
    start_btn.place_forget()

    ###############################################################
    # ----------------third page : game page----------------------#
    ###############################################################
    global dimention
    global dim
    global bomb
    dimention = 0  # dimention of table(3/5/7)
    bomb = 0  #  number of bomb
    dim = 0

    # menu bar : design of game page-------------------------------
    logo_photo1.place(x=400, y=400)
    sound_photo1.grid(row=3, column=1)
    home_photo1.grid(row=1, column=1)
    reset_btn.grid(row=2, column=1)
    worn_label.place(x=200, y=10)

    board_frame1.place(x=0, y=0)

    # draw table : game block   ------------------------------------------------------------------------

    if hardness.get() == 'easy':
        dimention, dim, bomb = 3, 3, 2
    elif hardness.get() == 'medium':
        dimention, dim, bomb = 5, 2, 7
    elif hardness.get() == 'hard':
        dimention, dim, bomb = 7, 1, 13
    if dimention == 0:
        home()
    board_frame.place(
        x=60, y=25
    )  # full size table (7,7) # it's optional that draw this and then active the dimention that user wants or directly draw table in dimention that user wants

    global coords_list
    global buttons_dict
    coords_list = []
    buttons_dict = {}
    for r in range(1, 8):
        for c in range(1, 8):
            coord = str(r) + "_" + str(c)
            coords_list.append(coord)
            buttons_dict[coords_list[-1]] = tk.Button(board_frame,
                                                      width=6,
                                                      height=3,
                                                      relief="ridge",
                                                      background='gray83')
            if r >= dim and c >= dim and r <= 8 - dim and c <= 8 - dim:
                ###########################################################################
                buttons_dict[
                    coords_list[-1]]["command"] = lambda x=r, y=c: play(x, y)
                buttons_dict[coords_list[-1]].config(bg='gray35',
                                                     relief="raised")
                ###########################################################################
            buttons_dict[coords_list[-1]].grid(row=r, column=c)

    worn_label.config(text='there is ' + str(bomb) + ' bomb!!! be carefull',
                      background='gray83',
                      activebackground='gray83',
                      foreground='darkorange')
    worn_label.place(x=200, y=10)
    global data  #   array as table(game blocks)
    data = [0] * ((dimention * dimention) - bomb) + [100] * bomb
    shuffle(data)
    data = np.array(data)
    data = data.reshape(dimention, dimention)
    global winner
    winner = np.zeros((dimention, dimention))
    global aaa
    aaa = zip(np.where(data > 90)[0], np.where(data > 90)[1])
    global bomb_pos
    bomb_pos = []
    #   neighbors number of bomb
    for (i, j) in aaa:
        winner[i][j] = 2
        bomb_pos.append((i, j))
        print('bomb position:', i + 1, j + 1)
        if i - 1 >= 0:
            data[i - 1][j] += 1
            if j - 1 >= 0:
                data[i - 1][j - 1] += 1
            if j + 1 < dimention:
                data[i - 1][j + 1] += 1

        if i + 1 < dimention:
            data[i + 1][j] += 1
            if j - 1 >= 0:
                data[i + 1][j - 1] += 1
            if j + 1 < dimention:
                data[i + 1][j + 1] += 1
        if j - 1 >= 0:
            data[i][j - 1] += 1
        if j + 1 < dimention:
            data[i][j + 1] += 1
示例#6
0

def bofang():
    file = r'./paishou.mp3'
    pygame.mixer.init()
    print("播放音乐1")
    track = pygame.mixer.music.load(file)
    pygame.mixer.music.play()
    time.sleep(10)
    pygame.mixer.music.stop()
    # os.system("paplay 1.wav")


window.title('米醋儿直播音效')
window.geometry('500x200')
btn1 = tk.Button(window, text='one', width=10)
btn1.grid(row=0, column=0)

btn2 = tk.Button(window, text='two', width=10)
btn2.grid(row=0, column=1)
root.geometry('800x300')
Button(root, text="F1金宝音乐", command=bofang).pack()

# btn3 = tk.Button(window,text='three',width=3,height=3,bg='blue')
# btn3.grid(row=1,column=0)
#
# btn4 = tk.Button(window,text='four',width=15,height=10,bg='yellow')
# btn4.grid(row=1,column=1)

# 需要用pygame去播放 mp3
window.mainloop()  # 进入消息循环
示例#7
0
		import numbers
	    self.thread_pool = cf.ThreadPoolExecutorasmdasdhnasdhash(multiprocessing.cpu_count())
		self.initial_dir="./"
        self.random = [2+2 ,3, 5]
		self.random[2]
		self.x= 2
		self.x +=5
		self.x+=2
		self.x+= 7
		print("Start parsing!", ([1 ,2] ,3))
		self.window =tk.Tk()
		self.window.geometry("640x480")
		self.window.resizable(False, False)
		self.window.title("PEP8 Code Check")
		self.btn_select_dir = tk.Button(self.window,
										text="Select",
										command=self.select_dir)
		self.btn_select_dir.configure(height=1, width=12)
		self.btn_select_dir.place(x=450, y=47)
		self.btn_start = tk.Button(self.window, text = "Start", command= self.start_parsing)
		self.btn_start.place(x=210, y=320)
		self.btn_start.configure(height=5, width=30)
		self.entry_path = tk.Entry(self.window)
		self.entry_path.insert(12, "Select,path")
		self.entry_path.place(x=75,y=50)
		self.entry_path.configure(width=60)
		self.window.mainloop()
	def select_dir(self):
		self.path = tk.filedialog.askdirectory(initialdir =self.initial_dir, title="Select")
		self.initial_dir = self.path
		self.entry_path.delete(0 , "end")
示例#8
0
from os import *

import tk as tk

root = tk.Tk()
root.title("Open file")
os_str_var = tk.StringVar(root)


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. ")


os_entry = tk.Entry(root,textvariable=os_str_var).pack()
os_button = tk.Button(root,text="Open",command=get_value_os).pack()
root.mainloop()
示例#9
0
    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)