本文整理汇总了Python中ttk.Frame.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.bind方法的具体用法?Python Frame.bind怎么用?Python Frame.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Frame
的用法示例。
在下文中一共展示了Frame.bind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ScrollableFrame
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import bind [as 别名]
class ScrollableFrame(Frame):
def __init__(self, root):
Frame.__init__(self, root)
self.canvas = ResizingCanvas(self, borderwidth=0)
self.frame = Frame(self.canvas)
self.vsb = Scrollbar(
self, orient="vertical", command=self.canvas.yview)
self.canvas.configure(yscrollcommand=self.vsb.set)
self.vsb.pack(side="right", fill="y")
self.canvas.pack(side="left", fill="both", expand=True)
self.canvas.create_window(
(4, 4), window=self.frame, anchor="nw", tags="self.frame")
self.frame.bind("<Configure>", self.OnFrameConfigure)
def OnFrameConfigure(self, event):
'''Reset the scroll region to encompass the inner frame'''
# print "OnFrameConfigure"
self.canvas.configure(scrollregion=self.canvas.bbox("all"))
示例2: mainframe
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import bind [as 别名]
class mainframe(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.filenm=None
self.streamnm = None
self.pack(fill=BOTH, expand=1)
self.parent = parent
self.initplayer()
self.player_process = None
self.seekthread = None
self.fstate = False
self.paused = True
self.trackmouse = True
self.stdout_thread = None
self.stream = False
self.inhibit_slider_trigger = False
self.q = LifoQueue()
self.currtime = 0
self.endtime = -1
def initplayer(self):
self.parentframe = Frame(self)
self.parentframe.pack(fill=BOTH, expand=True)
self.videoFrame = Frame(self.parentframe, width=800, height=480)
self.videoFrame.pack(side="top", fill="both", expand=True)
self.buttonframe = Frame(self.parentframe, padding="2 2 1 1")
self.buttonframe.pack(side="bottom", fill="x", expand=False)
self.seekbar = Scale(self.buttonframe, from_= 0, to=100, orient=HORIZONTAL)
self.seekbar.grid(column=0, columnspan=4, row=0, sticky=[N, E, S, W])
self.seekbar.configure(command=self.seeked)
self.selectbutton = Button(self.buttonframe, text="Select File")
self.selectbutton.grid(column=0, row=1, sticky=[E,W])
self.streambutton = Button(self.buttonframe, text="Open HTTP", command=self.streamopen)
self.streambutton.grid(column=1, row=1, sticky=[E,W])
self.playbutton = Button(self.buttonframe, text="Play")
self.playbutton.config(command=self.playpause)
self.playbutton.grid(column=2, row=1, sticky=[E,W])
self.fullscreenbutton = Button(self.buttonframe, text="Fullscreen", command=self.togglefullscreen)
self.fullscreenbutton.grid(column=3, row=1, sticky=[E,W])
for child in self.buttonframe.winfo_children(): child.grid_configure(padx=5, pady=5)
self.buttonframe.rowconfigure(0, weight=1)
self.buttonframe.rowconfigure(1, weight=1)
self.buttonframe.columnconfigure(0, weight=1)
self.buttonframe.columnconfigure(1, weight=1)
self.buttonframe.columnconfigure(2, weight=1)
self.buttonframe.columnconfigure(3, weight=1)
self.selectbutton.configure(command=self.fileopen)
self.videoFrame.bind("<Button-1>",self.playpause)
self.parent.bind("<F11>", self.togglefullscreen)
self.parent.bind("<Motion>",self.mouseops)
def mouseops(self,event=None):
self.videoFrame.config(cursor="")
self.videoFrame.after(5000,self.cursorhandler)
if self.trackmouse:
x, y = self.parent.winfo_pointerx(), self.parent.winfo_pointery()
windowx, windowy = self.parent.winfo_width(), self.parent.winfo_height()
if windowy - 30 <= y:
if self.fstate:
self.buttonframe.pack(side="bottom", fill="x", expand=False)
self.trackmouse = False
self.parent.after(5000, self.mousetracker)
self.inhibit_slider_trigger = False
elif self.fstate:
self.buttonframe.pack_forget()
self.inhibit_slider_trigger = True
else:
self.inhibit_slider_trigger = True
def mousetracker(self):
print 'Mouse Tracker'
self.trackmouse = True
self.videoFrame.after(0,self.mouseops)
def cursorhandler(self):
self.videoFrame.config(cursor="none")
def togglefullscreen(self, event=None):
self.fstate = not self.fstate
self.parent.attributes("-fullscreen",self.fstate)
if self.fstate:
self.fullscreenbutton.config(text="Exit Fullscreen")
self.buttonframe.pack_forget()
self.videoFrame.config(cursor="none")
else:
self.fullscreenbutton.config(text="Fullscreen")
self.buttonframe.pack(side="bottom", fill="x", expand=False)
self.videoFrame.after(5000, self.cursorhandler)
def fileopen(self):
self.filenm = askopenfilename(filetypes=[("Supported Files","*.mp4;*.mkv;*.mpg;*.avi;*.mov"),("All Files","*.*")])
self.stream = False
self.play()
def streamopen(self):
self.streamnm = Dlog(self.parent)
#.........这里部分代码省略.........
示例3: setCard
# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import bind [as 别名]
def setCard(self,cardnum,row,col):
dodel = False
if cardnum == -1:
dodel = True
cardnum = 1
card = Card(cardnum)
f = Frame(self, height = card.height, width = card.width)
if (row == 2 and self.client.player == 'p1') or (row == 3 and self.client.player == 'p2'):
f.config(height = card.height+20)
if self.client.player == 'p1':
f.grid(row=row+1, column=col)
else:
f.grid(row=6-row, column=NUM_COLS-col)
f.pack_propagate(0)
self.fgrid[row][col] = f
pic = Label(f)
if row <= 2:
card.flip()
if self.client.player == 'p2':
card.flip()
pic.config(image=card.img)
pic.image = card.img
pic.row = row
pic.col = col
pic.card = card
def clicked(pic,ins,card):
if ins.state == 'taking' and not pic.isNone:
if pic.card.number == ins.activeCard:
endTime = time.time()
ins.delta = round(endTime-self.startTime,2)
print(ins.delta)
print("Got in "+str(ins.delta))
ins.client.sendMessage('took,'+str(ins.delta)+','+str(ins.faultCount))
if not ins.multiplayer:
ins.client.oppSendMessage('p2,took,20,0')
ins.changeState('waiting')
pic.pack_forget()
ins.model[pic.row][pic.col].isNone = True
elif ins.activeCardRow == -1 or not (pic.row <= 2) == (ins.activeCardRow <= 2):
ins.faults[int(pic.row <= 2)] = 1
ins.faultCount = sum(ins.faults)
elif ins.state == 'move-select-start':
ins.movingPic = (pic.row, pic.col)
print('moving card:')
print(ins.movingPic)
if (((self.client.player == 'p1' and pic.row > 2) or (self.client.player == 'p2' and pic.row <= 2))\
and not pic.isNone) or not ins.multiplayer:
ins.infoLabel.config(text="Card chosen. Select destination.")
ins.changeState('move-select-stop')
else:
ins.infoLabel.config(text="Can't move that. Select a different card to move.")
ins.moveButton.config(text="Cancel")
elif ins.state == 'move-select-stop':
print('to:')
print((pic.row, pic.col))
if ((self.client.player == 'p1' and pic.row <= 2) or (self.client.player == 'p2' and pic.row > 2))\
and not pic.isNone:
ins.infoLabel.config(text="Illegal move. Select a different card to move.")
else:
ins.swapCards(self.movingPic,(pic.row, pic.col))
ins.infoLabel.config(text="Move completed. Select next card.")
ins.changeState('move-select-start')
f.bind("<Button-1>",lambda e,pic=pic,self=self,card=card:clicked(pic,self,card))
pic.bind("<Button-1>",lambda e,pic=pic,self=self,card=card:clicked(pic,self,card))
pic.pack(fill=BOTH)
self.model[row][col] = pic
if dodel:
pic.pack_forget()
self.model[row][col].isNone = True
else:
self.model[row][col].isNone = False