本文整理汇总了Python中Tkinter.OptionMenu.pack方法的典型用法代码示例。如果您正苦于以下问题:Python OptionMenu.pack方法的具体用法?Python OptionMenu.pack怎么用?Python OptionMenu.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.OptionMenu
的用法示例。
在下文中一共展示了OptionMenu.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
def initUI(self):
self.parent.title("Buttons")
self.style = Style()
self.style.theme_use("default")
frame = Frame(self, relief=GROOVE, borderwidth=5)
frame.pack(fill=BOTH, expand=1)
self.pack(fill = BOTH, expand = 1)
self.imageLabel = Label(frame, image = "")
self.imageLabel.pack(fill=BOTH, expand=1)
closeButton = Button(self, text="Close")
closeButton.pack(side=RIGHT)
okButton = Button(self, text="OK")
okButton.pack(side=RIGHT)
options = [item for item in dir(cv2.cv) if item.startswith("CV_CAP_PROP")]
option = OptionMenu(self, self.key, *options)
self.key.set(options[0])
option.pack(side="left")
spin = Spinbox(self, from_=0, to=1, increment=0.05)
self.val = spin.get()
spin.pack(side="left")
示例2: _init_corpus_select
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
def _init_corpus_select(self, parent):
innerframe = Frame(parent, background=self._BACKGROUND_COLOUR)
self.var = StringVar(innerframe)
self.var.set(self.model.DEFAULT_CORPUS)
Label(innerframe, justify=LEFT, text=' Corpus: ', background=self._BACKGROUND_COLOUR, padx = 2, pady = 1, border = 0).pack(side='left')
other_corpora = self.model.CORPORA.keys().remove(self.model.DEFAULT_CORPUS)
om = OptionMenu(innerframe, self.var, self.model.DEFAULT_CORPUS, command=self.corpus_selected, *self.model.non_default_corpora())
om['borderwidth'] = 0
om['highlightthickness'] = 1
om.pack(side='left')
innerframe.pack(side='top', fill='x', anchor='n')
示例3: __init__
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
training_error_laber = Label(self, text = 'Training Error: ')
training_error_laber.pack(side = 'left')
error_options = [round(0.1 + i*0.1, 2) for i in range(25)]
self.selected_error = DoubleVar(self, value = DEFAULT_TRAINING_ERROR)
option_menu = OptionMenu(self, self.selected_error, *error_options,
command = self._on_error_selection)
option_menu.pack(side = 'right')
示例4: Gui
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
class Gui(object):
"""
This is a single-transaction dialog box for characterizing
entries that could not be definitively classified by rule.
"""
BORDER = 5
ACCT_WID = 20
DESC_WID = 40
PADDING = 5
def __init__(self, statement, entry):
"""
instantiate a transaction window
"""
self.rules = statement.rules
self.root = Tk()
self.root.title("Manual Annotation")
t = Frame(self.root, bd=2 * self.BORDER)
# top stack: input file name
f = Frame(t)
caption = "File: " + statement.filename + ", line: " + str(statement.file_line)
Label(f, text=caption).pack()
f.pack(pady=self.PADDING)
# middle stack: entry details
f = Frame(t)
f1 = LabelFrame(f, text="Date")
self.date = Label(f1, text=entry.date)
self.date.pack(padx=self.PADDING, pady=self.PADDING)
f1.pack(side=LEFT, padx=self.PADDING)
f1 = LabelFrame(f, text="Amount")
self.amount = Label(f1, text=entry.amount)
self.amount.pack(padx=self.PADDING, pady=self.PADDING)
f1.pack(side=LEFT, padx=self.PADDING)
f1 = LabelFrame(f, text="Account")
self.acct = Text(f1, height=1, width=self.ACCT_WID)
if entry.account is not None:
self.acct.insert(END, entry.account)
self.acct.pack(padx=self.PADDING, pady=self.PADDING)
f1.pack(side=LEFT, padx=self.PADDING)
f1 = LabelFrame(f, text="Description")
self.desc = Text(f1, height=1, width=self.DESC_WID)
self.desc.insert(END, entry.description)
self.desc.pack(padx=self.PADDING, pady=self.PADDING)
f1.pack(side=LEFT, padx=self.PADDING)
f.pack(pady=self.PADDING)
# bottom stack: action buttons
f = Frame(t)
b = Button(f, text="Accept", command=self.accept)
b.pack(side=LEFT, padx=self.PADDING)
# account selection menu
self.account = StringVar(f)
self.account.set(entry.account)
m = OptionMenu(f, self.account, *sorted(statement.acc_list), command=self.chooseAcct)
m.pack(side=LEFT, padx=self.PADDING)
# aggregate description selection menu
self.description = StringVar(f)
self.menu = OptionMenu(f, self.description, *sorted(statement.agg_list), command=self.chooseDesc)
self.menu.pack(side=LEFT, padx=self.PADDING)
b = Button(f, text="Delete", command=self.delete)
b.pack(side=LEFT, padx=self.PADDING)
f.pack(padx=self.PADDING, pady=self.PADDING)
# finalize
t.pack(side=TOP)
self.entry = entry # default: return what we got
def accept(self):
"""
Accept button action - create Entry w/current description
"""
date = self.date.cget("text")
amount = self.amount.cget("text")
acct = self.account.get()
if acct == "None":
acct = None
descr = self.desc.get(1.0, END).replace("\n", "")
self.entry = Entry.Entry(date, amount, acct, descr)
self.root.destroy()
self.root.quit()
def delete(self):
"""
Delete button action - return a null Entry
"""
self.entry = None
self.root.destroy()
self.root.quit()
def chooseAcct(self, selection):
#.........这里部分代码省略.........
示例5: __init__
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
def __init__(self, statement, entry):
"""
instantiate a transaction window
"""
self.rules = statement.rules
self.root = Tk()
self.root.title("Manual Annotation")
t = Frame(self.root, bd=2 * self.BORDER)
# top stack: input file name
f = Frame(t)
caption = "File: " + statement.filename + ", line: " + str(statement.file_line)
Label(f, text=caption).pack()
f.pack(pady=self.PADDING)
# middle stack: entry details
f = Frame(t)
f1 = LabelFrame(f, text="Date")
self.date = Label(f1, text=entry.date)
self.date.pack(padx=self.PADDING, pady=self.PADDING)
f1.pack(side=LEFT, padx=self.PADDING)
f1 = LabelFrame(f, text="Amount")
self.amount = Label(f1, text=entry.amount)
self.amount.pack(padx=self.PADDING, pady=self.PADDING)
f1.pack(side=LEFT, padx=self.PADDING)
f1 = LabelFrame(f, text="Account")
self.acct = Text(f1, height=1, width=self.ACCT_WID)
if entry.account is not None:
self.acct.insert(END, entry.account)
self.acct.pack(padx=self.PADDING, pady=self.PADDING)
f1.pack(side=LEFT, padx=self.PADDING)
f1 = LabelFrame(f, text="Description")
self.desc = Text(f1, height=1, width=self.DESC_WID)
self.desc.insert(END, entry.description)
self.desc.pack(padx=self.PADDING, pady=self.PADDING)
f1.pack(side=LEFT, padx=self.PADDING)
f.pack(pady=self.PADDING)
# bottom stack: action buttons
f = Frame(t)
b = Button(f, text="Accept", command=self.accept)
b.pack(side=LEFT, padx=self.PADDING)
# account selection menu
self.account = StringVar(f)
self.account.set(entry.account)
m = OptionMenu(f, self.account, *sorted(statement.acc_list), command=self.chooseAcct)
m.pack(side=LEFT, padx=self.PADDING)
# aggregate description selection menu
self.description = StringVar(f)
self.menu = OptionMenu(f, self.description, *sorted(statement.agg_list), command=self.chooseDesc)
self.menu.pack(side=LEFT, padx=self.PADDING)
b = Button(f, text="Delete", command=self.delete)
b.pack(side=LEFT, padx=self.PADDING)
f.pack(padx=self.PADDING, pady=self.PADDING)
# finalize
t.pack(side=TOP)
self.entry = entry # default: return what we got
示例6: CreateView
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
class CreateView(Frame):
"""A class describing the list creation page of the UI"""
def __init__(self, parent, height, width, border_style, border_width,
background_colour):
Frame.__init__(self, parent, height=height, width=width)
#Connect to the word/list database
self.db = SpellingDatabase()
self.parent = parent
#Create a frame containing a menu for choosing word category
categorymenu_frame = Frame(self, width=340, height=30, relief=SUNKEN, bd=1)
categorymenu_frame.pack_propagate(0)
categorymenu_label = Label(categorymenu_frame, text="Category:")
wordlist_title = Label(categorymenu_frame, text="Select Words")
#Menu options: one for each category of word
optionList = ("Child", "ESOL", "Spelling Bee", "Custom")
self.category_v = StringVar()
self.category_v.set(optionList[0])
#Command causes word browser to be populated with words from chosen category
self.category_menu = OptionMenu(categorymenu_frame, self.category_v, *optionList, command=self.update_category)
self.category_menu.config(width=10)
self.category_menu.pack(side=RIGHT)
categorymenu_label.pack(side=RIGHT)
wordlist_title.pack(side=LEFT)
#Create frame for the title of the user list panel
userlist_title_frame = Frame(self, width=340, height=30)
userlist_title_frame.pack_propagate(0)
userlist_title = Label(userlist_title_frame, text="Your New List")
userlist_title_frame.grid(column=2, row=0)
userlist_title.pack(side=LEFT)
#Create frame for middle bar containing transfer buttons
middlebar_frame = Frame(self, width = 70, height=400)
middlebar_frame.grid_propagate(0)
#Buttons transfer words from one list to the other
transfer_right_button = Button(middlebar_frame, text="->", command=self.transfer_right)
transfer_left_button = Button(middlebar_frame, text="<-", command=self.transfer_left)
#Press this button to generate a random list from the current category
random_list_button = Button(middlebar_frame, text="Create", command=self.random_list)
random_list_label = Label(middlebar_frame, text="Random\nList")
self.random_list_entry = Entry(middlebar_frame, width=3, justify=RIGHT)
self.random_list_entry.insert(0, 15)
transfer_left_button.grid(column=0, row=1, padx=15, pady=50)
transfer_right_button.grid(column=0, row=0, padx=15, pady=50)
random_list_label.grid(column=0, row=2, pady=3)
self.random_list_entry.grid(column=0, row=3, pady=3)
random_list_button.grid(column=0, row=4, pady=3)
middlebar_frame.grid(column=1, row=1)
#random_list_button.grid(column=0, row=2)
#Create frame for "Add New Word" menu
addword_frame = Frame(self, width=340, height=150, bd=2, relief=SUNKEN)
addword_frame.grid_propagate(0)
addword_label = Label(addword_frame, text = "Add a new word:")
word_label = Label(addword_frame, text="Word:")
def_label = Label(addword_frame, text="Definition:")
use_label = Label(addword_frame, text="Example of Use:")
difficulty_label = Label(addword_frame, text="Difficulty:")
#Entry boxes and an option menu allowing the user to enter attributes of the new word
self.addword_entry = Entry(addword_frame, width = 28)
self.adddefinition_entry = Entry(addword_frame, width=28)
self.adduse_entry = Entry(addword_frame, width=28)
self.difficulty_v = StringVar()
self.difficulty_v.set("1")
difficulty_list = range(1,9)
self.difficulty_menu = OptionMenu(addword_frame, self.difficulty_v, *difficulty_list)
#Pressing this button adds the new word to the database
addword_button = Button(addword_frame, text = "Add", command = self.add_word)
addword_label.grid(row=0, column=0, sticky=W)
addword_button.grid(row=0, column=1, pady=2, sticky=E)
word_label.grid(row=1, column=0, sticky=W)
def_label.grid(row=2, column=0, sticky=W)
use_label.grid(row=3, column=0, sticky=W)
difficulty_label.grid(row=4, column=0, sticky=W)
self.addword_entry.grid(row=1, column=1, pady=2, sticky=E)
self.adddefinition_entry.grid(row=2, column=1, pady=2, sticky=E)
self.adduse_entry.grid(row=3, column=1, pady=2, sticky=E)
self.difficulty_menu.grid(row=4, column=1, pady=2, sticky=E)
addword_frame.grid(column=0, row=2)
#Frame for menu allowing users to save their new lists
savelist_frame = Frame(self, width=340, height=30, bd=2, relief=SUNKEN)
savelist_frame.pack_propagate(0)
savelist_label = Label(savelist_frame, text="List Name:")
#User enters the name of the new list here
self.savelist_entry = Entry(savelist_frame, width=25)
#Pressing this button adds the new list to the database
savelist_button = Button(savelist_frame, text="Save", command = self.save_list)
savelist_label.pack(side=LEFT)
savelist_button.pack(side=RIGHT)
self.savelist_entry.pack(side=RIGHT, padx=5)
savelist_frame.grid(column=2, row=2, sticky=N, pady=5)
#Create list panel for browsing the words stored in database
self.wordbrowse_frame = ListPane(self, height=25)
categorymenu_frame.grid(column=0, row=0)
#.........这里部分代码省略.........
示例7: TKParent
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
class TKParent():
def __init__(self,filename):
self.dialog = None
self.todolist = None
self.filename = filename
self.categories = []
self.cat_list = None
def do_refresh(self,category=None):
from Tkinter import END
if not self.todolist:
return
self.categories = []
todo = json.loads(open(self.filename,"r").read())
self.todolist.delete(0,END)
for item in todo:
curr_category = None
text = item["message"]
if "category" in item and item["category"]:
curr_category = item["category"]
text = "{0}: {1}".format(curr_category, text)
if not curr_category in self.categories:
self.categories.append(curr_category)
if category:
if category == "NONE":
if curr_category and curr_category != "NONE":
continue
elif category != curr_category:
continue
self.todolist.insert(END,text)
self.dialog.title("TODO ({0})".format(self.todolist.size()))
def refresh_list(self):
self.do_refresh()
def filter_list(self,arg):
if arg == "ALL":
self.refresh_list()
else:
self.do_refresh(arg)
def get_box(self):
if not self.dialog:
from Tkinter import Tk,Listbox,Button,Scrollbar,X,Y,BOTTOM,RIGHT,HORIZONTAL,VERTICAL,OptionMenu,StringVar
self.dialog = Tk()
self.dialog.title("TODO")
scrollbar = Scrollbar(self.dialog,orient=HORIZONTAL)
yscrollbar = Scrollbar(self.dialog,orient=VERTICAL)
self.todolist = Listbox(self.dialog,width=50,xscrollcommand=scrollbar.set,yscrollcommand=yscrollbar.set)
scrollbar.config(command=self.todolist.xview)
scrollbar.pack(side=BOTTOM,fill=X)
yscrollbar.config(command=self.todolist.yview)
yscrollbar.pack(side=RIGHT,fill=Y)
self.todolist.pack(side="left",fill="both",expand=True)
cat_list_name = StringVar()
cat_list_name.set("Category")
btn = Button(self.dialog,text="Refresh",command=self.refresh_list)
btn.pack()
self.refresh_list()
if self.categories:
self.cat_list = OptionMenu(self.dialog,cat_list_name,*(self.categories+["ALL","NONE"]),command=self.filter_list)
self.cat_list.pack()
return (self.dialog,self.todolist)
def add(self,msg):
from Tkinter import END
self.todolist.insert(END,msg)
示例8: __init__
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
def __init__(self, master):
# sets the image repository and the user labeled data
self.dictionaryLocation = "PreLabeledTrainingData/women/"
self.autoLabels = "AutoLabeledData/labels.csv"
self.autoImageLocation = "AutoLabeledData/"
self.autoFaceLocation = "AutoLabeledData/Faces/"
self.newImageLocation = "UserTrainingData/"
self.labelLocation = "UserTrainingData/womenlabels.csv"
#self.newImageLocation = "AutoLabeledData/"
#self.labelLocation = "AutoLabeledData/labels.csv"
self.userPredictor = userPredictor.UserPredictor("Models/", '/home/testing32/Downloads/word2vec/trunk/vectors.bin', "user_")
self.images = None
self.currentImage = None
self.currentUser = None
self.matches = []
self.master = master
# set the title
master.wm_title("Automatic Tinder")
# binds the frame and the key events
button_frame = Frame(master)
button_frame.bind_all("<Key>", self.key_press)
button_frame.pack()
# default menu value
variable = StringVar(button_frame)
variable.set("Local")
# set up the drop down menu for switching between Local images and Tinder images
w = OptionMenu(button_frame, variable, "Local", "Tinder", command=self.menu_change)
w.pack(side=LEFT)
# create the "No" button
self.no_btn = Button(button_frame, text="NO (1)", fg="red", command=self.no)
self.no_btn.pack(side=LEFT)
# create the "Yes" button
self.yes_btn = Button(button_frame, text="YES (2)", fg="blue", command=self.yes)
self.yes_btn.pack(side=LEFT)
# create the "Automate" button
self.auto_btn = Button(button_frame, text="Automate", fg="brown", command=self.auto)
self.auto_btn.pack(side=LEFT)
# create the "Previous Image" button
self.prev_img_btn = Button(button_frame, text="Previous Image", fg="black", command=self.showPreviousImage)
self.prev_img_btn.pack(side=LEFT)
# create the "Next Image" button
self.next_img_btn = Button(button_frame, text="Next Image", fg="black", command=self.showNextImage)
self.next_img_btn.pack(side=LEFT)
# create the "Matches" button
self.matches_text = StringVar(value="Matches (0)")
self.matches_btn = Button(button_frame, textvariable=self.matches_text, command=self.openMatches)
self.matches_btn.pack(side=BOTTOM)
# Setting up the profile text area
profile_frame = Frame(master)
profile_frame.pack()
self.profile_text = StringVar(value="")
self.profile_lbl = Label(profile_frame, textvariable=self.profile_text, width=60,wraplength=475)
self.profile_lbl.pack(side=BOTTOM)
# Setting up the image area
image_frame = Frame(master)
image_frame.pack()
# load the image
self.pic = Label()
self.pic.pack(side=BOTTOM)
# create the interface to our data
"""
self.imgInterface = AutoDataWrapper(
self.dictionaryLocation,
self.labelLocation)
"""
self.imgInterface = LocalDataWrapper(
self.dictionaryLocation,
self.labelLocation)
# Load the next user from the image interface
self.loadUser(self.imgInterface.getNextUser())
示例9: arange
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
# Add UDP interface to SMA server here
sma = None
f = arange(800-400./16, 400, -400./16)
corr = RealTimePlot(master=frame, mode='replace', ylim=[-50, 10], xlim=[f.min(), f.max()])
corr.tkwidget.pack(fill=BOTH, expand=1)
def set_itime(itimes):
itime = 2**int(itimes)
sma.write_int('integ_time', itime)
tvar = StringVar(root)
toptions = [str(i) for i in range(5, 32)]
tvar.set("20")
selitime = OptionMenu(root, tvar, *toptions, command=set_itime)
selitime.pack(side=RIGHT)
def quit_mon():
sma.stop()
root.quit()
quit = Button(master=frame, text='Quit', command=quit_mon)
quit.pack(side=BOTTOM)
def update_plots(widget, total_updates):
n = 32*4*sma.read_uint('integ_time')
rmsp2_c0 = sma.read_uint('rmsp2_chan0')*2**-32
rmsp2_c1 = sma.read_uint('rmsp2_chan1')*2**-32
rmsp2 = sqrt(rmsp2_c0 * rmsp2_c1)
cf = (2**-14) * array(CORR_OUT.unpack(sma.read('output_corr0', 32*4))).astype(float)
nf = concatenate((cf[16:], cf[:16])) / (n*rmsp2)
示例10: Example
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("IAF CALC 0.01")
self.pack(fill=BOTH, expand=1)
self.configure(background="white")
frameTOP = Frame(self)
frameTOP.config(bg="white")
frameTOP.pack(side=TOP)
frameFILES = Frame(frameTOP)
frameFILES.pack(side=LEFT, padx=10)
# --- BUTTON FOR FILE 1 --- #
frameF1 = LabelFrame(frameFILES, text="Eyes open file:", relief=FLAT, borderwidth=1, background="white")
frameF1.pack(fill=X, expand=1)
self.nameF1 = Entry(frameF1, width=50)
self.nameF1.config(bg="lightgray")
self.nameF1.pack(side=LEFT)
self.nameF1.delete(0, END)
self.nameF1.insert(0, "")
self.buttonLoadFile1 = Button(frameF1, text="...", command=self.askOpenFile1)
self.buttonLoadFile1.pack(side=LEFT, padx=5, pady=5)
# ----------------------- #
# --- BUTTON FOR FILE 2 --- #
frameF2 = LabelFrame(frameFILES, text="Eyes closed file:", relief=FLAT, borderwidth=1, background="white")
frameF2.pack(fill=X, expand=1)
self.nameF2 = Entry(frameF2, width=50)
self.nameF2.config(bg="lightgray")
self.nameF2.pack(side=LEFT)
self.nameF2.delete(0, END)
self.nameF2.insert(0, "")
self.buttonLoadFile2 = Button(frameF2, text="...", command=self.askOpenFile2)
self.buttonLoadFile2.pack(side=LEFT, padx=5, pady=5)
# ----------------------- #
# --- BUTTON FOR FILE OUTPUT --- #
frameO = LabelFrame(frameFILES, text="Output directory:", relief=FLAT, borderwidth=1, background="white")
frameO.pack(fill=X, expand=1)
self.nameO = Entry(frameO, width=50)
self.nameO.config(bg="lightgray")
self.nameO.pack(side=LEFT)
self.nameO.delete(0, END)
self.nameO.insert(0, "")
self.buttonSelectOutput = Button(frameO, text="...", command=self.askOutputDirectory)
self.buttonSelectOutput.pack(side=LEFT, padx=5, pady=5)
# -------------------------------#
# self.pack()
# self.pack(fill=Y, expand=1)
# ---------- PSD PARAMETER SELECTION ---------- #
framePARAM = Frame(frameTOP)
framePARAM.config(bg="white")
framePARAM.pack(side=LEFT, fill=X)
frame = LabelFrame(framePARAM, text="PSD Parameters", relief=RIDGE, borderwidth=1, background="white")
frame.pack(fill=BOTH, expand=1, side=TOP)
wFs = Label(frame, text="Fs:", bg="white")
wFs.pack(side=LEFT)
self.inputFs = Entry(frame, width=5)
self.inputFs.pack(side=LEFT, padx=5)
self.inputFs.delete(0, END)
self.inputFs.insert(0, "500")
wWS = Label(frame, text="Window size:", bg="white")
wWS.pack(side=LEFT)
self.inputWinSize = Entry(frame, width=5)
self.inputWinSize.pack(side=LEFT, padx=5)
self.inputWinSize.delete(0, END)
self.inputWinSize.insert(0, "1024")
wOL = Label(frame, text="Overlap:", bg="white")
wOL.pack(side=LEFT)
self.inputOverlap = Entry(frame, width=5)
self.inputOverlap.pack(side=LEFT, padx=5)
self.inputOverlap.delete(0, END)
self.inputOverlap.insert(0, "512")
wWT = Label(frame, text="Window function:", bg="white")
wWT.pack(side=LEFT)
variable = StringVar(frame)
variable.set("Hamming") # default value
self.inputWinType = OptionMenu(frame, variable, "Hamming", "Bartlett", "Blackman", "Hanning", "None")
self.inputWinType.config(bg="white", width=10)
self.inputWinType.pack(side=LEFT)
buttonRun = Button(frame, text="GO!", command=self.goTime)
buttonRun.pack(side=RIGHT)
# Channel selector
#.........这里部分代码省略.........
示例11: Viewer
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
class Viewer():
def __init__(self, image):
self.original = image
self.image = image.copy()
self.window = Tk()
self.genViews()
self.currentView = StringVar(self.window)
self.currentView.set('Original')
options = self.filters.keys();options.sort()
self.views = OptionMenu(self.window, self.currentView,
*options, command=self.applyFilter)
self.views.pack()
self.tkImage = ImageTk.PhotoImage(image)
self.lblImage = Label(image=self.tkImage)
self.lblImage.bind('<Button-1>', self.displayInfos)
self.lblImage.bind('<Button-3>', self.save)
self.lblImage.image = self.tkImage
self.lblImage.pack()
self.status = StringVar()
self.lblStatus = Label(textvariable=self.status, justify='right')
self.lblStatus.pack()
self.window.mainloop()
def displayInfos(self, event):
"""
Displays the coordinates in the status bar
"""
x = int((event.x-0.1)/args.scalefactor)
y = int((event.y-0.1)/args.scalefactor)
pixel = orig.getpixel((x, y))
self.setStatus("Coordinates : (%s:%s) - Pixel value : %s" %
(x, y, str(pixel)))
def setStatus(self, text):
"""
Changes the text in the status bar
"""
self.status.set(text)
def save(self, event):
"""
Saves the filtered image to a file
"""
options = {'filetypes':[('PNG','.png'),('GIF','.gif')]}
outfile = tkFileDialog.asksaveasfilename(**options)
if outfile == '':
return
else:
self.image.save(outfile)
return
def genViews(self):
"""
Generates filters based on the source image
"""
self.filters = {}
for plug in viewPlugins:
self.filters.update({plug.name:viewPlugins.index(plug)})
def applyFilter(self, view):
"""
Applies a filter to the image
"""
view = self.filters[self.currentView.get()]
plugin = viewPlugins[view]
if plugin.parameters:
for param in plugin.parameters.keys():
a = tkSimpleDialog.askinteger(
'Question', plugin.parameters[param])
if a is not None:
setattr(viewPlugins[view], param, a)
self.image = viewPlugins[view].process(self.original)
self.showImage(self.currentView.get(), self.image)
self.setStatus("")
return
def showImage(self, title, image):
"""
Updates the image in the window
"""
self.tkImage = ImageTk.PhotoImage(image)
self.lblImage.configure(image=self.tkImage)
self.lblImage.image = self.tkImage
示例12: guiDemo3
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
class guiDemo3(Frame):
def __init__(self,parent):
Frame.__init__(self,parent)
self.parent = parent
self.dict = {} #temporary
self.initUI() #start up the main menu
def initUI(self):
try:
self.parent.title("Mighty Cracker")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
#load buttons and labels
self.closeButton= Button(self, text="Close Program", command=self.confirmExit)
self.closeButton.pack(side=BOTTOM, padx=5, pady=5)
self.mainMenuLabel= Label(self, text="Main Menu")
self.mainMenuLabel.pack(side=TOP,padx=5, pady=5)
self.singleModeButton= Button(self, text="Single Computer Mode", command=self.unpackInitUI_LoadSingleComputerMode)
self.singleModeButton.pack(side=TOP, padx=5, pady=5)
self.networkModeButton= Button(self, text="Networking Mode", command=self.unpackInitUI_LoadNetworkMode)
self.networkModeButton.pack(side=TOP, padx=5, pady=5)
except Exception as inst:
print "============================================================================================="
print "GUI ERROR: An exception was thrown in initUI definition Try block"
#the exception instance
print type(inst)
#srguments stored in .args
print inst.args
#_str_ allows args tto be printed directly
print inst
print "============================================================================================="
#end of initUI////////////////////////////
def unpackInitUI_LoadSingleComputerMode(self):
self.closeButton.pack_forget()
self.mainMenuLabel.pack_forget()
self.singleModeButton.pack_forget()
self.networkModeButton.pack_forget()
self.singleModeUI()
def unpackInitUI_LoadNetworkMode(self):
self.closeButton.pack_forget()
self.mainMenuLabel.pack_forget()
self.singleModeButton.pack_forget()
self.networkModeButton.pack_forget()
self.networkModeUI()
def unpackSingleModeUI_LoadInitUI(self):
self.closeButton.pack_forget()
self.returnToInitUIButton.pack_forget()
self.singleModeLabel.pack_forget()
self.selectCrackingMethodLabel.pack_forget()
self.dictionaryCrackingMethodButton.pack_forget()
self.bruteForceCrackingMethodButton.pack_forget()
self.rainbowTableCrackingMethodButton.pack_forget()
self.initUI()
def unpackSingleModeUI_LoadSingleDictionaryUI(self):
self.closeButton.pack_forget()
self.returnToInitUIButton.pack_forget()
self.singleModeLabel.pack_forget()
self.selectCrackingMethodLabel.pack_forget()
self.dictionaryCrackingMethodButton.pack_forget()
self.bruteForceCrackingMethodButton.pack_forget()
self.rainbowTableCrackingMethodButton.pack_forget()
self.dictionaryCrackingMethodUI(0)
def unpackSingleModeUI_LoadSingleBruteForceUI(self):
self.closeButton.pack_forget()
self.returnToInitUIButton.pack_forget()
self.singleModeLabel.pack_forget()
self.selectCrackingMethodLabel.pack_forget()
self.dictionaryCrackingMethodButton.pack_forget()
self.bruteForceCrackingMethodButton.pack_forget()
self.rainbowTableCrackingMethodButton.pack_forget()
self.bruteForceCrackingMethodUI(0)
def unpackSingleModeUI_LoadSingleRainbowTableUI(self):
self.closeButton.pack_forget()
self.returnToInitUIButton.pack_forget()
self.singleModeLabel.pack_forget()
self.selectCrackingMethodLabel.pack_forget()
self.dictionaryCrackingMethodButton.pack_forget()
self.bruteForceCrackingMethodButton.pack_forget()
self.rainbowTableCrackingMethodButton.pack_forget()
self.rainbowTableCrackingMethodUI(0)
def singleModeUI(self):
try:
self.parent.title("Mighty Cracker")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
#.........这里部分代码省略.........
示例13: observation
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
#.........这里部分代码省略.........
self.curvar = Label(curresultsframe, text=self.iniparams["totbest"], bg=Styles.colours["grey"], width=20,
font=Styles.fonts["h2"])
self.curvar.grid(row=2, column=2, sticky=W)
modeldetails.grid(row=0, column=0, columnspan=3, sticky=W + E + N + S)
fm.grid(row=1, column=0, columnspan=3, sticky=W + E + N + S, padx=20)
self.numexperitments.grid(row=4, column=0, columnspan=3, sticky=W + E + N + S)
resultsframe.grid(row=7, column=0, columnspan=3, sticky=W + E + N + S)
curresultsframe.grid(row=8, column=0, columnspan=3, sticky=W + E + N + S)
f.grid(row=0, column=1, sticky=W + E + N + S)
# Create the graph base
def startgraph(self):
#Older versions of matplot do not support style command
try:
pl.style.use('ggplot')
except:
pass
root = Frame(self.frame)
self.graphframem = root
root.config(padx=20, pady=20, bg=Styles.colours["grey"])
self.graphtype = StringVar(root)
self.graphtype.set("Graph: Running Best (Overview)") # initial value
self.option = OptionMenu(root, self.graphtype, "Graph: Objective Value", "Graph: Running Best (Zoom)",
"Graph: Running Best (Overview)", "Graph: Variance", "Graph: Variance (Last 25)",
"Graph: Objective Value (Last 25)", "Graph: Running Best (Last 25)",
"Graph: Time (seconds)")
self.option.config(padx=5, pady=5,state=DISABLED, justify=LEFT, font=Styles.fonts["h1"], relief=FLAT,
highlightbackground=Styles.colours["yellow"], highlightthickness=1,
bg=Styles.colours["grey"])
self.option.pack(fill=BOTH)
def callback(*args):
if not self.lockgraph:
self.updategraph()
self.graphtype.trace("w", callback)
self.graphfigure = Figure(figsize=(6, 6), dpi=70, facecolor=Styles.colours["grey"])
self.graphframe = self.graphfigure.add_subplot(111, axisbg=Styles.colours["darkGrey"])
self.graphframe.set_xlabel('Iteration')
self.graphframe.set_ylabel('Objective Value')
canvas = FigureCanvasTkAgg(self.graphfigure, master=root)
canvas.show()
canvas.get_tk_widget().configure(background=Styles.colours["grey"], highlightcolor=Styles.colours["grey"],
highlightbackground=Styles.colours["grey"])
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
root.grid(row=0, column=0)
canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=0)
# Update a variable on the page
def updatevar(self, var, value):
if var == "kernel":
self.kernelinfo.config(text=value.upper())
self.lockvar = True
self.iniparams.update({
"x": [],
"y": [],
"mu": [],
"var": [],
示例14: Cockpit
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
#.........这里部分代码省略.........
"P": 0.0,
"I": 0.0,
"D": 0.0
}
}
}
self.parent = parent
self.initUI()
self._controlKeysLocked = False
if not isDummy:
self._link = INetLink(droneIp, dronePort)
else:
self._link = ConsoleLink()
self._link.open()
self._updateInfoThread = Thread(target=self._updateInfo)
self._updateInfoThreadRunning = False
self._readingState = False
self._start()
def initUI(self):
self.parent.title("Drone control")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.parent.bind_all("<Key>", self._keyDown)
self.parent.bind_all("<KeyRelease>", self._keyUp)
if system() == "Linux":
self.parent.bind_all("<Button-4>", self._onMouseWheelUp)
self.parent.bind_all("<Button-5>", self._onMouseWheelDown)
else:
#case of Windows
self.parent.bind_all("<MouseWheel>", self._onMouseWheel)
#Commands
commandsFrame = tkFrame(self)
commandsFrame.grid(column=0, row=0, sticky="WE")
self._started = IntVar()
self._startedCB = Checkbutton(commandsFrame, text="On", variable=self._started, command=self._startedCBChanged)
self._startedCB.pack(side=LEFT, padx=4)
# self._integralsCB = Checkbutton(commandsFrame, text="Int.", variable=self._integralsEnabled, \
# command=self._integralsCBChanged, state=DISABLED)
# self._integralsCB.pack(side=LEFT, padx=4)
self._quitButton = Button(commandsFrame, text="Quit", command=self.exit)
self._quitButton.pack(side=LEFT, padx=2, pady=2)
# self._angleLbl = Label(commandsFrame, text="Angle")
# self._angleLbl.pack(side=LEFT, padx=4)
#
# self._angleEntry = Entry(commandsFrame, state=DISABLED)
# self._angleEntry.pack(side=LEFT)
示例15: Cockpit
# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import pack [as 别名]
#.........这里部分代码省略.........
"P": 0.0,
"I": 0.0,
"D": 0.0
}
}
}
self.parent = parent
self.initUI()
self._controlKeysLocked = False
if not isDummy:
self._link = INetLink(droneIp, dronePort)
else:
self._link = ConsoleLink()
self._link.open()
self._updateInfoThread = Thread(target=self._updateInfo)
self._updateInfoThreadRunning = False
self._readingState = False
self._start()
def initUI(self):
self.parent.title("Drone control")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.parent.bind_all("<Key>", self._keyDown)
self.parent.bind_all("<KeyRelease>", self._keyUp)
if system() == "Linux":
self.parent.bind_all("<Button-4>", self._onMouseWheelUp)
self.parent.bind_all("<Button-5>", self._onMouseWheelDown)
else:
#case of Windows
self.parent.bind_all("<MouseWheel>", self._onMouseWheel)
#Commands
commandsFrame = tkFrame(self)
commandsFrame.grid(column=0, row=0, sticky="WE")
self._startedCB = Checkbutton(commandsFrame, text="On", variable=self._started, command=self._startedCBChanged)
self._startedCB.pack(side=LEFT, padx=4)
self._integralsCB = Checkbutton(commandsFrame, text="Int.", variable=self._integralsEnabled, \
command=self._integralsCBChanged, state=DISABLED)
self._integralsCB.pack(side=LEFT, padx=4)
self._quitButton = Button(commandsFrame, text="Quit", command=self.exit)
self._quitButton.pack(side=LEFT, padx=2, pady=2)
# self._angleLbl = Label(commandsFrame, text="Angle")
# self._angleLbl.pack(side=LEFT, padx=4)
#
# self._angleEntry = Entry(commandsFrame, state=DISABLED)
# self._angleEntry.pack(side=LEFT)