本文整理汇总了Python中tkinter.Tk.config方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.config方法的具体用法?Python Tk.config怎么用?Python Tk.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
def main():
root = Tk()
root.geometry("600x185+200+200")
app = MemberChecker(root)
menubar = Menu(root)
menubar.add_command(label="Clear log", command=app.clear_log)
menubar.add_command(label="Load API data", command=app.load_data)
root.config(menu=menubar)
root.pack_slaves()
root.mainloop()
示例2: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
class GUI:
def __init__(self):
self.app = Tk()
self.app.title('TicTacToe')
self.app.resizable(width=False, height=False)
self.board = Board()
self.font = Font(family="Helvetica", size=32)
self.buttons = {}
for x,y in self.board.fields:
handler = lambda x=x,y=y: self.move(x,y)
button = Button(self.app, command=handler, font=self.font, width=2, height=1)
button.grid(row=y, column=x)
self.buttons[x,y] = button
handler = lambda: self.reset()
button = Button(self.app, text='reset', command=handler)
button.grid(row=self.board.size+1, column=0, columnspan=self.board.size, sticky="WE")
self.update()
def reset(self):
self.board = Board()
self.update()
def move(self,x,y):
self.app.config(cursor="watch")
self.app.update()
self.board = self.board.move(x,y)
self.update()
move = self.board.best()
if move:
self.board = self.board.move(*move)
self.update()
self.app.config(cursor="")
def update(self):
for (x,y) in self.board.fields:
text = self.board.fields[x,y]
self.buttons[x,y]['text'] = text
self.buttons[x,y]['disabledforeground'] = 'black'
if text==self.board.empty:
self.buttons[x,y]['state'] = 'normal'
else:
self.buttons[x,y]['state'] = 'disabled'
winning = self.board.won()
if winning:
for x,y in winning:
self.buttons[x,y]['disabledforeground'] = 'red'
for x,y in self.buttons:
self.buttons[x,y]['state'] = 'disabled'
for (x,y) in self.board.fields:
self.buttons[x,y].update()
def mainloop(self):
self.app.mainloop()
示例3: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
def __init__(self, tk: Tk):
tk.title("Layered Polygons")
menubar = Menu(tk)
menu_file = Menu(menubar, tearoff=0)
menu_file.add_command(label="New...", command=self._new_scene)
menu_file.add_command(label="Open...", command=self._open_scene)
menu_file.add_separator()
menu_file.add_command(label="Save", command=self._save_scene)
menu_file.add_command(label="Save As...", command=self._save_scene_as)
menu_file.add_separator()
menu_export = Menu(menu_file, tearoff=0)
menu_export.add_command(label="Wavefront (.obj)...",
command=self._export_obj)
menu_file.add_cascade(label="Export As", menu=menu_export)
menu_file.add_separator()
menu_file.add_command(label="Quit", command=self._quit_app)
menubar.add_cascade(label="File", menu=menu_file)
tk.config(menu=menubar)
paned = PanedWindow(tk, relief=RAISED)
paned.pack(fill=BOTH, expand=1)
frame = Frame(paned)
paned.add(frame)
self._canvas = LayPolyCanvas(frame)
bar_x = Scrollbar(frame, orient=HORIZONTAL)
bar_x.pack(side=BOTTOM, fill=X)
bar_x.config(command=self._canvas.xview)
bar_y = Scrollbar(frame, orient=VERTICAL)
bar_y.pack(side=RIGHT, fill=Y)
bar_y.config(command=self._canvas.yview)
self._canvas.config(xscrollcommand=bar_x.set, yscrollcommand=bar_y.set)
self._canvas.pack(side=LEFT, expand=True, fill=BOTH)
# Thanks to the two guys on Stack Overflow for that!
# ( http://stackoverflow.com/a/7734187 )
self._layer_list = Listbox(paned, selectmode=SINGLE)
paned.add(self._layer_list)
self._scene = None
self._current_layer = None
self._is_drawing_polygon = False
self._tk = tk
self._canvas.bind("<Button-1>", self._canvas_left_click)
self._canvas.bind("<Button-3>", self._canvas_right_click)
self._canvas.bind("<Motion>", self._canvas_mouse_moved)
self._layer_list.bind("<<ListboxSelect>>", self._layer_change)
self._current_path = None
示例4: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
def main():
'''Makes the application
'''
root = Tk()
app = Application(master=root)
app.master.title("Password Generator")
root.minsize(500, 500)
root.maxsize(600, 600)
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Exit", command=root.destroy)
menubar.add_cascade(label="File", menu=filemenu)
root.config(bg='#2A2C2B', menu=menubar)
app.mainloop()
示例5: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
def __init__(self, num_rows, num_cols, best_possible):
self.rows = num_rows
self.cols = num_cols
self.expectedBest = best_possible
# create the root and the canvas
root = Tk()
# local function to bind/unbind events
self.bind = root.bind
self.unbind = root.unbind
# local function to change title
self.updateTitle = root.title
# local function to change cursor
self.updateCursor = lambda x: root.config(cursor=x)
# local function to start game
self.start = root.mainloop
# get screen width and height
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
# fix scaling for higher resolutions
if max(self.canvasWidth / ws, self.canvasHeight / hs) < 0.45:
self.scale = 2
self.canvas = Canvas(root, width=self.canvasWidth, height=self.canvasHeight)
self.canvas.pack()
# calculate position x, y
x = (ws - self.canvasWidth) // 2
y = (hs - self.canvasHeight) // 2
root.geometry('%dx%d+%d+%d' % (self.canvasWidth, self.canvasHeight, x, y))
root.resizable(width=0, height=0)
self.init()
# set up keypress events
root.bind("<Key>", self.keyPressed)
示例6: Frame1
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
def Frame1():
master = Tk()
master.resizable(width=0, height=0)
master.geometry("800x600")
master.config(bg="gold")
label_huidig_station = Label(master, text = "{}".format(bestemming_input))
label_huidig_station.place(x=100, y=100)
label_Tijd0 = Label(master, text = "{}".format(vertrektijd_list[0]))
label_Tijd0.place(x = 200, y= 150 )
label_Eindbestemming0 = Label(master, text = "{}".format(eindbestemming_list[0]))
label_Eindbestemming0.place(x = 300, y = 150)
label_Spoor0 = Label(master, text = "{}".format(spoor_list[0]))
label_Spoor0.place(x = 550, y = 150)
label_Typetrein0 = Label(master, text = "{}".format(treinsoort_list[0]))
label_Typetrein0.place(x= 320, y = 200)
label_Tijd1 = Label(master, text = "{}".format(vertrektijd_list[1]))
label_Tijd1.place(x = 200, y= 250 )
label_Eindbestemming1 = Label(master, text = "{}".format(eindbestemming_list[1]))
label_Eindbestemming1.place(x = 300, y = 250)
label_Spoor1 = Label(master, text = "{}".format(spoor_list[1]))
label_Spoor1.place(x = 550, y = 250)
label_Typetrein1 = Label(master, text = "{}".format(treinsoort_list[1]))
label_Typetrein1.place(x= 320, y = 300)
label_Tijd2 = Label(master, text = "{}".format(vertrektijd_list[2]))
label_Tijd2.place(x = 200, y= 350 )
label_Eindbestemming2 = Label(master, text = "{}".format(eindbestemming_list[2]))
label_Eindbestemming2.place(x = 300, y = 350)
label_Spoor2 = Label(master, text = "{}".format(spoor_list[2]))
label_Spoor2.place(x = 550, y = 350)
label_Typetrein2 = Label(master, text = "{}".format(treinsoort_list[2]))
label_Typetrein2.place(x= 320, y = 400)
label_Tijd3 = Label(master, text = "{}".format(vertrektijd_list[3]))
label_Tijd3.place(x = 200, y= 450 )
label_Eindbestemming3 = Label(master, text = "{}".format(eindbestemming_list[3]))
label_Eindbestemming3.place(x = 300, y = 450)
label_Spoor3 = Label(master, text = "{}".format(spoor_list[3]))
label_Spoor3.place(x = 550, y = 450)
label_Typetrein3 = Label(master, text = "{}".format(treinsoort_list[3]))
label_Typetrein3.place(x= 320, y = 500)
master.mainloop()
示例7: venster3
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
def venster3(event):
master = Tk()
master.resizable(width=0, height=0)
master.geometry("800x600")
master.config(bg="gold")
label_huidig_station = Label(master, text = "Huidig station")
label_huidig_station.place(x=100, y=100)
label_Tijd0 = Label(master, text = "Tijd0")
label_Tijd0.place(x = 200, y= 150 )
label_Eindbestemming0 = Label(master, text = "Eindbestemming0")
label_Eindbestemming0.place(x = 300, y = 150)
label_Spoor0 = Label(master, text = "Spoor0")
label_Spoor0.place(x = 550, y = 150)
label_Typetrein0 = Label(master, text = "TypeTrein0")
label_Typetrein0.place(x= 320, y = 200)
label_Tijd1 = Label(master, text = "Tijd1")
label_Tijd1.place(x = 200, y= 250 )
label_Eindbestemming1 = Label(master, text = "Eindbestemming1")
label_Eindbestemming1.place(x = 300, y = 250)
label_Spoor1 = Label(master, text = "Spoor1")
label_Spoor1.place(x = 550, y = 250)
label_Typetrein1 = Label(master, text = "TypeTrein1")
label_Typetrein1.place(x= 320, y = 300)
label_Tijd2 = Label(master, text = "Tijd2")
label_Tijd2.place(x = 200, y= 350 )
label_Eindbestemming2 = Label(master, text = "Eindbestemming2")
label_Eindbestemming2.place(x = 300, y = 350)
label_Spoor2 = Label(master, text = "Spoor2")
label_Spoor2.place(x = 550, y = 350)
label_Typetrein2 = Label(master, text = "TypeTrein2")
label_Typetrein2.place(x= 320, y = 400)
label_Tijd3 = Label(master, text = "Tijd3")
label_Tijd3.place(x = 200, y= 450 )
label_Eindbestemming3 = Label(master, text = "Eindbestemming3")
label_Eindbestemming3.place(x = 300, y = 450)
label_Spoor3 = Label(master, text = "Spoor3")
label_Spoor3.place(x = 550, y = 450)
label_Typetrein3 = Label(master, text = "TypeTrein3")
label_Typetrein3.place(x= 320, y = 500)
示例8: Xls2kml
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
class Xls2kml(object):
'''
Interface builted in Tkinter()
'''
def __init__(self):
'''
None -> None
Builds the Tkinter window and all his elements.
'''
# variables ----------------------------------------------------
# log file
open("erros.log", "w").close() # to open and clean the logfile
logging.basicConfig(level=logging.DEBUG, filename='erros.log')
sys.stderr = LogFile('stderr') # Redirect stderr
self.original_working_dir = os.getcwd() # original working dir
self.master = Tk() # Tk() object
self.master.title('EXCEL to KMZ Transformer - ver. 1.6') # window name
icons = os.getcwd() + os.sep + "icons" + os.sep # path to icons
foto_folder = os.getcwd() + os.sep + "fotos" # path to fotos
icon = icons + "compass.ico"
self.master.iconbitmap(icon) # window icon
self.master.resizable(width=FALSE, height=FALSE)
self.master.geometry("548x314")
self.file_name = "" # the name of the EXEL file
self.last_dir = "C:/"
# image to decorate the window
self.img = ImageTk.PhotoImage(Image.open(icons + "excel-kmz.jpg"))
# to use in frame, message, labels and buttons -----------------
self.message = StringVar()
self.message.set("\nSelecciona um ficheiro EXCEL")
bg = "gray25"
bg1 = "dark orange"
fc = "white smoke"
font = ("Helvetica", "8", "bold")
text0 = " ----- " # " ------------------------------------------ "
text1 = " Boris & Vladimir Software "
text = text0 + text1 + text0
# Menu ---------------------------------------------------------
self.menu = Menu(self.master)
self.master.config(menu=self.menu)
filemenu = Menu(self.menu)
self.menu.add_cascade(label="Ficheiro", menu=filemenu)
filemenu.add_command(label="Sair", command=self.__callback_3)
filemenu.add_command(label='Pasta Fotos', command=lambda: (self.__open_folder(foto_folder)))
# --------------------- NOVO -----------------------------------
self.openGE = BooleanVar() # não esquecer de importar BooleanVar
self.openGE.set(False)
optionsmenu = Menu(self.menu)
self.menu.add_cascade(label="Opções", menu=optionsmenu)
optionsmenu.add_checkbutton(label="Não abrir o Google Earth",
onvalue=True, offvalue=False,
variable=self.openGE)
docsmenu = Menu(self.menu)
docs = ["docs\manual.pdf", "docs\icons.pdf", "docs\colors.pdf",
"docs\GPS.xlsx", "docs\GPS.kmz", "docs\Celulas.xlsx",
"docs\Celulas.kmz", "docs\Foto.xlsx", "docs\Foto.kmz",
"docs\Quadrado.xls", "docs\Quadrado.kmz"]
self.menu.add_cascade(label="Documentação", menu=docsmenu)
docsmenu.add_command(label="Manual",
command=lambda: (self.__open_file(docs[0])))
docsmenu.add_command(label="Ícones",
command=lambda: (self.__open_file(docs[1])))
docsmenu.add_command(label="Cores",
command=lambda: (self.__open_file(docs[2])))
exemplemenu = Menu(docsmenu)
docsmenu.add_cascade(label="Exemplos", menu=exemplemenu)
gpsmenu = Menu(exemplemenu)
exemplemenu.add_cascade(label="Trajetos", menu=gpsmenu)
gpsmenu.add_command(label="Excel",
command=lambda: (self.__open_file(docs[3])))
gpsmenu.add_command(label="Google Earth",
command=lambda: (self.__open_file(docs[4])))
cellmenu = Menu(exemplemenu)
exemplemenu.add_cascade(label="Células Telefónicas", menu=cellmenu)
cellmenu.add_command(label="Excel",
command=lambda: (self.__open_file(docs[5])))
cellmenu.add_command(label="Google Earth",
command=lambda: (self.__open_file(docs[6])))
fotomenu = Menu(exemplemenu)
exemplemenu.add_cascade(label="Fotos", menu=fotomenu)
fotomenu.add_command(label="Excel",
command=lambda: (self.__open_file(docs[7])))
fotomenu.add_command(label="Google Earth",
command=lambda: (self.__open_file(docs[8])))
squaremenu = Menu(exemplemenu)
exemplemenu.add_cascade(label="Quadrado", menu=squaremenu)
squaremenu.add_command(label="Excel",
command=lambda: (self.__open_file(docs[9])))
squaremenu.add_command(label="Google Earth",
command=lambda: (self.__open_file(docs[10])))
helpmenu = Menu(self.menu)
#.........这里部分代码省略.........
示例9: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
class CollocationsView:
_BACKGROUND_COLOUR = "#FFF" # white
def __init__(self):
self.queue = q.Queue()
self.model = CollocationsModel(self.queue)
self.top = Tk()
self._init_top(self.top)
self._init_menubar()
self._init_widgets(self.top)
self.load_corpus(self.model.DEFAULT_CORPUS)
self.after = self.top.after(POLL_INTERVAL, self._poll)
def _init_top(self, top):
top.geometry("550x650+50+50")
top.title("NLTK Collocations List")
top.bind("<Control-q>", self.destroy)
top.protocol("WM_DELETE_WINDOW", self.destroy)
top.minsize(550, 650)
def _init_widgets(self, parent):
self.main_frame = Frame(parent, dict(background=self._BACKGROUND_COLOUR, padx=1, pady=1, border=1))
self._init_corpus_select(self.main_frame)
self._init_results_box(self.main_frame)
self._init_paging(self.main_frame)
self._init_status(self.main_frame)
self.main_frame.pack(fill="both", expand=True)
def _init_corpus_select(self, parent):
innerframe = Frame(parent, background=self._BACKGROUND_COLOUR)
self.var = StringVar(innerframe)
self.var.set(self.model.DEFAULT_CORPUS)
Label(
innerframe, justify=LEFT, text=" Corpus: ", background=self._BACKGROUND_COLOUR, padx=2, pady=1, border=0
).pack(side="left")
other_corpora = list(self.model.CORPORA.keys()).remove(self.model.DEFAULT_CORPUS)
om = OptionMenu(
innerframe,
self.var,
self.model.DEFAULT_CORPUS,
command=self.corpus_selected,
*self.model.non_default_corpora()
)
om["borderwidth"] = 0
om["highlightthickness"] = 1
om.pack(side="left")
innerframe.pack(side="top", fill="x", anchor="n")
def _init_status(self, parent):
self.status = Label(
parent, justify=LEFT, relief=SUNKEN, background=self._BACKGROUND_COLOUR, border=0, padx=1, pady=0
)
self.status.pack(side="top", anchor="sw")
def _init_menubar(self):
self._result_size = IntVar(self.top)
menubar = Menu(self.top)
filemenu = Menu(menubar, tearoff=0, borderwidth=0)
filemenu.add_command(label="Exit", underline=1, command=self.destroy, accelerator="Ctrl-q")
menubar.add_cascade(label="File", underline=0, menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
rescntmenu = Menu(editmenu, tearoff=0)
rescntmenu.add_radiobutton(
label="20", variable=self._result_size, underline=0, value=20, command=self.set_result_size
)
rescntmenu.add_radiobutton(
label="50", variable=self._result_size, underline=0, value=50, command=self.set_result_size
)
rescntmenu.add_radiobutton(
label="100", variable=self._result_size, underline=0, value=100, command=self.set_result_size
)
rescntmenu.invoke(1)
editmenu.add_cascade(label="Result Count", underline=0, menu=rescntmenu)
menubar.add_cascade(label="Edit", underline=0, menu=editmenu)
self.top.config(menu=menubar)
def set_result_size(self, **kwargs):
self.model.result_count = self._result_size.get()
def _init_results_box(self, parent):
innerframe = Frame(parent)
i1 = Frame(innerframe)
i2 = Frame(innerframe)
vscrollbar = Scrollbar(i1, borderwidth=1)
hscrollbar = Scrollbar(i2, borderwidth=1, orient="horiz")
self.results_box = Text(
i1,
font=tkinter.font.Font(family="courier", size="16"),
state="disabled",
borderwidth=1,
yscrollcommand=vscrollbar.set,
xscrollcommand=hscrollbar.set,
wrap="none",
width="40",
height="20",
exportselection=1,
#.........这里部分代码省略.........
示例10: take_screenshot_crop
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
def take_screenshot_crop(path):
pimage = _r.take_screenshot()
_, _, width, height = pimage.getbbox()
displays = _r.get_display_monitors()
leftmost, topmost = 0, 0
for d in displays:
if d[0] < leftmost:
leftmost = d[0]
if d[1] < topmost:
topmost = d[1]
root = Tk() # Creates a Tkinter window
root.overrideredirect(True) # Makes the window borderless
root.geometry("{0}x{1}+{2}+{3}".format(width, height, leftmost, topmost)) # window size = screenshot size
root.config(cursor="crosshair") # Sets the cursor to a crosshair
pimage_tk = ImageTk.PhotoImage(pimage) # Converts the PIL.Image into a Tkinter compatible PhotoImage
can = Canvas(root, width=width, height=height) # Creates a canvas object on the window
can.pack()
can.create_image((0, 0), image=pimage_tk, anchor="nw") # Draws the screenshot onto the canvas
# This class holds some information about the drawn rectangle
class CanInfo:
rect = None
startx, starty = 0, 0
# Stores the starting position of the drawn rectangle in the CanInfo class
def xy(event):
CanInfo.startx, CanInfo.starty = event.x, event.y
# Redraws the rectangle when the cursor has been moved
def capture_motion(event):
can.delete(CanInfo.rect)
CanInfo.rect = can.create_rectangle(CanInfo.startx, CanInfo.starty, event.x, event.y)
# Cancels screen capture
def cancel(event):
if event.keycode == 27: # cancel when pressing ESC
root.destroy()
# Saves the image when the user releases the left mouse button
def save_img(event):
startx, starty = CanInfo.startx, CanInfo.starty
endx, endy = event.x, event.y
# Puts the starting point in the upper left and the ending point in the lower right corner of the rectangle
if startx > endx:
startx, endx = endx, startx
if starty > endy:
starty, endy = endy, starty
crop_image = pimage.crop((startx, starty, endx, endy))
crop_image.save(path, "PNG")
root.destroy() # Closes the Tkinter window
# Binds mouse actions to the functions defined above
can.bind("<KeyPress>", cancel)
can.bind("<Button-1>", xy)
can.bind("<B1-Motion>", capture_motion)
can.bind("<ButtonRelease-1>", save_img)
can.focus_force() # Force focus of capture screen
root.mainloop() # Shows the Tk window and loops until it is closed
示例11: WindowApp
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
class WindowApp(object):
"""
The PDF Stampede app window
"""
def __init__(self, resizable=(True, True), geometry=(620, 220)):
assert (isinstance(resizable, (tuple, list)))
assert (isinstance(geometry, (tuple, list)))
self.root = Tk()
self.config = configparser.ConfigParser()
self.config_file_name = "config.ini"
self.config.read(self.config_file_name)
self.default_case = StringVar(value=self.config["DEFAULT"].get("case", "CASE"))
self.default_team = StringVar(value=self.config["DEFAULT"].get("team", "TEAM"))
self.default_series = StringVar()
self.default_last_index = StringVar()
self.root.title("The Stampede")
self.root.resizable(width=resizable[0], height=resizable[1])
self.root.geometry('{}x{}'.format(geometry[0], geometry[1]))
self.root.minsize(geometry[0], geometry[1])
self.root.maxsize(geometry[0]+200, geometry[1])
self.file_name = StringVar()
self.file_name.trace("w", self.file_name_changed)
self.stamp_button = None
self.add_widgets()
self.add_menus()
self.center(self.root)
def add_widgets(self):
# File
frame = Frame(self.root)
frame.pack(side=TOP, fill=X, expand=True, ipady=5)
file_label = Label(frame, text="PDF File", width=10)
file_label.pack(side=LEFT, padx=5, pady=5)
file_entry = Entry(frame, state=DISABLED, textvariable=self.file_name)
file_entry.pack(padx=5, side=LEFT, fill=X, expand=True)
file_button = Button(frame, text="Browse...", command=self.choose_pdf)
file_button.pack(padx=5, side=RIGHT)
# Case
frame = Frame(self.root)
frame.pack(side=TOP, fill=X, expand=True)
case_label = Label(frame, text="Case", width=10)
case_label.pack(side=LEFT, padx=5, pady=5)
case_entry = Entry(frame, textvariable=self.default_case)
case_entry.pack(fill=X, padx=5, expand=True)
# Team
frame = Frame(self.root)
frame.pack(fill=BOTH, expand=True)
team_label = Label(frame, text="Team", width=10)
team_label.pack(side=LEFT, padx=5, pady=5)
team_entry = Entry(frame, textvariable=self.default_team)
team_entry.pack(fill=X, padx=5, expand=True)
# Series
frame = Frame(self.root)
frame.pack(fill=BOTH, expand=True)
series_label = Label(frame, text="Series", width=10)
series_label.pack(side=LEFT, padx=5, pady=5)
series_entry = Entry(frame, textvariable=self.default_series)
series_entry.pack(fill=X, padx=5, expand=True)
# Last index
frame = Frame(self.root)
frame.pack(fill=BOTH, expand=True)
last_index_label = Label(frame, text="Last index", width=10)
last_index_label.pack(side=LEFT, padx=5, pady=5)
last_index_entry = Entry(frame, textvariable=self.default_last_index)
last_index_entry.pack(fill=X, padx=5, expand=True)
bottom_frame = Frame(self.root)
bottom_frame.pack(side=BOTTOM, fill=X, ipady=5, padx=5)
close_button = Button(bottom_frame, text="Quit", command=self.root.quit)
close_button.pack(side=RIGHT)
self.stamp_button = Button(bottom_frame, text="Stamp it!", state=DISABLED, command=self.stamp_it)
self.stamp_button.pack(side=RIGHT)
def stamp_it(self):
stamp_it(
self.file_name.get(),
self.default_case.get(),
self.default_team.get(),
self.default_series.get(),
self.default_last_index.get(),
)
def add_menus(self):
menu_bar = Menu(self.root)
stampede_menu = Menu(menu_bar, tearoff=0)
stampede_menu.add_command(label="Settings", command=self.edit_default_settings)
stampede_menu.add_separator()
stampede_menu.add_command(label="Quit", command=self.root.quit)
menu_bar.add_cascade(label="Stampede", menu=stampede_menu)
self.root.config(menu=menu_bar)
#.........这里部分代码省略.........
示例12: Label
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
instructions = Label(instructionsWindow, text="1. Make sure to have Firefox installed\n"
"2. Input your Villanova username\n"
"3. Input a valid Course Registration Number(CRN)\n"
"4. Do not close the FireFox browser\n"
"5. An email will be sent to your @villanova address when a spot opens up in the class\n"
)
instructions.pack()
instructionsWindow.mainloop()
subMenu = Menu(master)
Menu(master).add_cascade(label="Help", menu=subMenu)
subMenu.add_cascade(label="Instructions", command=instructions)
subMenu.add_cascade(label="Contact", command=contactInfo)
master.config(menu=subMenu)
topFrame = Frame(master)
topFrame.pack(side=TOP, fill=BOTH)
userLabel = Label(topFrame, text="Enter Villanova username:", fg="red", font=("Helvetica", 16))
userLabel.grid(row=0, sticky=E, padx=20)
usernameEntry = Entry(topFrame, fg="red")
usernameEntry.grid(row=0, column=1)
cDone = False
uDone = False
def goodUser():
errorMsg = Tk()
示例13: print
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
opcije=plain_text.split("|")
except Exception as e:
print(e)
opcije="0|||".split("|")
else:
opcije="0|||".split("|")
#else:
# os.makedirs("C:\\EOP")
# opcije="0||".split("|")
t.title('EOP')
t.config(bg='green',width = 300,height = 600)
c1=Checkbutton(t,text="Remember me",variable=remember,bg='lightblue',activebackground="blue")
c1.place(x=105,y=450)
if opcije[0]=="1":
c1.select()
l1=Label(t,text="REGISTER TO EOP",font=("Verdana",18),bg='pink')
l1.place(x=40,y=1)
l2=Label(t,text="USERNAME:",bg='pink')
l2.place(x=5,y=50)
l3=Label(t,text="E-MAIL:",bg='pink')
l3.place(x=5,y=100)
l4=Label(t,text="PASSWORD:",bg='pink')
l4.place(x=5,y=150)
示例14: __init__
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
class CollocationsView:
_BACKGROUND_COLOUR='#FFF' #white
def __init__(self):
self.queue = q.Queue()
self.model = CollocationsModel(self.queue)
self.top = Tk()
self._init_top(self.top)
self._init_menubar()
self._init_widgets(self.top)
self.load_corpus(self.model.DEFAULT_CORPUS)
self.after = self.top.after(POLL_INTERVAL, self._poll)
def _init_top(self, top):
top.geometry('550x650+50+50')
top.title('NLTK Collocations List')
top.bind('<Control-q>', self.destroy)
top.protocol('WM_DELETE_WINDOW', self.destroy)
top.minsize(550,650)
def _init_widgets(self, parent):
self.main_frame = Frame(parent, dict(background=self._BACKGROUND_COLOUR, padx=1, pady=1, border=1))
self._init_corpus_select(self.main_frame)
self._init_results_box(self.main_frame)
self._init_paging(self.main_frame)
self._init_status(self.main_frame)
self.main_frame.pack(fill='both', expand=True)
def _init_corpus_select(self, parent):
innerframe = Frame(parent, background=self._BACKGROUND_COLOUR)
self.var = StringVar(innerframe)
self.var.set(self.model.DEFAULT_CORPUS)
Label(innerframe, justify=LEFT, text=' Corpus: ', background=self._BACKGROUND_COLOUR, padx = 2, pady = 1, border = 0).pack(side='left')
other_corpora = list(self.model.CORPORA.keys()).remove(self.model.DEFAULT_CORPUS)
om = OptionMenu(innerframe, self.var, self.model.DEFAULT_CORPUS, command=self.corpus_selected, *self.model.non_default_corpora())
om['borderwidth'] = 0
om['highlightthickness'] = 1
om.pack(side='left')
innerframe.pack(side='top', fill='x', anchor='n')
def _init_status(self, parent):
self.status = Label(parent, justify=LEFT, relief=SUNKEN, background=self._BACKGROUND_COLOUR, border=0, padx = 1, pady = 0)
self.status.pack(side='top', anchor='sw')
def _init_menubar(self):
self._result_size = IntVar(self.top)
menubar = Menu(self.top)
filemenu = Menu(menubar, tearoff=0, borderwidth=0)
filemenu.add_command(label='Exit', underline=1,
command=self.destroy, accelerator='Ctrl-q')
menubar.add_cascade(label='File', underline=0, menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
rescntmenu = Menu(editmenu, tearoff=0)
rescntmenu.add_radiobutton(label='20', variable=self._result_size,
underline=0, value=20, command=self.set_result_size)
rescntmenu.add_radiobutton(label='50', variable=self._result_size,
underline=0, value=50, command=self.set_result_size)
rescntmenu.add_radiobutton(label='100', variable=self._result_size,
underline=0, value=100, command=self.set_result_size)
rescntmenu.invoke(1)
editmenu.add_cascade(label='Result Count', underline=0, menu=rescntmenu)
menubar.add_cascade(label='Edit', underline=0, menu=editmenu)
self.top.config(menu=menubar)
def set_result_size(self, **kwargs):
self.model.result_count = self._result_size.get()
def _init_results_box(self, parent):
innerframe = Frame(parent)
i1 = Frame(innerframe)
i2 = Frame(innerframe)
vscrollbar = Scrollbar(i1, borderwidth=1)
hscrollbar = Scrollbar(i2, borderwidth=1, orient='horiz')
self.results_box = Text(i1,
font=tkinter.font.Font(family='courier', size='16'),
state='disabled', borderwidth=1,
yscrollcommand=vscrollbar.set,
xscrollcommand=hscrollbar.set, wrap='none', width='40', height = '20', exportselection=1)
self.results_box.pack(side='left', fill='both', expand=True)
vscrollbar.pack(side='left', fill='y', anchor='e')
vscrollbar.config(command=self.results_box.yview)
hscrollbar.pack(side='left', fill='x', expand=True, anchor='w')
hscrollbar.config(command=self.results_box.xview)
#there is no other way of avoiding the overlap of scrollbars while using pack layout manager!!!
Label(i2, text=' ', background=self._BACKGROUND_COLOUR).pack(side='left', anchor='e')
i1.pack(side='top', fill='both', expand=True, anchor='n')
i2.pack(side='bottom', fill='x', anchor='s')
innerframe.pack(side='top', fill='both', expand=True)
def _init_paging(self, parent):
innerframe = Frame(parent, background=self._BACKGROUND_COLOUR)
self.prev = prev = Button(innerframe, text='Previous', command=self.previous, width='10', borderwidth=1, highlightthickness=1, state='disabled')
prev.pack(side='left', anchor='center')
self.next = next = Button(innerframe, text='Next', command=self.__next__, width='10', borderwidth=1, highlightthickness=1, state='disabled')
next.pack(side='right', anchor='center')
innerframe.pack(side='top', fill='y')
#.........这里部分代码省略.........
示例15: venster1
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import config [as 别名]
def venster1():
global label1
global root
global Button1
global Button2
global Button3
global Button4
global Button5
global label2
global label3
global Button6
global Button7
global HuidigStation
global Button8
global AnderStation
global Button9
global gegevens
root = Tk()
root.resizable(width=0, height=0)
root.geometry("800x600")
root.config(bg="gold")
label1 = Label(root, height=3, bg="gold", fg="darkblue", text="Welkom bij de NS", font=Gfont)
label1.pack()
HuidigStation = Label(root, height=3, bg="gold", fg="darkblue", text="info huidig Station", font=Gfont)
HuidigStation.pack_forget()
AnderStation = Label(root, height=3, bg="gold", fg="darkblue", text="Selecteer een ander station", font=Gfont)
AnderStation.pack_forget()
gegevens = Label(root, height=3, bg="gold", fg="darkblue", text="gegevens", font=Gfont)
gegevens.pack_forget()
Button1 = Button(root, wraplength=129, width = 12, text="Ik wil naar Amsterdam", bg = "#00246B", fg ="white", font = Buttonfont)
Button1.pack()
Button1.place(x=0, y=425)
Button2 = Button(root,wraplength=129, width = 12, text="Kopen los kaartje", bg = "#00246B", fg ="white", font = Buttonfont)
Button2.pack()
Button2.place(x=160, y=425)
Button3 = Button(root, wraplength=129,width = 12, text="Kopen OV-chipkaart", bg = "#00246B", fg ="white", font = Buttonfont) # hier moet een command
Button3.pack()
Button3.place(x=325, y=425)
Button4 = Button(root, wraplength=129,width = 12, text="Ik wil naar het buitenland", bg = "#00246B", fg ="white", font = Buttonfont)
Button4.pack()
Button4.place(x=490, y=425)
Button5 = Button(root, wraplength=129,width = 12, text="Reis informatie", bg = "#00246B", fg ="white", font = Buttonfont)
Button5.bind('<Button-1>', venster2)
Button5.pack()
Button5.place(x=650, y=425)
#Dropdownmenu
Button6 = Button(root, wraplength=125, justify=LEFT, text="Info huidig station",bg = "#00246B", fg = "white",font = Buttonfont, width=10)
Button6.bind('<Button-1>', venster3)
Button6.pack()
Button6.place(x=1000,y=1000)
Button7 = Button(root, wraplength=125, justify=LEFT, text="Info ander station",bg = "#00246B", fg = "white",font = Buttonfont, width=10)
Button7.bind('<Button-1>', venster4)
Button7.pack()
Button7.place(x=1000,y=1000)
photo1 = PhotoImage(file="Welkomsttekst.png") # je geeft een PhotoImage file een variabele
photo5 = PhotoImage(file="Bar.png")
photo5=PhotoImage(file="Bar.png")
label2 = Label(root, image=photo5, bg="darkblue")
label2.pack(side=BOTTOM)
label3 = Label(root, image=photo1, bg="#FFCC00") #je zet een foto in de label waarvan je eerder de naam had gegeven
label3.pack(side=TOP)
Button8 = Button(root, wraplength=125, justify=LEFT, text="Terug naar startscherm",bg = "#00246B", fg = "white",font = Buttonfont, width=10)
Button8.bind('<Button-1>', reset)
Button8.pack()
Button8.place(x=1000,y=1000)
Button9 = Button(root, wraplength=125, justify=LEFT, text="Gegevens",bg = "#00246B", fg = "white",font = Buttonfont, width=10)
Button9.bind('<Button-1>', venster5)
Button9.pack()
Button9.place(x=1000,y=1000)
root.mainloop()