def _create_widgets(self):
# Gold standard data
self.gold_path_label = ttk.Label(text="Gold Standard:")
self.gold_path_entry = ttk.Entry(textvariable=self.gold_path)
self.gold_path_filebutton = ttk.Button(text="...", command=self.findgoldfile)
# Training data for language 1
self.lang1_train_path_label = ttk.Label(text="Language 1 Training Data:")
self.lang1_train_path_entry = ttk.Entry(textvariable=self.lang1_train_path)
self.lang1_train_path_filebutton = ttk.Button(text="...", command=self.findlang1trainfile)
# Training data for language 2
self.lang2_train_path_label = ttk.Label(text="Language 2 Training Data:")
self.lang2_train_path_entry = ttk.Entry(textvariable=self.lang2_train_path)
self.lang2_train_path_filebutton = ttk.Button(text="...", command=self.findlang2trainfile)
# Examination
self.examine_button = ttk.Button(text="Examine!", command=self.launch_main)
# Redirected ouput
self.output_frame = ttk.Frame()
self.output = tk.Text(master=self.output_frame)
self.output_scroll = ttk.Scrollbar(self.output_frame)
self.output.configure(yscrollcommand=self.output_scroll.set)
self.output_scroll.configure(command=self.output.yview)
self.redirected = Redirector(self.output)
python类Entry()的实例源码
eval_gui.py 文件源码
项目:python-tagger
作者: Bilingual-Annotation-Task-Force
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
Embed_tkinter.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def tkinterApp():
import tkinter as tk
from tkinter import ttk
win = tk.Tk()
win.title("Python GUI")
aLabel = ttk.Label(win, text="A Label")
aLabel.grid(column=0, row=0)
ttk.Label(win, text="Enter a name:").grid(column=0, row=0)
name = tk.StringVar()
nameEntered = ttk.Entry(win, width=12, textvariable=name)
nameEntered.grid(column=0, row=1)
nameEntered.focus()
def buttonCallback():
action.configure(text='Hello ' + name.get())
action = ttk.Button(win, text="Print", command=buttonCallback)
action.grid(column=2, row=1)
win.mainloop()
#==================================================================
def __init__(self, parent, text="Edit", does_resize=False, *args):
ttk.Label.__init__(self, parent, *args)
self.parent = parent
self._text = text
self._variable = tk.StringVar()
self.configure(textvariable=self._variable)
self._variable.set(self._text)
self._entry = ttk.Entry(self, textvariable=self._variable)
self.bind("<Double-Button-1>", self._edit, "+")
self.bind("<Enter>", lambda: self.configure(cursor="hand2"), "+")
self._entry.bind("<FocusOut>", self._confirm, "+")
self._entry.bind("<Return>", self._confirm, "+")
if does_resize:
self._entry.bind("<Key>", self._resize)
self._resize()
self.configure(width=self._entry.cget("width"))
def createWidgets(self):
#Configuration
ttk.Label(root, text='Server IP').grid(row=0, column=0, sticky='news')
ttk.Label(root, text='Interval (ms)').grid(row=0,column=1, sticky='news')
ttk.Entry(root, textvariable=self.serverIP).grid(row=1,column=0,sticky='news')
ttk.Entry(root, textvariable=self.interval).grid(row=1,column=1,sticky='news')
#Buttons
tk.Button(root, textvariable=self.connectedMessage, justify='center', command=self.connectToServer).\
grid(row=2,column=0,columnspan=2,sticky='news')
tk.Button(root, text='Open', justify='center', command=self.telematics.openFile).\
grid(row=3,column=0,sticky='news')
tk.Button(root, text='Save', justify='center', command=self.telematics.saveFile).\
grid(row=3,column=1,sticky='news')
#Variables
r = 4
for name, var in self.values.items():
ttk.Label(root, text=name, width=20).grid(row=r,column=0)
ttk.Label(root, textvariable=self.values[name], width=20).grid(row=r,column=1)
r = r + 1
def create_parameters_frame(self, parent):
parameters = ttk.Frame(master=parent, padding=STANDARD_MARGIN)
parameters.grid(sticky='nsew')
heading = ttk.Label(parameters, text='Analysis parameters')
heading.grid(column=0, row=0, sticky='n')
for i, param in enumerate(self.parameters, start=1):
param_label = ttk.Label(parameters, text=param._name)
param_label.grid(row=i, column=0, sticky='nsew')
if type(param) == tk.BooleanVar:
param_entry = ttk.Checkbutton(parameters, variable=param)
elif hasattr(param, '_choices'):
param_entry = ttk.OptionMenu(parameters, param, param.get(),
*param._choices.keys())
else:
param_entry = ttk.Entry(parameters, textvariable=param)
param_entry.grid(row=i, column=1, sticky='nsew')
def init_frame(self):
self.dbfile = ''
self.file_entry = ttk.Entry(self, width=25)
self.file_entry.grid(column=0, row=1, columnspan=2, sticky='W')
self.selecdb_button = ttk.Button(self, text='Browse',
command=self.select_file)
self.selecdb_button.grid(column=2, row=1, sticky='E')
self.usage_check = CheckButton(self)
self.usage_check.grid(column = 0, row = 2, sticky='E')
self.usage_label = ttk.Label(self, text='Load also usage sentences')
self.usage_label.grid(column = 1, row = 2, sticky='W')
self.load_button = ttk.Button(self, text='Load words',
command=self.load_words)
self.load_button.grid(column = 2, row = 2, sticky='W')
def init_frame(self):
ttk.Label(self, text='App id').grid(column=0, row=0)
self.appid_entry = ttk.Entry(self, width=30)
self.appid_entry.grid(column=1, row = 0)
ttk.Label(self, text='App key').grid(column=0, row=1)
self.keyid_entry = ttk.Entry(self, width=30)
self.keyid_entry.grid(column=1, row = 1)
self.load_button = ttk.Button(self, text='Load definitions from OED',
command=self.load_info)
self.load_button.grid(column=0, row=2, columnspan = 2, rowspan = 2)
# self.load_button.state(['disabled'])
try: # for lazines I store my OED credentials in a file
secrets = open('secrets')
self.appid_entry.insert(0, secrets.readline()[:-1])
self.keyid_entry.insert(0, secrets.readline()[:-1])
secrets.close()
except:
pass
def __init__(self, parent, *args, **kwargs):
GridFrame.__init__(self, parent, *args, **kwargs)
self.aLabel = ttk.Label(self, text='Initial:')
self.a = ttk.Entry(self, style='EntryStyle.TEntry')
self.add(self.aLabel, 0, 0)
self.add(self.a, 0, 1)
self.bLabel = ttk.Label(self, text='Final:')
self.b = ttk.Entry(self, style='EntryStyle.TEntry')
self.add(self.bLabel, 1, 0)
self.add(self.b, 1, 1)
self.cLabel = ttk.Label(self, text='Next:')
self.c = ttk.Entry(self, style='EntryStyle.TEntry')
self.add(self.cLabel, 2, 0)
self.add(self.c, 2, 1)
GridFrame.configure(self)
def __init__(self, master):
super().__init__()
self.master = master
self.title("Add new Language")
self.geometry("300x150")
self.name_label = ttk.Label(self, text="Language Name", anchor="center")
self.name_entry = ttk.Entry(self)
self.code_label = ttk.Label(self, text="Language Code", anchor="center")
self.code_entry = ttk.Entry(self)
self.submit_button = ttk.Button(self, text="Submit", command=self.submit)
self.name_label.pack(fill=tk.BOTH, expand=1)
self.name_entry.pack(fill=tk.BOTH)
self.code_label.pack(fill=tk.BOTH, expand=1)
self.code_entry.pack(fill=tk.BOTH, expand=1)
self.submit_button.pack(fill=tk.X)
def copy_bindings(widget1, widget2):
"""Add all bindings of *widget1* to *widget2*.
You may need to call ``copy_bindings(porcupine.get_main_window(), widget)``
on widgets that can be focused by clicking them, like ``Text`` and
``Entry`` widgets. Porcupine's keyboard bindings return ``'break'``
and are bound to the main window, and thus work by default, but in
some cases returning ``'break'`` doesn't do anything when the focus
is in another widget inside the main window.
"""
# tkinter's bind() can do quite a few different things depending
# on how it's invoked
for sequence in widget1.bind():
tcl_command = widget1.bind(sequence)
# add=True doesn't work if the command is a string :(
widget2.tk.call('bind', widget2, sequence, '+' + tcl_command)
# see docs/utils.rst for explanation and docs
def setup_tab2(tab):
# new frame
new_frame = ttk.LabelFrame(tab, text='New Project Name')
new_frame.grid(columnspan=2, row=0, padx=5, pady=5, sticky='ew')
# New Project
name = tk.StringVar
name_entered = ttk.Entry(new_frame, width=19, textvariable=name)
name_entered.grid(column=0, row=0, padx=6, pady=5)
name_entered.focus()
# spacer
spacer_label = ttk.Label(new_frame, text='')
spacer_label.grid(columnspan=2, row=1, padx=5, pady=5)
# add button and commands
def add_command():
add_project(name_entered.get())
spacer_label.configure(text='Project was added!', foreground='green')
name_entered.delete(0, "end")
setup_tab1(TAB_1)
TAB_1.update()
add_button = ttk.Button(tab, text='Add New Project', command=add_command)
add_button.grid(columnspan=2, row=3, pady=5)
def _show_history(self):
history_window = self._create_window('History')
history_window.resizable(height=False, width=False)
history_window.geometry('{0}x{1}+{2}+{3}'.format(200, 90, 300, 150))
history_label = ttk.Label(
history_window, text='Enter number: ', background=self.bg)
history_label.grid(row=0, column=0, padx=5, pady=5)
history_entry = ttk.Entry(history_window, width=10)
history_entry.grid(row=0, column=1, padx=5, pady=5)
history_entry.focus_set()
help_text = ttk.Label(history_window, text='Number of files (in history) to view.\n\nPress Enter when done.',
background=self.bg, foreground="#C0C0C0", anchor=CENTER, justify='center')
help_text.grid(row=1, column=0, columnspan=2, padx=5, pady=5)
history_window.bind('<Return>',
lambda event, entry_widget=history_entry, window=history_window: self._evaluate(event, entry_widget, window))
history_window.bind('<KP_Enter>',
lambda event, entry_widget=history_entry, window=history_window: self._evaluate(event, entry_widget, window))
def restrict_access_button(self, gs):
"""Expand frame to reveal options when Restrict Read Access is selected."""
if self.access_button_var.get() == 1:
self.group_name_label = ttk.Label(self.access_frame,
width=20,
anchor=tk.E,
text='Group Name ')
self.group_name_label.grid(row=2, column=0, sticky='e')
self.group_name_label.grid_configure(pady=5)
self.group_name_var = tk.StringVar()
self.group_name_entry = ttk.Entry(self.access_frame,
width=20,
textvariable=self.group_name_var)
self.group_name_entry.grid(row=2, column=1, sticky='w')
self.group_name_entry.grid_configure(pady=5)
self.group_name_var.set('member')
else:
self.group_name_label.destroy()
self.group_name_entry.destroy()
def __init__(self, parent):
"""Send messages from the bot
Args:
parent:
"""
super(ChatFrame, self).__init__(parent, padding=8, text="Chat")
self.channel = tk.StringVar()
self.message = tk.StringVar()
self.channel_frame = ttk.Frame(self)
self.channel_frame.grid(column=0, row=0, sticky="W E")
self.channel_label = ttk.Label(self.channel_frame, text="Channel ID:")
self.channel_label.grid(column=0, row=0, sticky="W E")
self.channel_box = ttk.Entry(self.channel_frame, textvariable=self.channel)
self.channel_box.grid(column=0, row=1, sticky="W E")
self.channel_frame.columnconfigure(0, weight=1)
self.message_frame = ttk.Frame(self)
self.message_frame.grid(column=0, row=1, pady=8, sticky="W E")
self.message_label = ttk.Label(self.message_frame, text="Message:")
self.message_label.grid(column=0, row=0, sticky="W E")
self.message_box = ttk.Entry(self.message_frame, textvariable=self.message)
self.message_box.grid(column=0, row=1, sticky="W E")
self.message_frame.columnconfigure(0, weight=1)
self.send_button = ttk.Button(self, command=lambda: self.add_current_message(), text="Send")
self.send_button.grid(column=0, row=2, sticky="W")
self.columnconfigure(0, weight=1)
def __init__(self, parent):
"""
Create a new UI for the module
Args:
parent: A tk or ttk object
"""
super(ModuleUIFrame, self).__init__(parent)
self.columnconfigure(0, weight=1)
self.rowconfigure(1, weight=1)
# Set default values
from ....datatools import get_data
data = get_data()
# API Frame
api_frame = ttk.LabelFrame(self, padding=8, text="Google API")
api_frame.grid(row=0, column=0, sticky="W E N S")
api_frame.columnconfigure(0, weight=1)
# Add key fields
self.google_api_key = tk.StringVar()
ttk.Label(api_frame, text="Google API Key").grid(column=0, row=0, sticky="W E N S")
ttk.Entry(api_frame, textvariable=self.google_api_key).grid(
column=0, row=1, padx=0, pady=4, sticky="W E N S")
self.soundcloud_client_id = tk.StringVar()
ttk.Label(api_frame, text="SoundCloud Client ID").grid(column=0, row=2, sticky="W E N S")
ttk.Entry(api_frame, textvariable=self.soundcloud_client_id).grid(
column=0, row=3, padx=0, pady=4, sticky="W E N S")
ttk.Button(api_frame, command=lambda: self.update_keys(), text="Update API Data").grid(
column=0, row=4, padx=0, pady=4, sticky="W E N S")
if "google_api_key" in data["discord"]["keys"]:
self.google_api_key.set(data["discord"]["keys"]["google_api_key"])
if "soundcloud_client_id" in data["discord"]["keys"]:
self.soundcloud_client_id.set(data["discord"]["keys"]["soundcloud_client_id"])
GUI_tabbed_all_widgets.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_embed_frames_align_entry_west.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_tabbed_all_widgets_both_tabs.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_embed_frames_align_west.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_embed_frames_align.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_menubar_exit_quit.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_grid_layout.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_menubar_help.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_menubar_tearoff.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_menubar_exit.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_menubar_file.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_tabbed_all_widgets_both_tabs_radio.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_const_42.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_const_42_777_global_print.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget
GUI_const_42_print_func.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def click_me():
action.configure(text='Hello ' + name.get() + ' ' +
number_chosen.get())
# Adding a Textbox Entry widget