本文整理汇总了Python中ttk.Label.col方法的典型用法代码示例。如果您正苦于以下问题:Python Label.col方法的具体用法?Python Label.col怎么用?Python Label.col使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Label
的用法示例。
在下文中一共展示了Label.col方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setCard
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import col [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