本文整理汇总了Python中tkinter.ttk.Label.grid_forget方法的典型用法代码示例。如果您正苦于以下问题:Python Label.grid_forget方法的具体用法?Python Label.grid_forget怎么用?Python Label.grid_forget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Label
的用法示例。
在下文中一共展示了Label.grid_forget方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Example
# 需要导入模块: from tkinter.ttk import Label [as 别名]
# 或者: from tkinter.ttk.Label import grid_forget [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("")
#self.style = Style()
#self.style.theme_use("clam")
#self.pack(fill=BOTH, expand = 1)
self.labelU = Label(self, text="U:")
self.labelP = Label(self, text="P:")
self.mailrecipient = 'GoldenSights'
self.entryUsername = Entry(self)
self.entryUsername.focus_set()
self.entryUsername.bind('<Return>', lambda event: self.entryPassword.focus_set())
self.entryPassword = Entry(self)
self.entryPassword.config(show='•')
self.entryPassword.bind('<Return>', lambda event: self.login(self.entryUsername.get(), self.entryPassword.get()))
self.newbutton = Button(self, text="Login", command= lambda: self.login(self.entryUsername.get(), self.entryPassword.get()))
self.newbutton.bind('<Return>', lambda event: self.login(self.entryUsername.get(), self.entryPassword.get()))
self.newbutton.config(width=6)
self.quitbutton = Button(self, text="Quit", command= lambda: self.quit())
self.quitbutton.config(width=6)
self.labelU.grid(row=0, column=0,padx=0)
self.entryUsername.grid(row=0, column=1)
self.labelP.grid(row=1, column=0)
self.entryPassword.grid(row=1, column=1, pady=4)
self.newbutton.grid(row=2, column=1)
self.quitbutton.grid(row=3, column=1, pady=4)
self.labelErrorPointer = Label(self, text="◀")
self.indicatorGreen = PhotoImage(file="indicatorGreen.gif")
self.indicatorRed = PhotoImage(file="indicatorRed.gif")
self.indicatorBlue = PhotoImage(file="indicatorBlue.gif")
self.indicatorBlack = PhotoImage(file="indicatorBlack.gif")
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
w=400
h=480
x = (sw - w) / 2
y = (sh - h) / 2
self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y-50))
def login(self, username, password):
print('U: ' + username)
self.username = username
if username == '' or not all(char in string.ascii_letters+string.digits+'_-' for char in username):
print('Please enter a username')
self.entryUsername.focus_set()
self.labelErrorPointer.grid(row=0, column=2)
elif password == '':
print('Please enter a password')
self.entryPassword.focus_set()
self.labelErrorPointer.grid(row=1, column=2)
else:
self.labelErrorPointer.grid_forget()
print('Attempting login for ' + username)
try:
self.USERAGENT = username + ' practices Tkinter+PRAW mixing with utility by /u/GoldenSights.'
self.r = praw.Reddit(self.USERAGENT)
#self.r.login(username, password)
print('Success')
self.labelU.grid_forget()
self.labelP.grid_forget()
self.entryUsername.grid_forget()
self.entryPassword.grid_forget()
self.newbutton.grid_forget()
self.quitbutton.grid_forget()
self.usernamelabel = Label(self, text=username + ', Sending to /u/' + self.mailrecipient)
self.usernamelabel.grid(row=0, column=0, columnspan=8)
self.quitbutton.grid(row=900, column=0)
self.labellist = []
self.entrylist = []
self.verifylist = []
self.misclist = []
self.optionDiscuss = "Discussion Flair + Crossposting"
self.optionRegister = "Register a new Candidate"
self.prevmode = self.optionDiscuss
#.........这里部分代码省略.........
示例2: Example
# 需要导入模块: from tkinter.ttk import Label [as 别名]
# 或者: from tkinter.ttk.Label import grid_forget [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("")
self.style = Style()
self.style.theme_use("clam")
self.pack(fill=BOTH, expand = 1)
self.labelU = Label(self, text="U:")
self.labelP = Label(self, text="P:")
self.entryUsername = Entry(self)
self.entryUsername.config(relief='flat')
self.entryUsername.focus_set()
self.entryUsername.bind('<Return>', lambda event: self.entryPassword.focus_set())
self.entryPassword = Entry(self)
self.entryPassword.config(relief='flat', show='•')
self.entryPassword.bind('<Return>', lambda event: self.login(self.entryUsername.get(), self.entryPassword.get()))
self.newbutton = Button(self, text="Login", command= lambda: self.login(self.entryUsername.get(), self.entryPassword.get()))
self.newbutton.bind('<Return>', lambda event: self.login(self.entryUsername.get(), self.entryPassword.get()))
self.newbutton.config(width=6)
self.quitbutton = Button(self, text="Quit", command= lambda: self.quit())
self.quitbutton.config(width=6)
self.mailIconRed = PhotoImage(file="mail.gif")
self.labelRed = Label(self, image=self.mailIconRed)
self.mailIconGray = PhotoImage(file="mail2.gif")
self.labelGray = Label(self, image=self.mailIconGray)
self.labelKarma = Label(self, text = '•')
self.labelU.grid(row=0, column=0)
self.entryUsername.grid(row=0, column=1)
self.labelP.grid(row=1, column=0)
self.entryPassword.grid(row=1, column=1, pady=4)
self.newbutton.grid(row=2, column=1)
self.quitbutton.grid(row=3, column=1, pady=4)
'''
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
w=150
h=112
x = (sw - w) / 2
y = (sh - h) / 2
self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y-50))
'''
def login(self, username, password):
#print('U: ' + username)
self.username = username
if username == '':
#print('Please enter a username')
self.entryUsername.focus_set()
elif password == '':
#print('Please enter a password')
self.entryPassword.set_focus()
if username != '' and password != '':
#print('Attempting login for ' + username)
try:
self.USERAGENT = username + ' scans his inbox for new mail.'
self.r = praw.Reddit(self.USERAGENT)
#self.r.config._ssl_url = None
self.r.login(username, password)
#print('You have logged in as ' + username)
self.labelU.grid_forget()
self.labelP.grid_forget()
self.entryUsername.grid_forget()
self.entryPassword.grid_forget()
self.newbutton.grid_forget()
self.quitbutton.grid_forget()
self.usernamelabel = Label(self, text=username)
self.usernamelabel.grid(row=0, column=0, pady = 10, padx = 30)
self.quitbutton.grid(row=1, column=0)
self.labelKarma.grid(row = 3, column = 0)
self.playedSound = 'false'
self.loop()
except praw.errors.InvalidUserPass:
pass
#print('Invalid username or password')
def loop(self):
while True:
try:
#print('Starting new search')
hasmail = 'false'
for msg in self.r.get_unread(limit=None):
hasmail = 'true'
#.........这里部分代码省略.........
示例3: Example
# 需要导入模块: from tkinter.ttk import Label [as 别名]
# 或者: from tkinter.ttk.Label import grid_forget [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("")
# self.style = Style()
# self.style.theme_use("clam")
# self.pack(fill=BOTH, expand = 1)
self.quitbutton = Button(self, text="Quit", command=lambda: self.quit())
self.quitbutton.grid(row=3, column=1, pady=4)
self.labelErrorPointer = Label(self, text="◀")
self.labellist = []
self.entrylist = []
self.verifylist = []
self.misclist = []
self.optionCreate = "Create"
self.optionUpcoming = "Upcoming"
self.optionPast = "Past"
self.prevmode = self.optionCreate
self.curmode = self.optionCreate
self.optionvar = tkinter.StringVar(self)
self.optionvar.trace("w", self.permaloop)
self.optionvar.set(self.optionCreate)
self.option = OptionMenu(self, self.optionvar, self.optionCreate, self.optionUpcoming, self.optionPast)
self.optionpostmodevar = tkinter.StringVar(self)
self.optionpostmodevar.trace("w", self.permaloop)
self.optionpostmodevar.set("url")
self.optionpostmode = OptionMenu(self, self.optionpostmodevar, "url", "text")
self.labelText = Label(self, text="Selftext:")
self.entryText = Text(self)
self.labelURL = Label(self, text="URL:")
self.entryURL = Entry(self)
self.entryURL.configure(width=60)
self.sql = sqlite3.connect("sql.db")
print("Loaded SQL Database")
self.cur = self.sql.cursor()
self.cur.execute(
"CREATE TABLE IF NOT EXISTS upcoming(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT)"
)
self.cur.execute(
"CREATE TABLE IF NOT EXISTS past(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT, POSTLINK TEXT)"
)
self.cur.execute("CREATE TABLE IF NOT EXISTS internal(NAME TEXT, ID INT)")
print("Loaded Completed table")
self.cur.execute("SELECT * FROM internal")
f = self.cur.fetchone()
if not f:
print("Database is new. Adding ID counter")
self.cur.execute("INSERT INTO internal VALUES(?, ?)", ["counter", 1])
self.idcounter = 1
else:
self.idcounter = f[1]
print("Current ID counter: " + str(self.idcounter))
self.sql.commit()
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
w = 853
h = 480
x = (sw - w) / 2
y = (sh - h) / 2
self.parent.geometry("%dx%d+%d+%d" % (w, h, x, y - 50))
self.login()
def login(self):
try:
self.quitbutton.grid_forget()
self.quitbutton.grid(row=9000, column=0, columnspan=20)
self.option.grid(row=1, column=0, columnspan=8, pady=8)
self.updategui(fullclean=True)
except praw.errors.InvalidUserPass:
pass
print("Invalid username or password")
self.entryPassword.delete(0, 200)
self.labelErrorPointer.grid(row=1, column=2)
def permaloop(self, *args):
self.curmode = self.optionvar.get()
print("Was: " + self.prevmode + " | Now: " + self.curmode)
#.........这里部分代码省略.........
示例4: Example
# 需要导入模块: from tkinter.ttk import Label [as 别名]
# 或者: from tkinter.ttk.Label import grid_forget [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("")
#self.style = Style()
#self.style.theme_use("clam")
#self.pack(fill=BOTH, expand = 1)
self.quitbutton = Button(self, text="Quit", command= lambda: self.quit())
self.quitbutton.grid(row=3, column=1, pady=4)
self.labelErrorPointer = Label(self, text="◀")
self.labellist = []
self.entrylist = []
self.verifylist = []
self.misclist = []
self.optionCreate = "Create"
self.optionUpcoming = "Upcoming"
self.optionPast = "Past"
self.prevmode = self.optionCreate
self.curmode = self.optionCreate
self.optionvar = tkinter.StringVar(self)
self.optionvar.trace("w",self.permaloop)
self.optionvar.set(self.optionCreate)
self.option = OptionMenu(self, self.optionvar, self.optionCreate, self.optionUpcoming, self.optionPast)
self.optionpostmodevar = tkinter.StringVar(self)
self.optionpostmodevar.trace("w",self.permaloop)
self.optionpostmodevar.set('url')
self.optionpostmode = OptionMenu(self, self.optionpostmodevar, 'url', 'text')
self.labelText = Label(self, text='Selftext:')
self.entryText = Text(self)
self.labelURL = Label(self, text='URL:')
self.entryURL = Entry(self)
self.entryURL.configure(width=60)
self.sql = sqlite3.connect('sql.db')
print('Loaded SQL Database')
self.cur = self.sql.cursor()
self.cur.execute('CREATE TABLE IF NOT EXISTS upcoming(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT)')
self.cur.execute('CREATE TABLE IF NOT EXISTS past(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT, POSTLINK TEXT)')
self.cur.execute('CREATE TABLE IF NOT EXISTS internal(NAME TEXT, ID INT)')
print('Loaded Completed table')
self.cur.execute('SELECT * FROM internal')
f = self.cur.fetchone()
if not f:
print('Database is new. Adding ID counter')
self.cur.execute('INSERT INTO internal VALUES(?, ?)', ['counter', 1])
self.idcounter = 1
else:
self.idcounter = f[1]
print('Current ID counter: ' + str(self.idcounter))
self.sql.commit()
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
w=853
h=480
x = (sw - w) / 2
y = (sh - h) / 2
self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y-50))
self.login()
def login(self):
try:
self.quitbutton.grid_forget()
self.quitbutton.grid(row=9000, column=0, columnspan=20)
self.option.grid(row=1,column=0,columnspan=80,pady=8)
self.updategui(fullclean=True)
except praw.errors.InvalidUserPass:
pass
print('Invalid username or password')
self.entryPassword.delete(0,200)
self.labelErrorPointer.grid(row=1, column=2)
def permaloop(self, *args):
#.........这里部分代码省略.........