本文整理汇总了Python中Tkinter.Tk类的典型用法代码示例。如果您正苦于以下问题:Python Tk类的具体用法?Python Tk怎么用?Python Tk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tk类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
global drawing_area
root = Tk()
root.title("Drawer")
drawing_area = Canvas(root, width=300, height=300, bg="white")
# Binding Events to the canvas
drawing_area.bind("<B1-Motion>", drag)
drawing_area.bind("<ButtonRelease-1>", drag_end)
drawing_area.pack()
# Buttons
# Quit Button
b1 = Button(root, text="Quit")
b1.pack()
b1.bind("<Button-1>", quit)
# Clear Button
b2 = Button(root, text="Clear")
b2.pack()
b2.bind("<Button-1>", clear)
# Save Button
b3 = Button(root, text="Save")
b3.pack()
b3.bind("<Button-1>", save)
root.mainloop()
示例2: main
def main():
tk = Tk()
menuBar = Pmw.MainMenuBar(tk)
def command():
print('Pressed')
menuBar.addmenu('File', 'File')
menuBar.addmenuitem(
'File', 'command', 'Close',
command=command,
label='Close'
)
insertmenuitem(
menuBar,
'File', 'command', 'Open',
command=command,
index=0,
label='Open'
)
tk.configure(menu=menuBar)
tk.mainloop()
示例3: main
def main(posts = Search.FrontPage()):
#main window
root = Tk()
root.geometry("600x300+300+300")
app = GUI(root,posts)
root.mainloop()
示例4: main
def main():
queue = Queue.Queue()
parent = Tk()
musicplayer1 = musicplayer.MusicPlayer()
gui = Example(parent, queue, musicplayer1)
#client.endApplication()
parent.mainloop()
示例5: main
def main():
root=Tk()
root.geometry("250x150+300+300")
app=GUI(root)
app.mainloop()
pass
示例6: main
def main():
global self, root
root = Tk()
root.geometry("800x800+0+0")
self = at_graph(root)
self.pack(fill=BOTH, expand=1)
示例7: ColonistGame
class ColonistGame(object):
def __init__(self):
pass
def initialize_game(self):
#initialize model instances
print "initialize game"
self.model_instance = GameModel()
for colonist in self.model_instance.colonistlist:
print colonist.get_name()
self.root = Tk()
self.app = GameScreen(self.root, game_instance)
self.root.mainloop()
self.app.update_screen()
def next_turn(self):
"""
Model update
"""
self.model_instance.resolve_turn_phase()
"""
Screen update
"""
self.app.update_screen()
print "Next turn"
示例8: TK_Framework
class TK_Framework(object):
def __init__(self):
self.root = Tk()
# list of open windows
self.windows = {'main':self.root}
# setup the overall style of the gui
self.style = Style()
self.style.theme_use('clam')
def get_window(self,name):
return self.windows[name]
def create_window(self, name):
self.windows[name] = Toplevel()
@staticmethod
def open_file(init_dir):
filename = askopenfilename(initialdir=init_dir)
return filename
def hide_root(self):
"""Hides the root window"""
self.root.withdraw()
def get_root(self):
return self.root
示例9: __init__
def __init__(self):
Tk.__init__(self)
self.geometry('%dx%d+500+500' % (WIDTH,HEIGHT))
self.title('GooMPy')
self.canvas = Canvas(self, width=WIDTH, height=HEIGHT)
self.canvas.pack()
self.bind("<Key>", self.check_quit)
self.bind('<B1-Motion>', self.drag)
self.bind('<Button-1>', self.click)
self.label = Label(self.canvas)
self.radiogroup = Frame(self.canvas)
self.radiovar = IntVar()
self.maptypes = ['OSM', 'GoogleSatellite', 'Satellite']
self.add_radio_button('OSM', 0)
self.add_radio_button('GoogleSatellite', 1)
self.add_radio_button('Satellite', 2)
self.zoom_in_button = self.add_zoom_button('+', +1)
self.zoom_out_button = self.add_zoom_button('-', -1)
self.zoomlevel = ZOOM
maptype_index = 0
self.radiovar.set(maptype_index)
self.goompy = GooMPy(WIDTH, HEIGHT, LATITUDE, LONGITUDE, ZOOM, MAPTYPE)
self.restart()
示例10: TestBase
class TestBase(unittest.TestCase):
def setUp(self):
self.root = Tk()
def tearDown(self):
self.root.destroy()
示例11: interactive_ask_diff
def interactive_ask_diff(self, code, tmpfn, reffn, testid):
from os import environ
if 'UNITTEST_INTERACTIVE' not in environ:
return False
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()
phototmp = ImageTk.PhotoImage(Image.open(tmpfn))
photoref = ImageTk.PhotoImage(Image.open(reffn))
Label(root, text='The test %s\nhave generated an different'
'image as the reference one..' % testid).pack()
Label(root, text='Which one is good ?').pack()
Label(root, text=code, justify=LEFT).pack(side=RIGHT)
Label(root, image=phototmp).pack(side=RIGHT)
Label(root, image=photoref).pack(side=LEFT)
Button(root, text='Use the new image -->',
command=do_yes).pack(side=BOTTOM)
Button(root, text='<-- Use the reference',
command=do_close).pack(side=BOTTOM)
root.mainloop()
return self.retval
示例12: 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
示例13: checkExit
def checkExit():
root = Tk()
root.geometry("200x90+300+300")
app = Escape(root)
root.mainloop()
result = app.getStatus()
return result
示例14: main
def main():
app = "netconvert"
appOptions = parse_help(app)
# appOptions = []
root = Tk()
app = Launcher(root, app, appOptions)
root.mainloop()
示例15: __init__
class WelcomeDialog:
"""Manages the window and initialization for creating a the V.I.O.L.A.S. welcome
box."""
##### Initialization ####################################################################
def __init__( self ):
"""Initializes the welcome window."""
self.root = Tk()
self.root.title('Welcome')
self.root.geometry('515x350')
w = tk.Message(self.root, anchor='center',
text= " Welcome to V.I.O.L.A.S.!\n\n" +
" Visual Information Observation, Logging and Analysis System\n\n" +
" Key Features Include:\n\n" +
" *Ability to Read in any CSV File\n" +
" *Made to Order Graphical Representations\n" +
" *Quick and Easy Statistical Computation\n\n" +
" How to Use V.I.O.L.A.S:\n\n" +
" *Step 1: Under the file menu, use Open to import any csv file. The\n" +
" data will be presented in an easy to read format in the\n" +
" terminal.\n\n" +
" *Step 2: Under the graphs menu, one can create either a histogram, a\n" +
" scatterplot (4D,3D,2D), or a box plot. Each type of graphical\n" +
" representation takes user input in order to create the graph.\n\n" +
" *Step 3: Under the calculations menu, one can calculate the mean,\n" +
" median, mode, standard deviation, and the range depending on \n" +
" the user's wants. \n\n" +
" *Step 4: Have fun and immerse yourself in the wonders of \n" +
" graphical analysis that this program has to offer!\n\n",
background='blue', foreground='white', border=0, width=550, font='courier 12 bold')
w.pack()