本文整理汇总了Python中Tkinter.Tk.overrideredirect方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.overrideredirect方法的具体用法?Python Tk.overrideredirect怎么用?Python Tk.overrideredirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.overrideredirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: failure
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def failure(reason, cur_dir):
"""
Displays a "submission failure" picture and emails
a bug report to maintenance.
"""
bugmail = {"email": "[email protected]"}
send_email(bugmail, "QR Code Submission Failure", reason, None)
root = Tk()
root.focus_set()
# Get the size of the screen and place the splash screen in the center
gif = Image.open(str(cur_dir) + '/Images/Failure.gif')
width = gif.size[0]
height = gif.size[1]
flog = (root.winfo_screenwidth()/2-width/2)
blog = (root.winfo_screenheight()/2-height/2)
root.overrideredirect(1)
root.geometry('%dx%d+%d+%d' % (width*1, height + 44, flog, blog))
# Pack a canvas into the top level window.
# This will be used to place the image
failure_canvas = Canvas(root)
failure_canvas.pack(fill = "both", expand = True)
# Open the image
imgtk = PhotoImage(gif)
# Get the top level window size
# Need a call to update first, or else size is wrong
root.update()
cwidth = root.winfo_width()
cheight = root.winfo_height()
# create the image on the canvas
failure_canvas.create_image(cwidth/2, cheight/2.24, image=imgtk)
Button(root, text = str(
reason), width = 50, height = 2, command = root.destroy).pack()
root.after(5000, root.destroy)
root.mainloop()
示例2: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def main():
root = Tk()
# w, h = root.winfo_screenwidth(), root.winfo_screenheight()
w, h = 960, 540
# get value from arduino
# ser = serial.Serial('/dev/tty.usbserial', 9600)
pos = 0
root.overrideredirect(1)
root.focus_set()
root.bind("<Escape>", lambda e: e.widget.quit())
root.geometry("%dx%d+300+300" % (w, h))
canvas = Canvas(root, width=w, height=h, background="black")
rect0 = canvas.create_rectangle(w/2-75, h/2-20, w/2+75, h/2+20, fill="#05f", outline="#05f")
rect1 = canvas.create_rectangle(w/2-20, h/2-75, w/2+20, h/2+75, fill="#05f", outline="#05f")
canvas.pack()
while (True):
# gets angle and moves accordingly
# pos = ser.readline()
canvas.move(rect0, 1, 0)
canvas.move(rect1, 1, 0)
root.update()
root.after(30)
app = App(root)
time.sleep(0.5)
root.mainloop()
示例3: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def main():
root= Tk()
root.overrideredirect(1) # Remove title bar of window in GUI
board = Board(root)
chessUpdate = Thread(target = ChessUpdate, args = (board,))
chessUpdate.start()
root.mainloop()
示例4: expired
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def expired(cur_dir, amount):
"""
Displays a "deadline expired" picture
"""
root = Tk()
root.focus_set()
# Get the size of the screen and place the splash screen in the center
img = Image.open(str(cur_dir) + '/Images/Expired.gif')
width = img.size[0]
height = img.size[1]
flog = root.winfo_screenwidth()/2-width/2
blog = root.winfo_screenheight()/2-height/2
root.overrideredirect(True)
root.geometry('%dx%d+%d+%d' % (width*1, height + 44, flog, blog))
# Pack a canvas into the top level window.
# This will be used to place the image
expired_canvas = Canvas(root)
expired_canvas.pack(fill="both", expand=True)
# Open the image
imgtk = PhotoImage(img)
# Get the top level window size
# Need a call to update first, or else size is wrong
root.update()
cwidth = root.winfo_width()
cheight = root.winfo_height()
# create the image on the canvas
expired_canvas.create_image(cwidth/2, cheight/2.1, image=imgtk)
Button(root, text='Deadline Expired by ' + str(amount
) + '. Assignment Submitted, time '\
'noted', width=80, height=2, command=root.destroy).pack()
root.after(5000, root.destroy)
root.mainloop()
示例5: success
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def success(cur_dir):
"""
Displays a "successful submission" picture
"""
root = Tk()
root.focus_set()
# Get the size of the screen and place the splash screen in the center
img = Image.open(str(cur_dir) + '/Images/Success.gif')
width = img.size[0]
height = img.size[1]
flog = (root.winfo_screenwidth()/2-width/2)
blog = (root.winfo_screenheight()/2-height/2)
root.overrideredirect(1)
root.geometry('%dx%d+%d+%d' % (width, height, flog, blog))
# Pack a canvas into the top level window.
# This will be used to place the image
success_canvas = Canvas(root)
success_canvas.pack(fill = "both", expand = True)
# Open the image
imgtk = PhotoImage(img)
# Get the top level window size
# Need a call to update first, or else size is wrong
root.update()
cwidth = root.winfo_width()
cheight = root.winfo_height()
# create the image on the canvas
success_canvas.create_image(cwidth/2, cheight/2, image = imgtk)
root.after(4000, root.destroy)
root.mainloop()
示例6: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def main():
if (len(sys.argv) != 2):
print "Please specify IP or hostname of the server"
exit()
root = Tk()
root.overrideredirect(1)
root.geometry("320x240+0+0")
app = MainWindow(root, sys.argv[1])
root.mainloop()
示例7: run_text_editor
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def run_text_editor(filename):
root = Tk()
input_handler = user_input.user_input()
input_handler.start_instance(filename)
app = text_canvas.text_canvas(root, 12, input_handler, filename)
root.wm_attributes('-fullscreen', 1)
root.title('shim')
root.overrideredirect()
root.mainloop()
示例8: __init__
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def __init__(self):
config = ConfigParser.ConfigParser()
config.read('conf/sd.conf')
self.__sms_center = '0891' + Phone(config.get('serial', 'smscenter')).encode()
try:
self.__serial = serial.Serial(config.get('serial', 'port'), config.get('serial', 'baudrate'), timeout=1)
except Exception, e:
logging.error('cannot initiate serial port!')
root = Tk()
root.overrideredirect(True)
showerror('短信错误', '串口初始化失败!')
sys.exit(1)
示例9: TkDemoWindow
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
class TkDemoWindow(TkSlidingWindow):
def __init__(self, parent):
from Tkinter import Tk, Label, Button
self.parent = parent
self.win = Tk(className='moving')
self.win.overrideredirect(1)
self.win.tkraise()
self.label = Label(self.win, text=' '*25, font='fixed')
self.label.pack(padx=20, pady=10)
self.button = Button(self.win, text='OK', command=self.parent.hide)
self.button.pack(pady=5)
tksupport.install(self.win)
def demoText(self, text):
self.label.configure(text=text)
self.win.geometry('+%d+%d'%self.getScreenSize())
self.label.pack()
示例10: get_files
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def get_files(titlestring,filetype = ('.txt','*.txt')):
# Make a top-level instance and hide since it is ugly and big.
root = Tk()
root.withdraw()
# Make it almost invisible - no decorations, 0 size, top left corner.
root.overrideredirect(True)
root.geometry('0x0+0+0')
#
# Show window again and lift it to top so it can get focus,
# otherwise dialogs will end up behind the terminal.
root.deiconify()
root.attributes("-topmost",1)
root.focus_force()
filenames = []
filenames = tkFileDialog.askopenfilename(title=titlestring, filetypes=[filetype],multiple='True')
#do nothing if already a python list
if filenames == "":
print "You didn't open anything!"
return
root.destroy()
if isinstance(filenames,list):
result = filenames
elif isinstance(filenames,tuple):
result = list(filenames)
else:
#http://docs.python.org/library/re.html
#the re should match: {text and white space in brackets} AND anynonwhitespacetokens
#*? is a non-greedy match for any character sequence
#\S is non white space
#split filenames string up into a proper python list
result = re.findall("{.*?}|\S+",filenames)
#remove any {} characters from the start and end of the file names
result = [ re.sub("^{|}$","",i) for i in result ]
result.sort()
return result
示例11: intro
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
class intro(object):
def __init__(self):
self.master=Tk()
self.x = (self.master.winfo_screenwidth()/3) - (self.master.winfo_width())
self.y = (self.master.winfo_screenheight()/3) - (self.master.winfo_height())
self.master.geometry("+%d+%d" % (self.x, self.y))
self.master.overrideredirect(True)
self.master.resizable(False,False)
self.logointroimg=Image.open(r'img/Logo-introscreenmin.jpg')
self.Tkimage3= ImageTk.PhotoImage(self.logointroimg)
self.canvas = Canvas(self.master, height=378,width=672 )
self.canvas.create_image(336,186, image=self.Tkimage3)
self.canvas.pack()
self.master.after(1250,self.master.destroy)
self.master.mainloop()
示例12: start
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def start():
""" Calaculates several values for the game's run."""
global canvas, mainChar, root, i, k, bob, Link, bill, f, g, enemy
user32 = ctypes.windll.user32 #renders size to fullscreen
w = int(user32.GetSystemMetrics(0))
h = int(user32.GetSystemMetrics(1))
f = int(w/40) # calculates how many tiles needed
g = int(h/40)
print w
root = Tk()
root.title("Transparency")
frame = Frame(root)
canvas = Canvas(frame, bg="black", width=w, height=h)
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
print w, h
root.overrideredirect(1)
root.geometry("%dx%d+0+0" % (w, h))
root.focus_set() # <-- move focus to this widget
root.bind("<Escape>", quitApp) # All root bindings
root.bind("w", moveUp)
root.bind("s", moveDown)
root.bind("a", moveLeft)
root.bind("d", moveRight)
#root.bind("h", healthPotion)
root.bind("<space>", useItem)
root.bind("b", bossSpawn)
canvas.pack()
photoimage = ImageTk.PhotoImage(Image.open("dungeonTile.jpg"))
mainChar = ImageTk.PhotoImage(Image.open("CobaltKnight.png"))
enemy = ImageTk.PhotoImage(Image.open("LobsterRoach.png"))
im = Image.open("Karel.png")
print im.mode
x = 0
y = 0
print bill, "bill"
if bill == 0:
for i in range(f+1):
for k in range(g+1):
canvas.create_image(i*40, k*40, image=photoimage)
bill = 1
mainSpawn() #spawns main
mobSpawn(canvas,enemy) #spawns mobs
#bob = Label(canvas,width=w,height=h, text = "health", fg = 'red', font = ('Times', 30, 'bold'), anchor = 'nw')
#bob.pack()
bob = canvas.create_text(40,40, text = "bob", fill = "red", font = ('Times', 30, 'bold'), anchor = 'nw')
bar = "health " + str(Link.getHealth()) + "/" + str(Link.getMaxHealth())
canvas.itemconfig(bob, text=bar)
canvas.create_rectangle(w-120, 40 , w-40, 120, fill='black', outline = 'white')
canvas.create_rectangle(w-240, 40 , w-160, 120, fill='black', outline = 'white')
#createInterface(bob,canvas,i,k,Link.getHealth(),Link.getMaxHealth()) #creates user interface
#bob.pack()
frame.pack()
print "music"
#canvas.create_text(i,k, text = "health", fill = 'red', font = ('Times', 30, 'bold'), anchor = 'nw')
#f= wave.open( 'Naruto-Breakdown.wav', 'rb' )
#sampleRate= f.getframerate()
#channels= f.getnchannels()
#format = sound.AFMT_S16_LE
#snd= sound.Output( sampleRate, channels, format )
#s= f.readframes( 300000 )
#snd.play( s )
#while snd.isPlaying(): time.sleep( 0.05 )
#canvas.pack()
root.mainloop()
示例13: update
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def update(self):
self.ui_label2.config(text=time.strftime('%H:%M:%S', time.localtime(time.time())))
self.parent.update()
now = time.strftime(FMT, time.localtime(time.time()))
left = timedelta(FMT, now, DUETIME)
if left:
self.ui_label4.config(text=left)
else:
self.ui_label4.config(text='Time\'s up')
left = timedelta(FMT, now, '23:59:59')
self.ui_label6.config(text=left)
now = time.strftime('%y-%m-%d %H:%M:%S', time.localtime(time.time()))
left = timedelta(FMT_2, now, '14-9-13 00:00:00')
self.ui_label8.config(text=left)
now = time.strftime('%y-%m-%d %H:%M:%S', time.localtime(time.time()))
left = timedelta(FMT_2, now, '14-10-13 00:00:00')
self.ui_label10.config(text=left)
self.parent.after(1000, self.update)
root = Tk()
# make it cover the entire screen
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.overrideredirect(1)
root.geometry("%dx%d+0+0" % (w, h))
app = Clock(root)
root.mainloop()
示例14: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
def main():
settings_file = "settings.yaml"
photos=[]
gauth = GoogleAuth(settings_file=settings_file)
gauth.CommandLineAuth()
drive = GoogleDrive(gauth)
print "All files in root:"
# Auto-iterate through all files that matches this query
file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList()
print "List folders"
for file1 in file_list:
#print 'title: %s, id: %s' % (file1['title'], file1['id'])
#print 'mime: %s' % (file1['mimeType'])
if file1['mimeType'] == "application/vnd.google-apps.folder":
if file1['title'] == "Google Photos":
print "Found your photos:"
print 'Folder: %s, Id: %s' % (file1['title'],file1['id'])
found = True
if found == False:
print "Error, no Google Photos folder found"
sys.exit()
# Google Photos folder id =1Q4Xk107tDLn4SdoHOqZwy5AGyvIm2bNO1uubxlMqx34
# (found above)
#folder_id="1Q4Xk107tDLn4SdoHOqZwy5AGyvIm2bNO1uubxlMqx34"
#title: 2016, id: 1efl45Zs9_cFLEXzRERqqxIQp3Q
folder_id="1efl45Zs9_cFLEXzRERqqxIQp3Q" #
print "List files in folder 2016"
_q = {'q': "'{}' in parents and trashed=false".format(folder_id)}
photolist = drive.ListFile(_q).GetList()
for file1 in photolist:
#print 'title: %s, id: %s' % (file1['title'], file1['id'])
#print 'mime: %s' % (file1['mimeType'])
if file1['mimeType'] == "image/jpeg":
imageurl = file1['title']
imageid = file1['id']
#print 'title: %s' % (file1['title'])
print "Open " + str(imageurl) + " id: " + str(imageid)
# Download and show an image
myFile = drive.CreateFile({'id': imageid})
myFile.GetContentFile(imageurl)
print '%s downloaded ' %(imageurl) + " and it looks like this:"
# Create fullscreen window
root = Tk()
root.overrideredirect(True)
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
# Keyboard input
root.bind('<Key>', keyinput)
# Screen size?
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
#print str(screen_width) + "-" + str(screen_height)
image = Image.open(imageurl)
width, height = image.size
#print str(width) + "-" + str(height)
image = image.resize((screen_width, screen_height), Image.ANTIALIAS)
img = ImageTk.PhotoImage(image)
panel = Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
root.mainloop()
time.sleep(10)
示例15: Popen
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import overrideredirect [as 别名]
proc = Popen(['./capture/capture_raw_frames',
'0x000000',
str(bounds[0][0]),
str(bounds[0][1]),
str(bounds[1][0]),
str(bounds[1][1])],
stdout=PIPE)
mystdin = proc.stdout
root.tk.createfilehandler(mystdin, tkinter.READABLE, readappend)
prevrow = 0
prevcol = 0
def readappend(fh, _):
global prevrow, prevcol
mystr = mystdin.readline()
# print mystr
row, col = mystr.split(' ')
row = (int(row) - bounds[0][1]) * height / (bounds[1][1] - bounds[0][1])
col = (int(col) - bounds[0][0]) * width / (bounds[1][0] - bounds[0][0])
circle(prevcol, prevrow, 5, '#ffffff')
circle(col, row, 5, '#ff0000')
canvas.pack(fill=BOTH, expand=1)
prevrow = row
prevcol = col
clear()
root.after(10, calibrate_center)
root.overrideredirect(True)
root.mainloop()