本文整理汇总了Python中ttk.Button.config方法的典型用法代码示例。如果您正苦于以下问题:Python Button.config方法的具体用法?Python Button.config怎么用?Python Button.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Button
的用法示例。
在下文中一共展示了Button.config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: button_component
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
def button_component(self, button_txt, init_txt, r, c, help_txt='', mode=NORMAL):
'''adds a button component associated with an entry (the label only activates when help_txt != '')'''
b = Button(self, text=button_txt)
b.grid(row=r, column=c, sticky=W+E)
b.config(state=mode)
dir_var = StringVar()
dir_var.set(init_txt)
Entry(self, textvariable=dir_var).grid(row=r, column=c+1)
Label(self, text=help_txt).grid(row=r, column=c+2, sticky=W)
b.configure(command=lambda: self.browse_dir(dir_var, b))
return dir_var
示例2: GUI
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class GUI(Frame):
def __init__(self, master=None, **kw):
Frame.__init__(self, master, **kw)
self.initialize()
def initialize(self):
self.master.title(settings.APP_TITLE)
self.pack(fill=Tkinter.BOTH, expand=1)
self.columnconfigure(1, weight=1)
self.columnconfigure(3, pad=7)
self.rowconfigure(3, weight=1)
self.rowconfigure(5, pad=7)
lbl = Label(self, text="Журнал")
lbl.grid(sticky=Tkinter.W, pady=4, padx=5)
self.area = Tkinter.Text(self)
self.area.grid(row=1, column=0, columnspan=2, rowspan=4,
padx=5, sticky=Tkinter.E + Tkinter.W + Tkinter.S + Tkinter.N)
self.widgetLogger = WidgetLogger(self.area)
lbl = Label(self, text="Адрес репозитория: ")
lbl.grid(row=6)
self.repo_addr_str = Tkinter.StringVar()
self.repo_addr = Tkinter.Entry(self, textvariable=self.repo_addr_str)
self.repo_addr.grid(row=7)
lbl = Label(self, text="FTP для размещения: ")
lbl.grid(row=6, column=1)
self.ftp_addr_str = Tkinter.StringVar()
self.ftp_addr = Tkinter.Entry(self, textvariable=self.ftp_addr_str)
self.ftp_addr.grid(row=7, column=1, pady=1)
self.deploybtn = Button(self, text="Начать обновление", command=self.start_update_thread)
self.deploybtn.grid(row=10)
def start_update_thread(self):
# resetting vars
settings.DEFAULT_FTP_HOST = self.ftp_addr_str.get()
settings.DEFAULT_GIT_REPO = self.repo_addr_str.get()
self.deploybtn.config(text="Идет обновление...", state=Tkinter.DISABLED)
tr = Thread(target=lambda: full_cycle(self))
tr.start()
示例3: nuevoPais
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
def nuevoPais(self):
t = Toplevel(self)
t.wm_title("Pais")
Label(t, text="Nombre").grid(row=0, column=1)
E2 = Entry(t)
E2.grid(row=1, column=1)
button1 = Button(t, text="Cancelar", command=lambda: t.destroy())
button2 = Button(t, text="Guardar", command=lambda: self.nuevaEntradaPais(E2.get(), t))
button3 = Button(t, text="Borrar", command=lambda: self.BorrarPais(E2.get(), t))
button3.config(state="disabled")
button1.grid(row=2, column=0)
button2.grid(row=2, column=1)
button3.grid(row=2, column=2)
示例4: MainWindow
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class MainWindow(Tk):
def __init__(self):
Tk.__init__(self)
self.title(mainWindowTitle)
self.resizable(width=0, height=0)
self.__setStyles()
self.__initializeComponents()
self.__dataController = DataController();
self.mainloop()
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)
def __setStyles(self):
Style().configure("TButton", padding=buttonsTextPadding, font=buttonsFont)
def loadFileButtonClick(self):
fileName = tkFileDialog.askopenfilename(filetypes=[('Tablet files', '*.mtb'), ('Tablet files', '*.htd')])
if (fileName):
if (not self.__getInputParams()):
self.__showInvalidInputMessage()
return
self.lastFileName = fileName;
self.title(mainWindowTitle + " " + fileName)
self.__draw(fileName)
tkMessageBox.showinfo(measureDialogTitle,
measureDialogText + str(self.__dataController.getMeasure(fileName)))
self.redrawButton.config(state=NORMAL)
self.colorByCombobox.config(state="readonly")
self.colorsTableLengthEntry.config(state=NORMAL)
self.scaleTypeCombobox.config(state="readonly")
def __redrawButtonClick(self):
if (not self.__getInputParams()):
self.__showInvalidInputMessage()
return
self.__draw(self.lastFileName)
def __scaleTypeComboboxChange(self, event):
if (self.scaleTypeCombobox.get() == relativeScaleType):
#.........这里部分代码省略.........
示例5: Window
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class Window(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.style = Style()
self.style.theme_use("clam")
self.pack(fill=BOTH,expand=5)
self.parent.title("Document Similarity Checker")
self.dir = "Choose a directory"
self.setupInputs()
self.setButton()
def setupInputs(self):
self.chooseDir = Button(self, text="Choose",command=self.getDir)
self.chooseDir.place(x=10, y=10)
self.selpath = Label(self, text=self.dir, font=("Helvetica", 12))
self.selpath.place(x=150, y=10)
self.aLabel = Label(self, text="Alpha", font=("Helvetica", 12))
self.aLabel.place(x=10, y=50)
self.aEntry = Entry()
self.aEntry.place(x=200,y=50,width=400,height=30)
self.bLabel = Label(self, text="Beta", font=("Helvetica", 12))
self.bLabel.place(x=10, y=100)
self.bEntry = Entry()
self.bEntry.place(x=200,y=100,width=400,height=30)
def setButton(self):
self.quitButton = Button(self, text="Close",command=self.quit)
self.quitButton.place(x=520, y=250)
self.browserButton = Button(self, text="Open Browser",command=self.browser)
self.browserButton.place(x=400, y=250)
self.browserButton.config(state=DISABLED)
self.generate = Button(self, text="Generate Data",command=self.genData)
self.generate.place(x=10, y=250)
def browser(self):
import webbrowser
webbrowser.get('firefox').open('data/index.html')
self.browserButton.config(state=DISABLED)
def getDir(self):
globals.dir = tkFileDialog.askdirectory(parent=self.parent,initialdir="/",title='Select a directory')
self.selpath['text'] = globals.dir
#print globals.dir
#validate and process data
def genData(self):
valid = True
try:
globals.alpha = float(self.aEntry.get())
except ValueError:
globals.alpha = 0.0
valid = False
try:
globals.beta = float(self.bEntry.get())
except ValueError:
globals.beta = 0.0
valid = False
if not os.path.isdir(globals.dir) or globals.alpha>=1.0 or globals.beta>=1.0:
valid = False
if valid:
self.generate.config(state=DISABLED)
from compute import main as computeMain
computeMain()
from jsonutil import main as jsonMain
jsonMain()
self.browserButton.config(state=NORMAL)
self.generate.config(state=NORMAL)
示例6: Example
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class Example(Frame):
#Initialise values
ctrlpt1=[55,55]
ctrlpt2=[150,120]
ctrlpt3=[55,215]
pt1=[50,50]
pt2=[100,100]
clickno=2
toggle = 1
div_num = 10
#initilise Frame then initialise this Example class using initUI()
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Grass")
#Configure parent for column layout
Style().configure("TButton", padding=(0, 5, 0, 5),
font='serif 10')
self.columnconfigure(0, pad=3)
self.columnconfigure(1, pad=3)
self.columnconfigure(2, pad=3)
self.columnconfigure(3, pad=3)
self.rowconfigure(0, pad=3)
self.rowconfigure(1, pad=3)
self.rowconfigure(2, pad=3)
self.rowconfigure(3, pad=3)
self.rowconfigure(4, pad=3)
self.rowconfigure(5, pad=3)
self.rowconfigure(6, pad=3)
self.rowconfigure(7, pad=3)
self.rowconfigure(8, pad=3)
frame1 = Frame(self)
frame1.grid(row=0,columnspan=4)
self.lbl1 = Label(frame1, text="")
self.lbl1.pack(side=LEFT, padx=5, pady=5)
frame2 = Frame(self)
frame2.grid(row=1,columnspan=4)
lbl2 = Label(frame2, text="Divisions", width=6)
lbl2.pack(side=LEFT, padx=5, pady=5)
self.entry1=Entry(frame2)
self.entry1.pack(fill=X, padx=5, expand=True)
frame3 = Frame(self)
frame3.grid(row=2,columnspan=4)
self.lbl3 = Label(frame3, text="Divisions =%r"%self.div_num)
self.lbl3.pack(side=LEFT, expand=True)
set_point = Button(self, text="Set divisions", command=self.get_div)
set_point.grid(row=3, columnspan=2)
self.stop_place = Button(self, text="Toggle delete",\
command=self.change_toggle)
self.stop_place.grid(row = 3, column = 2,columnspan=2)
clr_btn = Button(self, text="Clear Canvas", command=self.clear_canvas)
clr_btn.grid(row = 4, column = 0,columnspan=2)
drw_btn = Button(self, text="Draw lines", command=self.draw_ctrllines)
drw_btn.grid(row = 4, column = 2,columnspan=2)
div = Button(self, text="Divide", command=self.draw_divide)
div.grid(row = 5, column = 0,columnspan=2)
strart = Button(self, text="Strings", command=self.string_art)
strart.grid(row = 5, column = 2,columnspan=2)
plotpar = Button(self, text="Parabola", command=self.plot_para)
plotpar.grid(row = 6, column = 0,columnspan=2)
self.w = Canvas(self, width=200, height=900)
self.w.grid(row=7, columnspan=4)
#Draw initial control points for user
self.id1=self.w.create_oval(self.ctrlpt1[0] - 2, self.ctrlpt1[1] - 2,\
self.ctrlpt1[0] + 2,self.ctrlpt1[1] + 2,fill="black",tags='maybe')
self.w.tag_bind(self.id1,'<Button-1>',self.del_elem)
id2=self.w.create_oval(
self.ctrlpt2[0] - 2, self.ctrlpt2[1] - 2,
self.ctrlpt2[0] + 2,self.ctrlpt2[1] + 2,fill="black"
)
self.w.tag_bind(id2,'<Button-1>',self.del_elem)
#.........这里部分代码省略.........
示例7: GameWindow
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class GameWindow(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.parent = parent
self.watchdog_socket = None
self.is_first_time = True
self.is_alive = True
self.play_again = False
self.controller = controller
self.root = self
self.keys = {}
self.items = []
self.extents = None # field size
self.background = None
# the following variables are needed for arrow key servicing
# <<<<<
self.amove = 'STAY'
self.ajump = 0
self.movereg = 0
self.bup = 0
self.bdown = 0
self.bleft = 0
self.bright = 0
self.sprint = 1
self.direction = None
self.next_move = 'STAY'
self.up_key = False
self.down_key = False
self.right_key = False
self.left_key = False
self.up_key_count = 0
self.down_key_count = 0
self.right_key_count = 0
self.left_key_count = 0
self.local_class = "SPECTATOR"
# >>>>>
# Everything that is visible in the side bar
# Info: Server, Nickname, Class, Score, Time
# Buttons: try again, leave
# <<<<<<
sidebar = Frame(self)
sidebar.pack(side='left',fill='y')
opts_frame = Frame(sidebar)
GameWindow.vSer = StringVar()
self.vN = StringVar()
self.vC = StringVar()
self.vS = StringVar()
self.vT = StringVar()
i = 0
label00 = Label(opts_frame, text='Server: ')
label00.grid(row=i,column=0)
self.labe01 = Label(opts_frame, textvariable=GameWindow.vSer)
self.labe01.grid(row=i,column=1)
i=i+1
if self.vC != "SPECTATOR":
label1 = Label(opts_frame, text='Nickname: ')
label1.grid(row=i,column=0)
self.label2 = Label(opts_frame, textvariable=self.vN)
self.label2.grid(row=i,column=1)
i=i+1
label3 = Label(opts_frame, text='Class: ')
label3.grid(row=i,column=0)
self.label4 = Label(opts_frame, textvariable=self.vC)
self.label4.grid(row=i,column=1)
i=i+1
label5 = Label(opts_frame, text='Score: ')
label5.grid(row=i,column=0)
self.label6 = Label(opts_frame, textvariable=self.vS)
self.label6.grid(row=i,column=1)
i=i+1
label7 = Label(opts_frame, text="Time")
label7.grid(row=i,column=0)
self.label8 = Label(opts_frame, textvariable=self.vT)
self.label8.grid(row=i,column=1)
opts_frame.pack(side='top',fill='x', )
self.leave_button = Button(sidebar, text="Try again!")
self.leave_button.pack(side='top',fill='x')
self.leave_button.config(command=self._again)
self.leave_button = Button(sidebar, text="Leave")
self.leave_button.pack(side='top',fill='x')
self.leave_button.config(command=self._leave)
# >>>>>>
# bind arrow key events to the canvas which is used to show the game field
self.canvas = Canvas(self)
self.canvas.bind('<KeyPress>', self.kp)
self.canvas.bind('<KeyRelease>', self.kr)
self.canvas.bind("<1>", lambda event: self.canvas.focus_set())
self.canvas.pack(expand=True,fill='both')
# List info: players on the game field
self.players_list = Text(sidebar, width=20, state=DISABLED)
self.players_list.pack(side='top',expand=True, fill='both')
# Start the scheduler
self._tick()
# key press
def kp(self,event):
if event.keysym == 'Up':
#.........这里部分代码省略.........
示例8: FindServer
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class FindServer(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.selected = "";
self.controller = controller
label = Label(self, text="Select server", font=TITLE_FONT, justify=CENTER, anchor=CENTER)
label.pack(side="top", fill="x", pady=10)
self.button1 = Button(self, text="Next",state="disabled", command=self.callback_choose)
button2 = Button(self, text="Refresh", command=self.callback_refresh)
button3 = Button(self, text="Back", command=self.callback_start)
scrollbar = Scrollbar(self)
self.mylist = Listbox(self, width=100, yscrollcommand = scrollbar.set )
self.mylist.bind("<Double-Button-1>", self.twoClick)
self.button1.pack()
button2.pack()
button3.pack()
# create list with a scroolbar
scrollbar.pack( side = "right", fill="y" )
self.mylist.pack( side = "top", fill = "x", ipadx=20, ipady=20, padx=20, pady=20 )
scrollbar.config( command = self.mylist.yview )
# create a progress bar
label2 = Label(self, text="Refresh progress bar", justify='center', anchor='center')
label2.pack(side="top", fill="x")
self.bar_lenght = 200
self.pb = Progressbar(self, length=self.bar_lenght, mode='determinate')
self.pb.pack(side="top", anchor='center', ipadx=20, ipady=20, padx=10, pady=10)
self.pb.config(value=0)
# to select he server user must double-click on it
def twoClick(self, event):
widget = event.widget
selection=widget.curselection()
value = widget.get(selection[0])
self.selected = value
self.button1.config(state="normal")
# save the selected server in a global variable
SELECTED_SERV = SERVER_LIST[selection[0]]
set_globvar(SELECTED_SERV)
# listen for broadcasts from port 8192
def listen_broadcasts(self, port, timeout):
# Set the progress bar to 0
self.pb.config(value=0)
step_size = ((self.bar_lenght/(MAX_NR_OF_SERVERS+1))/2)
list_of_servers = []
# Initialize the listener
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.bind(('', port))
s.settimeout(LISTENING_TIMEOUT)
# Listen for a number of times to get multiple servers
for _ in range(MAX_NR_OF_SERVERS + 1):
# Update the progress bar
self.pb.step(step_size)
self.pb.update_idletasks()
try:
message, address = s.recvfrom(8192)
m_split = message.split(';')
if m_split[0] == '\HELLO':
server_id = (m_split[1], address)
# Check if the server has not yet broadcasted itself.
if server_id not in list_of_servers:
list_of_servers.append(server_id)
except:
pass
# Close the socket
s.close()
if not list_of_servers:
# If no server found, pop a warning message.
tkMessageBox.showwarning("Find Servers", "No servers found. Refresh or create a new game.")
# Set the progress bar back to 0
self.pb.config(value=0)
# Return the whole list of available servers
return list_of_servers
# service the refresh button
def callback_refresh(self):
global SERVER_LIST
self.mylist.delete(0,END)
SERVER_LIST = self.listen_broadcasts(BROADCASTING_PORT, LISTENING_TIMEOUT)
for server_el in SERVER_LIST:
self.mylist.insert(END,(" "+str(server_el[0])+" IP: "+str(server_el[1])+" Time: "+str(time.asctime())))
def callback_choose(self):
self.mylist.delete(0,END)
self.button1.config(state="disabled")
self.controller.show_frame("ChooseType")
def callback_start(self):
self.mylist.delete(0,END)
self.button1.config(state="disabled")
self.controller.show_frame("StartPage")
示例9: CreateServer
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class CreateServer(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.controller = controller
CreateServer.local_world = None
label_1 = Label(self, text="Create server\n\n\n\n", font=TITLE_FONT, justify=CENTER, anchor=CENTER)
label_2 = Label(self, text="Server name:")
label_3 = Label(self, text="Gamefield (MxN):")
CreateServer.plx_name = 'none'
CreateServer.game_dim = '10X10'
self.entry_1 = Entry(self)
self.entry_2 = Entry(self)
self.entry_2.insert(0, '10x10')
self.entry_1.bind("<Key>", self.checkString)
self.button1 = Button(self, text="Create",state="disabled", command= self.callback_set)
self.button2 = Button(self, text="Back", command=lambda: controller.show_frame("StartPage"))
label_1.pack(side="top", fill="x", pady=10)
label_2.pack()
self.entry_1.pack()
label_3.pack()
self.entry_2.pack()
self.button1.pack(pady=10)
self.button2.pack(pady=20)
def com(self, controller, next_frame):
controller.show_frame(next_frame)
def checkString(self, event):
if self.entry_1:
self.button1.config(state="normal")
def callback_set(self):
set_global_state(1)
if self.get_name_field():
self.controller.show_frame("ChooseType")
# process user inputs
def get_name_field(self):
CreateServer.plx_name = self.entry_1.get()
CreateServer.game_dim = self.entry_2.get().upper()
flag2 = False
flag1 = self.string_check(CreateServer.plx_name,"Invalid server name")
if flag1:
flag2 = self.string_check(CreateServer.game_dim,"Invalid game field parameters")
if flag2:
m_split=CreateServer.game_dim.split('X')
if len(m_split)==2:
try:
_ = int(m_split[0])
except:
flag2 = False
try:
_ = int(m_split[1])
except:
flag2 = False
else:
flag2 = False
if flag2 == False:
tkMessageBox.showwarning("Error message", "Invalid game field parameters!")
return flag1 & flag2
# check if the string is usable
def string_check(self,s,msg):
temp = False
try:
s.decode('ascii')
except UnicodeEncodeError:
print "it was not an ascii-encoded unicode string"
tkMessageBox.showwarning("Error message", msg)
except UnicodeDecodeError:
print "it was not an ascii-encoded unicode string"
tkMessageBox.showwarning("Error message", msg)
else:
if len(CreateServer.plx_name) < 11 and len(CreateServer.plx_name) >= 1:
temp = True
else:
tkMessageBox.showwarning("Error message", "Please input 1-10 characters!")
return temp
示例10: MainControlFrame
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class MainControlFrame(Frame):
def __init__(self, master, sequencer):
Frame.__init__(self, master)
self.sequencer = sequencer
self.control_label = Label(self, text="Control")
self.start_button = Button(self, text="Start")
self.stop_button = Button(self, text="Stop")
self.start_button.config(command=self.sequencer.play)
self.stop_button.config(command=self.sequencer.stop)
self.control_label.pack()
self.start_button.pack()
self.stop_button.pack()
Label(self, text='Tempo').pack()
self.tempo_label = Label(self)
self.tempo_label.pack()
def set_tempo(v):
tempo = float(v)
self.sequencer.set_speed(tempo)
self.tempo_label.config(text='%3.0f' % tempo)
tempo_scale = Scale(self, from_=400, to=5, command=set_tempo, orient='vertical')
tempo_scale.set(self.sequencer.speed)
tempo_scale.pack()
measure_control_frame = Frame(self)
measure_control_frame.pack()
self.measure_resolution = StringVar(measure_control_frame)
self.measure_resolution.set(self.sequencer.measure_resolution)
self.beats_per_measure = StringVar(measure_control_frame)
self.beats_per_measure.set(self.sequencer.beats_per_measure)
Label(measure_control_frame, text='Resolution').grid(row=0, column=0, sticky='E')
measure_resolution_entry = Entry(measure_control_frame, textvariable=self.measure_resolution, width=3)
measure_resolution_entry.grid(row=0, column=1)
Label(measure_control_frame, text='Beats').grid(row=1, column=0, sticky='E')
beats_per_measure_entry = Entry(measure_control_frame, textvariable=self.beats_per_measure, width=3)
beats_per_measure_entry.grid(row=1, column=1)
change_measure_update = Button(measure_control_frame, text='Update Measure', command=self.change_measures)
change_measure_update.grid(row=2, columnspan=2)
# master_fader = mixer_frame.AudioFader(self, sequencer.getVolume, sequencer.setVolume)
# master_fader.pack()
def start_stop(self, event=None):
if self.sequencer.running:
self.sequencer.play()
else:
self.sequencer.stop()
def change_measures(self):
old_measure_resolution = self.sequencer.measure_resolution
old_beats_per_measure = self.sequencer.beats_per_measure
try:
measure_resolution = int(self.measure_resolution.get())
beats_per_measure = int(self.beats_per_measure.get())
self.sequencer.change_measures(beats_per_measure, measure_resolution)
print "ready to reload seq"
self.master.master._open_sequencer(self.sequencer)
except Exception as e:
print e
self.measure_resolution.set(old_measure_resolution)
self.beats_per_measure.set(old_beats_per_measure)
pass
示例11: App
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class App(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
self.centerWindow()
def initUI(self):
self.parent.title("Champion Pool Builder")
self.parent.iconbitmap("assets/icon.ico")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.buildMode = True
self.allPools = "assets/pools/"
self.champsLabel = Label(text="Champions")
self.champBox = Listbox(self)
self.champBoxScrollbar = Scrollbar(self.champBox, orient=VERTICAL)
self.champBox.config(yscrollcommand=self.champBoxScrollbar.set)
self.champBoxScrollbar.config(command=self.champBox.yview)
self.addButton = Button(self, text=">>", command=self.addChampToPool)
self.removeButton = Button(self, text="<<", command=self.removeChampFromPool)
self.saveButton = Button(self, text="Save champion pool", width=18, command=self.saveChampPool)
self.loadButton = Button(self, text="Load champion pool", width=18, command=lambda: self.loadChampPools(1))
self.confirmLoadButton = Button(self, text="Load", width=6, command=self.choosePool)
self.getStringButton = Button(self, text="Copy pool to clipboard", width=18, command=self.buildPoolString)
self.poolLabel = Label(text="Champion Pool")
self.poolBox = Listbox(self)
self.poolBoxScrollbar = Scrollbar(self.poolBox, orient=VERTICAL)
self.poolBox.config(yscrollcommand=self.poolBoxScrollbar.set)
self.poolBoxScrollbar.config(command=self.poolBox.yview)
self.champsLabel.place(x=5, y=5)
self.champBox.place(x=5, y=30)
self.addButton.place(x=150, y=60)
self.removeButton.place(x=150, y=100)
self.saveButton.place(x=350, y=30)
self.loadButton.place(x=350, y=60)
self.getStringButton.place(x=350, y=90)
self.poolLabel.place(x=200, y=5)
self.poolBox.place(x=200, y=30)
self.champBox.focus_set()
self.loadChampions()
def centerWindow(self):
w = 500
h = 200
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
x = (sw - w)/2
y = (sh - h)/2
self.parent.geometry("%dx%d+%d+%d" % (w, h, x, y))
def loadChampions(self, pooled=None):
if pooled:
with open("assets/Champions.txt", "r") as file:
champions = file.read().splitlines()
for champ in pooled:
champions.remove(champ)
for champion in sorted(champions):
self.champBox.insert(END, champion)
else:
with open("assets/Champions.txt", "r") as file:
champions = file.read().splitlines()
for champion in sorted(champions):
self.champBox.insert(END, champion)
def choosePool(self):
idx = self.poolBox.curselection()
chosenPool = self.poolBox.get(idx)
self.confirmLoadButton.place_forget()
self.loadChampPools(2, chosenPool)
def loadChampPools(self, level, pool=None):
if level == 1:
self.buildMode = False
self.champBox.delete(0, END)
self.poolBox.delete(0, END)
self.saveButton.config(state=DISABLED)
self.loadButton.config(state=DISABLED)
self.getStringButton.config(state=DISABLED)
self.confirmLoadButton.place(x=350, y=120)
with open("assets/champpools.txt", "r") as file:
champPools = file.read().splitlines()
for pool in champPools:
self.poolBox.insert(END, pool)
elif level == 2:
self.poolBox.delete(0, END)
self.buildMode = True
#.........这里部分代码省略.........
示例12: DronControll
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class DronControll(Frame):
#Botones Despegar aterrizar
btnDespegar = 0
btnAterrizar = 0
#Botones controll
btnGiroIzquierda = 0
btnGiroDerecha = 0
btnAdelante = 0
btnAtras = 0
btnIzquierda = 0
btnDerecha = 0
#Botones camera
btnTiltDownCamera = 0
btnTiltUpCamera = 0
btnPanLeft = 0
btnPanRight = 0
btnEnableCamera = 0
#TOPICS
pubControllDron = 0
pubControllTakeoff = 0
pubControllLanding = 0
#ETIQUETAS
etqControlDron = 0
etqControlCamera = 0
def __init__(self,parent,pubControllDron,pubControllTakeoff,pubControllLanding,pubControllCamera):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
self.pubControllDron = pubControllDron
self.pubControllTakeoff = pubControllTakeoff
self.pubControllLanding = pubControllLanding
self.pubControllCamera = pubControllCamera
def initUI(self):
self.parent.title("Quit button")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.initButtons()
self.etqControlDron = Label(self,text="Dron Controll")
self.etqControlDron.place(x=20,y=10)
self.etqControlCamera = Label(self,text="Camera Controll")
self.etqControlCamera.place(x=370,y=10)
def initButtons(self):
#Controll drone
self.btnIzquierda = Button(self,text = "Go Left",command = self.GoLeft)
self.btnIzquierda.place(x=60,y=60)
self.btnDerecha = Button(self,text = "Go Right",command = self.GoRight)
self.btnDerecha.place(x=260,y=60)
self.btnGiroIzquierda = Button(self, text="Rotate Left",command=self.Izquierda)
self.btnGiroIzquierda.place(x=50, y=100)
self.btnGiroDerecha = Button(self,text = "Rotate Right",command=self.Derecha);
self.btnGiroDerecha.place(x=250, y=100);
self.btnAdelante = Button(self,text = "Forward",command=self.Delante);
self.btnAdelante.place(x=160,y=50);
self.btnAtras = Button(self,text = "Backwards",command=self.Atras);
self.btnAtras.place(x=150,y=140);
#takeoff & landing
self.btnDespegar = Button(self,text = "Takeoff",command=self.Takeoff);
self.btnDespegar.place(x=50,y=220);
self.btnAterrizar = Button(self,text = "Landing",command=self.Land);
self.btnAterrizar.place(x=250,y=220);
self.btnAterrizar.config(state='disabled')
#camera_controll
self.btnTiltUpCamera = Button(self,text="Tilt Up Camera",command=self.tiltup)
self.btnTiltUpCamera.place(x=450,y=60);
self.btnTiltDownCamera = Button(self,text="Tilt Down Camera",command=self.tiltdown)
self.btnTiltDownCamera.place(x=600,y=60);
self.btnPanRight = Button(self,text="Pan Right Camera",command=self.panRight)
self.btnPanRight.place(x=600,y=150);
self.btnPanLeft = Button(self,text="Pan Left Camera",command=self.panLeft)
self.btnPanLeft.place(x=450,y=150);
#Camera controll
#.........这里部分代码省略.........
示例13: Evolution
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class Evolution(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def configure(self):
self.conf = Toplevel(self)
self.conf.wm_title("Configure Universe")
self.wc.reconfigure(self)
def initUI(self):
#create initial Beings object (not instantiated until live is called)
self.wc = WorldConfiguration()
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.columnconfigure(2, weight=1)
self.columnconfigure(4, pad=7)
self.rowconfigure(3, weight=1)
lbl = Label(self, text="PyLife")
lbl.grid(sticky = W, padx=25, pady=5)
self.world = Canvas(self, background="#7474DB")
self.world.grid(row=1, column=0, columnspan=3, rowspan=8, padx=5, sticky=E+W+N+S)
self.sbtn = Button(self, text="Stop")
self.sbtn.grid(row=1, column=4, pady = 5, sticky=E)
self.bbox = Text(self, height=20, width=36)
self.bbox.grid(row=3, column = 4, padx=5, sticky=E+W+N+S)
self.bbox1 = Text(self, height=11, width=36)
self.bbox1.grid(row=4, column=4, padx=5, sticky=E+W+N+S)
self.cbtn = Button(self, text="Close", command=self.parent.destroy)
self.cbtn.grid(row=9, column=4, pady=5)
self.cnfbtn = Button(self, text="Configure Universe")
self.cnfbtn.grid(row=9, column=0, padx=5)
self.timelbl = Text(self, height=1, width=10)
self.timelbl.grid(row=2, column=4, pady=5 )
b = Beings(self)
abtn = Button(self, text="Start", command=b.live) #Beings(cnfbtn, world, 4, 10, sbtn, bbox, bbox1, timelbl).live)
abtn.grid(row=1, column=4, pady=5, sticky=W)
self.cnfbtn.config(command=b.configure)
def close(self):
self.parent.destroy
示例14: toolUI
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
class toolUI(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Sequence modification parser")
self.columnconfigure(0, pad=5)
self.columnconfigure(1, pad=5, weight = 1)
self.columnconfigure(2, pad=5)
self.rowconfigure(0, pad=5, weight = 1)
self.rowconfigure(1, pad=5, weight = 1)
self.rowconfigure(2, pad=5, weight = 1)
self.rowconfigure(3, pad=5, weight = 1)
self.rowconfigure(4, pad=5, weight = 1)
self.rowconfigure(5, pad=5, weight = 1)
self.lInput = Label(self, text = "Input file")
self.lInput.grid(row = 0, column = 0, sticky = W)
self.lPRS = Label(self, text = "phospoRS Column Name")
self.lPRS.grid(row = 1, column = 0, sticky = W)
self.lScore = Label(self, text = "Min phosphoRS Score")
self.lScore.grid(row = 2, column = 0, sticky = W)
self.lDA = Label(self, text = "Check deamidation sites")
self.lDA.grid(row = 3, column = 0, sticky = W)
self.lLabFile = Label(self, text = "Label description file")
self.lLabFile.grid(row = 4, column = 0, sticky = W)
self.ifPathText = StringVar()
self.prsScoreText = StringVar(value = '0')
self.prsNameText = StringVar()
self.doDAVar = IntVar()
self.labFileText = StringVar(value = path.abspath('moddict.txt'))
self.ifPath = Entry(self, textvariable = self.ifPathText)
self.ifPath.grid(row = 0, column = 1, sticky = W+E)
self.prsName = Entry(self, textvariable = self.prsNameText)
self.prsName.grid(row = 1, column = 1, sticky = W+E)
self.prsScore = Entry(self, textvariable = self.prsScoreText, state = DISABLED)
self.prsScore.grid(row = 2, column = 1, sticky = W+E)
self.doDABox = Checkbutton(self, variable = self.doDAVar)
self.doDABox.grid(row = 3, column = 1, sticky = W)
self.labFile = Entry(self, textvariable = self.labFileText)
self.labFile.grid(row = 4, column = 1, sticky = W+E)
self.foButton = Button(self, text = "Select file", command = self.selectFileOpen)
self.foButton.grid(row = 0, column = 2, sticky = E+W, padx = 3)
self.prsButton = Button(self, text = "Select column", state = DISABLED, command = self.selectColumn)
self.prsButton.grid(row = 1, column = 2, sticky = E+W, padx = 3)
self.labFileButton = Button(self, text = "Select file", command = self.selectLabFileOpen)
self.labFileButton.grid(row = 4, column = 2, sticky = E+W, padx = 3)
self.startButton = Button(self, text = "Start", command = self.start, padx = 3, pady = 3)
self.startButton.grid(row = 5, column = 1, sticky = E+W)
self.pack(fill = BOTH, expand = True, padx = 5, pady = 5)
def selectFileOpen(self):
#Open file dialog
dlg = tkFileDialog.Open(self, filetypes = [('Excel spreadsheet', '*.xlsx')])
openName = dlg.show()
if openName != "":
self.ifPathText.set(openName)
self.findPRS(openName)#find phosphRS column
def selectLabFileOpen(self):
#Open labels file dialog
dlg = tkFileDialog.Open(self, filetypes = [('All files', '*.*')])
openName = dlg.show()
if openName != "":
self.labFileText.set(openName)
def findPRS(self, openName):
#find phosphoRS column
worksheet = load_workbook(openName, use_iterators = True).get_active_sheet() #open excel sheet
self.headers = [unicode(worksheet.cell(get_column_letter(columnNr) + '1').value).lower()
for columnNr in range(1, worksheet.get_highest_column() + 1)]
self.prsButton.config(state = "normal")
if 'phosphors site probabilities' in self.headers:
self.prsNameText.set('phosphoRS Site Probabilities')
elif 'phosphors: phospho_sty site probabilities' in self.headers:
self.prsNameText.set('PhosphoRS: Phospho_STY Site Probabilities')
elif 'phosphors: phospho site probabilities' in self.headers:
self.prsNameText.set('PhosphoRS: Phospho Site Probabilities')
else:
self.prsNameText.set('PhosphoRS column not found')
return
self.prsScore.config(state = 'normal')
#.........这里部分代码省略.........
示例15: initUI
# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import config [as 别名]
def initUI(self,cards):
self.parent.title("Karuta")
Style().configure("TButton")
p1,p2 = assignCards(cards,order)
for row in range(6):
for col in range(NUM_COLS):
if (NUM_COLS-col,row+1) in p1:
self.setCard(p1[(NUM_COLS-col,row+1)],row,col)
elif (col+1,6-row) in p2:
self.setCard(p2[(col+1,6-row)],row,col)
else:
self.setCard(-1,row,col)
self.p1 = [i for i in p1.values()]
self.p2 = [i for i in p2.values()]
def move():
if self.state == 'move-select-start' or self.state == 'move-select-stop':
self.changeState('waiting')
self.moveButton.config(text='Move')
self.infoLabel.config(text='Move cancelled')
elif self.state == 'waiting':
self.changeState('move-select-start')
self.infoLabel.config(text='Select card to move')
self.moveButton.config(text='Cancel')
self.update()
b = Button(self,text='Move',command=move)
b.grid(row=0,column=8)
self.moveButton = b
def playNextAudio():
if self.state == 'taking':
self.playNextAudio()
else:
self.client.sendMessage('play')
b = Button(self,text='Play',command=playNextAudio)
self.playButton = b
b.grid(row=0, column=9)
def reveal():
self.reveal()
b = Button(self,text='Reveal',command=reveal)
b.grid(row=0, column=10)
self.revealButton = b
if self.multiplayer:
b.config(state=DISABLED)
def rerack():
self.rerack()
b = Button(self,text='Rerack',command=rerack)
b.grid(row=0, column=11)
self.rerackButton = b
def ready():
if self.startTime < time.time() - 11:
if self.state == 'taking' and not self.activeCardRow == -1:
self.infoLabel.config(text="Card has not been found yet.")
self.update()
else:
self.moveButton.config(text="Move")
self.client.sendMessage('ready')
self.update()
b = Button(self,text='Ready',command=ready)
b.grid(row=0, column=12)
self.readyButton = b
l = Label(self,text='')
l.grid(row=0, column=0, columnspan=5)
self.infoLabel = l
self.pack()