本文整理汇总了Python中tkinter.ttk.Combobox.get方法的典型用法代码示例。如果您正苦于以下问题:Python Combobox.get方法的具体用法?Python Combobox.get怎么用?Python Combobox.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Combobox
的用法示例。
在下文中一共展示了Combobox.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SliderParameter
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class SliderParameter(Frame):
"""
A frame contening additionnals parameters for filter (represented by a SliderFrequency)
to set the type and the Q factor
parameters:
root: Canvas
the canvas to place the SliderParameter
type: String
A string representing the type of a filter
Q: String
the Q factor of a filter
id: int
ID of th SliderParameter
"""
def __init__(self,root, type, Q, id):
Frame.__init__(self,root)
self.root = root
self.typeFilter = StringVar()
self.typeFilter.set(type)
self.qFactor = StringVar()
self.qFactor.set(Q)
self.id = id
self.initialize()
def initialize(self):
""" Initialize the combobox contening all available type of filter
and the entry text to choose the value of Q factor
"""
self.typeCombo = Combobox(self.root, textvariable=self.typeFilter, values=F.values(), width="5")
self.typeCombo.grid(row=1,column=self.id, padx=10)
self.qText = Entry(self.root, textvariable=self.qFactor, width="5")
self.qText.grid(row=2,column=self.id, padx=10, pady=5)
def getQ(self):
""" return the value of the Q factor """
return self.qFactor.get()
def getType(self):
""" Return the type of the filter """
return self.typeCombo.get()
示例2: build_combobox_with_label
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
def build_combobox_with_label(values, master, row, col, toggle_background_elements):
def toggle_display():
for element in toggle_background_elements:
if var.get() == 'True':
element.configure(state='normal')
elif var.get() == 'False':
element.configure(state='disabled')
frame = Frame(master=master, bg='#FFCFC9')
frame.grid(row=row, column=col, padx=5)
label = Label(master=frame, text='Is logged in: ', justify=LEFT)
label.config(justify='right', bg='white')
label.grid(row=0, column=0, pady=2.5)
var = StringVar(master=frame, value=values[0])
cb = Combobox(master=frame, textvariable=var)
cb['values'] = values
cb.grid(row=0, column=1)
cb.bind('<<ComboboxSelected>>', lambda x: (var.set(cb.get()), toggle_display()))
if var.get() == 'False':
for element in toggle_background_elements:
element.configure(state='disabled')
return frame, var
示例3: AddDrawingRuleDialog
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class AddDrawingRuleDialog(d.Dialog):
def body(self, master, existingRule=None):
self.cmd = String()
Label(master, text= "Symbol:").grid(row=0)
Label(master, text= "Rule:" ).grid(row=1)
self.e1 = Input(master, width=20)
self.e2 = Dropdown(master, textvariable= self.cmd, width= 7, state= 'readonly')
self.e3 = Input(master, width=10)
self.e2['values'] = ['draw', 'turn', 'skip', 'back', 'color', 'thick']
self.e1.grid(row=0, column=1, columnspan=2)
self.e2.grid(row=1, column=1)
self.e3.grid(row=1, column=2)
if existingRule:
self.e1.insert(0, existingRule[1])
self.e2.set(existingRule[2])
#self.e2.insert(0, existingRule[2])
if len(existingRule) > 3:
self.e3.insert(0, existingRule[3])
return self.e1
def validate(self):
symb = self.e1.get()
rule = self.e2.get()
param = self.e3.get()
if symb and rule:
symb = symb.strip()
rule = rule.strip()
if param:
return (symb, rule, param)
else:
return (symb, rule)
def apply(self):
r = self.validate()
if r:
self.result = r
示例4: SimUI
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class SimUI(object):
def __init__(self, manager, fake_time, config_obj):
"""
initializes all default values and creates
a board, waits for run() to be called
to start the board
manager - sim manager class instance
"""
self.manager = manager
self.fake_time = fake_time
self.config_obj = config_obj
# Set up idle_add
self.queue = queue.Queue()
self.root = tk.Tk()
self.root.wm_title("PyFRC Robot Simulator v%s" % __version__)
# setup mode switch
frame = tk.Frame(self.root)
frame.pack(side=tk.TOP, anchor=tk.W)
self._setup_widgets(frame)
self.root.resizable(width=0, height=0)
self.mode_start_tm = 0
self.text_id = None
# connect to the controller
self.manager.on_mode_change(lambda mode: self.idle_add(self.on_robot_mode_change, mode))
self.on_robot_mode_change(self.manager.get_mode())
# create pygame joystick if supported
try:
from .pygame_joysticks import UsbJoysticks
except ImportError:
logger.warn("pygame not detected, real joystick support not loaded")
self.usb_joysticks = None
else:
self.usb_joysticks = UsbJoysticks(self)
logger.info("pygame was detected, real joystick support loaded!")
try:
self.root.lift()
self.root.attributes("-topmost", True)
self.root.attributes("-topmost", False)
except Exception:
pass
self.timer_fired()
def _setup_widgets(self, frame):
top = tk.Frame(frame)
top.grid(column=0, row=0)
bottom = tk.Frame(frame)
bottom.grid(column=0, row=1)
self.field = RobotField(frame, self.manager, self.config_obj)
self.field.grid(column=1, row=0, rowspan=2)
# status bar
self.status = tk.Label(frame, bd=1, relief=tk.SUNKEN, anchor=tk.E)
self.status.grid(column=0, row=2, columnspan=2, sticky=tk.W + tk.E)
# analog
slot = tk.LabelFrame(top, text="Analog")
self.analog = []
for i in range(len(hal_data["analog_in"])):
if hal_data["analog_in"][i]["initialized"] or hal_data["analog_out"][i]["initialized"]:
label = tk.Label(slot, text=str(i))
label.grid(column=0, row=i + 1)
vw = ValueWidget(slot, clickable=True, minval=-10.0, maxval=10.0)
vw.grid(column=1, row=i + 1)
self.set_tooltip(vw, "analog", i)
else:
vw = None
self.analog.append(vw)
slot.pack(side=tk.LEFT, fill=tk.Y, padx=5)
# digital
slot = tk.LabelFrame(top, text="Digital")
label = tk.Label(slot, text="PWM")
label.grid(column=0, columnspan=4, row=0)
self.pwm = []
for i in range(len(hal_data["pwm"])):
if hal_data["pwm"][i]["initialized"]:
c = i // 10
label = tk.Label(slot, text=str(i))
#.........这里部分代码省略.........
示例5: AppGUI
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class AppGUI(Frame):
def __init__(self, master=None):
# Avoiding to send it continuously.
self.lock = False
Frame.__init__(self, master)
self.grid()
self.master = master
# Setting for ComboBox.
self.url_lang_combobox_str = StringVar()
self.url_lang_combobox_list = lang_list
# UI components.
self.receiver_email_text = Label(self, text="Receiver:")
self.receiver_email_field = Entry(self, width=50)
self.subject_text = Label(self, text='Subject:')
self.subject_field = Entry(self, width=50)
self.receiver_name_text = Label(self, text='Name:')
self.receiver_name_field = Entry(self, width=50)
self.url_lang_text = Label(self, text='Link lang:')
self.url_lang_combobox = Combobox(self, textvariable=self.url_lang_combobox_str, values=self.url_lang_combobox_list, state='readonly')
self.send_progressbar = Progressbar(self, orient='horizontal', length=500, mode='determinate', maximum=300)
self.send_button = Button(self, text='Send', command=self._send_mail)
self.quit_button = Button(self, text='Exit', command=self.__exit)
self.log_msg_text = ScrolledText(self)
# Attachment.
self.mail_attachment_list = attachment_list[:]
self.url_lang_link_title = None
self.url_lang_link = copy.deepcopy(content_link)
# Mailer
self._mailer = None
# Let Mailer can control components.
Mailer.window_content = self
self.__create_widgets()
def _send_mail(self):
if not self.lock:
threading.Thread(target=self.__send_mail).start()
else:
messagebox.showinfo('Warning', "Now it's processing...")
def _choose(self, event):
# arr = self.url_lang_link.get(self.url_lang_combobox_str.get()) # Get the array by choosing language.
pass
def _modify_content_url_link(self):
link_arr = self.url_lang_link.get(self.url_lang_combobox_str.get())
content = self._mailer.content
for index in range(len(link_arr)):
content_index = content.index(self.url_lang_link_title[index]) + len(self.url_lang_link_title[index])
content = content[:content_index] + '\n' + link_arr[index] + content[content_index:]
self._mailer.content = content
return False
def _make_mailer(self):
self.mail_attachment_list = attachment_list[:] # Clone a list.
if atta_lang_list[self.url_lang_combobox.current()]:
for i in range(len(self.mail_attachment_list)):
# Only from the third file to the end file can change language.
if i > 2:
# Modify the file name.
att = self.mail_attachment_list[i].split('.')
self.mail_attachment_list[i] = ''.join([' ', atta_lang_list[self.url_lang_combobox.current()], '.']).join(att)
# ** IMPORTANT, we set the content path here!!
path = 'content.docx'
if self.url_lang_combobox.get() == lang_list[2] or self.url_lang_combobox.get() == lang_list[3]:
path = 'content chinese.docx'
if debug_log:
print(self.mail_attachment_list)
# ** IMPORTANT, we have to new an object here. Otherwise, we couldn't check the error checking.
return Mailer(content_path=path, attachment_list=self.mail_attachment_list)
def __create_widgets(self):
"""
Construct all of the UI components.
"""
self.receiver_email_text.grid(row=0, column=0)
self.receiver_email_field.grid(row=0, column=1, columnspan=6)
self.subject_text.grid(row=1, column=0)
self.subject_field.grid(row=1, column=1, columnspan=6)
self.subject_field.insert(0, 'Osaka Mariko Apartment Location & Condition')
self.receiver_name_text.grid(row=2, column=0)
self.receiver_name_field.grid(row=2, column=1, columnspan=6)
self.url_lang_text.grid(row=3, column=0)
self.url_lang_combobox.grid(row=3, column=2, columnspan=2)
self.send_progressbar.grid(row=4, column=0, columnspan=7)
self.send_button.grid(row=5, column=2)
self.quit_button.grid(row=5, column=3)
self.log_msg_text.grid(row=6, column=0, columnspan=7)
# Default setting.
self.url_lang_combobox.current(0)
self.url_lang_combobox.bind("<<ComboboxSelected>>", self._choose)
def __exit(self):
#.........这里部分代码省略.........
示例6: EntryVidget
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class EntryVidget(
Vidget,
Eventor,
):
"""
EntryVidget contains a main Frame and an Entry widget.
The entry widget takes all space of the main frame.
The main frame can be used to configure the size of the entry widget.
EntryVidget adds the following abilities:
- Simplify the use of validator function.
- Notify pre-change and and post-change events.
"""
# Default validator function
_DEFAULT_VALIDATOR = (lambda x: True)
# Event notified when text is to be changed
TEXT_CHANGE_SOON = 'TEXT_CHANGE_SOON'
# Event notified when text is changed
TEXT_CHANGE_DONE = 'TEXT_CHANGE_DONE'
def __init__(
self,
text=None,
validator=None,
widget_type=None,
master=None,
):
"""
Initialize object.
@param text: Initial text. Default is empty.
@param validator: Validator function that determines whether text
entered by user or set by `text_set` method is valid. The validator
function takes the new value as argument and returns True if the new
value is valid.
@param widget_type: One of ['Entry', 'Spinbox', 'Combobox']. Default is
'Entry'.
@param master: Master widget.
@return: None.
"""
# Initialize Vidget.
# Create main frame widget.
Vidget.__init__(self, master=master)
# Initialize Eventor
Eventor.__init__(self)
# If widget type is None or `Entry`
if widget_type is None or widget_type == 'Entry':
# Create Entry widget
self._text_widget = Entry(master=self.widget())
# If widget type is `Spinbox`
elif widget_type == 'Spinbox':
# Create Spinbox widget
self._text_widget = Spinbox(master=self.widget())
# If widget type is `Combobox`
elif widget_type == 'Combobox':
# Create Combobox widget
self._text_widget = Combobox(master=self.widget())
# If widget type is something else
else:
# Raise error
raise ValueError(widget_type)
# Set the text widget as config target
self.config_target_set(self._text_widget)
# Whether the text widget's value is changing
self._is_changing = False
# Old widget state
self._old_widget_state = NORMAL
# Validator function
self._validator = validator \
if validator is not None else EntryVidget._DEFAULT_VALIDATOR
# Create validator wrapper
self._validator_wrapper = self._validator_wrapper_create()
# Register the validator wrapper with Tkinter. Get reference ID.
self._validator_wrapper_ref_id = \
self.text_widget().winfo_toplevel().register(
self._validator_wrapper
)
# Mount the validator wrapper to the text widget
self._validator_wrapper_mount()
# If the text widget is Combobox
#.........这里部分代码省略.........
示例7: SimUI
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class SimUI(object):
def __init__(self, manager, fake_time, config_obj):
"""
initializes all default values and creates
a board, waits for run() to be called
to start the board
manager - sim manager class instance
"""
self.manager = manager
self.fake_time = fake_time
self.config_obj = config_obj
# Set up idle_add
self.queue = queue.Queue()
self.root = tk.Tk()
self.root.wm_title("PyFRC Robot Simulator v%s" % __version__)
self.root.protocol("WM_DELETE_WINDOW", self._delete_window)
# setup mode switch
frame = tk.Frame(self.root)
frame.pack(side=tk.TOP, anchor=tk.W)
self._setup_widgets(frame)
self.root.resizable(width=0, height=0)
# Allow extending the simulation from 3rd party libraries
# -> TODO: better API for this
self.extensions = []
for ep in iter_entry_points(group="robotpysim", name=None):
try:
extension = ep.load()
except ImportError:
logger.debug("Error importing extension '%s'", ep.name, exc_info=True)
else:
logger.debug("Loaded simulation extension '%s'", ep.name)
extension = extension()
if hasattr(extension, "update_tk_widgets"):
self.extensions.append(extension)
self.mode_start_tm = 0
self.text_id = None
# connect to the controller
self.manager.on_mode_change(
lambda mode: self.idle_add(self.on_robot_mode_change, mode)
)
self.on_robot_mode_change(self.manager.get_mode())
# create pygame joystick if supported
try:
from .pygame_joysticks import UsbJoysticks
except ImportError:
logger.warn("pygame not detected, real joystick support not loaded")
self.usb_joysticks = None
else:
self.usb_joysticks = UsbJoysticks(self)
logger.info("pygame was detected, real joystick support loaded!")
try:
self.root.lift()
self.root.attributes("-topmost", True)
self.root.attributes("-topmost", False)
except Exception:
pass
self.timer_fired()
def _delete_window(self):
self.root.destroy()
if self.usb_joysticks is not None:
self.usb_joysticks.close()
def _setup_widgets(self, frame):
top = tk.Frame(frame)
top.grid(column=0, row=0)
bottom = tk.Frame(frame)
bottom.grid(column=0, row=1)
self.field = RobotField(frame, self.manager, self.config_obj)
self.field.grid(column=1, row=0, rowspan=2)
# status bar
self.status = tk.Label(frame, bd=1, relief=tk.SUNKEN, anchor=tk.E)
self.status.grid(column=0, row=2, columnspan=2, sticky=tk.W + tk.E)
# analog
slot = tk.LabelFrame(top, text="Analog")
self.analog = []
for i in range(len(hal_data["analog_in"])):
if (
hal_data["analog_in"][i]["initialized"]
#.........这里部分代码省略.........
示例8: Main
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class Main():
def __init__(self):
f=open('degur.yaml','r',encoding='utf-8')
self.data=yaml.load(f.read())
f.close()
root=Tk()
root.wm_title('Дежурства v 0.1.1 (c) 2013-2015, Shershakov D.')
root.geometry('{0}x{1}+0+0'.format(root.winfo_screenwidth()-10,root.winfo_screenheight()-80))
root.rowconfigure(1,weight=1)
root.columnconfigure(1,weight=1)
root.columnconfigure(2,weight=1)
f0=Frame(root)
f1=Frame(root)
f2=Frame(root)
self.y=Combobox(f0,width=4)
self.m=Combobox(f0,width=4)
self.y.grid(row=0,column=0)
self.m.grid(row=1,column=0)
self.y.bind('<<ComboboxSelected>>',self.setY)
self.m.bind('<<ComboboxSelected>>',self.setM)
f0.grid(row=0,column=0,rowspan=10,sticky=N+S+E+W)
f1.grid(row=1,column=1,sticky=N+S+E+W)
f2.grid(row=1,column=2,sticky=N+S+E+W)
self.g1=Gr(f1,self.data)
self.g2=Gr(f2,self.data,SCRY=self.g1.scrY)
self.set0()
self.g1.yview2=self.g2.yview
root.bind('<F1>',lambda e: MyHelp(root,self.data,self.y.get()))
root.bind_all('<Control-F3>',lambda e: statistic_q(self.data,self.y.get(),v='план'))
root.bind_all('<Shift-F3>',lambda e: statistic_q(self.data,self.y.get(),v='табель'))
root.bind_all('<Control-F4>',lambda e: statistic(self.data,self.y.get(),v='план'))
root.bind_all('<Shift-F4>',lambda e: statistic(self.data,self.y.get(),v='табель'))
root.bind_all('<F3>',lambda e: statistic_q(self.data,self.y.get(),v='авто'))
root.bind_all('<F4>',lambda e: statistic(self.data,self.y.get(),v='авто'))
root.bind_all('<F5>',lambda e: tabel(self.data,self.y.get(),self.m.get()))
root.bind_all('<F7>',lambda e: otp(self.data,self.y.get(),v='авто'))
root.bind_all('<F8>',lambda e: statistic_xx(self.data,self.y.get(),v='авто'))
root.bind_all('<F9>',lambda e: per(self.data,self.y.get(),v='авто'))
root.bind_all('<Control-F8>',lambda e: statistic_xx(self.data,self.y.get(),v='план'))
FreeConsole()
root.mainloop()
def set0(self,*e):
Y=sorted(list(self.data.keys()))
self.y['values']=Y
self.y.set(Y[0])
self.setY(*e)
def setY(self,*e):
M=sorted([x for x in self.data[self.y.get()] if str(x).isnumeric()])
self.m['values']=M
self.m.set(M[0])
self.setM(*e)
def setM(self,*e):
y=self.y.get()
m=self.m.get()
self.g1.set(y,m)
self.g2.set(y,m)
示例9: Gr
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class Gr():
def __init__(self,root,data,SCRY=None):
self.data=data
self.columns=[x for x in range(1,8)]+['day']
root.rowconfigure(1,weight=1)
root.columnconfigure(0,weight=1)
root.columnconfigure(1,weight=1)
root.columnconfigure(2,weight=1)
f=Frame(root)
f.columnconfigure(0,weight=1)
f.rowconfigure(1,weight=1)
self.v=Combobox(root)
self.v.grid(row=0,column=0)
self.v.bind('<<ComboboxSelected>>',self.select_ver)
f.grid(row=1,column=0,columnspan=3,sticky=N+S)
self.tree=Treeview(f,
columns=self.columns,
displaycolumns=['day']+self.columns[:-1],
show='headings')
#self.tree.tag_configure('odd',background='white')
#self.tree.tag_configure('even',background='gray')
self.tree.tag_configure('dif',foreground='brown')
self.tree.tag_configure('work',background='white')
self.tree.tag_configure('short',background='#F5EFE0')
self.tree.tag_configure('rest',background='#E0B0B0')
self.tree.tag_configure('holyday',background='#E7B7A4')
for c in self.columns:
self.tree.heading(c,text=c)
self.tree.column(c,width=65,anchor='center')
self.tree.column('day',width=30)
scrX=Scrollbar(f,orient='horizontal',command=self.tree.xview)
self.tree['xscrollcommand']=scrX.set
if not SCRY:
self.scrY=Scrollbar(f,orient='vertical',command=self.yview)
self.tree['yscrollcommand']=self.scrY.set
else:
self.tree['yscrollcommand']=SCRY.set
self.tree.grid(row=1,column=0,sticky=N+S)
if not SCRY:
self.scrY.grid(row=1,column=1,sticky=N+S)
scrX.grid(row=2,column=0,sticky=E+W)
def set(self,y,m):
self.y=y
self.m=m
self.show()
def yview(self,*args):
self.tree.yview(*args)
self.yview2(*args)
def yview2(self,*args):
pass
def show(self):
d=self.data[self.y][self.m]
V=list(d['degur'].keys())
self.v['values']=V
self.v.set(V[0])
self.select_ver()
def select_ver(self,*e):
self.tree.delete(*self.tree.get_children())
d=self.data[self.y][self.m]
offset=d['offset']
v=self.v.get()
col=[]
for i,deg in enumerate(d['degurs']):
self.tree.heading(i+1,text=deg)
col.append(i+1)
self.tree.configure(displaycolumns=['day']+col)
items=dict()
if 'табель' in d['degur']:
a=[''.join(x) for x in zip(*[[x for x in d['degur']['план'][j]] \
for j in d['degurs']])]
b=[''.join(x) for x in zip(*[[x for x in d['degur']['табель'][j]] \
for j in d['degurs']])]
c=[x!=y for x,y in zip(a,b)]
else:
c=[False]*32
for i in range(1,d['days']+1):
tag = (i+offset) % 7 in [0,6] and 'rest' or 'work'
if i in d['holydays'] : tag='holyday'
elif i in d['restdays'] : tag='rest'
elif i in d['shortdays'] : tag='short'
elif i in d['workdays'] : tag='work'
if c[i]: tag=[tag,'dif']
ii=self.tree.insert('','end',values=['-','-','-','-','-'],tag=tag)
self.tree.set(ii,column='day',value=i)
items[i]=ii
for j,s in d['degur'][v].items(): # j-degur
if not s: continue
for i,val in enumerate(s[1:-1]):
if val=='J':
val='до'
elif val=='j':
val='од'
elif val=='a':
val='10'
self.tree.set(items[i+1],column=d['degurs'].index(j)+1,value=val)
if s[0]=='Н':
#.........这里部分代码省略.........
示例10: GUI
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class GUI(tkinter.Tk):
def __init__(self,):
tkinter.Tk.__init__(self)
self.title('Van der Pol Generator Visualizer v1.0')
self.geometry('800x450')
self.colors = self.get_colors()
self.parameters_label = tkinter.Label(self, text='Parameters', font=("Arial", 16))
self.parameters_label.place(x=20, y=17)
self.l_parameter_label = tkinter.Label(self, text='l = ', font=('Times New Roman', 13, 'italic'))
self.l_parameter_label.place(x=20, y=60)
self.l_parameter_entry = tkinter.Entry(self)
self.l_parameter_entry.config(width=8)
self.l_parameter_entry.place(x=60, y=63)
self.m_parameter_label = tkinter.Label(self, text='m = ', font=('Times New Roman', 13, 'italic'))
self.m_parameter_label.place(x=20, y=90)
self.m_parameter_entry = tkinter.Entry(self)
self.m_parameter_entry.config(width=8)
self.m_parameter_entry.place(x=60, y=93)
self.start_x_label = tkinter.Label(self, text='Start X = ', font=('Arial', 11))
self.start_x_label.place(x=20, y=160)
self.start_x_entry = tkinter.Entry(self)
self.start_x_entry.config(width=8)
self.start_x_entry.insert(0, '0.0')
self.start_x_entry.place(x=90, y=163)
self.start_y_label = tkinter.Label(self, text='Start Y = ', font=('Arial', 11))
self.start_y_label.place(x=20, y=180)
self.start_y_entry = tkinter.Entry(self)
self.start_y_entry.config(width=8)
self.start_y_entry.insert(0, '0.1')
self.start_y_entry.place(x=90, y=183)
self.h_label = tkinter.Label(self, text='h = ', font=('Arial', 11))
self.h_label.place(x=180, y=160)
self.steps_label = tkinter.Label(self, text='Steps = ', font=('Arial', 11))
self.steps_label.place(x=180, y=180)
self.h_entry = tkinter.Entry(self)
self.h_entry.config(width=8)
self.h_entry.insert(0, '0.01')
self.h_entry.place(x=210, y=163)
self.steps_entry = tkinter.Entry(self)
self.steps_entry.config(width=8)
self.steps_entry.insert(0, '10000')
self.steps_entry.place(x=240, y=183)
self.color_label = tkinter.Label(self, text='Color', font=('Arial', 11))
self.color_label.place(x=20, y=240)
self.color_box = Combobox(self, values=self.colors)
self.color_box.set('Black')
self.color_box.place(x=20, y=265)
self.add_button = tkinter.Button(self, text='Add', font=('Arial', 13), width=10, command=self.add_graphic)
self.add_button.place(x=220, y=260)
self.show_button = tkinter.Button(self, text='SHOW', font=('Arial', 14), width=15, height=2, command=self.show)
self.show_button.place(x=300, y=350)
self.plot = Plot()
self.info_labels = tkinter.Listbox(self, selectmode='MULTIPLE', width=60, height=17)
self.info_labels.bind('<<ListboxSelect>>', self.on_select)
self.info_labels.place(x=420, y=20)
def on_select(self, event):
selected = event.widget.curselection()
if not selected:
return
num = selected[0]
self.plot.remove(0)
self.info_labels.delete(num)
def show(self):
self.plot.draw()
def get_values(self):
try:
l_parameter = float(self.l_parameter_entry.get())
except ValueError:
self.show_error('l parameter is invalid')
return
try:
m_parameter = float(self.m_parameter_entry.get())
except ValueError:
self.show_error('m parameter is invalid')
return
start_x = float(self.start_x_entry.get())
start_y = float(self.start_y_entry.get())
#.........这里部分代码省略.........
示例11: Application
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class Application(Frame):
def __init__(self, master=None):
master.title("Мережа зустрічного поширення")
Frame.__init__(self, master)
self.Network = CPN(100, 2, 100)
self.grid()
self.createWidgets()
def createWidgets(self):
self.function_label = Label(self)
self.function_label["text"] = "Задати функцію"
self.function_label.grid(row=0, column=0)
self.function_combo = Combobox(self)
self.function_combo["values"] = ["x*x", "cos(x)"]
self.function_combo.set("x*x")
self.function_combo.grid(row=0, column=1)
self.a_label = Label(self)
self.a_label["text"] = "Задати ліву межу"
self.a_label.grid(row=1, column=0)
self.a = Entry(self)
self.a.insert(END, '0')
self.a.grid(row=1, column=1)
self.b_label = Label(self)
self.b_label["text"] = "Задати праву межу"
self.b_label.grid(row=2, column=0)
self.b = Entry(self)
self.b.insert(END, '50')
self.b.grid(row=2, column=1)
self.learning_button = Button(self)
self.learning_button["text"] = "Навчити"
self.learning_button["command"] = self.make_points
self.learning_button.grid(row=3, column=0)
self.check_button = Button(self)
self.check_button["text"] = "Розпізнати"
self.check_button["command"] = self.check
self.check_button.grid(row=3, column=1)
self.learn_canvas = Canvas(self)
self.learn_canvas.grid(row=4, column=0)
self.check_canvas = Canvas(self)
self.check_canvas.grid(row=4, column=1)
def make_points(self):
function = self.function_combo.get()
a = int(self.a.get())
b = int(self.b.get())
x = []
y = []
func = lambda x: eval(function)
for i in range(a, b):
x.append(i)
y.append(func(i))
self.Network.set_input(x+y)
self.Network.learn()
x_learned = []
y_learned = []
learned = []
for i in range(a, b):
x_learned.append(0)
y_learned.append(func(i))
self.Network.set_input(x_learned + y_learned)
self.Network.propagate()
learned = self.Network.get_output()
x_v = int(len(learned)/2)
f = Figure()
a = f.add_subplot(111)
a.plot(x, y, '--bo')
canvas = FigureCanvasTkAgg(f, master=self)
canvas.show()
canvas.get_tk_widget().grid(row=4, column=0)
f = Figure()
b = f.add_subplot(111)
b.plot(learned[:x_v], learned[x_v:], '--bo')
canvas = FigureCanvasTkAgg(f, master=self)
canvas.show()
canvas.get_tk_widget().grid(row=4, column=1)
def check(self):
function = self.function_combo.get()
a = int(self.a.get())
b = int(self.b.get())
x = []
y = []
func = lambda x: eval(function)
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class FenOptions:
def __init__(self):
self.root=Tk()
self.root.title('Donjon & Python-Option')
self.root.bind('<F12>', switchDebug)
#--------Barres de volume------#
self.varVolumeGlobal = IntVar()
self.varVolumeGlobal.set(Audio.volumeGlobal)
self.varVolumeMusique = IntVar()
self.varVolumeMusique.set(Audio.volumeMusic)
self.varVolumeSons = IntVar()
self.varVolumeSons.set(Audio.volumeSound)
self.scaleVolumeGlobal = Scale(self.root,from_=0,
to=100,resolution=1,
orient=HORIZONTAL,
length=300,width=20,
label="Volume principal",
tickinterval=20,
variable=self.varVolumeGlobal,
command = self.setVolumeGlobal)
self.scaleVolumeMusique = Scale(self.root,from_=0,
to=100,resolution=1,orient=HORIZONTAL,
length=300,
width=20,
label="Volume Musique",
tickinterval=20,
variable=self.varVolumeMusique,
command = self.setVolumeMusique)
self.scaleVolumeSons = Scale(self.root,
from_=0,
to=100,
resolution=1,
orient=HORIZONTAL,
length=300,
width=20,
label="Volume Bruitages",
tickinterval=20,
variable=self.varVolumeSons,
command = self.setVolumeSons)
self.scaleVolumeGlobal.set(Audio.volumeGlobal)
self.scaleVolumeMusique.set(Audio.volumeMusic)
self.scaleVolumeSons.set(Audio.volumeSound)
self.scaleVolumeGlobal.pack(padx=10,pady=10)
self.scaleVolumeMusique.pack(padx=10,pady=10)
self.scaleVolumeSons.pack(padx=10,pady=10)
#-----Sélection des textures----#
Label(self.root, text='Texture Pack :').pack()
self.box = Combobox(self.root, values=listdir('TexturePack'), state='readonly')
self.box.bind('<<ComboboxSelected>>', self.selectionnerPack)
self.box.current(0)
self.box.pack()
def selectionnerPack(self, event) :
global texturePack
texturePack = self.box.get()
def run(self):
self.root.mainloop()
Audio.volumeGlobal = volume
Audio.setVolumeMusic()
def setVolumeGlobal(self, volume):
Audio.volumeGlobal = volume
Audio.setVolumeMusic()
def setVolumeMusique(self, volume):
Audio.volumeMusic = volume
Audio.setVolumeMusic()
def setVolumeSons(self, volume):
Audio.volumeSound = volume
示例13: callback
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
def callback(combobox: ttk.Combobox):
"""Reduce the displayed values to substring matches to the user's input."""
text = combobox.get()
combobox.config(values=sorted(list(n for n in names if text in n)))
示例14: reactToClick
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class OptimizerMainWindow:
"""
classdocs
"""
# TODO: change that name
def reactToClick(self, event):
a = AddRestrictionDialog(self)
def __init__(self, optimizer):
# always have a reference to model/controller
self.optimizer = optimizer
# setup main GUI and make stretchable
self.guiRoot = Tk()
self.guiRoot.title("OPTIMIZR")
self.guiRoot.columnconfigure(1, weight=1)
self.guiRoot.rowconfigure(0, weight=1)
# left (settings) and right (sequences) part
self.frameLeft = Frame(self.guiRoot)
self.frameLeft.grid(row=0, column=0, sticky=W + E + N + S)
self.frameLeft.columnconfigure(0, weight=1)
self.frameRight = Frame(self.guiRoot)
self.frameRight.grid(row=0, column=1, sticky=W + E + N + S)
self.frameRight.columnconfigure(0, weight=1)
self.frameRight.rowconfigure(0, weight=1)
self.frameRight.rowconfigure(1, weight=1)
self.frameSpeciesControll = LabelFrame(self.frameLeft, text="Species", pady=10, padx=10)
self.frameSpeciesControll.columnconfigure(1, weight=1)
self.frameOptimizationControll = LabelFrame(self.frameLeft, text="Optimization", pady=10, padx=10)
self.frameRestrictionControll = LabelFrame(self.frameLeft, text="Restriction Enzymes", pady=10, padx=10)
self.frameSpeciesControll.grid(row=0, column=0, sticky=W + E, padx=10, pady=10)
self.frameOptimizationControll.grid(row=1, column=0, sticky=W + E, padx=10, pady=10)
self.frameRestrictionControll.grid(row=2, column=0, sticky=W + E, padx=10, pady=10)
# Species Controll
Label(self.frameSpeciesControll, text="Source:").grid(row=0, column=0)
Label(self.frameSpeciesControll, text="Target:").grid(row=1, column=0)
self.comboSourceSpecies = Combobox(self.frameSpeciesControll, state="readonly")
self.comboSourceSpecies.grid(row=0, column=1, pady=5, sticky="ew")
self.comboTargetSpecies = Combobox(self.frameSpeciesControll, state="readonly")
self.comboTargetSpecies.grid(row=1, column=1, pady=5, sticky="we")
self.buttonSpeciesList = Button(self.frameSpeciesControll, text="Edit Species List")
self.buttonSpeciesList.grid(row=2, column=1, pady=5, sticky="e")
self.comboSourceSpecies.bind("<<ComboboxSelected>>", self.actionOptimizerSettingsChanged)
self.comboTargetSpecies.bind("<<ComboboxSelected>>", self.actionOptimizerSettingsChanged)
# Optimization Controll
Label(self.frameOptimizationControll, text="Optimization Strategy:").grid(row=0, column=0)
self.comboOptimizationStrategy = Combobox(self.frameOptimizationControll, state="readonly")
self.comboOptimizationStrategy.grid(row=0, column=1)
self.comboOptimizationStrategy["values"] = self.optimizer.possibleOptimizationStrategies
self.comboOptimizationStrategy.bind("<<ComboboxSelected>>", self.actionOptimizerSettingsChanged)
# Restriction Enzymes
self.listRestriction = Listbox(self.frameRestrictionControll)
self.listRestriction.grid(row=0, column=0, columnspan=3, pady=5, sticky=W + E)
self.frameRestrictionControll.columnconfigure(0, weight=1)
self.buttonRestricionAdd = Button(self.frameRestrictionControll, text=" + ")
self.buttonRestricionDel = Button(self.frameRestrictionControll, text=" - ")
self.buttonRestricionAdd.grid(row=1, column=1, padx=5)
self.buttonRestricionDel.grid(row=1, column=2, padx=5)
# Source Sequence Frame
self.frameSourceSequence = LabelFrame(self.frameRight, text="Source Sequence", padx=10, pady=10)
self.frameResultSequence = LabelFrame(self.frameRight, text="Result Sequence", padx=10, pady=10)
self.frameSourceSequence.grid(row=0, column=0, sticky="wens", padx=10, pady=10)
self.frameResultSequence.grid(row=1, column=0, sticky="wens", padx=10, pady=10)
self.buttonSourceLoad = Button(self.frameSourceSequence, text=" Load ")
self.textSourceSeq = ScrolledText(self.frameSourceSequence, height=10)
self.buttonSourceLoad.grid(row=0, column=1, sticky="e", pady=5)
self.textSourceSeq.grid(row=1, column=0, columnspan=2, sticky="wens")
self.frameSourceSequence.columnconfigure(0, weight=1)
self.frameSourceSequence.rowconfigure(1, weight=1)
self.textSourceSeq.frame.columnconfigure(1, weight=1)
self.textSourceSeq.frame.rowconfigure(0, weight=1)
self.buttonOptimize = Button(self.frameResultSequence, text=" OPTIMIZE! ")
self.buttonOptimize.bind("<ButtonRelease>", self.actionOptimize)
self.buttonRemoveRestriction = Button(self.frameResultSequence, text=" RESTRICTION-B-GONE! ")
self.buttonRemoveRestriction.bind("<ButtonRelease>", self.actionRemoveRestricion)
self.buttonSaveResult = Button(self.frameResultSequence, text=" Save ")
self.textResultSequence = ScrolledText(self.frameResultSequence, height=10)
self.buttonOptimize.grid(column=0, row=0, pady=5, sticky="w")
self.buttonRemoveRestriction.grid(column=1, row=0, pady=5, padx=10, sticky="w")
self.textResultSequence.grid(row=1, column=0, columnspan=4, sticky="wens")
self.buttonSaveResult.grid(row=2, column=3, pady=5, sticky="e")
self.frameResultSequence.columnconfigure(2, weight=1)
self.frameResultSequence.rowconfigure(1, weight=1)
self.textResultSequence.frame.columnconfigure(1, weight=1)
self.textResultSequence.frame.rowconfigure(0, weight=1)
#.........这里部分代码省略.........
示例15: Application
# 需要导入模块: from tkinter.ttk import Combobox [as 别名]
# 或者: from tkinter.ttk.Combobox import get [as 别名]
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
root.title("NHL Stats to CSV")
self.pack()
self.createWidgets()
def createWidgets(self):
frame1 = Frame(self)
season_frame = Frame(frame1)
self.seasonlabel = Label(season_frame, text="Season")
season_list = ('2013-2014', '2012-2013', '2011-2012', '2010-2011',
'2009-2010', '2008-2009', '2007-2008', '2006-2007',
'2005-2006', '2003-2004', '2002-2003', '2001-2002',
'2000-2001', '1999-2000', '1998-1999', '1997-1998')
self.season = Combobox(season_frame, values=season_list, state='readonly')
self.season.current(0)
self.seasonlabel.pack()
self.season.pack()
season_frame.pack(side=LEFT, padx=5, pady=5)
position_frame = Frame(frame1)
self.positionlabel = Label(position_frame, text="Position")
position_list = ('All Skaters', 'Goalies', 'Forwards', 'Defenseman',
'Center', 'Left Wing', 'Right Wing')
self.position = Combobox(position_frame, values=position_list, state='readonly')
self.position.current(0)
self.positionlabel.pack()
self.position.pack()
position_frame.pack(side=LEFT, padx=5, pady=5)
frame1.pack(side=TOP)
frame2 = Frame(self)
gameType_frame = Frame(frame2)
self.gameTypelabel = Label(gameType_frame, text="Game Type")
gameType_list = ('Regular Season', 'Playoffs')
self.gameType = Combobox(gameType_frame, values=gameType_list, state='readonly')
self.gameType.current(0)
self.gameTypelabel.pack()
self.gameType.pack()
gameType_frame.pack(side=LEFT, padx=5, pady=5)
grouping_frame = Frame(frame2)
self.groupinglabel = Label(grouping_frame, text="Grouping")
grouping_list = ('By League', 'By Team')
self.grouping = Combobox(grouping_frame, values=grouping_list, state='readonly')
self.grouping.current(0)
self.groupinglabel.pack()
self.grouping.pack()
grouping_frame.pack(side=LEFT, padx=5, pady=5)
frame2.pack(side=TOP)
frame3 = Frame(self)
self.progress = Label(frame3, text="Choose Options and Press Start", relief=SUNKEN, width=30)
self.progress.pack()
frame3.pack(side=TOP, padx=5, pady=5)
frame4 = Frame(self)
self.start = Button(frame4, text="Start", command=self.start)
self.QUIT = Button(frame4, text="Quit", command=self.quit)
self.start.pack(side=LEFT)
self.QUIT.pack(side=LEFT)
frame4.pack(side=TOP)
def quit(self):
root.destroy()
def start(self):
self.progress.config(text="Working...")
season_fn = self.season.get()
season = season_fn.replace("-", "")
gameType = self.gameType.get()
if gameType == "Regular Season":
gameType = "2"
else:
gameType = "3"
grouping = self.grouping.get()
position = self.position.get()
if position == "All Skaters":
position = "S"
position = position[0]
# For csv filename
gameTypes = {"2": "regularseason", "3": "playoffs"}
positions = {"S": "skater", "G": "goalie", "F": "forward", "D": "defenseman",
"C": "center", "L": "leftwing", "R": "rightwing"}
gameType_fn = gameTypes[gameType]
position_fn = positions[position]
grouping_fn = ""
if grouping == "By League":
grouping_fn = "byleague"
else:
grouping_fn = "byteam"
self.filename = "nhl_" + season_fn + "_" + gameType_fn + "_" + position_fn + "stats" + "_" + grouping_fn + ".csv"
# Stat column headings
#.........这里部分代码省略.........