本文整理汇总了Python中tkinter.OptionMenu.grid方法的典型用法代码示例。如果您正苦于以下问题:Python OptionMenu.grid方法的具体用法?Python OptionMenu.grid怎么用?Python OptionMenu.grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.OptionMenu
的用法示例。
在下文中一共展示了OptionMenu.grid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
def __init__(self, pipepanel, pipeline_name, *args, **kwargs) :
PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs)
self.info = 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)
Pipelines=["InitialChIPseqQC", "ChIPseq" ]
Pipeline = self.Pipeline = StringVar()
Pipeline.set(Pipelines[0])
om = OptionMenu(eframe, Pipeline, *Pipelines, 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=20,pady=5)
readtypes = ['Single', 'Paired']
self.readtype = readtype = StringVar()
readtype.set(readtypes[0])
readtype_menu = OptionMenu(eframe, readtype, *readtypes)
readtype_menu.grid(row=3, column=3, sticky=E, pady=5)
readtype_label = Label(eframe, text="-end ")
readtype_label.grid( row=3, column=4, stick=W, pady=5)
self.add_info(eframe)
self.option_controller()
self.peakinfo_fn = 'peakcall.tab'
self.contrast_fn = 'contrast.tab'
示例2: __init__
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
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)
示例3: GuiBasicSettings
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
class GuiBasicSettings(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.pack()
#Unit
self.sizeUnits = {"Byte": 1, "KiB":1024, "MiB":1024**2, "GiB":1024**3}
self._initFile()
self._initSize()
def _initFile(self):
self._fileLbl = Label(self, text="File: ")
self._fileTxt = Entry(self)
self._fileTxt.insert(0, "/tmp/out.txt")
self._fileBtn = Button(self, text="Create", command=self._callbackFun)
self._fileLbl.grid(row=0, column=0)
self._fileTxt.grid(row=0, column=1)
self._fileBtn.grid(row=0, column=2)
def _initSize(self):
self._sizeLbl = Label(self, text="FileSize: ")
self._sizeTxt = Entry(self)
self._sizeTxt.insert(0, "1024")
self._sizeVar = StringVar()
self._sizeVar.set("Byte") #FIXME: replace "Byte" with variable
sizeOptParam = (self, self._sizeVar) + tuple(self.sizeUnits.keys())
self._sizeOptMen = OptionMenu(*sizeOptParam)
self._sizeLbl.grid(row=1, column=0)
self._sizeTxt.grid(row=1, column=1)
self._sizeOptMen.grid(row=1, column=2)
def _callbackFun(self):
print("_callbackBtn")
self.outerCallback()
def enableButton(self, enabled=True):
if enabled:
self._fileBtn.config(state="normal")
else:
self._fileBtn.config(state="disabled")
def getFileName(self):
return self._fileTxt.get()
def getFileSize(self):
mult = int(self.sizeUnits[self._sizeVar.get()])
val = int(self._sizeTxt.get())
return val * mult
def setCallback(self, aCallback):
self.outerCallback = aCallback
示例4: AccountDialog
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
class AccountDialog(gui.tksimpledialog.Dialog):
def __init__(self, parent, title="", login_name="", password="", path="", dx="dx11"):
self.login_name = login_name
self.password = password
self.path = path
self.dx = dx
self.entry_ln = None
self.variable = None
self.entry_pw = None
self.entry_path = None
self.entry_dx = None
super().__init__(parent, title)
def body(self, master):
Label(master, text="Login Name:").grid(row=0)
Label(master, text="Password:").grid(row=1)
Label(master, text="Eve Path:").grid(row=2)
Label(master, text="DirectX:").grid(row=3)
self.entry_ln = Entry(master)
self.entry_pw = Entry(master, show="*")
self.entry_path = Entry(master)
self.variable = StringVar(master)
self.variable.set(self.dx)
self.entry_dx = OptionMenu(master, self.variable, "dx9", "dx11")
self.entry_ln.insert(END, self.login_name)
self.entry_pw.insert(END, self.password)
self.entry_path.insert(END, self.path)
# self.entry_path.bind("<FocusIn>", self.select_eve_path)
self.entry_ln.grid(row=0, column=1)
self.entry_pw.grid(row=1, column=1)
self.entry_path.grid(row=2, column=1)
self.entry_dx.grid(row=3, column=1)
return self.entry_ln
# def select_eve_path(self, event):
# if event.widget == self.entry_path:
# self.path
# res = os.path.normpath(askdirectory(initialdir=self.path))
# self.path = res
# self.entry_path.insert(END, res)
def apply(self):
login_name = self.entry_ln.get()
password = self.entry_pw.get()
path = self.entry_path.get()
dx = self.variable.get()
self.result = [login_name, password, path, dx]
示例5: __init__
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
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=["initialqc", "exomeseq-germline", "exomeseq-somatic", "exomeseq-somatic-tumoronly"]
self.label2pipeline = { k:v for k,v in zip(PipelineLabels, Pipelines)}
Pipeline = self.Pipeline = StringVar()
PipelineLabel = self.PipelineLabel = StringVar()
self.Pipeline = StringVar()
PipelineLabel.set(PipelineLabels[0])
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)
targetsL=Label(eframe,
text="Target Capture Kit")
#,fg=textLightColor,bg=baseColor)
targetsL.grid(row=5,column=0,sticky=W,padx=10,pady=5)
targetsE = Entry(eframe,textvariable=self.targetspath, width=50)
if self.genome=="hg19":
self.targetspath.set(
"/data/CCBR_Pipeliner/db/PipeDB/lib/SS_v5_UTRs_hg19.bed" )
elif self.genome=="hg38":
self.targetspath.set(
"/data/CCBR_Pipeliner/db/PipeDB/lib/SS_v5_UTRs_hg38.bed" )
else:
self.targetspath.set(
"/data/CCBR_Pipeliner/db/PipeDB/lib/SureSelect_mm10.bed")
targetsE.grid(row=5,column=1,columnspan=6,sticky=W,padx=10,pady=5)
self.targetspath.trace('w', lambda a,b,c,x="targetspath":self.makejson(x))
label = Label (eframe,
text =
"By default, the path to the Agilent V5+UTR targets file is filled in here" )
label.grid(row=6, column=0, columnspan=5, sticky=W, padx=10, pady=5)
示例6: __init__
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
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)
Pipelines=["initialqcgenomeseq","wgslow"]
Pipeline = self.Pipeline = StringVar()
Pipeline.set(Pipelines[0])
om = OptionMenu(eframe, Pipeline, *Pipelines, 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)
示例7: TwySearch
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
class TwySearch(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.grid()
self.create_widgets()
def create_widgets(self) :
#Search keyword
self.keyword_desc = Label(self,text="Enter Keyword")
self.keyword_desc.grid(row=0, column=0, columnspan=3)
self.keyword = Entry(self)
self.keyword.grid(row=1, column=0, columnspan=3)
#Divider
self.div1 = Label(self,text="____________________________________________________________________")
self.div1.grid(row=3, column=0, columnspan=3)
#ADVANCED OPTIONS
self.advanced_opts_div = Label(self,text="ADVANCED OPTIONS")
self.advanced_opts_div.grid(row=4, column=0, columnspan=3)
#Divider
self.div2 = Label(self,text="____________________________________________________________________")
self.div2.grid(row=5, column=0, columnspan=3)
#MAX_Results
self.max_results_desc = Label(self,text="Maximum Results")
self.max_results_desc.grid(row=7, column=0, columnspan=1)
self.max_results = Entry(self)
self.max_results.grid(row=8, column=0, columnspan=1)
#Geocode
#(latitude,longitude,radius[mi/km])
self.geocode_desc = Label(self,text="Enter Geocode")
self.geocode_desc.grid(row=7, column=1, columnspan=1)
self.geocode = Entry(self)
self.geocode.grid(row=8, column=1, columnspan=1)
#Lang
#use 639-1 language codes
#picked top languages http://www.statista.com/statistics/267129/most-used-languages-on-twitter/
self.lang_desc = Label(self,text="Select Language")
self.lang_desc.grid(row=7, column=2, columnspan=1)
self.lang_options = {'None':'None','Arabic':'ar', 'Dutch':'nl', 'English':'en', 'Japanese':'ja', 'Korean':'ko',
'Portuguese':'pt', 'Spanish':'es', 'Malay':'ms', 'Thai':'th'}
self.lang_v = StringVar()
self.lang_v.set(self.lang_options['None'])
self.lang_om = OptionMenu(self, self.lang_v, *self.lang_options)
self.lang_om.grid(row=8, column=2, columnspan=1)
#Result_type
self.result_type_desc = Label(self,text="Select Result Type")
self.result_type_desc.grid(row=9, column=0, columnspan=1)
result_type_options = ['Mixed','Recent','Popular']
self.result_type_v = StringVar()
self.result_type_v.set(result_type_options[0])
self.result_type_om = OptionMenu(self, self.result_type_v, *result_type_options)
self.result_type_om.grid(row=10, column=0, columnspan=1)
#Max Date
#(YYYY-MM-DD)
self.max_date_desc = Label(self,text="Enter Max Date")
self.max_date_desc.grid(row=9, column=2, columnspan=1)
self.max_date = Entry(self)
self.max_date.grid(row=10, column=2, columnspan=1)
#Divider
self.div3 = Label(self,text="____________________________________________________________________")
self.div3.grid(row=11, column=0, columnspan=3)
#File Name
self.file_name = Button(self, text="Save as...", command=self.save_as)
self.file_name.grid(row=12, column=0, columnspan=1)
#Execute search
self.search_button = Button(self, text="Search", command=self.start_search)
self.search_button.grid(row=12, column=2, columnspan=1)
def save_as(self):
self.file_opt = options = {}
options['filetypes'] = [('JSON', '.json'), ('Tab Separated', '.tsv')]
options['initialfile'] = 'myfile.tsv'
options['parent'] = root
file = filedialog.asksaveasfilename(**self.file_opt)
self.file_name = file
self.file_type = os.path.splitext(file)[1]
#new user popup window
def popup(self):
self.w=NewUser(self.master)
self.master.wait_window(self.w.top)
def start_search(self):
#new user check
user = TwitterUser()
if user.new_user():
webbrowser.open(user.auth_url())
new_user = self.popup()
user.save_user(self.w.value)
#.........这里部分代码省略.........
示例8: __init__
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
def __init__(self, master, gconf, directory=None):
self.master = master
self.initialized = False
self.master.bind('<Return>', self.infer)
self.master.bind('<Escape>', lambda a: self.master.quit())
self.master.protocol('WM_DELETE_WINDOW', self.quit)
self.dir = os.path.abspath(ifnone(directory, ifnone(gconf['prev_query_path'], os.getcwd())))
self.frame = Frame(master)
self.frame.pack(fill=BOTH, expand=1)
self.frame.columnconfigure(1, weight=1)
row = 0
# pracmln project options
Label(self.frame, text='PRACMLN Project: ').grid(row=row, column=0,
sticky='ES')
project_container = Frame(self.frame)
project_container.grid(row=row, column=1, sticky="NEWS")
# new proj file
self.btn_newproj = Button(project_container, text='New Project...', command=self.new_project)
self.btn_newproj.grid(row=0, column=1, sticky="WS")
# open proj file
self.btn_openproj = Button(project_container, text='Open Project...', command=self.ask_load_project)
self.btn_openproj.grid(row=0, column=2, sticky="WS")
# save proj file
self.btn_updateproj = Button(project_container, text='Save Project...', command=self.noask_save_project)
self.btn_updateproj.grid(row=0, column=3, sticky="WS")
# save proj file as...
self.btn_saveproj = Button(project_container, text='Save Project as...', command=self.ask_save_project)
self.btn_saveproj.grid(row=0, column=4, sticky="WS")
# grammar selection
row += 1
Label(self.frame, text='Grammar: ').grid(row=row, column=0, sticky='E')
grammars = ['StandardGrammar', 'PRACGrammar']
self.selected_grammar = StringVar()
self.selected_grammar.trace('w', self.settings_setdirty)
l = OptionMenu(*(self.frame, self.selected_grammar) + tuple(grammars))
l.grid(row=row, column=1, sticky='NWE')
# logic selection
row += 1
Label(self.frame, text='Logic: ').grid(row=row, column=0, sticky='E')
logics = ['FirstOrderLogic', 'FuzzyLogic']
self.selected_logic = StringVar()
self.selected_logic.trace('w', self.settings_setdirty)
l = OptionMenu(*(self.frame, self.selected_logic) + tuple(logics))
l.grid(row=row, column=1, sticky='NWE')
# mln section
row += 1
Label(self.frame, text="MLN: ").grid(row=row, column=0, sticky='NE')
self.mln_container = FileEditBar(self.frame, directory=self.dir,
filesettings={'extension': '.mln', 'ftypes': [('MLN files', '.mln')]},
defaultname='*unknown{}',
importhook=self.import_mln,
deletehook=self.delete_mln,
projecthook=self.save_proj,
filecontenthook=self.mlnfilecontent,
fileslisthook=self.mlnfiles,
updatehook=self.update_mln,
onchangehook=self.project_setdirty)
self.mln_container.editor.bind("<FocusIn>", self._got_focus)
self.mln_container.grid(row=row, column=1, sticky="NEWS")
self.mln_container.columnconfigure(1, weight=2)
self.frame.rowconfigure(row, weight=1)
row += 1
self.use_emln = IntVar()
self.use_emln.set(0)
self.cb_use_emln = Checkbutton(self.frame, text="use model extension",
variable=self.use_emln,
command=self.onchange_use_emln)
self.cb_use_emln.grid(row=row, column=1, sticky="W")
# mln extension section
row += 1
self.emlncontainerrow = row
self.emln_label = Label(self.frame, text="EMLN: ")
self.emln_label.grid(row=self.emlncontainerrow, column=0, sticky='NE')
self.emln_container = FileEditBar(self.frame,
directory=self.dir,
filesettings={'extension': '.emln', 'ftypes': [('MLN extension files','.emln')]},
defaultname='*unknown{}',
importhook=self.import_emln,
deletehook=self.delete_emln,
projecthook=self.save_proj,
filecontenthook=self.emlnfilecontent,
fileslisthook=self.emlnfiles,
updatehook=self.update_emln,
onchangehook=self.project_setdirty)
self.emln_container.grid(row=self.emlncontainerrow, column=1, sticky="NEWS")
self.emln_container.editor.bind("<FocusIn>", self._got_focus)
#.........这里部分代码省略.........
示例9: MLNQueryGUI
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
class MLNQueryGUI(object):
def __init__(self, master, gconf, directory=None):
self.master = master
self.initialized = False
self.master.bind('<Return>', self.infer)
self.master.bind('<Escape>', lambda a: self.master.quit())
self.master.protocol('WM_DELETE_WINDOW', self.quit)
self.dir = os.path.abspath(ifnone(directory, ifnone(gconf['prev_query_path'], os.getcwd())))
self.frame = Frame(master)
self.frame.pack(fill=BOTH, expand=1)
self.frame.columnconfigure(1, weight=1)
row = 0
# pracmln project options
Label(self.frame, text='PRACMLN Project: ').grid(row=row, column=0,
sticky='ES')
project_container = Frame(self.frame)
project_container.grid(row=row, column=1, sticky="NEWS")
# new proj file
self.btn_newproj = Button(project_container, text='New Project...', command=self.new_project)
self.btn_newproj.grid(row=0, column=1, sticky="WS")
# open proj file
self.btn_openproj = Button(project_container, text='Open Project...', command=self.ask_load_project)
self.btn_openproj.grid(row=0, column=2, sticky="WS")
# save proj file
self.btn_updateproj = Button(project_container, text='Save Project...', command=self.noask_save_project)
self.btn_updateproj.grid(row=0, column=3, sticky="WS")
# save proj file as...
self.btn_saveproj = Button(project_container, text='Save Project as...', command=self.ask_save_project)
self.btn_saveproj.grid(row=0, column=4, sticky="WS")
# grammar selection
row += 1
Label(self.frame, text='Grammar: ').grid(row=row, column=0, sticky='E')
grammars = ['StandardGrammar', 'PRACGrammar']
self.selected_grammar = StringVar()
self.selected_grammar.trace('w', self.settings_setdirty)
l = OptionMenu(*(self.frame, self.selected_grammar) + tuple(grammars))
l.grid(row=row, column=1, sticky='NWE')
# logic selection
row += 1
Label(self.frame, text='Logic: ').grid(row=row, column=0, sticky='E')
logics = ['FirstOrderLogic', 'FuzzyLogic']
self.selected_logic = StringVar()
self.selected_logic.trace('w', self.settings_setdirty)
l = OptionMenu(*(self.frame, self.selected_logic) + tuple(logics))
l.grid(row=row, column=1, sticky='NWE')
# mln section
row += 1
Label(self.frame, text="MLN: ").grid(row=row, column=0, sticky='NE')
self.mln_container = FileEditBar(self.frame, directory=self.dir,
filesettings={'extension': '.mln', 'ftypes': [('MLN files', '.mln')]},
defaultname='*unknown{}',
importhook=self.import_mln,
deletehook=self.delete_mln,
projecthook=self.save_proj,
filecontenthook=self.mlnfilecontent,
fileslisthook=self.mlnfiles,
updatehook=self.update_mln,
onchangehook=self.project_setdirty)
self.mln_container.editor.bind("<FocusIn>", self._got_focus)
self.mln_container.grid(row=row, column=1, sticky="NEWS")
self.mln_container.columnconfigure(1, weight=2)
self.frame.rowconfigure(row, weight=1)
row += 1
self.use_emln = IntVar()
self.use_emln.set(0)
self.cb_use_emln = Checkbutton(self.frame, text="use model extension",
variable=self.use_emln,
command=self.onchange_use_emln)
self.cb_use_emln.grid(row=row, column=1, sticky="W")
# mln extension section
row += 1
self.emlncontainerrow = row
self.emln_label = Label(self.frame, text="EMLN: ")
self.emln_label.grid(row=self.emlncontainerrow, column=0, sticky='NE')
self.emln_container = FileEditBar(self.frame,
directory=self.dir,
filesettings={'extension': '.emln', 'ftypes': [('MLN extension files','.emln')]},
defaultname='*unknown{}',
importhook=self.import_emln,
deletehook=self.delete_emln,
projecthook=self.save_proj,
filecontenthook=self.emlnfilecontent,
fileslisthook=self.emlnfiles,
updatehook=self.update_emln,
onchangehook=self.project_setdirty)
self.emln_container.grid(row=self.emlncontainerrow, column=1, sticky="NEWS")
#.........这里部分代码省略.........
示例10: popup_window_contrast
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
def popup_window_contrast(self) :
text = "Comparing ChIP-seq Peaks"
contrast_fn = join(self.workpath.get(),self.contrast_fn)
peakinfo_fn = join(self.workpath.get(),self.peakinfo_fn)
NA='N/A'
try :
groups = list(set([l.split('\t')[-1].strip() for l in open(peakinfo_fn) if l.split('\t')[-1].strip()]))
if len(groups) < 2 :
showwarning( 'WARNING!', "More than one groups need to be fefined in Peak Information File!" )
print( 'groups:', groups )
return
except IOError :
showerror( 'Error', "Did you set peak information?" )
print('Error:', 'Cannot process peakcall.tab file:')
return
top = Toplevel()
info = LabelFrame(top, text=text )#"Group Information")
print( groups )
contrast_vars = []
contrast_menus = []
n = 0
groups.insert(0, NA)
for i in range( int((len(groups)-1)*(len(groups)-2)/2) ):
n = n + 1
v1, v2 = StringVar(), StringVar()
contrast_vars.append( [v1, v2] )
o1, o2 = OptionMenu(info, v1, *groups), OptionMenu(info, v2, *groups)
contrast_menus.append( [o1, o2] )
v1.set(NA)
v2.set(NA)
vslabel = Label(info, text=" VS ")
o1.grid( row=n, column=0, padx=4, pady=1 )
o2.grid( row=n, column=2, padx=4, pady=1 )
vslabel.grid( row=n, column=1, padx=4, pady=1 )
def savefunc() :
info_text = StringIO()
for v1, v2 in contrast_vars :
v1 = v1.get() if v1.get() != NA else ""
v2 = v2.get() if v2.get() != NA else ""
if v1 and v2 :
pass
elif v1 or v2 :
showerror( 'Error', "None or Both columns should be selected!" )
return
else:
continue
print( v1, v2, file=info_text, sep="\t" )
fp = open( contrast_fn, 'w' )
fp.write( info_text.getvalue() )
fp.close()
def loadfunc() :
#self.readpaste( filename, info_text )
for i, l in enumerate(open( contrast_fn )) :
v1, v2 = l.split('\t')
v1 = v1.strip()
v2 = v2.strip()
if v1 :
try : assert v1 in groups
except :
showwarning('WARNING', 'Group name is not in the selection list!' )
print( 'v1:',v1 )
print( 'group:', groups )
continue
if v2 :
try: assert v2 in groups
except :
showwarning('WARNING', 'Group name is not in the selection list!' )
print( 'v2:',v2 )
print( 'group:', groups )
continue
contrast_vars[i][0].set(v1)
contrast_vars[i][1].set(v2)
def clearfunc() :
for v1, v2 in contrast_vars :
v1.set(NA)
v2.set(NA)
info_clear_button = Button(top,
text="Clear",
command = clearfunc )
info_save_button = Button(top,
text="Save",
#.........这里部分代码省略.........
示例11: FileEditBar
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
class FileEditBar(Frame, object):
def __init__(self, master, directory='.', filesettings=None, defaultname='*unknown{}', importhook=None,
deletehook=None, projecthook=None, filecontenthook=None, selectfilehook=None,
fileslisthook=None, updatehook=None, onchangehook=None):
self.master = master
Frame.__init__(self, master)
self.selected_file = StringVar()
self.selected_file.trace("w", self.select_file)
self._dirty = False
self._dirty_file_name = ''
self._editor_dirty = False
self.dir = directory
self.fsettings = filesettings
self.defaultname = defaultname
# hooks
self.import_hook = importhook
self.delete_hook = deletehook
self.save_project_hook = projecthook
self.filecontent_hook = filecontenthook
self.update_hook = updatehook
self.select_file_hook = selectfilehook
self.files_list_hook = fileslisthook
self.onchange_hook = onchangehook
row = 0
self.columnconfigure(1, weight=2)
files = []
self.file_buffer = {}
self.file_reload = True
if len(files) == 0: files.append("")
self.list_files = OptionMenu(*(self, self.selected_file) + tuple(files))
self.list_files.grid(row=row, column=1, sticky="NWE")
# new file
self.btn_newfile = Button(self, text='New', command=self.new_file)
self.btn_newfile.grid(row=row, column=2, sticky="E")
# import file
self.btn_importfile = Button(self, text='Import', command=self.import_file)
self.btn_importfile.grid(row=row, column=3, sticky="E")
# delete file
self.btn_delfile = Button(self, text='Delete', command=self.delete_file)
self.btn_delfile.grid(row=row, column=4, sticky="E")
# save button
self.btn_update_file = Button(self, text='Save', command=self.save_file)
self.btn_update_file.grid(row=row, column=6, sticky="E")
# save as.. button
self.btn_saveas_file = Button(self, text='Save as...', command=self.saveas_file)
self.btn_saveas_file.grid(row=row, column=7, sticky="E")
# editor
row += 1
self.editor = SyntaxHighlightingText(self, change_hook=self.onchange_filecontent)
self.editor.grid(row=row, column=1, columnspan=7, sticky="NWES")
self.rowconfigure(row, weight=1)
@property
def dirty(self):
return self._dirty or self.file_buffer != {}
@dirty.setter
def dirty(self, d):
self._dirty = (d or self.file_buffer != {})
if self.onchange_hook:
self.onchange_hook(dirty=self._dirty)
def new_file(self):
self.list_files['menu'].add_command(label=self.defaultname.format(self.fsettings.get('extension', '.mln')), command=_setit(self.selected_file, self.defaultname.format(self.fsettings.get('extension', '.mln'))))
self.selected_file.set(self.defaultname.format(self.fsettings.get('extension', '.mln')))
self.file_buffer[self.defaultname.format(self.fsettings.get('extension', '.mln'))] = ''
self.editor.delete("1.0", END)
self.dirty = True
def import_file(self):
filename = askopenfilename(initialdir=self.dir, filetypes=self.fsettings.get('ftypes'), defaultextension=self.fsettings.get('extension', '.mln'))
if filename:
fpath, fname = ntpath.split(filename)
self.dir = os.path.abspath(fpath)
content = mlnpath(filename).content
if self.import_hook is not None:
self.import_hook(fname, content)
self.update_file_choices()
self.selected_file.set(fname)
self.dirty = True
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
def __init__(self, pipepanel, pipeline_name, *args, **kwargs) :
PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs)
self.info = 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=["CellRanger","Initial/QC","Clustering","Multi-Sample Clustering" ]
Pipelines=["cellranger","scrnaseqinit","scrnaseqcluster", "scrnaseqmulticluster"]
self.label2pipeline = { k:v for k,v in zip(PipelineLabels, Pipelines)}
PipelineLabel = self.PipelineLabel = StringVar()
self.Pipeline = StringVar()
PipelineLabel.set(PipelineLabels[0])
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)
self.crOpts = crOpts = LabelFrame( eframe,
text="CellRanger Settings" )
self.scrCRID = scrCRID = StringVar()
scrCRID.set("SPECIFY_PREFIX_HERE")
self.scrExpected = scrExpected = StringVar()
scrExpected.set("3000")
scrcridL = Label(crOpts, text="CellRanger Sample ID: ")
scrcridE = Entry(crOpts, bd =2, width=25, textvariable=scrCRID)
scrcridL.grid(row=9,column=1,sticky=W,padx=10,pady=5)
scrcridE.grid(row=9,column=2,sticky=W,padx=0,pady=5)
screxpectedL = Label(crOpts, text="Expected number of cells: ")
screxpectedE = Entry(crOpts, bd =2, width=8, textvariable=scrExpected)
screxpectedL.grid(row=10,column=1,sticky=W,padx=10,pady=5)
screxpectedE.grid(row=10,column=2,sticky=W,padx=0,pady=5)
self.clusterOpts = clusterOpts = LabelFrame( eframe,
text="Clustering and tSNE Options" )
self.scrPCs = scrPCs = StringVar()
scrPCs.set("12")
self.scrRes = scrRes = StringVar()
scrRes.set("0.6")
#scrPCs.trace('w', lambda a,b,c,x="scrPCs": makejson(x))
#Filter out genes < [5] read counts in < [2] samples
scrpcsL = Label(clusterOpts, text="Include principal components 1 through ")
scrpcsE = Entry(clusterOpts, bd =2, width=3, textvariable=scrPCs)
scrresL = Label(clusterOpts, text="with clustering resolution: ")
scrresE = Entry(clusterOpts, bd =2, width=3, textvariable=scrRes)
scrpcsL.grid(row=9,column=1,sticky=W,padx=10,pady=5)
scrpcsE.grid(row=9,column=2,sticky=W,padx=0,pady=5)
scrresL.grid(row=9,column=3,sticky=W,padx=5,pady=5)
scrresE.grid(row=9,column=4,sticky=W,padx=0,pady=5)
#scrRes.trace('w', lambda a,b,c,x="scrPCs": makejson(x))
clusterOpts.grid( row=8, column=0, columnspan=4, sticky=W, padx=20, pady=10 )
self.multiclusterOpts = multiclusterOpts = LabelFrame( eframe,
text = "Multi-Sample Clustering and tSNE Options")
scrccsL = Label(multiclusterOpts, text="Include canonical components 1 through ")
scrccsE = Entry(multiclusterOpts, bd =2, width=3, textvariable=scrPCs)
scrmcresL = Label(multiclusterOpts, text="with clustering resolution: ")
scrmcresE = Entry(multiclusterOpts, bd =2, width=3, textvariable=scrRes)
scrccsL.grid(row=9,column=1,sticky=W,padx=10,pady=5)
scrccsE.grid(row=9,column=2,sticky=W,padx=0,pady=5)
scrmcresL.grid(row=9,column=3,sticky=W,padx=5,pady=5)
scrmcresE.grid(row=9,column=4,sticky=W,padx=0,pady=5)
self.qcOpts = qcOpts = LabelFrame( eframe,
text="Initial Settings" )
countL = Label( qcOpts, text="Counts/Matrix Dir:" )
countL.grid(row=9, column=1, sticky=W, padx=10, pady=5 )
countpath=StringVar()
self.countpath = countpath
count_entry = Entry(qcOpts,
bd =2,
width = 50,
#bg = entryBgColor,
#fg = entryFgColor,
textvariable = countpath, state='normal'
)
count_entry.grid( row=9, column=2, columnspan=3 )
self.count_button = count_button = Button( qcOpts,
text="Open Directory",
command=self.set_count_directory )
count_button.grid( row=9, column=5 )
#.........这里部分代码省略.........
示例13: Application
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.send_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.bind((host, port))
self.grid()
self.columnconfigure(0, minsize=100)
self.columnconfigure(1, minsize=200)
self.columnconfigure(2, minsize=200)
self.columnconfigure(3, minsize=150)
self.columnconfigure(4, minsize=150)
self.columnconfigure(5, minsize=150)
self.columnconfigure(6, minsize=150)
self.create_widgets()
self.settables = self.assemble_settables()
self.gui_logger = logging.getLogger('gui')
self.request_update()
def create_widgets(self):
self.create_monitor()
self.create_check_buttons()
self.create_ranges()
self.create_scales()
self.create_radio_buttons()
self.create_voices()
self.quitButton = Button(self, text='Quit', command=self.quit)
self.quitButton.grid(columnspan=7, sticky=E + W)
def assemble_settables(self):
settables = self.winfo_children()
for w in settables:
settables += w.winfo_children()
return [w for w in settables if w.__class__.__name__ in ['Scale', 'Checkbutton']]
def create_radio_buttons(self):
# Scale related
entries = ['DIATONIC', 'HARMONIC', 'MELODIC', 'PENTATONIC', 'PENTA_MINOR',
'GREEK_CHROMATIC', 'GREEK_ENHARMONIC']
self.scale = StringVar()
self.scale.set('DIATONIC')
self.rb_frame = Frame(self)
for e in entries:
rb = Radiobutton(self.rb_frame, value=e, text=e, anchor=W,
command=self.send_scale, variable=self.scale)
rb.grid(row=len(self.rb_frame.winfo_children()), sticky=W)
self.rb_frame.grid(column=1, row=len(self.grid_slaves(column=1)), rowspan=3)
def create_monitor(self):
self.monitor_frame = LabelFrame(self, text="Monitor and Transport")
this_cycle = Scale(self.monitor_frame, label='cycle_pos', orient=HORIZONTAL,
from_=1, to=16, resolution=1)
this_cycle.disable, this_cycle.enable = (None, None)
this_cycle.ref = 'cycle_pos'
this_cycle.grid(column=0, row=0, sticky=E + W)
self.updateButton = Button(self.monitor_frame,
text='Reload all Settings',
command=self.request_update)
self.updateButton.grid(row=1, sticky=E + W)
self.ForceCaesuraButton = Button(self.monitor_frame,
text='Force Caesura',
command=self.force_caesura)
self.ForceCaesuraButton.grid(row=2, sticky=E + W)
self.saveBehaviourButton = Button(self.monitor_frame,
text='Save current behaviour',
command=self.request_saving_behaviour)
self.saveBehaviourButton.grid(row=3, sticky=E + W)
self.saveBehaviourNameEntry = Entry(self.monitor_frame)
self.saveBehaviourNameEntry.grid(row=4, sticky=E + W)
self.saveBehaviourNameEntry.bind('<KeyRelease>', self.request_saving_behaviour)
self.selected_behaviour = StringVar()
self.selected_behaviour.trace('w', self.new_behaviour_chosen)
self.savedBehavioursMenu = OptionMenu(self.monitor_frame,
self.selected_behaviour, None,)
self.savedBehavioursMenu.grid(row=5, sticky=E + W)
self.monitor_frame.grid(column=0, row=10, sticky=E + W)
def request_update(self):
self.send({'sys': 'update'})
def request_saving_behaviour(self, event=None):
"""callback for save behaviour button and textentry"""
if event and event.widget == self.saveBehaviourNameEntry:
if event.keysym == 'Return':
name = self.saveBehaviourNameEntry.get()
self.saveBehaviourNameEntry.delete(0, len(name))
else:
return
else: # button was pressed
name = self.saveBehaviourNameEntry.get()
if name:
self.send({'sys': ['save_behaviour', name]})
def force_caesura(self):
self.send({'force_caesura': True})
def create_voices(self):
voice_ids = ['1', '2', '3', '4']
SCALES = OrderedDict([
('pan_pos', {'min': -1, 'max': 1, 'start': 0.5, 'res': 0.001}),
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
class DropdownList:
def __init__(self, master, filemask='*.mln', default=None, allowNone=False, onselchange=None, directory='.'):
self.allowNone = allowNone
self.directory = directory
self.list_frame = master
self.onchange = onselchange
if type(filemask) != list:
filemask = [filemask]
self.file_mask = filemask
self.updateList()
if havePMW:
self.list = ComboBox(master, selectioncommand=onselchange, scrolledlist_items = self.files)
self.list.component('entryfield').component('entry').configure(state = 'readonly', relief = 'raised')
self.picked_name = self.list
else:
self.picked_name = StringVar()
self.list = OptionMenu(*(master, self.picked_name) + tuple(self.files))
if onselchange is not None:
self.picked_name.trace("w", self.onchange)
if default is not None:
self.select(default)
else:
self.select(self.files[0])
def __getattr__(self, name):
return getattr(self.list, name)
def get(self):
return self.picked_name.get()
def select(self, item):
if item in self.files:
if not havePMW:
self.picked_name.set(item)
else:
self.list.selectitem(item)
def updateList(self):
self.files = []
if self.allowNone:
self.files.append("")
if os.path.exists(self.directory):
for filename in os.listdir(self.directory):
for fm in self.file_mask:
if fnmatch(filename, fm):
self.files.append(filename)
self.files.sort()
if len(self.files) == 0 and not self.allowNone: self.files.append("(no %s files found)" % str(self.file_mask))
def makelist(self):
if havePMW:
self.list = ComboBox(self.list_frame,
selectioncommand = self.onSelChange,
scrolledlist_items = self.files,
)
self.list.grid(row=0, column=0, padx=0, pady=0, sticky="NEWS")
self.list.component('entryfield').component('entry').configure(state = 'readonly', relief = 'raised')
self.picked_name = self.list
else:
self.list = OptionMenu(*(self.list_frame, self.picked_name) + tuple(self.files))
self.list.grid(row=0, column=0, sticky="NEW")
self.picked_name.trace("w", self.onSelChange)
self.select(self.files[0])
def setDirectory(self, directory, keep=False):
self.directory = directory
self.updateList()
self.makelist()
# if keep is true, only the files list will be updated but the content of the
# text area will not be altered/removed
if not keep: self.select("")
def onSelChange(self, name, index=0, mode=0):
filename = self.picked_name.get()
if self.onchange != None:
self.onchange(filename)
示例15: Example
# 需要导入模块: from tkinter import OptionMenu [as 别名]
# 或者: from tkinter.OptionMenu import grid [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("")
#self.style = Style()
#self.style.theme_use("clam")
#self.pack(fill=BOTH, expand = 1)
self.labelU = Label(self, text="U:")
self.labelP = Label(self, text="P:")
self.mailrecipient = 'GoldenSights'
self.entryUsername = Entry(self)
self.entryUsername.focus_set()
self.entryUsername.bind('<Return>', lambda event: self.entryPassword.focus_set())
self.entryPassword = Entry(self)
self.entryPassword.config(show='•')
self.entryPassword.bind('<Return>', lambda event: self.login(self.entryUsername.get(), self.entryPassword.get()))
self.newbutton = Button(self, text="Login", command= lambda: self.login(self.entryUsername.get(), self.entryPassword.get()))
self.newbutton.bind('<Return>', lambda event: self.login(self.entryUsername.get(), self.entryPassword.get()))
self.newbutton.config(width=6)
self.quitbutton = Button(self, text="Quit", command= lambda: self.quit())
self.quitbutton.config(width=6)
self.labelU.grid(row=0, column=0,padx=0)
self.entryUsername.grid(row=0, column=1)
self.labelP.grid(row=1, column=0)
self.entryPassword.grid(row=1, column=1, pady=4)
self.newbutton.grid(row=2, column=1)
self.quitbutton.grid(row=3, column=1, pady=4)
self.labelErrorPointer = Label(self, text="◀")
self.indicatorGreen = PhotoImage(file="indicatorGreen.gif")
self.indicatorRed = PhotoImage(file="indicatorRed.gif")
self.indicatorBlue = PhotoImage(file="indicatorBlue.gif")
self.indicatorBlack = PhotoImage(file="indicatorBlack.gif")
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
w=400
h=480
x = (sw - w) / 2
y = (sh - h) / 2
self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y-50))
def login(self, username, password):
print('U: ' + username)
self.username = username
if username == '' or not all(char in string.ascii_letters+string.digits+'_-' for char in username):
print('Please enter a username')
self.entryUsername.focus_set()
self.labelErrorPointer.grid(row=0, column=2)
elif password == '':
print('Please enter a password')
self.entryPassword.focus_set()
self.labelErrorPointer.grid(row=1, column=2)
else:
self.labelErrorPointer.grid_forget()
print('Attempting login for ' + username)
try:
self.USERAGENT = username + ' practices Tkinter+PRAW mixing with utility by /u/GoldenSights.'
self.r = praw.Reddit(self.USERAGENT)
#self.r.login(username, password)
print('Success')
self.labelU.grid_forget()
self.labelP.grid_forget()
self.entryUsername.grid_forget()
self.entryPassword.grid_forget()
self.newbutton.grid_forget()
self.quitbutton.grid_forget()
self.usernamelabel = Label(self, text=username + ', Sending to /u/' + self.mailrecipient)
self.usernamelabel.grid(row=0, column=0, columnspan=8)
self.quitbutton.grid(row=900, column=0)
self.labellist = []
self.entrylist = []
self.verifylist = []
self.misclist = []
self.optionDiscuss = "Discussion Flair + Crossposting"
self.optionRegister = "Register a new Candidate"
self.prevmode = self.optionDiscuss
#.........这里部分代码省略.........