本文整理汇总了Python中ttk.Combobox类的典型用法代码示例。如果您正苦于以下问题:Python Combobox类的具体用法?Python Combobox怎么用?Python Combobox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Combobox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, master):
#-----------------------Interface gráfica----------------------------------------------------
self.frame1 = Frame(master, bg = COR_FUNDO)
self.frame1.place(relheight = 1.0, relwidth = 1.0)
self.botao_refresh = Button(self.frame1, text = 'Atualizar dispositivos', font = ('Courier','10'),
fg = 'black', bg = COR_BOTAO_2, borderwidth = 3,
command = self.devices)
self.botao_refresh.place(relx = 0.202, rely = 0.02, relwidth = 0.54)
Label(self.frame1, text = 'Escolha o dispositivo(CUIDADO)',
font=('Courier','14'), fg = 'red', bg = COR_FUNDO).place(relx = 0.02, rely = 0.12)
self.device = Combobox(self.frame1, font = ('Ariel','15'))
self.device.place(relx = 0.04, rely = 0.20, relwidth = 0.90)
Label(self.frame1, text='Escolha o Sistema de arquivos',
font=('Courier','14'), fg = 'white', bg = COR_FUNDO).place(relx = 0.02, rely = 0.32)
self.sis = Combobox(self.frame1, font = ('Ariel','15'))
self.sis.place(relx = 0.04, rely = 0.40, relwidth = 0.90)
self.botao_formatar = Button(self.frame1, text = 'Formatar', font = ('Courier','25'),
fg = 'black', bg = COR_BOTAO_1, borderwidth = 3,
command = self.formatar)
self.botao_formatar.bind("<Button-1>", self.mudabotao)
self.botao_formatar.place(relx = 0.21, rely = 0.82, relwidth = 0.54)
self.devices()
self.sis_file()
示例2: SnapFrame
class SnapFrame(Frame):
def __init__(self, parent, cb=dummy):
Frame.__init__(self, parent)
self.parent = parent
self.cb = cb
self._init_ui()
def _cb(self, *args):
self.cb(SNAP_DICT[self._var.get()])
def _init_ui(self):
self._var = StringVar()
self.snap_combobox = Combobox(
self, values=SNAP_DICT.keys(),
width=5, textvariable=self._var,
state='readonly')
self.snap_combobox.set(SNAP_DICT.keys()[0])
self._var.trace('w', self._cb)
self.snap_label = Label(self, text='Snap')
self.snap_label.pack(side=LEFT)
self.snap_combobox.pack(side=LEFT)
示例3: __init__
def __init__(self, master, customers, payments, refresh):
Toplevel.__init__(self,master)
self.root = master
self.refresh = refresh
self.title("Check In")
self.iconname = "Check In"
self.name = StringVar() # variable for customer
self.customers = customers # customers object
self.payments = payments
self.names = []
self.workout = StringVar()
self.workouts = []
self.workouts_form = []
self.date = StringVar()
self.date.set(strftime("%m/%d/%Y"))
self.refresh_time = 15 # in minutes
self.output = '' # for the output label at the bottom
self.schedule = Schedule()
self.logger = Logger() #throws IOError if file is open
inf = Frame(self)
inf.pack(padx=10,pady=10,side='top')
Label(inf, text="Name:").grid(row=0,column=0,sticky=E,ipady=2,pady=2,padx=10)
Label(inf, text='Date:').grid(row=1,column=0,sticky=E,ipady=2,pady=2,padx=10)
Label(inf, text="Workout:").grid(row=2,column=0,sticky=E,ipady=2,pady=2,padx=10)
self.name_cb = Combobox(inf, textvariable=self.name, width=30,
values=self.names)
self.name_cb.grid(row=0,column=1,sticky=W,columnspan=2)
self.date_ent = Entry(inf, textvariable=self.date)
self.date_ent.grid(row=1,column=1,sticky=W)
self.date_ent.bind('<FocusOut>', self.update_workouts)
Button(inf,text='Edit', command=self.enable_date_ent).grid(row=1,column=2,sticky=E)
self.workout_cb = Combobox(inf, textvariable=self.workout, width=30,
values=self.workouts_form,state='readonly')
self.workout_cb.grid(row=2,column=1,sticky=W,columnspan=2)
self.log_btn=Button(inf,text="Log Workout",command=self.log,width=12)
self.log_btn.grid(row=3,column=1,columnspan=2,pady=4,sticky='ew')
stf = Frame(self)
stf.pack(padx=10,pady=10,fill='x',side='top')
self.scrolled_text = ScrolledText(stf,height=15,width=50,wrap='word',state='disabled')
self.scrolled_text.pack(expand=True,fill='both')
self.update_workouts()
self.update_names()
self.bind('<Return>',self.log)
self.name_cb.focus_set() # set the focus here when created
#disable the date field
self.disable_date_ent()
#start time caller
self.time_caller()
示例4: __initializeComponents
def __initializeComponents(self):
self.imageCanvas = Canvas(master=self, width=imageCanvasWidth,
height=windowElementsHeight, bg="white")
self.imageCanvas.pack(side=LEFT, padx=(windowPadding, 0),
pady=windowPadding, fill=BOTH)
self.buttonsFrame = Frame(master=self, width=buttonsFrameWidth,
height=windowElementsHeight)
self.buttonsFrame.propagate(0)
self.loadFileButton = Button(master=self.buttonsFrame,
text=loadFileButtonText, command=self.loadFileButtonClick)
self.loadFileButton.pack(fill=X, pady=buttonsPadding);
self.colorByLabel = Label(self.buttonsFrame, text=colorByLabelText)
self.colorByLabel.pack(fill=X)
self.colorByCombobox = Combobox(self.buttonsFrame, state=DISABLED,
values=colorByComboboxValues)
self.colorByCombobox.set(colorByComboboxValues[0])
self.colorByCombobox.bind("<<ComboboxSelected>>", self.__colorByComboboxChange)
self.colorByCombobox.pack(fill=X, pady=buttonsPadding)
self.rejectedValuesPercentLabel = Label(self.buttonsFrame, text=rejectedMarginLabelText)
self.rejectedValuesPercentLabel.pack(fill=X)
self.rejectedValuesPercentEntry = Entry(self.buttonsFrame)
self.rejectedValuesPercentEntry.insert(0, defaultRejectedValuesPercent)
self.rejectedValuesPercentEntry.config(state=DISABLED)
self.rejectedValuesPercentEntry.pack(fill=X, pady=buttonsPadding)
self.colorsSettingsPanel = Labelframe(self.buttonsFrame, text=visualisationSettingsPanelText)
self.colorsTableLengthLabel = Label(self.colorsSettingsPanel, text=colorsTableLengthLabelText)
self.colorsTableLengthLabel.pack(fill=X)
self.colorsTableLengthEntry = Entry(self.colorsSettingsPanel)
self.colorsTableLengthEntry.insert(0, defaultColorsTableLength)
self.colorsTableLengthEntry.config(state=DISABLED)
self.colorsTableLengthEntry.pack(fill=X)
self.scaleTypeLabel = Label(self.colorsSettingsPanel, text=scaleTypeLabelText)
self.scaleTypeLabel.pack(fill=X)
self.scaleTypeCombobox = Combobox(self.colorsSettingsPanel, state=DISABLED,
values=scaleTypesComboboxValues)
self.scaleTypeCombobox.set(scaleTypesComboboxValues[0])
self.scaleTypeCombobox.bind("<<ComboboxSelected>>", self.__scaleTypeComboboxChange)
self.scaleTypeCombobox.pack(fill=X)
self.colorsTableMinLabel = Label(self.colorsSettingsPanel, text=colorsTableMinLabelText)
self.colorsTableMinLabel.pack(fill=X)
self.colorsTableMinEntry = Entry(self.colorsSettingsPanel)
self.colorsTableMinEntry.insert(0, defaultColorsTableMin)
self.colorsTableMinEntry.config(state=DISABLED)
self.colorsTableMinEntry.pack(fill=X)
self.colorsTableMaxLabel = Label(self.colorsSettingsPanel, text=colorsTableMaxLabelText)
self.colorsTableMaxLabel.pack(fill=X)
self.colorsTableMaxEntry = Entry(self.colorsSettingsPanel)
self.colorsTableMaxEntry.insert(0, defaultColorsTableMax)
self.colorsTableMaxEntry.config(state=DISABLED)
self.colorsTableMaxEntry.pack(fill=X)
self.colorsSettingsPanel.pack(fill=X, pady=buttonsPadding)
self.redrawButton = Button(master=self.buttonsFrame, text=redrawButtonText,
state=DISABLED, command=self.__redrawButtonClick)
self.redrawButton.pack(fill=X, pady=buttonsPadding)
self.buttonsFrame.pack(side=RIGHT, padx=windowPadding, pady=windowPadding, fill=BOTH)
示例5: __init__
def __init__(self, parent, **kwargs):
"""!
A constructor for the class
@param self The pointer for the object
@param parent The parent object for the frame
@param **kwargs Other arguments as accepted by ttk.Combobox
"""
#Initialise the inherited class
Combobox.__init__(self, parent, **kwargs)
示例6: SendGCode
class SendGCode(LabelFrame):
def __init__(self, root, prtr, settings, log, *arg):
LabelFrame.__init__(self, root, *arg, text="Send gcode")
self.app = root
self.printer = prtr
self.settings = settings
self.log = log
self.entry = Entry(self, width=50)
self.entry.grid(row=1, column=1, columnspan=3, sticky=N+E+W)
self.bSend = Button(self, text="Send", width=4, command=self.doSend, state=DISABLED)
self.bSend.grid(row=1, column=4, padx=2)
self.entry.delete(0, END)
self.entry.bind('<Return>', self.hitEnter)
self.gcv = StringVar(self)
gclist = gcoderef.gcKeys()
self.gcv.set(gclist[0])
l = Label(self, text="G Code Reference:", justify=LEFT)
l.grid(row=2, column=1, columnspan=2, sticky=W)
self.gcm = Combobox(self, textvariable=self.gcv)
self.gcm['values'] = gclist
self.gcm.grid(row=2, column=3, padx=2)
self.gcm.bind('<<ComboboxSelected>>', self.gcodeSel)
#self.bInfo = Button(self, text="Info", width=9, command=self.doInfo)
#self.bInfo.grid(row=2, column=4, padx=2)
#def doInfo(self):
def gcodeSel(self, *arg):
verb = self.gcv.get()
self.log.logMsg("%s: %s" % (verb, gcoderef.gcText(verb)))
def activate(self, flag):
if flag:
self.bSend.config(state=NORMAL)
else:
self.bSend.config(state=DISABLED)
def hitEnter(self, e):
self.doSend()
def doSend(self):
cmd = self.entry.get()
verb = cmd.split()[0]
if self.app.printerAvailable(cmd=verb):
self.log.logMsg("Sending: %s" % cmd)
self.printer.send_now(cmd)
示例7: __init__
def __init__(self, master, customers, payments, output_text, refresh):
Frame.__init__(self, master)
self.refresh = refresh
self.master = master
self.output_text = output_text
self.customers = customers
self.payments = payments
self.pname = StringVar()
self.pnames = []
self.mname = StringVar()
self.mnames = []
self.date = StringVar()
self.nmonths = StringVar()
self.punches = StringVar()
self.nmonths.set('1')
self.punches.set(str(10))
self.date.set(strftime("%m/%d/%Y"))
self.columnconfigure(0,weight=1)
# Monthly Customers
monthly_lf = LabelFrame(self, text="Monthly Customers Payment")
monthly_lf.grid(padx=5,pady=5,row=0,column=0,sticky='ew')
Label(monthly_lf,text="Name:").grid(row=0,column=0,sticky='e',padx=(10,0),pady=(10,2))
Label(monthly_lf,text="Date:").grid(row=0,column=3,sticky='e',padx=(10,0),pady=(10,2))
Label(monthly_lf,text="# Months:").grid(row=1,column=0,columnspan=2,sticky='e',padx=(10,0),pady=(2,10))
self.mname_cb = Combobox(monthly_lf,textvariable=self.mname,width=20,values=self.mnames,
state='readonly')
self.mname_cb.grid(row=0,column=1,columnspan=2,sticky='ew',pady=(10,2))
Entry(monthly_lf,textvariable=self.date,width=15).grid(row=0,column=4,sticky='ew',padx=(0,10),pady=(10,2))
Entry(monthly_lf,textvariable=self.nmonths).grid(row=1,column=2,sticky='ew',pady=(2,10))
Button(monthly_lf,text='Submit',command=self.monthly_payment).grid(row=1,column=4,sticky='ew',padx=(0,10),pady=(2,10))
for i in range(5):
monthly_lf.columnconfigure(i,weight=1)
# Punch Card Customers
puch_lf = LabelFrame(self, text="Punch Card Customers (Purchace Card)")
puch_lf.grid(padx=5,pady=5,row=1,column=0,sticky='ew')
Label(puch_lf,text="Name:").grid(row=0,column=0,sticky='e',padx=(10,0),pady=(10,2))
Label(puch_lf,text="Punches:").grid(row=0,column=2,sticky='e',pady=(10,2))
self.pname_cb = Combobox(puch_lf,textvariable=self.pname,width=20,values=self.pnames,state='readonly')
self.pname_cb.grid(row=0,column=1,sticky='ew',pady=(10,2))
Entry(puch_lf,textvariable=self.punches,width=15).grid(row=0,column=3,sticky='ew',padx=(0,10),pady=(10,2))
Button(puch_lf,text='Submit',command=self.new_punchcard).grid(row=3,column=3,sticky='ew',padx=(0,10),pady=(2,10))
for i in range(4):
puch_lf.columnconfigure(i,weight=1)
self.update_names()
示例8: add_param_fields
def add_param_fields(self, frame, rownum, object_map):
#create the fields
key_option_val = StringVar(frame)
key_option_val.set(self.keywords[0])
key_option_menu = Combobox(frame, textvariable=key_option_val, state='readonly')
key_option_menu['values'] = self.keywords
key_option_menu.grid(row=0, column=0, sticky=W, pady=10, padx=10)
val_text = StringVar(frame)
val_entry = Entry(frame, textvariable=val_text)
val_entry.grid(row=0, column=1, pady=10, padx=10, sticky=W)
object_map.append((key_option_val, val_text))
示例9: initUI
def initUI(self):
self.parent.title("TRAM")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
#Model Text
self.t = Text(self, borderwidth=3, relief="sunken")
self.t.config(font=("consolas", 12), undo=True, wrap='word')
self.t.grid(row=0, column=0, padx=2, pady=2, sticky=(N, W, E, S))
#Search Panel
searchPanel = LabelFrame(self, text="Find your model")
searchPanel.grid(row=0, column=1, padx=2, pady=2, sticky=N)
Label(searchPanel, text="Model name").grid(row=0, column=0, padx=2, pady=2, sticky=W)
searchQueryEntry = Entry(searchPanel, textvariable=self.searchQuery)
searchQueryEntry.grid(row=0, column=1, padx=2, pady=2, sticky=W)
Label(searchPanel, text="Transformation").grid(row=1, column=0, padx=2, pady=2, sticky=W)
preferredTransformation = StringVar()
box = Combobox(searchPanel, textvariable=preferredTransformation, state='readonly')
box['values'] = ('Any...', 'Object Change', 'Object Extension', 'Specialization', 'Functionality Extension', 'System Extension', 'Soft Simplification', 'Hard Simplification')
box.current(0)
box.grid(row=1, column=1, padx=2, pady=2, sticky=W)
findButton = Button(searchPanel, text="Find", command = self.__findModels)
findButton.grid(row=2, column=1, padx=2, pady=2, sticky=E)
#Listbox with recommendations
recommendationPanel = LabelFrame(self, text="Recommended models (transformations)")
recommendationPanel.grid(row=0, column=1, padx=2, pady=2, sticky=(W,E,S))
self.l = Listbox(recommendationPanel)
self.l.pack(fill=BOTH, expand=1)
#Button frame
transformButtonPanel = Frame(recommendationPanel)
transformButtonPanel.pack(fill=BOTH, expand=1)
viewButton = Button(transformButtonPanel, text="View", command = self.__loadSelectedModel)
viewButton.grid(row=1, column=0, padx=2, pady=2)
transformButton = Button(transformButtonPanel, text="Transform", command = self.__transformModel)
transformButton.grid(row=1, column=2, padx=2, pady=2)
示例10: editor
def editor():
"""Run editor"""
global zone_dessin
global grid
global entry_retour
global combobox_difficulty
global lvlList
grid = Grid()
# Windows
fenetre = Tk()
fenetre.geometry("500x525")
fenetre.title("Editeur Hanjie")
fenetre.resizable(width=False, height=False)
# Canvas
zone_dessin = Canvas(fenetre,width=500,height=500, bg="white")
zone_dessin.place(x=0,y=0)
Initialisation()
zone_dessin.bind("<Button-1>", Swap)
# Entry
default_text = StringVar()
entry_retour = Entry(fenetre,width=20,textvariable=default_text)
default_text.set("Level name...")
entry_retour.place(x=2,y=503)
# Save Button
button_save = Button(fenetre,text="Save", width=8,height=1, command = But_Save)
button_save.place(x=130,y=500)
# Load Button
button_load = Button(fenetre,text="Load", width=8,height=1, command = But_Load)
button_load.place(x=200,y=500)
# Reset Button
button_load = Button(fenetre,text="Reset", width=8,height=1, command = But_Reset)
button_load.place(x=270,y=500)
# Difficulty Combobox
lvlSelect = StringVar()
lvlList = ('LVL 1', 'LVL 2', 'LVL 3', 'LVL 4', 'LVL 5')
combobox_difficulty = Combobox(fenetre, values = lvlList, state = 'readonly')
combobox_difficulty.set(lvlList[0])
combobox_difficulty.place(x=340,y=502)
fenetre.mainloop()
示例11: JournalEntry
class JournalEntry(LabelFrame):
def __init__(self, parent, question, i, defaultanswer, *options):
LabelFrame.__init__(self, parent, text=question, padx=5, pady=5)
self.var = StringVar(parent)
try:
if defaultanswer in options:
options = tuple(x for x in options if x != defaultanswer)
options = (defaultanswer,) + options
self.var.set(options[0])
except IndexError:
self.var.set("")
self.om = Combobox(self, textvariable=self.var)
self.om['values'] = options
self.om.pack(padx=5,pady=5, side="left")
self.grid(row=i,column=0,columnspan=3, sticky=W, pady=10)
示例12: __init__
def __init__(self, root, prtr, settings, log, *arg):
LabelFrame.__init__(self, root, *arg, text="Send gcode")
self.app = root
self.printer = prtr
self.settings = settings
self.log = log
self.entry = Entry(self, width=50)
self.entry.grid(row=1, column=1, columnspan=3, sticky=N+E+W)
self.bSend = Button(self, text="Send", width=4, command=self.doSend, state=DISABLED)
self.bSend.grid(row=1, column=4, padx=2)
self.entry.delete(0, END)
self.entry.bind('<Return>', self.hitEnter)
self.gcv = StringVar(self)
gclist = gcoderef.gcKeys()
self.gcv.set(gclist[0])
l = Label(self, text="G Code Reference:", justify=LEFT)
l.grid(row=2, column=1, columnspan=2, sticky=W)
self.gcm = Combobox(self, textvariable=self.gcv)
self.gcm['values'] = gclist
self.gcm.grid(row=2, column=3, padx=2)
self.gcm.bind('<<ComboboxSelected>>', self.gcodeSel)
示例13: __init__
def __init__(self, menu):
Tk.__init__(self)
self.title("Pick a level")
icon = PhotoImage(file=os.getcwd() + '/res/logo/logo.gif')
self.tk.call("wm", "iconphoto", self._w, icon)
self.eval('tk::PlaceWindow %s center' % self.winfo_pathname(self.winfo_id()))
self.levels = [file[:-4] for file in listdir("res/levels")]
self.protocol("WM_DELETE_WINDOW", self.shutdownTTK)
if not self.levels: # No levels
self.withdraw()
tkMessageBox.showwarning("Error", 'There doesn\'t seem to be any levels saved. Create one pressing the "Design Level" button!')
self.shutdownTTK()
else:
self.menu = menu
self.value = StringVar()
self.levels_list = Combobox(self, textvariable=self.value, state='readonly')
self.levels_list['values'] = self.levels
self.levels_list.current(0)
self.levels_list.grid(column=0, row=0)
self.button = Button(self, text="Begin Level", command=self.begin_level)
self.button.grid(column=0, row=1)
self.mainloop()
示例14: init_ui
def init_ui(self):
self.parent.title("Activity Logger")
self.parent.focusmodel("active")
self.style = Style()
self.style.theme_use("aqua")
self.combo_text = StringVar()
cb = self.register(self.combo_complete)
self.combo = Combobox(self,
textvariable=self.combo_text,
validate="all",
validatecommand=(cb, '%P'))
self.combo['values'] = ["Food", "Email", "Web"]
self.combo.pack(side=TOP, padx=5, pady=5, fill=X, expand=0)
#self.entry = Text(self, bg="white", height="5")
#self.entry.pack(side=TOP, padx=5, pady=5, fill=BOTH, expand=1)
self.pack(fill=BOTH, expand=1)
self.centre()
self.ok = Button(self, text="Ok", command=self.do_ok)
self.ok.pack(side=RIGHT, padx=5, pady=5)
self.journal = Button(self, text="Journal", command=self.do_journal)
self.journal.pack(side=RIGHT, padx=5, pady=5)
self.exit = Button(self, text="Exit", command=self.do_exit)
self.exit.pack(side=RIGHT, padx=5, pady=5)
示例15: initializeComponents
def initializeComponents(self):
self.boxValue = StringVar()
self.boxValue.trace('w', \
lambda name, index, mode, \
boxValue = self.boxValue : \
self.box_valueEditted(boxValue))
self.box = Combobox(self,\
justify = 'left',\
width = 50, \
textvariable = self.boxValue,\
)
self.box.pack(side = 'left',expand = 1, padx = 5, pady = 5)
self.box.bind('<<ComboboxSelected>>',self.box_selected)
self.box.bind('<Return>',self.box_returned)
self.importButton = Button(self, \
text = "Import", \
command = self.importButton_clicked,\
)
self.importButton.pack(side = 'left',expand = 1)
self.cmd_str = StringVar(None,"Prefix Only")
self.switchButton = Button(self, \
textvariable = self.cmd_str, \
command = self.switchButton_clicked, \
)
self.switchButton.pack(side = 'right', padx = 5, pady = 5)