本文整理汇总了Python中tkinter.ttk.Label类的典型用法代码示例。如果您正苦于以下问题:Python Label类的具体用法?Python Label怎么用?Python Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Label类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: Example
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Listbox")
self.pack(fill=BOTH, expand=1)
acts = ['Scarlett Johansson', 'Rachel Weiss',
'Natalie Portman', 'Jessica Alba']
lb = Listbox(self)
for i in acts:
lb.insert(END, i)
lb.bind("<<ListboxSelect>>", self.onSelect)
lb.place(x=20, y=20)
self.var = StringVar()
self.label = Label(self, text=0, textvariable=self.var)
self.label.place(x=20, y=210)
def onSelect(self, val):
sender = val.widget
idx = sender.curselection()
value = sender.get(idx)
self.var.set(value)
开发者ID:KimBoWoon,项目名称:Python_Practice,代码行数:32,代码来源:TKBook.py
示例2: initUI
def initUI(self):
self.username = ''
self.r = praw.Reddit(USERAGENT)
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.login(self.entryUsername.get()))
self.entryUsername.bind('<Up>', lambda event: self.entryUsername.insert(0, self.username))
self.quitbutton = Button(self, text="Quit", command= lambda: self.quit())
self.quitbutton.config(width=6)
self.labelKarma = Label(self, text = '•')
self.labelKarma.grid(row = 3, column = 1)
self.labelU.grid(row=0, column=0)
self.entryUsername.grid(row=0, column=1)
self.quitbutton.grid(row=2, column=1, pady=4)
self.usernamelabel = Label(self, text='')
self.usernamelabel.grid(row=1, column=1)
开发者ID:Ortharn,项目名称:reddit,代码行数:31,代码来源:karmacount.py
示例3: Form
class Form(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.parent.title("Example Form")
self.pack(fill=BOTH, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='First Name', width=10)
l.pack(side=LEFT, padx=5, pady=5)
self.firstName = Entry(f)
self.firstName.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='Last Name', width=10)
l.pack(side=LEFT, padx=5, pady=5)
self.lastName = Entry(f)
self.lastName.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='Full Name', width=10)
l.pack(side=LEFT, padx=5, pady=5)
self.fullName = Label(f, text='ALEX POOPKIN', width=10)
self.fullName.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='', width=10)
l.pack(side=LEFT, padx=5, pady=0)
self.errorMessage = Label(f, text='Invalid character int the name!', foreground='red', width=30)
self.errorMessage.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
b = Button(f, text='Close', command=lambda : self.parent.quit())
b.pack(side=RIGHT, padx=5, pady=10)
b['default'] = ACTIVE
b.focus_set()
self.clearButton = Button(f, text='Clear')
self.clearButton.pack(side=RIGHT, padx=5, pady=10)
self.clearButton['state'] = DISABLED
self.sendButton = Button(f, text='Send')
self.sendButton.pack(side=RIGHT, padx=5, pady=10)
开发者ID:alex-kooper,项目名称:knockouttk,代码行数:60,代码来源:form.py
示例4: initUI
def initUI(self):
self.parent.title("Windows")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.columnconfigure(1, weight=1)
self.columnconfigure(3, pad=7)
self.rowconfigure(6, weight=1)
self.rowconfigure(5, pad=7)
lbl = Label(self, text="BookManager")
lbl.grid(sticky=W, pady=4, padx=5)
self.area = Text(self) #WHITE TEXT BOX
self.area.grid(row=1, column=0, columnspan=3, rowspan=4,
padx=5, sticky=E+W+S+N)
abtn = Button(self, text="add", command=self.press_add)
abtn.grid(row=1, column=3)
srcbtn = Button(self, text="search", command=self.press_search)
srcbtn.grid(row=2, column=3, pady=3)
rbtn = Button(self, text="remove", command=self.press_remove)
rbtn.grid(row=3, column=3, pady=3)
sbtn = Button(self, text="show all", command=self.press_show)
sbtn.grid(row=4, column=3, pady=3)
开发者ID:damidam125,项目名称:forPYTHON,代码行数:29,代码来源:make_gui.py
示例5: OkFrame
class OkFrame(MessageFrame):
def __init__(self, master, config):
super(OkFrame, self).__init__(master, config)
if config.full_screen:
self._make_full(master)
self.master.grid_rowconfigure(0, weight=1)
self.master.grid_rowconfigure(1, weight=1)
self.master.grid_columnconfigure(0, weight=1)
self._frame_lbl = Label(
self.master,
text='',
anchor='center',
font=self._config.item_font
)
self._frame_lbl.grid(row=0, column=0, sticky='snew')
self._next_btn = Button(
self.master,
text='OK',
command=self._next_cmd
)
self._next_btn.grid(row=1, column=0, sticky='snew')
def show(master, config, msg):
new_window = Toplevel(master)
dlg = OkFrame(new_window, config)
dlg._frame_lbl['text'] = msg
def _next_cmd(self):
self._master.destroy()
开发者ID:aphistic,项目名称:copilot,代码行数:33,代码来源:message.py
示例6: initUI
def initUI(self):
self.parent.title("Windows")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.columnconfigure(1, weight=1)
self.columnconfigure(3, pad=7)
self.rowconfigure(3, weight=1)
self.rowconfigure(5, pad=7)
lbl = Label(self, text="Windows")
lbl.grid(sticky=W, pady=4, padx=5)
area = Text(self)
area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N)
abtn = Button(self, text="Activate")
abtn.grid(row=1, column=3)
cbtn = Button(self, text="Close")
cbtn.grid(row=2, column=3, pady=4)
hbtn = Button(self, text="Help")
hbtn.grid(row=5, column=0, padx=5)
obtn = Button(self, text="OK")
obtn.grid(row=5, column=3)
开发者ID:Austin-Xie,项目名称:python-cave,代码行数:29,代码来源:Window.py
示例7: create_widgets
def create_widgets(self):
''' Creates appropriate widgets on this frame.
'''
self.columnconfigure(0, weight=1)
self.rowconfigure(3, weight=1)
frame_for_save_btn = Frame(self)
frame_for_save_btn.columnconfigure(1, weight=1)
self.status_lbl = Label(frame_for_save_btn, text='')
self.status_lbl.grid(row=0, column=1, sticky=N+W)
save_solution_btn = Button(frame_for_save_btn, text='Save solution',
command=self.on_save_solution)
save_solution_btn.grid(row=1, column=0, sticky=W+N, padx=5, pady=5)
self.progress_bar = Progressbar(frame_for_save_btn,
mode='determinate', maximum=100)
self.progress_bar.grid(row=1, column=1, sticky=W+E, padx=10, pady=5)
frame_for_save_btn.grid(sticky=W+N+E+S, padx=5, pady=5)
frame_for_btns = Frame(self)
self._create_file_format_btn('*.xlsx', 1, frame_for_btns, 0)
self._create_file_format_btn('*.xls', 2, frame_for_btns, 1)
self._create_file_format_btn('*.csv', 3, frame_for_btns, 2)
self.solution_format_var.set(1)
frame_for_btns.grid(row=1, column=0, sticky=W+N+E+S, padx=5, pady=5)
self.data_from_file_lbl = Label(self, text=TEXT_FOR_FILE_LBL, anchor=W,
justify=LEFT,
wraplength=MAX_FILE_PARAMS_LBL_LENGTH)
self.data_from_file_lbl.grid(row=2, column=0, padx=5, pady=5,
sticky=W+N)
self.solution_tab = SolutionFrameWithText(self)
self.solution_tab.grid(row=3, column=0, sticky=W+E+S+N, padx=5, pady=5)
开发者ID:nishimaomaoxiong,项目名称:pyDEA,代码行数:33,代码来源:solution_tab_frame_gui.py
示例8: DateWidget
class DateWidget(Frame):
"""Gets a date from the user."""
def __init__(self, master):
"""Make boxes, register callbacks etc."""
Frame.__init__(self, master)
self.label = Label(self, text="När är du född?")
self.label.pack()
self.entry_text = StringVar()
self.entry_text.trace("w", lambda *args: self.onEntryChanged())
self.entry = Entry(self, width=date_entry_width,
textvariable=self.entry_text)
self.entry.insert(0, "ÅÅÅÅ-MM-DD")
self.entry.pack(pady=small_pad)
self.button = Button(self, text="Uppdatera",
command=lambda: self.onDateChanged())
self.button.pack()
self.entry.focus_set()
self.entry.select_range(0, END)
self.entry.bind("<Return>", lambda x: self.onDateChanged())
def setListener(self, pred_view):
"""Select whom to notify when a new date is entered."""
self.pred_view = pred_view
def onDateChanged(self):
"""Notifies the PredictionWidget that the date has been changed."""
try:
date = datetime.datetime.strptime(self.entry.get(),
"%Y-%m-%d").date()
self.pred_view.update(date)
except ValueError:
self.entry.configure(foreground="red")
def onEntryChanged(self):
"""Reset the text color."""
self.entry.configure(foreground="")
开发者ID:JoelSjogren,项目名称:horoskop,代码行数:33,代码来源:main.py
示例9: StatusBar
class StatusBar(TagReaderListener):
def __init__(self, master):
super().__init__()
self.label = Label(master, text='', anchor=W)
self.label.pack()
self.index = 0
self.expected_count = 0
def start_task(self, text):
self.label['text'] = text + "..."
def task_complete(self):
self.label['text'] += 'Done'
def read_complete(self, elapsed_time):
self.set("{} files read in {} milliseconds".format(self.expected_count, round(elapsed_time, 2)))
def read_start(self, count):
self.expected_count = count
self.index = 0
self.set("Reading tags in {} files".format(self.expected_count))
def file_read(self, file):
self.index += 1
percent = round(100 * self.index / self.expected_count, 2)
self.set("Reading tags in {} files: {}%".format(self.expected_count, percent))
def counting_files(self):
self.set("Counting files...")
def set(self, text: str):
self.label['text'] = text
开发者ID:realmassy,项目名称:MusicLibrary,代码行数:32,代码来源:ui.py
示例10: PredictionWidget
class PredictionWidget(Frame):
"""Shows a prediction to the user."""
def __init__(self, master):
"""Make boxes, register callbacks etc."""
Frame.__init__(self, master)
self.active_category = StringVar()
self.bind("<Configure>", self.onResize)
self.date = None
self.predictor = Predictor()
self.category_buttons = self.createCategoryButtons()
self.text = Label(self, justify=CENTER, font="Arial 14")
def createCategoryButtons(self):
"""Create the buttons used to choose category. Return them."""
result = []
icons = self.readIcons()
categories = self.predictor.categories()
for i in categories:
if i in icons:
icon = icons[i]
else:
icon = icons["= default ="]
category_button = Radiobutton(self, image=icon,
variable=self.active_category, value=i, indicatoron=False,
width=icon_size, height=icon_size, command=self.update)
category_button.image_data = icon
result.append(category_button)
self.active_category.set(categories[0])
return result
def readIcons(self):
"""Read the gui icons from disk. Return them."""
result = {}
categories = open(nextToThisFile("icons.txt")).read().split("\n\n")
for i in categories:
category_name, file_data = i.split("\n", maxsplit=1)
image = PhotoImage(data=file_data)
result[category_name] = image
return result
def onResize(self, event):
"""Rearrange the children when the geometry of self changes."""
if event.widget == self:
center = (event.width / 2, event.height / 2)
radius = min(center) - icon_size / 2
self.text.place(anchor=CENTER, x=center[0], y=center[1])
for i, j in enumerate(self.category_buttons):
turn = 2 * math.pi
angle = turn * (1 / 4 - i / len(self.category_buttons))
j.place(anchor=CENTER,
x=center[0] + math.cos(angle) * radius,
y=center[1] - math.sin(angle) * radius)
def update(self, date=None):
"""Change contents based on circumstances. Set date if given."""
if date:
self.date = date
if self.date:
predictions = self.predictor.predict(self.date)
prediction = predictions[self.active_category.get()]
prediction = textwrap.fill(prediction, width=20)
else:
prediction = ""
self.text.configure(text=prediction)
开发者ID:JoelSjogren,项目名称:horoskop,代码行数:60,代码来源:main.py
示例11: __init__
def __init__(self, url):
self.url = url
self.root = Tk()
self.root.title("验证码")
while True:
try:
image_bytes = urlopen(self.url).read()
break
except socket.timeout:
print('获取验证码超时:%s\r\n重新获取.' % (self.url))
continue
except urllib.error.URLError as e:
if isinstance(e.reason, socket.timeout):
print('获取验证码超时:%s\r\n重新获取.' % (self.url))
continue
# internal data file
data_stream = io.BytesIO(image_bytes)
# open as a PIL image object
self.pil_image = Image.open(data_stream)
# convert PIL image object to Tkinter PhotoImage object
self.tk_image = ImageTk.PhotoImage(self.pil_image)
self.label = Label(self.root, image=self.tk_image, background='brown')
self.label.pack(padx=5, pady=5)
self.button = Button(self.root, text="刷新验证码", command=self.refreshImg)
self.button.pack(padx=5, pady=5)
randCodeLable = Label(self.root, text="验证码:")
randCodeLable.pack(padx=5, pady=5)
self.randCode = Entry(self.root)
self.randCode.pack(padx=5, pady=5)
self.loginButton = Button(self.root, text="登录", default=tkinter.ACTIVE)
self.loginButton.pack(padx=5, pady=5)
开发者ID:stonezyl,项目名称:urbtix,代码行数:35,代码来源:LoginUI.py
示例12: create_widgets
def create_widgets(self): # Call from override, if any.
# Bind to self widgets needed for entry_ok or unittest.
self.frame = frame = Frame(self, padding=10)
frame.grid(column=0, row=0, sticky='news')
frame.grid_columnconfigure(0, weight=1)
entrylabel = Label(frame, anchor='w', justify='left',
text=self.message)
self.entryvar = StringVar(self, self.text0)
self.entry = Entry(frame, width=30, textvariable=self.entryvar)
self.entry.focus_set()
self.error_font = Font(name='TkCaptionFont',
exists=True, root=self.parent)
self.entry_error = Label(frame, text=' ', foreground='red',
font=self.error_font)
self.button_ok = Button(
frame, text='OK', default='active', command=self.ok)
self.button_cancel = Button(
frame, text='Cancel', command=self.cancel)
entrylabel.grid(column=0, row=0, columnspan=3, padx=5, sticky=W)
self.entry.grid(column=0, row=1, columnspan=3, padx=5, sticky=W+E,
pady=[10,0])
self.entry_error.grid(column=0, row=2, columnspan=3, padx=5,
sticky=W+E)
self.button_ok.grid(column=1, row=99, padx=5)
self.button_cancel.grid(column=2, row=99, padx=5)
开发者ID:1st1,项目名称:cpython,代码行数:27,代码来源:query.py
示例13: __init__
def __init__(self, pipepanel, pipeline_name, *args, **kwargs) :
PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs)
self.pairs = None
eframe = self.eframe = LabelFrame(self,text="Options")
#,fg=textLightColor,bg=baseColor)
eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 )
label = Label(eframe,text="Pipeline")#,fg=textLightColor,bg=baseColor)
label.grid(row=3,column=0,sticky=W,padx=10,pady=5)
PipelineLabels = ['Initial QC',
'Germline',
'Somatic Tumor-Normal',
'Somatic Tumor-Only']
Pipelines=["initialqcgenomeseq",
"wgslow",
'wgs-somatic',
'wgs-somatic-tumoronly']
self.label2pipeline = { k:v for k,v in zip(PipelineLabels, Pipelines)}
PipelineLabel = self.PipelineLabel = StringVar()
Pipeline = self.Pipeline = StringVar()
PipelineLabel.set(PipelineLabels[0])
#om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller)
om = OptionMenu(eframe, PipelineLabel, *PipelineLabels, command=self.option_controller)
om.config()#bg = widgetBgColor,fg=widgetFgColor)
om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor)
#om.pack(side=LEFT,padx=20,pady=5)
om.grid(row=3,column=1,sticky=W,padx=10,pady=5)
开发者ID:jlac,项目名称:Pipeliner,代码行数:31,代码来源:genomeseq.py
示例14: build_widgets
def build_widgets(self):
"Build the various widgets that will be used in the program."
# Create processing frame widgets.
self.processing_frame = LabelFrame(self, text='Processing Mode:')
self.mode_var = StringVar(self, 'encode')
self.decode_button = Radiobutton(self.processing_frame,
text='Decode Cipher-Text',
command=self.handle_radiobuttons,
value='decode',
variable=self.mode_var)
self.encode_button = Radiobutton(self.processing_frame,
text='Encode Plain-Text',
command=self.handle_radiobuttons,
value='encode',
variable=self.mode_var)
self.freeze_var = BooleanVar(self, False)
self.freeze_button = Checkbutton(self.processing_frame,
text='Freeze Key & Primer',
command=self.handle_checkbutton,
offvalue=False,
onvalue=True,
variable=self.freeze_var)
# Create encoding frame widgets.
self.encoding_frame = LabelFrame(self, text='Encoding Options:')
self.chain_size_label = Label(self.encoding_frame, text='Chain Size:')
self.chain_size_entry = Entry(self.encoding_frame)
self.plain_text_label = Label(self.encoding_frame, text='Plain-Text:')
self.plain_text_entry = Entry(self.encoding_frame)
# Create input frame widgets.
self.input_frame = LabelFrame(self, text='Input Area:')
self.input_text = ScrolledText(self.input_frame, **self.TEXT)
# Create output frame widgets.
self.output_frame = LabelFrame(self, text='Output Area:')
self.output_text = ScrolledText(self.output_frame, **self.TEXT)
开发者ID:jacob-carrier,项目名称:code,代码行数:34,代码来源:recipe-578076.py
示例15: setup_gui
def setup_gui(self):
self.parent.title("Stein - Saks - Papir")
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
# Label for rapportering
label = Label(self.parent, textvariable=self.resultat_label)
label.place(x=800, y=50)
# Buttons
# Disse fyrer av metoden self.arranger_enkeltspill som er
# definert i klassen. Denne metoden tar aksjonen til mennesket
# som startup, og gjennomfoerer spillet
# Samme type oppfoersel for de tre aksjons-knappene
rock_button = Button(self, text="Stein",
command=lambda: self.arranger_enkeltspill(Action("rock")))
rock_button.place(x=800, y=400)
scissors_button = Button(self, text="Saks",
command=lambda: self.arranger_enkeltspill(Action("scissor")))
scissors_button.place(x=900, y=400)
paper_button = Button(self, text="Papir",
command=lambda: self.arranger_enkeltspill(Action("paper")))
paper_button.place(x=1000, y=400)
# quit_button avslutter GUI'et naar den trykkes
quit_button = Button(self, text="Quit", command=self.quit)
quit_button.place(x=1000, y=450)
# Embedde en graf i vinduet for aa rapportere fortloepende score
self.fig = FigureCanvasTkAgg(pylab.figure(), master=self)
self.fig.get_tk_widget().grid(column=0, row=0)
self.fig.show()
开发者ID:vhellem,项目名称:Plab,代码行数:28,代码来源:RockPaper.py
示例16: initialize_ui
def initialize_ui(self):
default_padding = {'padx': 10, 'pady' : 10}
customer_frame = Frame(self)
self.customer_id_label = Label(customer_frame, text = "Customer id:", style="BW.TLabel")
self.customer_id_label.pack(default_padding, side = LEFT)
self.customer_id_value = Label(customer_frame,style="BW.TLabel")
self.customer_id_value["textvariable"] = self.controller.customer_id
self.customer_id_value.pack(default_padding, side = LEFT)
customer_frame.pack(expand = True, fill = "x")
self.take_picture_frame = Frame(self, border = 10)
self.picture_mode = IntVar()
Radiobutton(self.take_picture_frame, text = "Light", variable = self.picture_mode, value = 1).pack(side = LEFT)
Radiobutton(self.take_picture_frame, text = "Dark", variable = self.picture_mode, value = 2).pack(side = LEFT)
self.button_take_picture = Button(self.take_picture_frame, text = "Take picture", command = self.take_picture)
self.button_take_picture.pack(expand = True, fill = "x", side = BOTTOM)
self.take_picture_frame.pack(expand = True)
self.button_update = Button(self, text = "Update", command = self.controller.run_update_script)
self.button_update.pack(expand = True, fill = "x")
开发者ID:khlumzeemee,项目名称:3dprinter,代码行数:26,代码来源:ApplicationMVC.py
示例17: Example
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Listbox")
self.pack(fill=BOTH, expand=1)
acts = ["Scarlett Johansson", "Rachel Weiss", "Natalie Portman", "Jessica Alba", "Angelina jolie", "Emma Stone", "Sandra Bullock", "Julia Roberts",
"Jennifer Lawrence", "Mila Kunis", "Jennifer Aniston", "Charlize Theron", "Cameron Diaz", "Nicole Kidman", "Meryl Streep", "Reese Witherspoon"]
lb = Listbox(self, selectmode="multiple")
for i in acts:
lb.insert(END, i)
lb.bind("<<ListboxSelect>>", self.onSelect)
lb.pack(pady=15)
self.var = StringVar()
self.label = Label(self, text=0, textvariable=self.var)
self.label.pack()
def onSelect(self, val):
sender = val.widget
idx = sender.curselection()
value = sender.get(idx)
self.var.set(value)
开发者ID:Exodus111,项目名称:Projects,代码行数:30,代码来源:listbox.py
示例18: insert_entry_field
def insert_entry_field(self, txt):
frame = Frame(self.frame)
frame.pack(fill="x")
label = Label(frame, text=txt, width=6)
label.pack(side="left", anchor="n", padx=5, pady=5)
entry = Entry(frame)
entry.pack(fill="x", padx=5, pady=5, expand=True)
self.entries["Entry"][txt] = entry
开发者ID:Exodus111,项目名称:Projects,代码行数:8,代码来源:main.py
示例19: __init__
def __init__(self, parent, url=None, buttonSEC=False, buttonRSS=False):
super(DialogURL, self).__init__(parent)
self.parent = parent
parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", parent.geometry())
dialogX = int(parentGeometry.group(3))
dialogY = int(parentGeometry.group(4))
self.accepted = False
self.url = None
self.transient(self.parent)
self.title("Enter URL")
self.urlVar = StringVar()
self.urlVar.set(url if url is not None else "http://")
frame = Frame(self)
urlLabel = Label(frame, text=_("URL:"), underline=0)
urlEntry = Entry(frame, textvariable=self.urlVar, width=60)
urlEntry.focus_set()
okButton = Button(frame, text=_("OK"), command=self.ok)
cancelButton = Button(frame, text=_("Cancel"), command=self.close)
if buttonSEC:
usSecButton = Button(frame, text=_("SEC search"), command=self.usSec)
usSecButton.grid(row=1, column=1, sticky=W, pady=3)
ToolTip(usSecButton, text=_("Opens US SEC Edgar Company Search (in web browser)\n\n"
"(1) Find the company in web browser,\n"
"(2) Click 'documents' button for desired filing,\n"
"(3) Find 'data files' panel, instance document row, 'document' column,\n"
"(4) On instance document file name, right-click browser menu: 'copy shortcut',\n"
"(5) Come back to this dialog window,\n"
"(6) Ctrl-v (paste) shortcut into above URL text box,\n"
"(7) Click ok button to load instance document"),
wraplength=480)
if buttonRSS:
rssButton = Button(frame, text=_("SEC RSS"), command=self.rssFeed)
rssButton.grid(row=1, column=1, pady=3)
ToolTip(rssButton, text=_("Opens current US SEC Edgar RSS feed"),
wraplength=480)
urlLabel.grid(row=0, column=0, sticky=W, pady=3, padx=3)
urlEntry.grid(row=0, column=1, columnspan=3, sticky=EW, pady=3, padx=3)
okButton.grid(row=1, column=2, sticky=E, pady=3)
ToolTip(okButton, text=_("Opens above URL from web cache, downloading to cache if necessary"), wraplength=240)
cancelButton.grid(row=1, column=3, sticky=EW, pady=3, padx=3)
ToolTip(cancelButton, text=_("Cancel operation"))
frame.grid(row=0, column=0, sticky=(N,S,E,W))
frame.columnconfigure(1, weight=1)
window = self.winfo_toplevel()
window.columnconfigure(0, weight=1)
self.geometry("+{0}+{1}".format(dialogX+50,dialogY+100))
self.bind("<Alt-u>", lambda *ignore: urlEntry.focus_set())
self.bind("<Return>", self.ok)
self.bind("<Escape>", self.close)
self.protocol("WM_DELETE_WINDOW", self.close)
self.grab_set()
self.wait_window(self)
开发者ID:Arelle,项目名称:Arelle,代码行数:56,代码来源:DialogURL.py
示例20: Main
class Main(Frame):
"""Main class for our browser.
Note that we inherit from Frame, making this a Frame object.
"""
def __init__(self, master):
Frame.__init__(self, master)
self.master = master
self.master.title("Browser")
self.header = {"User-Agent":"Tkinter Browser 0.1"}
# Here we make our widgets.
self.top_frame = Frame(self)
self.url_frame = Frame(self.top_frame)
self.url_label = Label(self.url_frame, text="Url: ", anchor="n")
self.url_entry = Entry(self.url_frame, width=80)
self.url_button = Button(self.url_frame, text="Go", command=self.go_button)
self.bottom_frame = Frame(self)
self.text_field = Text(self.bottom_frame)
#Here we pack our widgets.
self.top_frame.pack(side="top", padx=15, pady=15)
self.url_frame.pack(anchor="center")
self.bottom_frame.pack(side="bottom", fill="both", expand=True)
self.text_field.pack(side="bottom", fill="both", expand=True)
self.url_label.pack(side="left")
self.url_entry.pack(side="left", fill="x", expand=True)
self.url_button.pack(side="left", padx=5)
self.text_field.config(state="disabled", padx=5, pady=5)
def go_button(self):
url = self.url_entry.get()
if url:
if "http://" not in url:
url = "http://"+url
page_text = self.get_page(url)
self.text_field.config(state="normal")
self.text_field.delete(1.0, "end")
self.text_field.insert("end", page_text)
self.text_field.config(state="disable")
def get_page(self, url):
s = requests.Session()
resp = s.get(url, headers=self.header)
data = resp.text
soup = bs(data, "html.parser")
page_text = soup.find_all(text=True)
page_text = filter(self.visible, page_text)
return "".join([str(i)+'\n' for i in page_text])
def visible(self, e):
if e.parent.name in ('style', 'script', '[document]', 'head', 'title'):
return False
elif re.match('<!--.*-->', str(e.encode('utf-8'))):
return False
return True
开发者ID:Exodus111,项目名称:Projects,代码行数:56,代码来源:browser.py
注:本文中的tkinter.ttk.Label类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论