本文整理汇总了Python中tkinter.Tk类的典型用法代码示例。如果您正苦于以下问题:Python Tk类的具体用法?Python Tk怎么用?Python Tk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tk类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getFileInput
def getFileInput():
root = Tk()
root.withdraw()
wordFile = filedialog.askopenfile(title="Open Word File", mode="r", parent=root)
if wordFile is None:
raise SystemExit
return wordFile
开发者ID:nalexander50,项目名称:Daily-Programmer,代码行数:7,代码来源:Hacking.py
示例2: goodUser
def goodUser():
errorMsg = Tk()
goodCRN = Label(errorMsg, text="Please enter a valid Villanova username")
goodCRN.pack()
errorMsg.mainloop()
开发者ID:Plonski,项目名称:ClassSelect-Villanova,代码行数:7,代码来源:front.py
示例3: enable
def enable(self, app=None):
"""Enable event loop integration with Tk.
Parameters
----------
app : toplevel :class:`Tkinter.Tk` widget, optional.
Running toplevel widget to use. If not given, we probe Tk for an
existing one, and create a new one if none is found.
Notes
-----
If you have already created a :class:`Tkinter.Tk` object, the only
thing done by this method is to register with the
:class:`InputHookManager`, since creating that object automatically
sets ``PyOS_InputHook``.
"""
if app is None:
try:
from tkinter import Tk # Py 3
except ImportError:
from Tkinter import Tk # Py 2
app = Tk()
app.withdraw()
self.manager.apps[GUI_TK] = app
return app
开发者ID:MovingAverage,项目名称:ipython,代码行数:25,代码来源:inputhook.py
示例4: main
def main():
root = Tk()
ex = Janela(root)
root.geometry("300x250+300+300")
center(root)
root.mainloop()
开发者ID:vpperego,项目名称:vagasGenerator,代码行数:7,代码来源:VagasGenerator.py
示例5: main
def main():
root = Tk()
f1 = tkinter.Frame(width=200, height=200)
ex = Example(root)
f1.pack(fill="both", expand=True, padx=20, pady=20)
ex.place(in_=f1, anchor="c", relx=.5, rely=.5)
root.mainloop()
开发者ID:KittyMcSnuggles,项目名称:reddit,代码行数:7,代码来源:client.py
示例6: __init__
def __init__(self, app, kind='', icon_file=None, center=True):
self.findIcon()
Tk.__init__(self)
if center:
pass
self.__app = app
self.configBorders(app, kind, icon_file)
开发者ID:minghu6,项目名称:minghu6_py,代码行数:7,代码来源:windows.py
示例7: interactive_ask_ref
def interactive_ask_ref(self, code, imagefn, testid):
from os import environ
if 'UNITTEST_INTERACTIVE' not in environ:
return True
from tkinter import Tk, Label, LEFT, RIGHT, BOTTOM, Button
from PIL import Image, ImageTk
self.retval = False
root = Tk()
def do_close():
root.destroy()
def do_yes():
self.retval = True
do_close()
image = Image.open(imagefn)
photo = ImageTk.PhotoImage(image)
Label(root, text='The test %s\nhave no reference.' % testid).pack()
Label(root, text='Use this image as a reference ?').pack()
Label(root, text=code, justify=LEFT).pack(side=RIGHT)
Label(root, image=photo).pack(side=LEFT)
Button(root, text='Use as reference', command=do_yes).pack(side=BOTTOM)
Button(root, text='Discard', command=do_close).pack(side=BOTTOM)
root.mainloop()
return self.retval
开发者ID:kivy,项目名称:kivy,代码行数:30,代码来源:common.py
示例8: TkWindowMainLoop
class TkWindowMainLoop(Thread):
'''class for thread that handles Tk window creation and main loop'''
def __init__(self, client):
Thread.__init__(self)
self.window = None
self.canvas = None
self.client = client
self.start()
def callbackDeleteWindow(self):
self.client.stop()
def stop(self):
self.window.quit()
def run(self):
self.window = Tk()
self.canvas = Canvas(self.window, width=1024, height=768)
self.canvas.pack()
self.window.protocol("WM_DELETE_WINDOW", self.callbackDeleteWindow)
self.window.mainloop()
def getWindow(self):
return self.window
def getCanvas(self):
return self.canvas
开发者ID:IwfY,项目名称:TkStein3d,代码行数:34,代码来源:tkwindowmainloop.py
示例9: save
def save():
"""This function will save the file.
It will also save the day, too!
You just might be safe with this one!"""
from tkinter import Tk
import tkinter.filedialog
root = Tk()
root.withdraw()
fd = tkinter.filedialog.FileDialog(master=root,title='Project Celestia')
savefile = fd.go()
if savefile != None:
import os.path, tkinter.dialog
if os.path.exists(savefile):
if os.path.isdir(savefile):
tkinter.filedialog.FileDialog.master.bell()
return savefile
d = tkinter.dialog.Dialog(master=None,title='Hold your horses!',
text='Are you sure you want to rewrite this file?'
'\nI mean, I have already seen the file before...\n'
'\n-Twilight Sparkle',
bitmap='questhead',default=0,strings=('Eeyup','Nah'))
if d.num != 1:
return savefile
else:
FlashSentry.save_error()
root.destroy()
开发者ID:JaredMFProgramming,项目名称:ProjectCelestia,代码行数:27,代码来源:celestia.py
示例10: __init__
def __init__(self,root):
Tk.__init__(self,root)
self.root = root
self.MAX_F = 12
self.info = StringVar()
self.sliders = []
self.parameters = []
self.filters = []
self.isAdvancedMode = False
self.isWritting = False
self.configFile = "config.xml"
self.cw = ConfigWritter(self.configFile)
if not isfile(self.configFile): self._createConfigFile()
self.cp = ConfigParser(self.configFile)
self._parseConfigFile()
self.canvas = Canvas()
self.canvas.pack(expand=YES,fill=BOTH)
self.initialize()
开发者ID:Gorgorot38,项目名称:Sonotone-RICM4,代码行数:26,代码来源:gui.py
示例11: _calltip_window
def _calltip_window(parent): # htest #
import re
from tkinter import Tk, Text, LEFT, BOTH
root = Tk()
root.title("Test calltips")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
root.geometry("+%d+%d"%(x, y + 150))
class MyEditWin: # conceptually an editor_window
def __init__(self):
text = self.text = Text(root)
text.pack(side=LEFT, fill=BOTH, expand=1)
text.insert("insert", "string.split")
root.update()
self.calltip = CallTip(text)
text.event_add("<<calltip-show>>", "(")
text.event_add("<<calltip-hide>>", ")")
text.bind("<<calltip-show>>", self.calltip_show)
text.bind("<<calltip-hide>>", self.calltip_hide)
text.focus_set()
root.mainloop()
def calltip_show(self, event):
self.calltip.showtip("Hello world", "insert", "end")
def calltip_hide(self, event):
self.calltip.hidetip()
MyEditWin()
开发者ID:5outh,项目名称:Databases-Fall2014,代码行数:32,代码来源:CallTipWindow.py
示例12: __init__
def __init__(self, title="", message="", button="Ok", image=None,
checkmessage="", style="clam", **options):
"""
Create a messagebox with one button and a checkbox below the button:
parent: parent of the toplevel window
title: message box title
message: message box text
button: message displayed on the button
image: image displayed at the left of the message
checkmessage: message displayed next to the checkbox
**options: other options to pass to the Toplevel.__init__ method
"""
Tk.__init__(self, **options)
self.resizable(False, False)
self.title(title)
s = Style(self)
s.theme_use(style)
if image:
Label(self, text=message, wraplength=335,
font="Sans 11", compound="left",
image=image).grid(row=0, padx=10, pady=(10, 0))
else:
Label(self, text=message, wraplength=335,
font="Sans 11").grid(row=0, padx=10, pady=(10, 0))
b = Button(self, text=button, command=self.destroy)
b.grid(row=2, padx=10, pady=10)
self.var = BooleanVar(self)
c = Checkbutton(self, text=checkmessage, variable=self.var)
c.grid(row=1, padx=10, pady=0, sticky="e")
self.grab_set()
b.focus_set()
self.wait_window(self)
开发者ID:j4321,项目名称:Sudoku-Tk,代码行数:32,代码来源:custom_messagebox.py
示例13: ingresarUsuario
def ingresarUsuario(cls):
cls.nombre=""
def salir():
root.quit()
def cargarArchivo():
cls.nombre=a.get()
root.destroy()
def obtenerN():
n=a.get()
return (n)
root = Tk()
root.title('CargarDatos')
a = StringVar()
atxt = Entry(root, textvariable=a,width=20)
cargar = Button(root, text="Cargar Archivo", command=cargarArchivo,width=15)
salirB= Button(root, text ="Salir", command=root.destroy, width=10)
atxt.grid(row=0, column=0)
cargar.grid(row=1, column=0)
salirB.grid(row=1,column=1)
root.mainloop()
return (obtenerN())
开发者ID:jupmorenor,项目名称:201210-pygroup-advanced,代码行数:26,代码来源:generales.py
示例14: main
def main():
q = Queue()
root = Tk()
root.geometry("400x350+300+300")
Example(root, q)
root.mainloop()
开发者ID:chengyi818,项目名称:kata,代码行数:7,代码来源:1_calculating_pi.py
示例15: main
def main():
#abort shutdown
abortShutdown()
#load the application
root = Tk()
app = FullScreenApp(root)
root.mainloop()
开发者ID:ilmeo,项目名称:python-homeTheater,代码行数:7,代码来源:homeTheater.py
示例16: test
def test():
"""
Kolorem czarnym są narysowane obiekty utworzone
za pomocą klas fabrycznych.
Kolorem czerwonym obiekty utworzone przy użyciu
funkcji shapeFactory
"""
creator = RectangleCreator()
rect = creator.factory("Rectangle",a=40,b=60)
rect2 = shapeFactory("Rectangle",a=40,b=60, outline="#f00")
creator = TriangleCreator()
tri = creator.factory("Triangle",a=100,b=100,c=100)
tri2 = shapeFactory("Triangle",a=100,b=100,c=100,outline="#f00")
creator = SquareCreator()
sq = creator.factory("Square",a=60)
sq2 = shapeFactory("Square",a=60,outline="#f00")
root = Tk()
w = Window(root)
w.drawShape(rect,100,100)
w.drawShape(rect2,100,200)
w.drawShape(tri,200,100)
w.drawShape(tri2,200,200)
w.drawShape(sq,370,100)
w.drawShape(sq2,370,200)
root.geometry("600x400+100+100")
root.mainloop()
开发者ID:kpiszczek,项目名称:wzorceuj,代码行数:26,代码来源:cw2a.py
示例17: main
def main():
logger.level = logs.DEBUG
usage = 'PRACMLN Query Tool'
parser = argparse.ArgumentParser(description=usage)
parser.add_argument("-i", "--mln", dest="mlnarg", help="the MLN model file to use")
parser.add_argument("-d", "--dir", dest="directory", action='store', help="the directory to start the tool from", metavar="FILE", type=str)
parser.add_argument("-x", "--emln", dest="emlnarg", help="the MLN model extension file to use")
parser.add_argument("-q", "--queries", dest="queryarg", help="queries (comma-separated)")
parser.add_argument("-e", "--evidence", dest="dbarg", help="the evidence database file")
parser.add_argument("-r", "--results-file", dest="outputfile", help="the results file to save")
parser.add_argument("--run", action="store_true", dest="run", default=False, help="run with last settings (without showing GUI)")
args = parser.parse_args()
opts_ = vars(args)
root = Tk()
conf = PRACMLNConfig(DEFAULT_CONFIG)
app = MLNQueryGUI(root, conf, directory=os.path.abspath(args.directory) if args.directory else None)
if args.run:
logger.debug('running mlnlearn without gui')
app.infer(savegeometry=False, options=opts_)
else:
root.mainloop()
开发者ID:bbferka,项目名称:pracmln,代码行数:26,代码来源:mlnquery.py
示例18: main
def main(options):
"""Create GUI and perform interactions."""
root = Tk()
root.title('Oscilloscope GUI')
gui = Tdsgui(root, options)
print(type(gui))
root.mainloop()
开发者ID:scbrac,项目名称:pyTDSserial,代码行数:7,代码来源:tdsgui.py
示例19: __init__
def __init__(self, drs, size_canvas=True, canvas=None):
"""
:param drs: ``AbstractDrs``, The DRS to be drawn
:param size_canvas: bool, True if the canvas size should be the exact size of the DRS
:param canvas: ``Canvas`` The canvas on which to draw the DRS. If none is given, create a new canvas.
"""
master = None
if not canvas:
master = Tk()
master.title("DRT")
font = Font(family='helvetica', size=12)
if size_canvas:
canvas = Canvas(master, width=0, height=0)
canvas.font = font
self.canvas = canvas
(right, bottom) = self._visit(drs, self.OUTERSPACE, self.TOPSPACE)
width = max(right+self.OUTERSPACE, 100)
height = bottom+self.OUTERSPACE
canvas = Canvas(master, width=width, height=height)#, bg='white')
else:
canvas = Canvas(master, width=300, height=300)
canvas.pack()
canvas.font = font
self.canvas = canvas
self.drs = drs
self.master = master
开发者ID:BohanHsu,项目名称:developer,代码行数:31,代码来源:drt.py
示例20: savePreset
def savePreset(main, filename=None):
if filename is None:
root = Tk()
root.withdraw()
filename = simpledialog.askstring(title='Save preset',
prompt='Save config file as...')
root.destroy()
if filename is None:
return
config = configparser.ConfigParser()
fov = 'Field of view'
config['Camera'] = {
'Frame Start': main.frameStart,
'Shape': main.shape,
'Shape name': main.tree.p.param(fov).param('Shape').value(),
'Horizontal readout rate': str(main.HRRatePar.value()),
'Vertical shift speed': str(main.vertShiftSpeedPar.value()),
'Clock voltage amplitude': str(main.vertShiftAmpPar.value()),
'Frame Transfer Mode': str(main.FTMPar.value()),
'Cropped sensor mode': str(main.cropParam.value()),
'Set exposure time': str(main.expPar.value()),
'Pre-amp gain': str(main.PreGainPar.value()),
'EM gain': str(main.GainPar.value())}
with open(os.path.join(main.presetDir, filename), 'w') as configfile:
config.write(configfile)
main.presetsMenu.addItem(filename)
开发者ID:fedebarabas,项目名称:tormenta,代码行数:31,代码来源:guitools.py
注:本文中的tkinter.Tk类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论