Example #1
0
 def __init__(self, *args, **kwargs):
     initialText = ''
     if args[-1].__class__ == ''.__class__:
         initialText = args[-1]
         args = args[:-1]
     tk.Label.__init__(self, *args, **kwargs)
     self['textvariable'] = self._stringvar = tk.StringVar()
     if initialText:
         self.set(initialText)
     self.pack()
Example #2
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)
Example #3
0
    def __init__(self, *args, **kwargs):
        self._entry = tk.Entry(*args, **kwargs)
        self._priorValue = ''
        self._stringvarChangedSuppressed = False
        self._stringvar = tk.StringVar()
        self._entry['textvariable'] = self._stringvar
        self._stringvar.trace('w', self._stringvarChanged)
        self._entry.pack()

        self._entry.bind('<Return>'  , lambda event: self.onReturn   ())
        self._entry.bind('<Up>'      , lambda event: self.onUp       ())
        self._entry.bind('<Down>'    , lambda event: self.onDown     ())
        self._entry.bind('<FocusIn>' , lambda event: self.onFocus    ())
        self._entry.bind('<FocusOut>', lambda event: self.onFocusLost())
Example #4
0
File: view.py Project: johnwin/nvpy
    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()
Example #5
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()
Example #6
0
    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_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)
       
        # setup the scrollbar
        self.sb_notes = tk.Scrollbar(left_frame, orient=tk.VERTICAL)
        
        # exportselection=0 means it doesn't automatically export to
        # x selection. with that active, selecting in the text widget
        # removes selection in listbox.
        # thank you http://stackoverflow.com/a/756875
        self.lb_notes = tk.Listbox(left_frame, exportselection=0,
                                   yscrollcommand=self.sb_notes.set)
        
        self.sb_notes.config(command=self.lb_notes.yview)
        self.sb_notes.pack(side=tk.RIGHT, fill=tk.Y)
        
        # need both fill and expand to make it fill all avail area
        self.lb_notes.pack(fill=tk.BOTH, expand=1)

        right_frame = tk.Frame(paned_window, width=400)
        paned_window.add(right_frame)

        # 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)
            # 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)

#        def cb_ut_fi(event):
#            self.set_current_text(CURTEXT_USER)
#
#        self.user_text.bind('<FocusIn>', cb_ut_fi)
#
#        def cb_ut_m(event):
#            self.set_user_mode(MODE_MODIFIED)
#
#        self.user_text.bind('<<Change>>', cb_ut_m)
#
#        # setup sys_text ################################################
#        self.sys_text, self._sys_mode_label_var = \
#                      create_scrolled_text(bottom_frame, "System Environment")
#
#        def cb_st_fi(event):
#            self.set_current_text(CURTEXT_SYS)
#
#        self.sys_text.bind('<FocusIn>', cb_st_fi)
#
#        def cb_st_c(event):
#            self.set_sys_mode(MODE_MODIFIED)
#            
#        self.sys_text.bind('<<Change>>', cb_st_c)

        # 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()
Example #7
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)