当前位置: 首页>>代码示例>>Python>>正文


Python Entry.cget方法代码示例

本文整理汇总了Python中tkinter.Entry.cget方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.cget方法的具体用法?Python Entry.cget怎么用?Python Entry.cget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.Entry的用法示例。


在下文中一共展示了Entry.cget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AddManually

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import cget [as 别名]
class AddManually(Frame):

    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        self.controller = controller

        self.place(relx=0.0, rely=0.0, relheight=0.62, relwidth=0.72)
        self.configure(relief=GROOVE)
        self.configure(borderwidth="2")
        self.configure(relief=GROOVE)
        self.configure(width=125)

        self.label_top = Label(self)
        self.label_top.place(relx=0.4, rely=0.03, height=21, width=112)
        self.label_top.configure(text="Add items manually")

        self.name = Entry(self, fg='grey')
        self.name.place(relx=0.05, rely=0.31, relheight=0.08, relwidth=0.29)
        self.name.insert(0, "Input name here")
        self.name.bind('<Button-1>', lambda event: greytext(self.name))

        self.link = Entry(self, fg='grey')
        self.link.place(relx=0.65, rely=0.31, relheight=0.08, relwidth=0.29)
        self.link.insert(0, "Input link here")
        self.link.bind('<Button-1>', lambda event: greytext(self.link))

        self.add_btn = Button(self, command=self.send_data)
        self.add_btn.place(relx=0.42, rely=0.44, height=34, width=100)
        self.add_btn.configure(text="Add item")

        self.back = Button(self, command=lambda: controller.show_frame('Main'))
        self.back.place(relx=0.42, rely=0.64, height=34, width=100)
        self.back.configure(text="Go back")

        name_label = Label(self)
        name_label.place(relx=0.05, rely=0.22, height=21, width=38)
        name_label.configure(text="Name")

        link_label = Label(self)
        link_label.place(relx=0.65, rely=0.22, height=21, width=28)
        link_label.configure(text="Link")

    def send_data(self):
        if self.link.cget('fg') == 'grey' or self.name.cget('fg') == 'grey':
            return
        link = self.link.get()
        if link.strip() != '':
            name = self.name.get()
            self.controller.add_item(link, name)
            print("Item added")
开发者ID:s0hvaperuna,项目名称:Custom-playlist,代码行数:52,代码来源:addlink.py

示例2: Main

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import cget [as 别名]
class Main(Frame):
    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        self.controller = controller
        self.db_set = False

        self.configure(relief=GROOVE)
        self.configure(borderwidth="2")

        # Manual link adding
        self.manual_btn = Button(self)
        self.manual_btn.place(relx=0.07, rely=0.81, height=45, width=130)
        self.manual_btn.configure(activebackground="#d9d9d9")
        self.manual_btn.configure(highlightbackground="#d9d9d9")
        self.manual_btn.configure(pady="0")
        self.manual_btn.configure(text="Add manually")
        self.manual_btn.configure(width=130)

        self.file_btn = Button(self)
        self.file_btn.place(relx=0.67, rely=0.81, height=45, width=150)
        self.file_btn.configure(activebackground="#d9d9d9")
        self.file_btn.configure(highlightbackground="#d9d9d9")
        self.file_btn.configure(pady="0")
        self.file_btn.configure(text="Add from file")

        self.label = Label(self)
        self.label.place(relx=0.08, rely=0.0, height=61, width=484)
        self.label.configure(text="Create new playlists and add content to them")
        self.label.configure(width=485)

        self.listbox = Listbox(self)
        self.listbox.place(relx=0.38, rely=0.22, relheight=0.31, relwidth=0.17)
        self.listbox.configure(background="white")
        self.listbox.configure(disabledforeground="#a3a3a3")
        self.listbox.configure(foreground="#000000")
        self.listbox.configure(selectmode=SINGLE)
        self.listbox.configure(width=105)
        for name, value in config.configparser.items('Playlists'):
            if os.path.isdir(value):
                self.listbox.insert('end', name)
            else:
                config.remove_value('Playlists', name)
        self.listbox.bind('<<ListboxSelect>>', self.onselect)

        self.label_name = Label(self)
        self.label_name.place(relx=0.7, rely=0.22, height=31, width=84)
        self.label_name.configure(foreground="#000000")
        self.label_name.configure(text="Name")
        self.label_name.configure(width=85)

        self.entry = Entry(self)
        self.entry.place(relx=0.63, rely=0.31, relheight=0.08, relwidth=0.29)
        self.entry.configure(background="white")
        self.entry.configure(foreground="#000000")
        self.entry.configure(insertbackground="black")
        self.entry.configure(takefocus="0")
        self.entry.configure(width=175)

        self.change_name = Button(self)
        self.change_name.place(relx=0.7, rely=0.42, height=34, width=97)
        self.change_name.configure(activebackground="#d9d9d9")
        self.change_name.configure(highlightbackground="#d9d9d9")
        self.change_name.configure(highlightcolor="black")
        self.change_name.configure(pady="0")
        self.change_name.configure(text="Rename")
        self.change_name.configure(width=100)

        self.new_playlist = Button(self, command=self.new_database)
        self.new_playlist.place(relx=0.08, rely=0.28, height=54, width=107)
        self.new_playlist.configure(activebackground="#d9d9d9")
        self.new_playlist.configure(highlightbackground="#d9d9d9")
        self.new_playlist.configure(highlightcolor="black")
        self.new_playlist.configure(pady="0")
        self.new_playlist.configure(text="Create new playlist")
        self.new_playlist.configure(width=105)

        self.db_name = Entry(self)
        self.db_name.place(relx=0.07, rely=0.44, relheight=0.08, relwidth=0.22)
        self.db_name.configure(fg='grey')
        self.db_name.configure(width=135)
        self.db_name.insert(0, "Input database name here")
        self.db_name.bind('<Button-1>', lambda event: greytext(self.db_name))

    def onselect(self, event):
        w = event.widget
        index = int(w.curselection()[0])
        value = w.get(index)
        set_database(config.configparser.get('Playlists', value))
        if not database.check_integrity():
            messagebox.showwarning('Integrity check failed', 'You might be missing some entries in your list')
        if not self.db_set:
            self.manual_btn.configure(command=lambda: self.controller.show_frame('AddManually'))
            self.file_btn.configure(command=lambda: self.controller.show_frame('ReadFromFile'))
            self.db_set = True

    def new_database(self):
        name = self.db_name.get()
        names = config.configparser.options('Playlists')
        print(name, names)
        if name.strip() == '' or self.db_name.cget('fg') == 'grey':
#.........这里部分代码省略.........
开发者ID:s0hvaperuna,项目名称:Custom-playlist,代码行数:103,代码来源:addlink.py


注:本文中的tkinter.Entry.cget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。