本文整理汇总了Python中tkinter.Button.place方法的典型用法代码示例。如果您正苦于以下问题:Python Button.place方法的具体用法?Python Button.place怎么用?Python Button.place使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Button
的用法示例。
在下文中一共展示了Button.place方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_entries
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
def list_entries(self, Medikom, results, entry_type):
if entry_type == 0: # tasks (left column)
x = self.SPACE_TWO
else: # information (right column)
x = self.WIN_WIDTH / 2 + (.25 * self.SPACE_ONE)
for i, (id, ts, title) in enumerate(results):
ts = self.format_ts(ts)
task_button = Button(
self, text=ts + title, font='Courier 10', anchor='w',
command=Callable(self.view_details, Medikom, id))
task_button.place(
x=x, y=(i + 1) * (self.ROW_HIGHT + self.ROW_SPACE),
width=(self.WIN_WIDTH / 2) - (1.25 * self.SPACE_ONE),
height=self.ROW_HIGHT)
rm_task_button = Button(
self, text='√',
command=Callable(self.rm_entry, Medikom, id, title))
rm_task_button.place(
x=x + (self.WIN_WIDTH / 2) - (1.25 * self.SPACE_ONE),
y=(i + 1) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.SPACE_TWO, height=self.ROW_HIGHT)
# highlight selected entries and those with priority
if self.selected_id and (id == self.selected_id):
task_button.config(bg='lightblue')
rm_task_button.config(bg='lightblue')
if title.startswith('!'):
task_button.config(bg='IndianRed2')
rm_task_button.config(bg='IndianRed2')
示例2: Launcher
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
class Launcher(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Score viewer")
self.pack(fill=BOTH, expand=1)
self.okButton = Button(self, text="Open export", command=self.onClick)
self.okButton.place(relx=0.5, rely=0.5, anchor=CENTER)
def onClick(self):
fname = askopenfilename(filetypes=(("Scoreboard files", "*.sc"),
("All files", "*.*")))
if fname:
OpenReadScores(fname)
# try:
# OpenReadScores(fname)
# except:
# print("Failed to read file\n'%s'" % fname)
# print("Exception: " + str(sys.exc_info()[0]))
return
示例3: Application
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
class Application(object):
def __init__(self):
self.helper = YouDaoHelper()
self.window = Tk()
self.window.title(u'知了词典')
self.window.geometry("280x350+700+300")
# 输入框
self.entry = Entry(self.window)
self.entry.place(x=10, y=10, width=200, height=25)
# 提交按钮
self.submit_btn = Button(self.window, text=u'查询', command=self.submit)
self.submit_btn.place(x=220, y=10, width=50, height=25)
# 翻译结果标题
self.title_label = Label(self.window, text=u'翻译结果:')
self.title_label.place(x=10, y=55)
# 翻译结果
self.result_text = Text(self.window, background='#ccc')
self.result_text.place(x=10, y=75, width=260, height=265)
def submit(self):
# 1. 从输入框中获取用户输入的值
content = self.entry.get()
# 2. 把这个值发送给有道的服务器,进行翻译
result = self.helper.crawl(content)
# 3. 把结果放在底部的Text控件中
self.result_text.delete(1.0,END)
self.result_text.insert(END,result)
def run(self):
self.window.mainloop()
示例4: view_new_title
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
def view_new_title(self, Medikom, entry_type):
self.selected_id = False
self.overview(Medikom)
if entry_type == 0:
text = "Titel der neuen Aufgabe:"
elif entry_type == 1:
text = "Titel der neuen Information:"
details_label = Label(
self, text=text, font='Liberation 10',
fg='Black')
details_label.place(
x=self.SPACE_TWO / 2,
y=(self.n + 2) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH - self.SPACE_TWO, height=self.ROW_HIGHT)
textframe = Text(self, font='Liberation 12', height=1, width=int(self.WIN_WIDTH / 4))
textframe.place(
x=self.SPACE_TWO, y=(self.n + 3) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH - self.SPACE_ONE - 10, height=self.ROW_HIGHT)
create_button = Button(
self, text='Erstellen',
command=lambda: self.add_entry(Medikom, entry_type, textframe.get(1.0, END).strip()))
create_button.place(
x=(self.WIN_WIDTH / 2) - (self.WIN_WIDTH / 16),
y=(self.n + 4) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH / 8, height=self.ROW_HIGHT)
示例5: initUI
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
def initUI(self):
self.parent.title("Quit button")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
quitButton = Button(self, text="Quit",
command=self.quit)
quitButton.place(x=50, y=50)
示例6: initUI
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
def initUI(self):
self.parent.title("My Tool Client")
self.pack(fill=BOTH, expand=1)
quitButton = Button(self, text="Exit",
command=self.quit, padx=50, pady=30)
quitButton.place(x=674, y=0)
myToolLabel = Label(self, text="Welcome to MyTool!", font=("Helvetica",16), padx=50)
employeeName = Label(self, text="Julio", font=("Helvetica",10), padx=50)
myToolLabel.place(x=0, y=0)
employeeName.place(x=0, y=30)
dateAndTime = Label(self, text=time.asctime())
dateAndTime.place(x=0, y=50)
示例7: AddManually
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [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")
示例8: additems
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
def additems(i, doreturn=False, bgcolor="#555"):
returnable = []
for item in i:
global totalitems
totalitems += 1
ff = Frame(f, bg=bgcolor)
item.body = item.author.name + ' || ' + item.fullname + '\n' + item.body
item.body = str(totalitems) + '\n' + item.body
ibody = item.body.replace('\n\n', '\n')
ifinal = ''
for paragraph in ibody.split('\n'):
ifinal += '\n'.join(textwrap.wrap(paragraph))
ifinal += '\n'
item.body = ifinal
ww = 680
wh = 10
wx = 20
wy = 20
#print(ww, wh, wx, wy)
ff.ww = ww
ff.wh = wh
ff.wx = wx
ff.wy = wy
ff.body = item.body
ff.sourceitem = item
ff.configure(width=ww, height=wh)
ff.place(x=wx, y=wy)
ff.bind("<B1-Motion>", framedrag)
ff.bind("<ButtonRelease-1>", resetdrag)
ff.pack_propagate(0)
l = Label(ff, text=item.body, bg="#777")
l.place(x=10,y=10)
rt = Text(ff, width= 15, height= (len(ifinal.split('\n'))) - 2)
rt.sourceitem = item
rt.place(x=400,y=10)
rb = Button(ff, text="Reply", command= lambda rep=rt: reply(rep))
rb.place(x=400,y=wh-20)
ff.rt = rt
ff.rb = rb
if not doreturn:
widgets.append(ff)
else:
returnable.append(ff)
if doreturn:
return returnable
else:
refreshscreen()
示例9: overview
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
def overview(self, Medikom):
# get content
tasks_results, information_results = Medikom.get_titles()
# clear screen
canvas = Canvas(self, width=self.WIN_WIDTH, height=self.WIN_HIGHT * 2)
canvas.place(x=0, y=0)
# headers
tasks_label = Label(self, text='Aufgaben', font='Liberation 14')
tasks_label.place(
x=0, y=0, width=self.WIN_WIDTH/2, height=self.ROW_HIGHT)
info_label = Label(self, text='Informationen', font='Liberation 14')
info_label.place(
x=self.WIN_WIDTH/2, y=0,
width=self.WIN_WIDTH/2, height=self.ROW_HIGHT)
self.list_entries(Medikom, tasks_results, 0)
self.list_entries(Medikom, information_results, 1)
# lower window part
canvas.create_line(
self.SPACE_ONE, (self.n + 1.5) * (self.ROW_HIGHT + self.ROW_SPACE),
self.WIN_WIDTH - self.SPACE_ONE, (self.n + 1.5) * (self.ROW_HIGHT + self.ROW_SPACE),
fill='#000001', width=1)
add_task_button = Button(self, text='+',
command=Callable(self.view_new_title, Medikom, 0))
add_task_button.place(
x=self.WIN_WIDTH / 4 - self.SPACE_TWO / 2,
y=self.n * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.SPACE_TWO, height=self.ROW_HIGHT)
add_info_button = Button(self, text='+',
command=Callable(self.view_new_title, Medikom, 1))
add_info_button.place(
x=0.75 * self.WIN_WIDTH - self.SPACE_TWO / 2,
y=self.n * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.SPACE_TWO, height=self.ROW_HIGHT)
if self.selected_id is None:
selection_label = Label(
self, text='Kein Eintrag ausgewählt.', font='Liberation 10')
selection_label.place(
x=self.WIN_WIDTH / 2 - 0.125 * self.WIN_WIDTH,
y=(self.n + 1) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH / 4, height=self.ROW_HIGHT)
示例10: _init_ui
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
def _init_ui(self):
# Label to specify video link
lbl_video_url = Label(self, text="Video URL:")
lbl_video_url.place(x=20, y=20)
# Entry to enter video url
entr_video_url = Entry(self, width=50, textvariable=self._video_url)
entr_video_url.place(x=100, y=20)
# Checkbutton to extract audio
cb_extract_audio = Checkbutton(self, var=self._extract_audio, text="Only keep audio")
cb_extract_audio.pack()
cb_extract_audio.place(x=20, y=60)
# Button to browse for location
b_folder_choose = Button(self, text="Choose output directory", command=self.ask_directory)
b_folder_choose.place(x=150, y=90)
# Button to start downloading
b_start_download = Button(self, text="Start download", command=self.download)
b_start_download.place(x=20, y=90)
# Log window to log progress
self._logger.place(x=20, y=130)
示例11: __init__
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
class _Testdialog:
"""Only used to test dialog from CLI"""
def __init__(self, master):
"""Initialize CLI test GUI"""
frame = Frame(master, width=300, height=300)
frame.pack()
self.master = master
self.x, self.y, self.w, self.h = -1, -1, -1, -1
self.Button_1 = Button(text="Test Dialog", relief="raised", width="15")
self.Button_1.place(x=84, y=36)
self.Button_1.bind("<ButtonRelease-1>", self.Button_1_Click)
def Button_1_Click(self, event): #click method for component ID=1
"""Launch Select_Py_Version for CLI testing."""
rbL = ['2.5.5', '2.6.6', 'PYPY 3.2.2']
dialog = Select_Py_Version(self.master, "Test Dialog", dialogOptions={'rbL':rbL})
print( '===============Result from Dialog====================' )
print( dialog.result)
print( '=====================================================' )
示例12: view_edit_title
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
def view_edit_title(self, Medikom, id, old_title, *__):
self.overview(Medikom)
text = "Neuer Titel des Eintrags:"
details_label = Label(
self, text=text, font='Liberation 10',
fg='Black')
details_label.place(
x=self.SPACE_TWO / 2,
y=(self.n + 2) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH - self.SPACE_TWO, height=self.ROW_HIGHT)
textframe = Text(self, font='Liberation 12', height=1, width=int(self.WIN_WIDTH / 4))
textframe.place(
x=self.SPACE_TWO, y=(self.n + 3) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH - self.SPACE_ONE - 10, height=self.ROW_HIGHT)
textframe.insert(END, old_title)
create_button = Button(
self, text='Aktualisieren',
command=lambda: self.update_entry_title(Medikom, id, textframe.get(1.0, END).strip()))
create_button.place(
x=(self.WIN_WIDTH / 2) - (self.WIN_WIDTH / 16),
y=(self.n + 4) * (self.ROW_HIGHT + self.ROW_SPACE),
width=self.WIN_WIDTH / 8, height=self.ROW_HIGHT)
示例13: game
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
class game(object):
def __init__(self):
self.root = Tk()
self.root["width"]=logix.WIDTH*(CARDW+PAD)+3*PAD
self.root["height"]=logix.HEIGHT*(CARDH+PAD)+3*PAD + 50
self.root.title("Unocolour")
self.mainscreen()
self.root.mainloop()
def mainscreen(self):
self.gamename = tkinter.Label(self.root, text = "UNOCOLOUR", font = ("Ariel", 24))
self.gamename.place(x=(logix.WIDTH*(CARDW+PAD)+3*PAD-400)//2, y=10, width = 400, height = 25)
self.startbutton = Button(text = "Start", command=self.startgame)
self.startbutton.place(x=(logix.WIDTH*(CARDW+PAD)+3*PAD-100)//2, y=60, width = 100, height = 25)
def startgame(self):
self.cardcounter = tkinter.Label(text = "Cards: 108")
self.cardcounter.place(x=10, y=25)
self.lvltitle = tkinter.Label(text = "Level I")
self.lvltitle.place(x=10, y=10)
self.b=board(self.root, self)
self.b.place(x=10,y=50)
self.startbutton.destroy()
del self.startbutton
def endgame(self):
self.b.destroy()
self.cardcounter.destroy()
self.lvltitle.destroy()
del self.b, self.cardcounter, self.lvltitle
self.mainscreen()
def update_counter(self, n):
self.cardcounter["text"] = "Cards: {}".format(n)
def update_level(self, n):
self.lvltitle["text"] = "Level {}".format(romanik(n))
示例14: __init__
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
class Gui:
def __init__(self, master):
self.arduino = None
self.port = "COM7"
self.updater = Thread()
self.windowframe = Frame(master)
self.port_entry = Entry(self.windowframe)
self.port_label = Label(self.windowframe, text="COM Port:")
self.arduino_connect_button = Button(self.windowframe, text="Connect Arduino", command=self.connect_arduino)
self.start_button = Button(self.windowframe, text="Start", command=self.start)
self.stop_Button = Button(self.windowframe, text="Exit", command=master.destroy)
self.temperature_plot = Plot(self.windowframe, "Time [min]", "T\n\n°C", 500)
self.place_widgets()
def place_widgets(self):
self.windowframe.place(x=10, y=10, width=500, height=560)
self.port_label.place(x=0, y=0, height=25, width=160)
self.port_entry.place(x=170, y=0, height=25, width=160)
self.arduino_connect_button.place(x=340, y=0, width=160, height=25)
self.start_button.place(x=0, y=30, width=245, height=25)
self.stop_Button.place(x=255, y=30, height=25, width=245)
self.temperature_plot.place(x=0, y=60, height=500, width=500)
def connect_arduino(self):
if self.port_entry.get() != "":
self.port = self.port_entry.get()
self.arduino = Arduino(self.port)
sleep(1)
def start(self):
def update():
start_time = datetime.now()
while True:
thermocouple_temperature = self.arduino.thermocouple_temperature.get()
runtime = (datetime.now() - start_time).seconds / 60.0
self.temperature_plot.add_datapoint(runtime, thermocouple_temperature)
self.updater._target = update
self.updater.start()
self.arduino.start_updater()
示例15: ReadFromFile
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import place [as 别名]
class ReadFromFile(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.controller = controller
self.link_first = True
self.items = []
self.place(relx=0.0, rely=0.0, relheight=0.62, relwidth=0.72)
self.configure(relief=GROOVE)
self.configure(borderwidth="2")
label_top = Label(self)
label_top.place(relx=0.42, rely=0.03, height=21, width=105)
label_top.configure(text="Select a file to read")
self.file_select = Button(self, command=self.fopen)
self.file_select.place(relx=0.43, rely=0.14, height=34, width=97)
self.file_select.configure(text="Select file")
self.back = Button(self, command=lambda: controller.show_frame('Main'))
self.back.place(relx=0.8, rely=0.87, height=34, width=97)
self.back.configure(text="Go back")
self.delimeter = Entry(self)
self.delimeter.place(relx=0.02, rely=0.11, relheight=0.06, relwidth=0.21)
self.delimeter.insert(0, ' -<>- ')
label_delim = Label(self)
label_delim.place(relx=0.02, rely=0.03, height=21, width=57)
label_delim.configure(text="Delimeter")
self.switch_label = Label(self)
self.switch_label.place(relx=0.73, rely=0.31, height=21, width=38)
self.switch_label.configure(text="Link")
self.switch_label2 = Label(self)
self.switch_label2.place(relx=0.9, rely=0.31, height=21, width=38)
self.switch_label2.configure(text="Name")
self.change_order = Button(self, command=self.switch_order)
self.change_order.place(relx=0.82, rely=0.31, height=24, width=32)
self.change_order.configure(text="<->")
name_or_link = Label(self)
name_or_link.place(relx=0.75, rely=0.19, height=21, width=97)
name_or_link.configure(text="Name or link first")
self.items_text = Text(self)
self.items_text.place(relx=0.02, rely=0.5, relheight=0.46, relwidth=0.76)
self.items_text.configure(wrap=tk.WORD)
label_items = Label(self)
label_items.place(relx=0.35, rely=0.42, height=21, width=35)
label_items.configure(text="Items")
self.commit_btn = Button(self, command=self.commit)
self.commit_btn.place(relx=0.83, rely=0.64, height=34, width=67)
self.commit_btn.configure(text="Commit")
self.Label12 = Label(self)
self.Label12.place(relx=0.02, rely=0.19, height=21, width=88)
self.Label12.configure(text="Link formatting (optional)")
self.link_part1 = Entry(self, fg='grey')
self.link_part1.place(relx=0.02, rely=0.28, relheight=0.06, relwidth=0.37)
self.link_part1.insert(0, "Start of the link here")
self.link_part1.bind('<Button-1>', lambda event: greytext(self.link_part1))
self.link_part2 = Entry(self, fg='grey')
self.link_part2.place(relx=0.02, rely=0.36, relheight=0.06, relwidth=0.37)
self.link_part2.insert(0, "End of the link here")
self.link_part2.bind('<Button-1>', lambda event: greytext(self.link_part2))
def fopen(self):
filename = askopenfilename()
if filename == '':
return
self.items.clear()
self.items_text.delete(1.0, 'end')
with open(filename, encoding='utf-8-sig') as f:
lines = f.read().splitlines()
delim = self.delimeter.get()
for line in lines:
try:
link, name = line.split(delim, 1)
if not self.link_first:
name, link = link, name
if '{DELETED} ' in name[:13]:
continue
s, e = self.get_link_formatting()
link = s + link + e
self.items += [(link, name)]
self.items_text.insert('end', ("name: " + name + "\nlink: " +
link + '\n\n'))
except ValueError:
print("Something went wrong: ", line)
def get_link_formatting(self):
#.........这里部分代码省略.........